Extend the "Wasted" column to show space still to waste

This commit is contained in:
Andrea Mazzoleni 2015-02-12 21:03:38 +01:00
parent bed594c8b0
commit 8f2b148ff1
5 changed files with 34 additions and 18 deletions

View file

@ -23,6 +23,8 @@ SnapRAID HISTORY
old state. old state.
* The -e, --filter-error option is more efficient and triggers * The -e, --filter-error option is more efficient and triggers
a lot less data to be read. a lot less data to be read.
* In the "status" command the "Wasted" column now shows a negative
number for the amount of space that you can still waste.
* Renames the -s and -t options to -S and -B as they are intended to * Renames the -s and -t options to -S and -B as they are intended to
be manual only operations. be manual only operations.

View file

@ -68,7 +68,7 @@ int state_status(struct snapraid_state* state)
uint64_t file_size; uint64_t file_size;
uint64_t file_block_count; uint64_t file_block_count;
uint64_t file_block_free; uint64_t file_block_free;
uint64_t base = 1024 * 1024 * (uint64_t)1024; uint64_t base = 1024 * 1024 * 1024ULL;
block_off_t parity_block_free; block_off_t parity_block_free;
unsigned unsynced_blocks; unsigned unsynced_blocks;
uint64_t all_wasted; uint64_t all_wasted;
@ -123,7 +123,7 @@ int state_status(struct snapraid_state* state)
block_off_t disk_block_max_by_space; block_off_t disk_block_max_by_space;
block_off_t disk_block_max_by_parity; block_off_t disk_block_max_by_parity;
block_off_t disk_block_max; block_off_t disk_block_max;
uint64_t wasted; int64_t wasted;
/* for each file in the disk */ /* for each file in the disk */
node = disk->filelist; node = disk->filelist;
@ -178,27 +178,34 @@ int state_status(struct snapraid_state* state)
disk_block_max_by_space = disk_block_count + disk->free_blocks; disk_block_max_by_space = disk_block_count + disk->free_blocks;
disk_block_max_by_parity = blockmax + parity_block_free; disk_block_max_by_parity = blockmax + parity_block_free;
/* the maximum usable space in a disk is limited by the smaller */ /* the maximum usable space in a disk is limited by the smallest */
/* between the disk size and the parity size */ /* of the disk size and the parity size */
/* the wasted space is the space that we have to leave */ /* the wasted space is the space that we have to leave */
/* free on the data disk, when the parity is filled up */ /* free on the data disk, when the parity is filled up */
if (disk_block_max_by_space < disk_block_max_by_parity) { if (disk_block_max_by_space < disk_block_max_by_parity) {
disk_block_max = disk_block_max_by_space; disk_block_max = disk_block_max_by_space;
/* no wasted space, as we have enough parity */
wasted = 0;
} else { } else {
disk_block_max = disk_block_max_by_parity; disk_block_max = disk_block_max_by_parity;
/* wasted space is the difference of the two maximum size */
wasted = (disk_block_max_by_space - disk_block_max_by_parity) * (uint64_t)state->block_size;
} }
/* wasted space is the difference of the two maximum size */
/* if negative, it's extra space available in parity */
wasted = (int64_t)disk_block_max_by_space - (int64_t)disk_block_max_by_parity;
wasted *= state->block_size;
all_wasted += wasted; all_wasted += wasted;
file_block_free += disk_block_max - disk_block_count; file_block_free += disk_block_max - disk_block_count;
printf("%8u", disk_file_count); printf("%8u", disk_file_count);
printf("%8u", disk_file_fragmented); printf("%8u", disk_file_fragmented);
printf("%8u", disk_extra_fragment); printf("%8u", disk_extra_fragment);
printf("%6" PRIu64 ".%01" PRIu64, wasted / base, (wasted * 10 / base) % 10); if (wasted < -100LL * 1024 * 1024 * 1024) {
printf(" -");
} else if (wasted < 0) {
printf("%6" PRId64 ".%01" PRIu64, wasted / (int64_t)base, (-wasted * 10 / base) % 10);
} else {
printf("%6" PRIu64 ".%01" PRIu64, wasted / base, (wasted * 10 / base) % 10);
}
printf("%8" PRIu64, disk_file_size / base); printf("%8" PRIu64, disk_file_size / base);
printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / base); printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / base);
printf(" %3u%%", perc(disk_block_count, disk_block_max)); printf(" %3u%%", perc(disk_block_count, disk_block_max));
@ -215,6 +222,7 @@ int state_status(struct snapraid_state* state)
ftag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space); ftag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space);
ftag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity); ftag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity);
ftag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max); ftag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max);
ftag("summary:disk_space_wasted:%s:%" PRId64 "\n", disk->name, wasted);
} }
/* totals */ /* totals */

View file

@ -645,8 +645,8 @@ It includes information about the parity fragmentation, how old
are the blocks without checking, and all the recorded silent are the blocks without checking, and all the recorded silent
errors encountered while scrubbing. errors encountered while scrubbing.
.PP .PP
Note that the information presented refers at the latest time you run \[dq]sync\[dq]. Note that the information presented refers at the latest time you
Later modifications are not taken into account. run \[dq]sync\[dq]. Later modifications are not taken into account.
.PP .PP
Nothing is modified. Nothing is modified.
.SS smart .SS smart
@ -1179,7 +1179,7 @@ In details, for each file, even of few bytes, a whole block of parity is
always allocated, and with many files this may result in a lot of unused always allocated, and with many files this may result in a lot of unused
parity space. And when you completely fill the parity disk, you are not parity space. And when you completely fill the parity disk, you are not
allowed to add more files in the data disks. allowed to add more files in the data disks.
But note that wasted parity doesn\'t sum between data disk. Wasted space Note that wasted parity doesn\'t sum between data disk. Wasted space
resulting from a high number of files in a data disk, limits only resulting from a high number of files in a data disk, limits only
the amount of data in such data disk and not in others. the amount of data in such data disk and not in others.
.PP .PP
@ -1191,6 +1191,8 @@ in 12 GiB less space available in the data disk.
You can get the amount of wasted space in each disk using \[dq]status\[dq]. You can get the amount of wasted space in each disk using \[dq]status\[dq].
This is the amount of space that you must leave free in the data This is the amount of space that you must leave free in the data
disks, or use for files not included in the array. disks, or use for files not included in the array.
If this value is negative, it means that your are near to fill
the parity, and it represent the space you can still waste.
.PP .PP
To avoid to problem, you can use a bigger partition for parity. To avoid to problem, you can use a bigger partition for parity.
For example, if you have the parity partition bigger than 12 GiB For example, if you have the parity partition bigger than 12 GiB

View file

@ -371,8 +371,8 @@ Commands
are the blocks without checking, and all the recorded silent are the blocks without checking, and all the recorded silent
errors encountered while scrubbing. errors encountered while scrubbing.
Note that the information presented refers at the latest time you run "sync". Note that the information presented refers at the latest time you
Later modifications are not taken into account. run "sync". Later modifications are not taken into account.
Nothing is modified. Nothing is modified.
@ -920,7 +920,7 @@ Configuration
always allocated, and with many files this may result in a lot of unused always allocated, and with many files this may result in a lot of unused
parity space. And when you completely fill the parity disk, you are not parity space. And when you completely fill the parity disk, you are not
allowed to add more files in the data disks. allowed to add more files in the data disks.
But note that wasted parity doesn't sum between data disk. Wasted space Note that wasted parity doesn't sum between data disk. Wasted space
resulting from a high number of files in a data disk, limits only resulting from a high number of files in a data disk, limits only
the amount of data in such data disk and not in others. the amount of data in such data disk and not in others.
@ -932,6 +932,8 @@ Configuration
You can get the amount of wasted space in each disk using "status". You can get the amount of wasted space in each disk using "status".
This is the amount of space that you must leave free in the data This is the amount of space that you must leave free in the data
disks, or use for files not included in the array. disks, or use for files not included in the array.
If this value is negative, it means that your are near to fill
the parity, and it represent the space you can still waste.
To avoid to problem, you can use a bigger partition for parity. To avoid to problem, you can use a bigger partition for parity.
For example, if you have the parity partition bigger than 12 GiB For example, if you have the parity partition bigger than 12 GiB

View file

@ -397,8 +397,8 @@ It includes information about the parity fragmentation, how old
are the blocks without checking, and all the recorded silent are the blocks without checking, and all the recorded silent
errors encountered while scrubbing. errors encountered while scrubbing.
Note that the information presented refers at the latest time you run "sync". Note that the information presented refers at the latest time you
Later modifications are not taken into account. run "sync". Later modifications are not taken into account.
Nothing is modified. Nothing is modified.
@ -996,7 +996,7 @@ In details, for each file, even of few bytes, a whole block of parity is
always allocated, and with many files this may result in a lot of unused always allocated, and with many files this may result in a lot of unused
parity space. And when you completely fill the parity disk, you are not parity space. And when you completely fill the parity disk, you are not
allowed to add more files in the data disks. allowed to add more files in the data disks.
But note that wasted parity doesn't sum between data disk. Wasted space Note that wasted parity doesn't sum between data disk. Wasted space
resulting from a high number of files in a data disk, limits only resulting from a high number of files in a data disk, limits only
the amount of data in such data disk and not in others. the amount of data in such data disk and not in others.
@ -1008,6 +1008,8 @@ in 12 GiB less space available in the data disk.
You can get the amount of wasted space in each disk using "status". You can get the amount of wasted space in each disk using "status".
This is the amount of space that you must leave free in the data This is the amount of space that you must leave free in the data
disks, or use for files not included in the array. disks, or use for files not included in the array.
If this value is negative, it means that your are near to fill
the parity, and it represent the space you can still waste.
To avoid to problem, you can use a bigger partition for parity. To avoid to problem, you can use a bigger partition for parity.
For example, if you have the parity partition bigger than 12 GiB For example, if you have the parity partition bigger than 12 GiB