Log more information about the filesystems

This commit is contained in:
Andrea Mazzoleni 2026-01-30 09:54:54 +01:00
parent 9f081f9c22
commit f134201438
7 changed files with 237 additions and 100 deletions

View file

@ -393,7 +393,6 @@ static int parity_handle_fill(struct snapraid_split_handle* split, data_off_t si
pathprint(spaceholder_path, sizeof(spaceholder_path), "%s%s", split->path, ".spaceholder");
if (!skip_space_holder) {
data_off_t spaceholder_size = 256 * 1024 * 1024;
int spaceholder_f;
spaceholder_f = open(spaceholder_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
@ -403,8 +402,8 @@ static int parity_handle_fill(struct snapraid_split_handle* split, data_off_t si
}
/* note that in Windows ftruncate is really allocating space */
if (ftruncate(spaceholder_f, spaceholder_size) != 0) {
log_fatal("WARNING Failed to resize the space holder file '%s' to %" PRIu64 " bytes.\n", spaceholder_path, spaceholder_size);
if (ftruncate(spaceholder_f, WINDOWS_SPACEHOLDER_SIZE) != 0) {
log_fatal("WARNING Failed to resize the space holder file '%s' to %u bytes.\n", spaceholder_path, WINDOWS_SPACEHOLDER_SIZE);
log_fatal("Assuming that no more space is available.\n");
close(spaceholder_f);
remove(spaceholder_path);

View file

@ -573,5 +573,10 @@ int ambient_temperature(void);
*/
extern volatile int global_interrupt;
/**
* Size of the spaceholder file for Windows to avoid the message of low disk space
*/
#define WINDOWS_SPACEHOLDER_SIZE (256 * 1024 * 1024)
#endif

View file

@ -1749,6 +1749,9 @@ int snapraid_main(int argc, char* argv[])
if (operation == OPERATION_DIFF) {
state_read(&state);
/* refresh the size info to log correct info */
state_refresh(&state);
ret = state_diff(&state);
/* abort if sync needed */
@ -1821,6 +1824,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_DRY) {
state_read(&state);
/* refresh the size info to log correct info */
state_refresh(&state);
/* filter */
state_skip(&state);
state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error);
@ -1845,6 +1851,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_SCRUB) {
state_read(&state);
/* refresh the size info before the content write */
state_refresh(&state);
memory();
/* intercept signals while operating */

View file

@ -1668,6 +1668,7 @@ void state_refresh(struct snapraid_state* state)
{
tommy_node* i;
unsigned l, s;
uint64_t bs = (uint64_t)state->block_size;
/* for all disks */
for (i = state->maplist; i != 0; i = i->next) {
@ -1694,15 +1695,15 @@ void state_refresh(struct snapraid_state* state)
}
/* set the new free blocks */
map->total_blocks = total_space / state->block_size;
map->free_blocks = free_space / state->block_size;
map->total_blocks = total_space / bs;
map->free_blocks = free_space / bs;
/* also update the disk info */
disk->total_blocks = map->total_blocks;
disk->free_blocks = map->free_blocks;
if (disk->fstype[0])
log_tag("fsinfo_data:%s:%s:%s\n", disk->name, disk->fstype, disk->fslabel);
log_tag("fsinfo_data_split:%s:%" PRIu64 ":%" PRIu64 ":%s:%s\n", disk->name, disk->total_blocks * bs, disk->free_blocks * bs, disk->fstype, disk->fslabel);
log_tag("fsinfo_data:%s:%" PRIu64 ":%" PRIu64 "\n", disk->name, disk->total_blocks * bs, disk->free_blocks * bs);
}
/* for all parities */
@ -1725,17 +1726,31 @@ void state_refresh(struct snapraid_state* state)
/* LCOV_EXCL_STOP */
}
/* add the new free blocks */
state->parity[l].total_blocks += total_space / state->block_size;
state->parity[l].free_blocks += free_space / state->block_size;
#ifdef WIN32
/*
* Take into account the space we have to leave free
* to avoid the waring about low space
*/
if (free_space >= WINDOWS_SPACEHOLDER_SIZE)
free_space -= WINDOWS_SPACEHOLDER_SIZE;
else
free_space = 0;
#endif
if (split->fstype[0]) {
if (s == 0)
log_tag("fsinfo_parity:%s:%s:%s\n", lev_config_name(l), split->fstype, split->fslabel);
else
log_tag("fsinfo_parity:%s/%u:%s:%s\n", lev_config_name(l), s, split->fstype, split->fslabel);
}
/* add the new free blocks */
uint64_t split_total_blocks = total_space / bs;
uint64_t split_free_blocks = free_space / bs;
state->parity[l].total_blocks += split_total_blocks;
state->parity[l].free_blocks += split_free_blocks;
if (s == 0)
log_tag("fsinfo_parity_split:%s:%" PRIu64 ":%" PRIu64 ":%s:%s\n", lev_config_name(l), split_total_blocks * bs, split_free_blocks * bs, split->fstype, split->fslabel);
else
log_tag("fsinfo_parity_split:%s/%u:%" PRIu64 ":%" PRIu64 ":%s:%s\n", lev_config_name(l), s, split_total_blocks * bs, split_free_blocks * bs, split->fstype, split->fslabel);
}
log_tag("fsinfo_parity:%s:%" PRIu64 ":%" PRIu64 "\n", lev_config_name(l), state->parity[l].total_blocks * bs, state->parity[l].free_blocks * bs);
}
/* note what we don't set need_write = 1, because we don't want */
@ -2726,7 +2741,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
log_tag("content_allocation:%s:%" PRIi64 ":%" PRIi64 "\n",
log_tag("content_data:%s:%" PRIi64 ":%" PRIi64 "\n",
buffer,
v_total_blocks * (uint64_t)state->block_size,
v_free_blocks * (uint64_t)state->block_size);
@ -2744,7 +2759,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
log_tag("content_data:%s:%s\n",
log_tag("content_data_split:%s:%s\n",
buffer,
uuid);
@ -2828,7 +2843,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
log_tag("content_allocation:%s:%" PRIi64 ":%" PRIi64 "\n",
log_tag("content_parity:%s:%" PRIi64 ":%" PRIi64 "\n",
lev_config_name(v_level),
v_total_blocks * (uint64_t)state->block_size,
v_free_blocks * (uint64_t)state->block_size);
@ -2849,8 +2864,8 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
state->parity[v_level].total_blocks = v_total_blocks;
state->parity[v_level].free_blocks = v_free_blocks;
log_tag("content_parity:%s:%s:%s:%" PRIi64 "\n",
lev_config_name(v_level),
log_tag("content_parity_split:%s:%s:%s:%" PRIi64 "\n",
lev_config_name(v_level), /* P command always has a single split */
state->parity[v_level].split_map[0].uuid,
state->parity[v_level].split_map[0].path,
state->parity[v_level].split_map[0].size);
@ -2918,7 +2933,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
state->parity[v_level].free_blocks = v_free_blocks;
}
log_tag("content_allocation:%s:%" PRIi64 ":%" PRIi64 "\n",
log_tag("content_parity:%s:%" PRIi64 ":%" PRIi64 "\n",
lev_config_name(v_level),
v_total_blocks * (uint64_t)state->block_size,
v_free_blocks * (uint64_t)state->block_size);
@ -2983,7 +2998,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
pathcpy(parity_name, sizeof(parity_name), lev_config_name(v_level));
else
pathprint(parity_name, sizeof(parity_name), "%s/%u", lev_config_name(v_level), s);
log_tag("content_parity:%s:%s:%s:%" PRIi64 "\n",
log_tag("content_parity_split:%s:%s:%s:%" PRIi64 "\n",
parity_name,
state->parity[v_level].split_map[s].uuid,
state->parity[v_level].split_map[s].path,
@ -3217,11 +3232,11 @@ static void* state_write_thread(void* arg)
sputb32(map->free_blocks, f);
sputbs(map->uuid, f);
if (context->first) {
log_tag("content_allocation:%s:%" PRIi64 ":%" PRIi64 "\n",
log_tag("content_data:%s:%" PRIi64 ":%" PRIi64 "\n",
map->name,
map->total_blocks * (uint64_t)state->block_size,
map->free_blocks * (uint64_t)state->block_size);
log_tag("content_data:%s:%s\n",
log_tag("content_data_split:%s:%s\n",
map->name,
map->uuid);
}
@ -3241,7 +3256,7 @@ static void* state_write_thread(void* arg)
sputb32(state->parity[l].total_blocks, f);
sputb32(state->parity[l].free_blocks, f);
if (context->first) {
log_tag("content_allocation:%s:%" PRIi64 ":%" PRIi64 "\n",
log_tag("content_parity:%s:%" PRIi64 ":%" PRIi64 "\n",
lev_config_name(l),
state->parity[l].total_blocks * (uint64_t)state->block_size,
state->parity[l].free_blocks * (uint64_t)state->block_size);
@ -3257,7 +3272,7 @@ static void* state_write_thread(void* arg)
else
pathprint(parity_name, sizeof(parity_name), "%s/%u", lev_config_name(l), s);
if (context->first) {
log_tag("content_parity:%s:%s:%s:%" PRIi64 "\n",
log_tag("content_parity_split:%s:%s:%s:%" PRIi64 "\n",
parity_name,
state->parity[l].split_map[s].uuid,
state->parity[l].split_map[s].path,

View file

@ -130,11 +130,45 @@ The UUID of the filesystem containing the path.
.PD
.RE
.TP
.B fsinfo_data:<disk_name>:<type>:<label>
.B fsinfo_data:<disk_name>:<size>:<free>
The filesystem information of the specified data disk.
.RS 4
.PD 0
.HP 4
.I <size>
The size of the data disk (uint).
.HP 4
.I <free_size>
The free size in the data disk (uint).
.PD
.RE
.TP
.B fsinfo_parity:<parity_level>:<size>:<free>
The filesystem information of the specified parity disk.
In case of multiple splits this is the sum of the sizes of all
splits.
.RS 4
.PD 0
.HP 4
.I <size>
The size of the parity disk (uint).
.HP 4
.I <free_size>
The free size in the parity disk (uint).
.PD
.RE
.TP
.B fsinfo_data_split:<disk_name>:<size>:<free>:<type>:<label>
The filesystem information of the specified data disk.
.RS 4
.PD 0
.HP 4
.I <size>
The size of the data disk (uint).
.HP 4
.I <free_size>
The free size in the data disk (uint).
.HP 4
.I <type>
The filesystem type. A string like \`ext4\`, \`ntfs\`.
.HP 4
@ -143,11 +177,17 @@ The label associated to the filesystem.
.PD
.RE
.TP
.B fstype_parity]:<parity_level>[/<split_index>]:<type>:<label>
The filesystem information of the specified parity disk.
.B fsinfo_parity_split:<parity_level>[/<split_index>]:<size>:<free>:<type>:<label>
The filesystem information of the specified parity split.
.RS 4
.PD 0
.HP 4
.I <size>
The size of the parity disk (uint).
.HP 4
.I <free_size>
The free size in the parity disk (uint).
.HP 4
.I <type>
The filesystem type. A string like \`ext4\`, \`ntfs\`.
.HP 4
@ -188,32 +228,42 @@ The absolute path to a content file being written (escaped).
You will see multiple writes as the content file is saved in
multiple copies.
.TP
.B content_parity:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity files as stored in the content file.
.B content_data:<disk_name>:<size>:<free_size>
The size of the data disk as stored in the content file.
.RS 4
.PD 0
.HP 4
.I <parity_level>[/<split_index>]
One of \`parity\`, \`2\-parity\`,
..., \`6\-parity\`. This corresponds to the level of redundancy.
In case of split parity, the parity name is followed
by \`/N\` to indicate the split index, where N starts
from 0. The \`/0\` is always omitted.
.HP 4
.I <uuid>
The UUID of the disk containing the path as stored
in the content file.
.HP 4
.I <path>
The path (escaped).
.I <disk_name>
Name of the data disk.
.HP 4
.I <size>
The size of the parity file (uint).
The size of the data disk (uint).
.HP 4
.I <free_size>
The free size in the data disk (uint).
.PD
.RE
.TP
.B content_data:<disk_name>:<uuid>
The data disk as stored in the content file.
.B content_parity:<parity_level>:<size>:<free_size>
The size of the parity disk as stored in the content file.
In case of multiple splits this is the sum of the sizes of all
splits.
.RS 4
.PD 0
.HP 4
.I <parity_level>
Name of the parity.
.HP 4
.I <size>
The total size of the parity disk (uint).
.HP 4
.I <free_size>
The free size in the parity disk (uint).
.PD
.RE
.TP
.B content_data_split:<disk_name>:<uuid>
The data disk info as stored in the content file.
.RS 4
.PD 0
.HP 4
@ -226,19 +276,26 @@ content file.
.PD
.RE
.TP
.B content_allocation:<disk_name>:<size>:<free_size>
The size of disk and parity as stored in the content file.
.B content_parity_split:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity split info as stored in the content file.
.RS 4
.PD 0
.HP 4
.I <disk_name>
Name of the data or parity disk.
.I <parity_level>[/<split_index>]
One of \`parity\`, \`2\-parity\`,
..., \`6\-parity\`. This corresponds to the level of redundancy.
In case of split parity, the parity name is followed
by \`/N\` to indicate the split index, where N starts
from 0. The \`/0\` is always omitted.
.HP 4
.I <uuid>
The UUID of the disk containing the path.
.HP 4
.I <path>
The path of the parity file (escaped).
.HP 4
.I <size>
The size of the data in the disk or parity (uint).
.HP 4
.I <free_size>
The free size in the disk or parity (uint).
The size of the parity file (uint).
.PD
.RE
.TP

View file

@ -93,15 +93,33 @@ Configuration Tags
<path> - The path (escaped).
<uuid> - The UUID of the filesystem containing the path.
=fsinfo_data:<disk_name>:<type>:<label>
=fsinfo_data:<disk_name>:<size>:<free>
The filesystem information of the specified data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
=fsinfo_parity:<parity_level>:<size>:<free>
The filesystem information of the specified parity disk.
In case of multiple splits this is the sum of the sizes of all
splits.
<size> - The size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
=fsinfo_data_split:<disk_name>:<size>:<free>:<type>:<label>
The filesystem information of the specified data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
<type> - The filesystem type. A string like `ext4`, `ntfs`.
<label> - The label associated to the filesystem.
=fstype_parity]:<parity_level>[/<split_index>]:<type>:<label>
The filesystem information of the specified parity disk.
=fsinfo_parity_split:<parity_level>[/<split_index>]:<size>:<free>:<type>:<label>
The filesystem information of the specified parity split.
<size> - The size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
<type> - The filesystem type. A string like `ext4`, `ntfs`.
<label> - The label associated to the filesystem.
@ -138,33 +156,41 @@ Content Tags
You will see multiple writes as the content file is saved in
multiple copies.
=content_parity:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity files as stored in the content file.
=content_data:<disk_name>:<size>:<free_size>
The size of the data disk as stored in the content file.
<disk_name> - Name of the data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
=content_parity:<parity_level>:<size>:<free_size>
The size of the parity disk as stored in the content file.
In case of multiple splits this is the sum of the sizes of all
splits.
<parity_level> - Name of the parity.
<size> - The total size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
=content_data_split:<disk_name>:<uuid>
The data disk info as stored in the content file.
<disk_name> - Name of the data disk.
<uuid> - The UUID of the disk filesystem as stored in the
content file.
=content_parity_split:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity split info as stored in the content file.
<parity_level>[/<split_index>] - One of `parity`, `2-parity`,
..., `6-parity`. This corresponds to the level of redundancy.
In case of split parity, the parity name is followed
by `/N` to indicate the split index, where N starts
from 0. The `/0` is always omitted.
<uuid> - The UUID of the disk containing the path as stored
in the content file.
<path> - The path (escaped).
<uuid> - The UUID of the disk containing the path.
<path> - The path of the parity file (escaped).
<size> - The size of the parity file (uint).
=content_data:<disk_name>:<uuid>
The data disk as stored in the content file.
<disk_name> - Name of the data disk.
<uuid> - The UUID of the disk filesystem as stored in the
content file.
=content_allocation:<disk_name>:<size>:<free_size>
The size of disk and parity as stored in the content file.
<disk_name> - Name of the data or parity disk.
<size> - The size of the data in the disk or parity (uint).
<free_size> - The free size in the disk or parity (uint).
=content_info:<kind>:<counter>
The counters in the content file.

View file

@ -100,15 +100,33 @@ These tags report the memory usage and global configuration.
<path> - The path (escaped).
<uuid> - The UUID of the filesystem containing the path.
fsinfo_data:<disk_name>:<type>:<label>
fsinfo_data:<disk_name>:<size>:<free>
The filesystem information of the specified data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
fsinfo_parity:<parity_level>:<size>:<free>
The filesystem information of the specified parity disk.
In case of multiple splits this is the sum of the sizes of all
splits.
<size> - The size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
fsinfo_data_split:<disk_name>:<size>:<free>:<type>:<label>
The filesystem information of the specified data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
<type> - The filesystem type. A string like `ext4`, `ntfs`.
<label> - The label associated to the filesystem.
fstype_parity]:<parity_level>[/<split_index>]:<type>:<label>
The filesystem information of the specified parity disk.
fsinfo_parity_split:<parity_level>[/<split_index>]:<size>:<free>:<type>:<label>
The filesystem information of the specified parity split.
<size> - The size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
<type> - The filesystem type. A string like `ext4`, `ntfs`.
<label> - The label associated to the filesystem.
@ -148,33 +166,41 @@ These tags report the information stored in the content file.
You will see multiple writes as the content file is saved in
multiple copies.
content_parity:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity files as stored in the content file.
content_data:<disk_name>:<size>:<free_size>
The size of the data disk as stored in the content file.
<disk_name> - Name of the data disk.
<size> - The size of the data disk (uint).
<free_size> - The free size in the data disk (uint).
content_parity:<parity_level>:<size>:<free_size>
The size of the parity disk as stored in the content file.
In case of multiple splits this is the sum of the sizes of all
splits.
<parity_level> - Name of the parity.
<size> - The total size of the parity disk (uint).
<free_size> - The free size in the parity disk (uint).
content_data_split:<disk_name>:<uuid>
The data disk info as stored in the content file.
<disk_name> - Name of the data disk.
<uuid> - The UUID of the disk filesystem as stored in the
content file.
content_parity_split:<parity_level>[/<split_index>]:<uuid>:<path>:<size>
The parity split info as stored in the content file.
<parity_level>[/<split_index>] - One of `parity`, `2-parity`,
..., `6-parity`. This corresponds to the level of redundancy.
In case of split parity, the parity name is followed
by `/N` to indicate the split index, where N starts
from 0. The `/0` is always omitted.
<uuid> - The UUID of the disk containing the path as stored
in the content file.
<path> - The path (escaped).
<uuid> - The UUID of the disk containing the path.
<path> - The path of the parity file (escaped).
<size> - The size of the parity file (uint).
content_data:<disk_name>:<uuid>
The data disk as stored in the content file.
<disk_name> - Name of the data disk.
<uuid> - The UUID of the disk filesystem as stored in the
content file.
content_allocation:<disk_name>:<size>:<free_size>
The size of disk and parity as stored in the content file.
<disk_name> - Name of the data or parity disk.
<size> - The size of the data in the disk or parity (uint).
<free_size> - The free size in the disk or parity (uint).
content_info:<kind>:<counter>
The counters in the content file.