* [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage
@ 2012-10-02 18:36 Goffredo Baroncelli
2012-10-02 18:36 ` [PATCH 1/2] Add btrfs filesystem disk-usage command Goffredo Baroncelli
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Goffredo Baroncelli @ 2012-10-02 18:36 UTC (permalink / raw)
To: linux-btrfs
Cc: Hugo Mills, Roman Mamedov, Sébastien Maury,
Goffredo Baroncelli
Hi all,
This serie of patches adds a new command called "btrfs filesystem
disk-usage". I added this command because it is not so easy to get
the information about the disk usage from the command "fi df" and "fi show".
>From the man page (see 2nd patch):
[...]
The command btrfs filesystem disk-usage is used to query the
status of the chunks, how many space on the disk(s) are used by
the chunks, how many space are available in the chunks, and an
estimation of the free space of the filesystem.
[...]
$ ./btrfs filesystem disk-usage --help
usage: btrfs filesystem disk-usage [-d][-s][-k] <path> [<path>..]
Show space usage information for a mount point(s).
-k Set KB (1024 bytes) as unit
-s Don't show the summary section
-d Don't show the detail section
$ ./btrfs filesystem disk-usage /
Path: /
Summary:
Disk_size: 72.57GB
Disk_allocated: 25.10GB
Disk_unallocated: 47.48GB
Logical_size: 23.06GB
Used: 11.01GB
Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB)
Data_to_disk_ratio: 92 %
Details:
Chunk-type Mode Chunk-size Logical-size Used
Data Single 21.01GB 21.01GB 10.34GB
System DUP 80.00MB 40.00MB 4.00KB
System Single 4.00MB 4.00MB 0.00
Metadata DUP 4.00GB 2.00GB 686.93MB
Metadata Single 8.00MB 8.00MB 0.00
Where:
Disk_size -> sum of sizes of teh disks
Disk_allocated -> sum of chunk sizes
Disk_unallocated -> Disk_size - Disk_allocated
Logical_size -> sum of logical area sizes
Used -> logical area used
Free_(Estimated) -> on the basis of allocated
chunk, an estrapolation of
the free space
Data_to_disk_ratio -> ration between the space occuped
by a chunk and the real space
available ( due to duplication
and/or RAID level)
Chunk-type -> kind of chunk
Mode -> allocation policy of a chunk
Chunk-size -> area of disk(s) occuped by the
chunk (see it as raw space used)
Logical-size -> logical area size of the chunk
Used -> portion of the logical area
used by the filesystem
You can pull this change from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
disk_free
Comments are welcome.
BR
Goffredo Baroncelli
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] Add btrfs filesystem disk-usage command 2012-10-02 18:36 [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Goffredo Baroncelli @ 2012-10-02 18:36 ` Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-02 23:46 ` [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Chris Mason 2 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-02 18:36 UTC (permalink / raw) To: linux-btrfs Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> The command btrfs filesystem disk-usage is used to query the status of the chunks, how many space on the disk(s) are used by the chunks, how many space are available in the chunks, and an estimation of the free space of the filesystem. --- cmds-filesystem.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index b1457de..72f9b36 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -22,6 +22,7 @@ #include <errno.h> #include <uuid/uuid.h> #include <ctype.h> +#include <sys/vfs.h> #include "kerncompat.h" #include "ctree.h" @@ -153,6 +154,286 @@ static int cmd_df(int argc, char **argv) return 0; } +static u64 disk_size( char *path){ + struct statfs sfs; + + if( statfs(path, &sfs) < 0 ) + return 0; + else + return sfs.f_bsize * sfs.f_blocks; + +} + + +static void print_string(char *s, int w) +{ + int i; + + printf("%s", s); + for( i = strlen(s) ; i < w ; i++ ) + putchar(' '); +} + +#define DF_SHOW_SUMMARY (1<<1) +#define DF_SHOW_DETAIL (1<<2) +#define DF_HUMAN_UNIT (1<<3) + +static void pretty_sizes_r(u64 size, int w, int mode) +{ + if( mode & DF_HUMAN_UNIT ){ + char *s = pretty_sizes(size); + printf("%*s", w, s); + free(s); + } else { + printf("%*llu", w, size/1024); + + } +} + +static int _cmd_disk_usage(char *path, int mode) +{ + struct btrfs_ioctl_space_args *sargs; + u64 count = 0, i; + int ret; + int fd; + int e, width; + u64 total_disk; /* fielsystem size == sum of + disk sizes */ + u64 total_chunks; /* sum of chunks sizes on disk(s) */ + u64 total_used; /* logical space used */ + u64 total_free; /* logical space un-used */ + double K; + + + fd = open_file_or_dir(path); + if (fd < 0) { + fprintf(stderr, "ERROR: can't access to '%s'\n", path); + return 12; + } + + sargs = malloc(sizeof(struct btrfs_ioctl_space_args)); + if (!sargs) + return -ENOMEM; + + sargs->space_slots = 0; + sargs->total_spaces = 0; + + ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); + e = errno; + if (ret) { + fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", + path, strerror(e)); + free(sargs); + return ret; + } + if (!sargs->total_spaces) + return 0; + + count = sargs->total_spaces; + + sargs = realloc(sargs, sizeof(struct btrfs_ioctl_space_args) + + (count * sizeof(struct btrfs_ioctl_space_info))); + if (!sargs) + return -ENOMEM; + + sargs->space_slots = count; + sargs->total_spaces = 0; + + ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); + e = errno; + if (ret) { + fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", + path, strerror(e)); + close(fd); + free(sargs); + return ret; + } + + total_disk = disk_size(path); + e = errno; + if( total_disk == 0 ){ + fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n", + path, strerror(e)); + close(fd); + free(sargs); + return ret; + } + + total_chunks = total_used = total_free = 0; + + for (i = 0; i < sargs->total_spaces; i++) { + int ratio=1; + u64 allocated; + + u64 flags = sargs->spaces[i].flags; + + if (flags & BTRFS_BLOCK_GROUP_RAID0) { + ratio=1; + } else if (flags & BTRFS_BLOCK_GROUP_RAID1) { + ratio=2; + } else if (flags & BTRFS_BLOCK_GROUP_DUP) { + ratio=2; + } else if (flags & BTRFS_BLOCK_GROUP_RAID10) { + ratio=2; + } else { + ratio=1; + } + + allocated = sargs->spaces[i].total_bytes * ratio; + + total_chunks += allocated; + total_used += sargs->spaces[i].used_bytes; + total_free += (sargs->spaces[i].total_bytes - + sargs->spaces[i].used_bytes); + + } + K = ((double)total_used + (double)total_free) / + (double)total_chunks; + + if( mode & DF_HUMAN_UNIT ) + width = 12; + else + width = 18; + + printf("Path: %s\n", path); + if( mode & DF_SHOW_SUMMARY ){ + printf("Summary:\n"); + printf(" Disk_size:\t\t"); + pretty_sizes_r(total_disk, width, mode); + printf("\n Disk_allocated:\t"); + pretty_sizes_r(total_chunks, width, mode); + printf("\n Disk_unallocated:\t"); + pretty_sizes_r(total_disk-total_chunks, width, mode); + printf("\n Logical_size:\t\t"); + pretty_sizes_r(total_used+total_free, width, mode); + printf("\n Used:\t\t\t"); + pretty_sizes_r(total_used, width, mode); + printf("\n Free_(Estimated):\t"); + pretty_sizes_r((u64)(K*total_disk-total_used), width, mode); + printf("\t(Max: "); + pretty_sizes_r(total_disk-total_chunks+total_free, + 0, mode ); + printf(", Min: "); + pretty_sizes_r((total_disk-total_chunks)/2+total_free, + 0, mode ); + printf(")\n Data_to_disk_ratio:\t%*.0f %%\n", + width-2, K*100); + } + + if( ( mode & DF_SHOW_DETAIL ) && ( mode & DF_SHOW_SUMMARY ) ) + printf("\n"); + + if( mode & DF_SHOW_DETAIL ){ + /* Remember: the terminals have maximum 80 columns + do not believe to who says otherwise */ + printf("Details:\n"); + printf(" %-12s%-8s%*s%*s%*s\n", + "Chunk-type", + "Mode", + width, "Chunk-size", + 1+width, "Logical-size", + width, "Used" + ); + + for (i = 0; i < sargs->total_spaces; i++) { + char *description=""; + int ratio=1; + char *r_mode; + u64 allocated; + + u64 flags = sargs->spaces[i].flags; + + if (flags & BTRFS_BLOCK_GROUP_DATA) { + if (flags & BTRFS_BLOCK_GROUP_METADATA){ + description = "Data+M.data"; + } else { + description = "Data"; + } + } else if (flags & BTRFS_BLOCK_GROUP_SYSTEM) { + description = "System"; + } else if (flags & BTRFS_BLOCK_GROUP_METADATA) { + description = "Metadata"; + } + + if (flags & BTRFS_BLOCK_GROUP_RAID0) { + r_mode = "RAID0"; + ratio=1; + } else if (flags & BTRFS_BLOCK_GROUP_RAID1) { + r_mode = "RAID1"; + ratio=2; + } else if (flags & BTRFS_BLOCK_GROUP_DUP) { + r_mode = "DUP"; + ratio=2; + } else if (flags & BTRFS_BLOCK_GROUP_RAID10) { + r_mode = "RAID10"; + ratio=2; + } else { + r_mode = "Single"; + ratio=1; + } + + allocated = sargs->spaces[i].total_bytes * ratio; + + printf(" "); + print_string(description,12); + print_string(r_mode, 8); + pretty_sizes_r(allocated, width, mode); + pretty_sizes_r(sargs->spaces[i].total_bytes , + width+1, mode); + + pretty_sizes_r(sargs->spaces[i].used_bytes, + width, mode); + printf("\n"); + + } + } + free(sargs); + + return 0; +} + +static const char * const cmd_disk_usage_usage[] = { + "btrfs filesystem disk-usage [-d][-s][-k] <path> [<path>..]", + "Show space usage information for a mount point(s).", + "", + "-k\tSet KB (1024 bytes) as unit", + "-s\tDon't show the summary section", + "-d\tDon't show the detail section", + NULL +}; + +static int cmd_disk_usage(int argc, char **argv) +{ + + int flags=DF_SHOW_SUMMARY|DF_SHOW_DETAIL|DF_HUMAN_UNIT; + int i, more_than_one=0; + + if (check_argc_min(argc, 2)) + usage(cmd_df_usage); + + for(i=1; i< argc ; i++){ + if(!strcmp(argv[i],"-d")) + flags &= ~DF_SHOW_DETAIL; + else if(!strcmp(argv[i],"-s")) + flags &= ~DF_SHOW_SUMMARY; + else if(!strcmp(argv[i],"-k")) + flags &= ~DF_HUMAN_UNIT; + else{ + int r; + if(more_than_one) + printf("\n"); + r = _cmd_disk_usage(argv[i], flags); + if( r ) return r; + more_than_one=1; + } + + } + + return 0; +} + + + static int uuid_search(struct btrfs_fs_devices *fs_devices, char *search) { char uuidbuf[37]; @@ -530,6 +811,7 @@ static int cmd_label(int argc, char **argv) const struct cmd_group filesystem_cmd_group = { filesystem_cmd_group_usage, NULL, { { "df", cmd_df, cmd_df_usage, NULL, 0 }, + { "disk-usage", cmd_disk_usage, cmd_disk_usage_usage, NULL, 0 }, { "show", cmd_show, cmd_show_usage, NULL, 0 }, { "sync", cmd_sync, cmd_sync_usage, NULL, 0 }, { "defragment", cmd_defrag, cmd_defrag_usage, NULL, 0 }, -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-02 18:36 [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 1/2] Add btrfs filesystem disk-usage command Goffredo Baroncelli @ 2012-10-02 18:36 ` Goffredo Baroncelli 2012-10-02 23:46 ` [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Chris Mason 2 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-02 18:36 UTC (permalink / raw) To: linux-btrfs Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> --- man/btrfs.8.in | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..3215216 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem disk-usage\fP\fI [-s][-d][-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -214,6 +216,98 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem disk-usage\fP [-s][-d][-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fB-s\fP Don't show the summary section + +\fB-d\fP Don't show the detail section + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +A chunk DUPlicated or with a RAID1/RAID10 level +requires a space two time greater than the logical one. Different RAID levels +have a different ratio disk-usage / logical space offered. + +Because some files (the small ones) are stored in the +metadata chunks the computation of the \fIfree space\fP and \fIused space\fP +is complex: depending by the file size different allocation policies are used. + +The command \fBbtrfs filesystem disk-usage\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem disk-usage\fP shows: + +.RS +.IP Disk\ size +the total size of the disks which compose the filesystem. + +.IP Disk\ allocated +the size of the area of the disks used by the chunks. + +.IP Disk\ unallocated +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP Logical\ size +the available logical space of chunk. + +.IP Used +the portion of the logical space used by the file and metadata. + +.IP Free\ (estimated) +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP Data\ to\ disk\ ratio +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP Mode +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-02 18:36 [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 1/2] Add btrfs filesystem disk-usage command Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 2/2] Update help page Goffredo Baroncelli @ 2012-10-02 23:46 ` Chris Mason 2012-10-03 6:22 ` Goffredo Baroncelli 2 siblings, 1 reply; 14+ messages in thread From: Chris Mason @ 2012-10-02 23:46 UTC (permalink / raw) To: Goffredo Baroncelli Cc: linux-btrfs@vger.kernel.org, Hugo Mills, Roman Mamedov, Sébastien Maury, Goffredo Baroncelli On Tue, Oct 02, 2012 at 12:36:08PM -0600, Goffredo Baroncelli wrote: > Hi all, > > This serie of patches adds a new command called "btrfs filesystem > disk-usage". I added this command because it is not so easy to get > the information about the disk usage from the command "fi df" and "fi show". > > From the man page (see 2nd patch): I like it, thanks. Could you please update btrfs fi df to show this instead of adding a new command though? -chris ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-02 23:46 ` [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Chris Mason @ 2012-10-03 6:22 ` Goffredo Baroncelli 2012-10-03 6:34 ` Roman Mamedov 2012-10-03 11:22 ` Chris Mason 0 siblings, 2 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-03 6:22 UTC (permalink / raw) To: Chris Mason, Goffredo Baroncelli, linux-btrfs@vger.kernel.org, Hugo Mills, Roman Mamedov, Sébastien Maury, Goffredo Baroncelli On Wed, Oct 3, 2012 at 1:46 AM, Chris Mason <chris.mason@fusionio.com> wrote: [...] > I like it, thanks. Could you please update btrfs fi df to show this > instead of adding a new command though? Hi Chris, no problem to update the patches, however I have one suggestion: - leave "btrfs fi df" as is to no break any script (if any) which would uses it. Hide it from the help and deprecating it in the man page. This because the output is very different. - renaming "btrfs fi disk-usage" in "btrfs fi disk-free", which make sense. Let me know which choiche you prefer. BR G.Baroncelli > > -chris ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-03 6:22 ` Goffredo Baroncelli @ 2012-10-03 6:34 ` Roman Mamedov 2012-10-03 6:40 ` Sébastien Maury 2012-10-03 9:14 ` Martin Steigerwald 2012-10-03 11:22 ` Chris Mason 1 sibling, 2 replies; 14+ messages in thread From: Roman Mamedov @ 2012-10-03 6:34 UTC (permalink / raw) To: Goffredo Baroncelli Cc: Chris Mason, linux-btrfs@vger.kernel.org, Hugo Mills, Sébastien Maury, Goffredo Baroncelli [-- Attachment #1: Type: text/plain, Size: 1271 bytes --] On Wed, 3 Oct 2012 08:22:06 +0200 Goffredo Baroncelli <kreijack@gmail.com> wrote: > On Wed, Oct 3, 2012 at 1:46 AM, Chris Mason <chris.mason@fusionio.com> wrote: > [...] > > I like it, thanks. Could you please update btrfs fi df to show this > > instead of adding a new command though? > > Hi Chris, > no problem to update the patches, however I have one suggestion: > - leave "btrfs fi df" as is to no break any script (if any) which > would uses it. Hide it from the help and deprecating it in the man > page. This because the output is very different. > - renaming "btrfs fi disk-usage" in "btrfs fi disk-free", which make sense. 1) btrfs is still labeled experimental, so no script author should have seriously relied on utilities text output to stay unchanged long-term; personally I don't see modifying it (especially not in some superficial way, but as a part of major improvement) to be a problem; 2) "disk-usage" and "disk-free" are both way too awkward and too long to type, compared to "fi df", and "df" is the expected shorthand for "disk free" in the UNIX land. -- With respect, Roman ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Stallman had a printer, with code he could not see. So he began to tinker, and set the software free." [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-03 6:34 ` Roman Mamedov @ 2012-10-03 6:40 ` Sébastien Maury 2012-10-03 9:14 ` Martin Steigerwald 1 sibling, 0 replies; 14+ messages in thread From: Sébastien Maury @ 2012-10-03 6:40 UTC (permalink / raw) To: Roman Mamedov, Goffredo Baroncelli Cc: Chris Mason, linux-btrfs@vger.kernel.org, Hugo Mills, Goffredo Baroncelli, sebastien.maury Hi, Thanks for this patch. Personally, i don't mind any of the propositions as the developpement is still in progress and may be adapted. Furthermore, as Roman said, df is more well known for unix users. Thanks to your work on that, i've started developing a bunch of scripts for monitoring btrfs disk usage (and also for monitoring snapper if anyone use it) through nagios. Regards. Sébastien Roman Mamedov <rm@romanrm.ru> a écrit : > On Wed, 3 Oct 2012 08:22:06 +0200 > Goffredo Baroncelli <kreijack@gmail.com> wrote: > >> On Wed, Oct 3, 2012 at 1:46 AM, Chris Mason >> <chris.mason@fusionio.com> wrote: >> [...] >> > I like it, thanks. Could you please update btrfs fi df to show this >> > instead of adding a new command though? >> >> Hi Chris, >> no problem to update the patches, however I have one suggestion: >> - leave "btrfs fi df" as is to no break any script (if any) which >> would uses it. Hide it from the help and deprecating it in the man >> page. This because the output is very different. >> - renaming "btrfs fi disk-usage" in "btrfs fi disk-free", which make sense. > > 1) btrfs is still labeled experimental, so no script author should have > seriously relied on utilities text output to stay unchanged long-term; > personally I don't see modifying it (especially not in some superficial way, > but as a part of major improvement) to be a problem; > > 2) "disk-usage" and "disk-free" are both way too awkward and too > long to type, > compared to "fi df", and "df" is the expected shorthand for "disk > free" in the > UNIX land. > > -- > With respect, > Roman > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > "Stallman had a printer, > with code he could not see. > So he began to tinker, > and set the software free." > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-03 6:34 ` Roman Mamedov 2012-10-03 6:40 ` Sébastien Maury @ 2012-10-03 9:14 ` Martin Steigerwald 1 sibling, 0 replies; 14+ messages in thread From: Martin Steigerwald @ 2012-10-03 9:14 UTC (permalink / raw) To: linux-btrfs Cc: Roman Mamedov, Goffredo Baroncelli, Chris Mason, Hugo Mills, Sébastien Maury, Goffredo Baroncelli Am Mittwoch, 3. Oktober 2012 schrieb Roman Mamedov: > On Wed, 3 Oct 2012 08:22:06 +0200 > > Goffredo Baroncelli <kreijack@gmail.com> wrote: > > On Wed, Oct 3, 2012 at 1:46 AM, Chris Mason > > <chris.mason@fusionio.com> wrote: [...] > > > > > I like it, thanks. Could you please update btrfs fi df to show > > > this instead of adding a new command though? > > > > Hi Chris, > > no problem to update the patches, however I have one suggestion: > > - leave "btrfs fi df" as is to no break any script (if any) which > > would uses it. Hide it from the help and deprecating it in the man > > page. This because the output is very different. > > - renaming "btrfs fi disk-usage" in "btrfs fi disk-free", which make > > sense. > > 1) btrfs is still labeled experimental, so no script author should have > seriously relied on utilities text output to stay unchanged long-term; > personally I don't see modifying it (especially not in some superficial > way, but as a part of major improvement) to be a problem; I am not fond of parsing command output unless using specific options that some commands provide to just provide one value. I.e. if the command provides options specifically for scripts parsing output. And if I do it nonetheless, I am not surprised when it breaks at a time, like with find - ls which now reports decimal part of file modification timestamps. I think having a library with a function to get those values via a defined API would be way to go. Or querying such stuff via udisks or whatever. I am very happy to see better size reporting. -- Martin 'Helios' Steigerwald - http://www.Lichtvoll.de GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage 2012-10-03 6:22 ` Goffredo Baroncelli 2012-10-03 6:34 ` Roman Mamedov @ 2012-10-03 11:22 ` Chris Mason 1 sibling, 0 replies; 14+ messages in thread From: Chris Mason @ 2012-10-03 11:22 UTC (permalink / raw) To: Goffredo Baroncelli Cc: Chris Mason, linux-btrfs@vger.kernel.org, Hugo Mills, Roman Mamedov, Sébastien Maury, Goffredo Baroncelli On Wed, Oct 03, 2012 at 12:22:06AM -0600, Goffredo Baroncelli wrote: > On Wed, Oct 3, 2012 at 1:46 AM, Chris Mason <chris.mason@fusionio.com> wrote: > [...] > > I like it, thanks. Could you please update btrfs fi df to show this > > instead of adding a new command though? > > Hi Chris, > no problem to update the patches, however I have one suggestion: > - leave "btrfs fi df" as is to no break any script (if any) which > would uses it. Hide it from the help and deprecating it in the man > page. This because the output is very different. > - renaming "btrfs fi disk-usage" in "btrfs fi disk-free", which make sense. > > Let me know which choiche you prefer. I think it is better to replace btrfs fi df. There should not be many scripts relying on it yet. -chris ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH][BTRFS-PROGS][V1] btrfs filesystem df
@ 2012-10-03 11:43 Goffredo Baroncelli
2012-10-03 11:43 ` [PATCH 2/2] Update help page Goffredo Baroncelli
0 siblings, 1 reply; 14+ messages in thread
From: Goffredo Baroncelli @ 2012-10-03 11:43 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, Goffredo Baroncelli
This serie of patches updated the command "btrfs filesystem
df". I update this command because it is not so easy to get
the information about the disk usage from the command "fi df" and "fi show".
>From the man page (see 2nd patch):
[...]
The command btrfs filesystem df is used to query the
status of the chunks, how many space on the disk(s) are used by
the chunks, how many space are available in the chunks, and an
estimation of the free space of the filesystem.
[...]
$ ./btrfs filesystem df --help
usage: btrfs filesystem disk-usage [-d][-s][-k] <path> [<path>..]
Show space usage information for a mount point(s).
-k Set KB (1024 bytes) as unit
-s Don't show the summary section
-d Don't show the detail section
$ ./btrfs filesystem df /
Path: /
Summary:
Disk_size: 72.57GB
Disk_allocated: 25.10GB
Disk_unallocated: 47.48GB
Logical_size: 23.06GB
Used: 11.01GB
Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB)
Data_to_disk_ratio: 92 %
Details:
Chunk-type Mode Chunk-size Logical-size Used
Data Single 21.01GB 21.01GB 10.34GB
System DUP 80.00MB 40.00MB 4.00KB
System Single 4.00MB 4.00MB 0.00
Metadata DUP 4.00GB 2.00GB 686.93MB
Metadata Single 8.00MB 8.00MB 0.00
Where:
Disk_size -> sum of sizes of teh disks
Disk_allocated -> sum of chunk sizes
Disk_unallocated -> Disk_size - Disk_allocated
Logical_size -> sum of logical area sizes
Used -> logical area used
Free_(Estimated) -> on the basis of allocated
chunk, an estrapolation of
the free space
Data_to_disk_ratio -> ration between the space occuped
by a chunk and the real space
available ( due to duplication
and/or RAID level)
Chunk-type -> kind of chunk
Mode -> allocation policy of a chunk
Chunk-size -> area of disk(s) occuped by the
chunk (see it as raw space used)
Logical-size -> logical area size of the chunk
Used -> portion of the logical area
used by the filesystem
You can pull this change from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
disk_free
Comments are welcome.
BR
Goffredo Baroncelli
Changelog:
V0->V1 Change the name of command from disk-usage to df
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-03 11:43 [PATCH][BTRFS-PROGS][V1] btrfs filesystem df Goffredo Baroncelli @ 2012-10-03 11:43 ` Goffredo Baroncelli 0 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-03 11:43 UTC (permalink / raw) To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, Goffredo Baroncelli --- man/btrfs.8.in | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..ed20448 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem df\fP\fI [-s][-d][-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -214,6 +216,98 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem df\fP [-s][-d][-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fB-s\fP Don't show the summary section + +\fB-d\fP Don't show the detail section + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +A chunk DUPlicated or with a RAID1/RAID10 level +requires a space two time greater than the logical one. Different RAID levels +have a different ratio disk-usage / logical space offered. + +Because some files (the small ones) are stored in the +metadata chunks the computation of the \fIfree space\fP and \fIused space\fP +is complex: depending by the file size different allocation policies are used. + +The command \fBbtrfs filesystem df\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem df\fP shows: + +.RS +.IP Disk\ size +the total size of the disks which compose the filesystem. + +.IP Disk\ allocated +the size of the area of the disks used by the chunks. + +.IP Disk\ unallocated +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP Logical\ size +the available logical space of chunk. + +.IP Used +the portion of the logical space used by the file and metadata. + +.IP Free\ (estimated) +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP Data\ to\ disk\ ratio +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP Mode +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH][BTRFS-PROGS][V2] btrfs filesystem df
@ 2012-10-03 17:22 Goffredo Baroncelli
2012-10-03 17:22 ` [PATCH 2/2] Update help page Goffredo Baroncelli
0 siblings, 1 reply; 14+ messages in thread
From: Goffredo Baroncelli @ 2012-10-03 17:22 UTC (permalink / raw)
To: linux-btrfs; +Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov
>From the man page (see 2nd patch):
[...]
The command btrfs filesystem df is used to query the
status of the chunks, how many space on the disk(s) are used by
the chunks, how many space are available in the chunks, and an
estimation of the free space of the filesystem.
[...]
$ ./btrfs filesystem df --help
usage: btrfs filesystem disk-usage [-d|-s][-k] <path> [<path>..]
Show space usage information for a mount point(s).
-k Set KB (1024 bytes) as unit
-s Show the summary section only
-d Show the detail section only
$ ./btrfs filesystem df /
Path: /
Summary:
Disk_size: 72.57GB
Disk_allocated: 25.10GB
Disk_unallocated: 47.48GB
Logical_size: 23.06GB
Used: 11.01GB
Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB)
Data_to_disk_ratio: 92 %
Details:
Chunk-type Mode Chunk_size Logical_size Used
Data Single 21.01GB 21.01GB 10.34GB
System DUP 80.00MB 40.00MB 4.00KB
System Single 4.00MB 4.00MB 0.00
Metadata DUP 4.00GB 2.00GB 686.93MB
Metadata Single 8.00MB 8.00MB 0.00
Where:
Disk_size -> sum of sizes of teh disks
Disk_allocated -> sum of chunk sizes
Disk_unallocated -> Disk_size - Disk_allocated
Logical_size -> sum of logical area sizes
Used -> logical area used
Free_(Estimated) -> on the basis of allocated
chunk, an estrapolation of
the free space
Data_to_disk_ratio -> ration between the space occuped
by a chunk and the real space
available ( due to duplication
and/or RAID level)
Chunk_type -> kind of chunk
Mode -> allocation policy of a chunk
Chunk_size -> area of disk(s) occuped by the
chunk (see it as raw space used)
Logical_size -> logical area size of the chunk
Used -> portion of the logical area
used by the filesystem
You can pull this change from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
disk_free
Please pull.
BR
Goffredo Baroncelli
Changelog:
V0->V1 Change the name of command from disk-usage to df
V1->V2 Uses getopt(); replace "-" with "_"; change the behaviour
of the switches '-s' and '-d'.
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-03 17:22 [PATCH][BTRFS-PROGS][V2] btrfs filesystem df Goffredo Baroncelli @ 2012-10-03 17:22 ` Goffredo Baroncelli 0 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-03 17:22 UTC (permalink / raw) To: linux-btrfs Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> --- man/btrfs.8.in | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..0db588f 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem df\fP\fI [-s|-d][-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -214,6 +216,98 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem df\fP [-s|-d][-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fB-s\fP Show the summary section only + +\fB-d\fP Show the detail section only + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +A chunk DUPlicated or with a RAID1/RAID10 level +requires a space two time greater than the logical one. Different RAID levels +have a different ratio disk-usage / logical space offered. + +Because some files (the small ones) are stored in the +metadata chunks the computation of the \fIfree space\fP and \fIused space\fP +is complex: depending by the file size different allocation policies are used. + +The command \fBbtrfs filesystem df\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem df\fP shows: + +.RS +.IP Disk\ size +the total size of the disks which compose the filesystem. + +.IP Disk\ allocated +the size of the area of the disks used by the chunks. + +.IP Disk\ unallocated +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP Logical\ size +the available logical space of chunk. + +.IP Used +the portion of the logical space used by the file and metadata. + +.IP Free\ (estimated) +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP Data\ to\ disk\ ratio +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP Mode +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH][BTRFS-PROGS][V3] btrfs filesystem df
@ 2012-10-04 17:27 Goffredo Baroncelli
2012-10-04 17:27 ` [PATCH 2/2] Update help page Goffredo Baroncelli
0 siblings, 1 reply; 14+ messages in thread
From: Goffredo Baroncelli @ 2012-10-04 17:27 UTC (permalink / raw)
To: Chris Mason
Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov,
linux-btrfs
Hi Chris,
this serie of patches updated the command "btrfs filesystem
df". I update this command because it is not so easy to get
the information about the disk usage from the command "fi df" and "fi show".
This patch was the result of some discussions on the btrfs
mailing list. Many thanks to all the contributors.
>From the man page (see 2nd patch):
[...]
The command btrfs filesystem df is used to query the
status of the chunks, how many space on the disk(s) are used by
the chunks, how many space are available in the chunks, and an
estimation of the free space of the filesystem.
[...]
$ ./btrfs filesystem df --help
usage: btrfs filesystem disk-usage [-k] <path> [<path>..]
Show space usage information for a mount point(s).
-k Set KB (1024 bytes) as unit
$ ./btrfs filesystem df /
Path: /
Summary:
Disk_size: 72.57GB
Disk_allocated: 25.10GB
Disk_unallocated: 47.48GB
Logical_size: 23.06GB
Used: 11.01GB
Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB)
Data_to_disk_ratio: 92 %
Details:
Chunk_type Mode Size_(disk) Size_(logical) Used
Data Single 21.01GB 21.01GB 10.34GB
System DUP 80.00MB 40.00MB 4.00KB
System Single 4.00MB 4.00MB 0.00
Metadata DUP 4.00GB 2.00GB 686.93MB
Metadata Single 8.00MB 8.00MB 0.00
Where:
Disk_size -> sum of sizes of teh disks
Disk_allocated -> sum of chunk sizes
Disk_unallocated -> Disk_size - Disk_allocated
Logical_size -> sum of logical area sizes
Used -> logical area used
Free_(Estimated) -> on the basis of allocated
chunk, an estrapolation of
the free space
Data_to_disk_ratio -> ration between the space occuped
by a chunk and the real space
available ( due to duplication
and/or RAID level)
Chunk_type -> kind of chunk
Mode -> allocation policy of a chunk
Size_(disk) -> area of disk(s) occuped by the
chunk (see it as raw space used)
Size_(logical) -> logical area size of the chunk
Used -> portion of the logical area
used by the filesystem
You can pull this change from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
disk_free
Please pull.
BR
Goffredo Baroncelli
Changelog:
V0->V1 Change the name of command from disk-usage to df
V1->V2 Uses getopt(); replace "-" with "_"; change the behaviour
of the switches '-s' and '-d'.
V2->V3 Removed the options '-s' and '-d'; replaced Chunk-size
and Logical-size with Size_(disk) and Size_(logical).
Update the man page.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-04 17:27 [PATCH][BTRFS-PROGS][V3] btrfs filesystem df Goffredo Baroncelli @ 2012-10-04 17:27 ` Goffredo Baroncelli 0 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-04 17:27 UTC (permalink / raw) To: Chris Mason Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, linux-btrfs, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> --- man/btrfs.8.in | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..96c9239 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem df\fP\fI [-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -214,6 +216,104 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem df\fP [-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +Depending by the allocation policy a chunk may require a space on +the disk greater than the logical space that it provides. E.g. +a chunk DUPlicated or with a RAID1/RAID10 level +requires a space on the disk +two times greater than the logical space provided. +Different RAID levels +have a different ratio disk-usage / logical space offered. + +Normally the file contents are stored in the Data chunks; however +small files (which fit into a btree leaf) are stored in the +metadata chunks. So the computation of the \fIfree space\fP +and \fIused space\fP +is complex: depending by the file size different +allocation policies are used. + +The command \fBbtrfs filesystem df\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem df\fP shows: + +.RS +.IP \fBDisk\ size\fP +the total size of the disks which compose the filesystem. + +.IP \fBDisk\ allocated\fP\ or\ \fBSize_(disk)\fP +the size of the area of the disks used by the chunks. + +.IP \fBDisk\ unallocated\fP +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP \fBLogical\ size\fP\ or\ \fBSize_(logical)\fP +the available logical space of chunk. + +.IP \fBUsed\fP +the portion of the logical space used by the file and metadata. + +.IP \fBFree\ (estimated)\fP +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP \fBData\ to\ disk\ ratio\fP +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP \fBMode\fP +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.IP \fBChunk\ type\fP +the kind of chunk (Data, Metdata, System...) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH][BTRFS-PROGS][V4] btrfs filesystem df @ 2012-10-13 17:47 Goffredo Baroncelli 2012-10-13 17:47 ` [PATCH 2/2] Update help page Goffredo Baroncelli 0 siblings, 1 reply; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-13 17:47 UTC (permalink / raw) To: Chris Mason Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, linux-btrfs, Martin Steigerwald Hi Chris, this serie of patches updated the command "btrfs filesystem df". I update this command because it is not so easy to get the information about the disk usage from the command "fi df" and "fi show". This patch was the result of some discussions on the btrfs mailing list. Many thanks to all the contributors. from the man page (see 2nd patch): [...] The command btrfs filesystem df is used to query the status of the chunks, how many space on the disk(s) are used by the chunks, how many space are available in the chunks, and an estimation of the free space of the filesystem. [...] $ ./btrfs filesystem df --help usage: btrfs filesystem disk-usage [-k] <path> [<path>..] Show space usage information for a mount point(s). -k Set KB (1024 bytes) as unit $ ./btrfs filesystem df / Path: / Summary: Disk_size: 72.57GB Disk_allocated: 25.10GB Disk_unallocated: 47.48GB Logical_size: 23.06GB Used: 11.01GB Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB) Data_to_disk_ratio: 92 % Allocated_area: Type Mode Size_(disk) Size_(logical) Used Data Single 21.01GB 21.01GB 12.77GB System DUP 80.00MB 40.00MB 4.00KB System Single 4.00MB 4.00MB 0.00 Metadata DUP 4.00GB 2.00GB 709.63MB Metadata Single 8.00MB 8.00MB 0.00 Where: Disk_size -> sum of sizes of teh disks Disk_allocated -> sum of chunk sizes Disk_unallocated -> Disk_size - Disk_allocated Logical_size -> sum of logical area sizes Used -> logical area used Free_(Estimated) -> on the basis of allocated chunk, an estrapolation of the free space Data_to_disk_ratio -> ration between the space occuped by a chunk and the real space available ( due to duplication and/or RAID level) Type -> kind of chunk Mode -> allocation policy of a chunk Size_(disk) -> area of disk(s) occuped by the chunk (see it as raw space used) Size_(logical) -> logical area size of the chunk Used -> portion of the logical area used by the filesystem You can pull this change from http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git branch disk_free Please pull. BR Goffredo Baroncelli Changelog: V3->V4 Removed the switch -d -s from getopt(), aligned the column Size_(logical), renamed the fields: - Details -> Allocated_area - Chunk_type -> Type V2->V3 Removed the options '-s' and '-d'; replaced Chunk-size and Logical-size with Size_(disk) and Size_(logical). Update the man page. V1->V2 Uses getopt(); replace "-" with "_"; change the behaviour of the switches '-s' and '-d'. V0->V1 Change the name of command from disk-usage to df ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-13 17:47 [PATCH][BTRFS-PROGS][V4] btrfs filesystem df Goffredo Baroncelli @ 2012-10-13 17:47 ` Goffredo Baroncelli 0 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-13 17:47 UTC (permalink / raw) To: Chris Mason Cc: Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, linux-btrfs, Martin Steigerwald, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> --- man/btrfs.8.in | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..ecd0916 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem df\fP\fI [-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -214,6 +216,104 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem df\fP [-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +Depending by the allocation policy a chunk may require a space on +the disk greater than the logical space that it provides. E.g. +a chunk DUPlicated or with a RAID1/RAID10 level +requires a space on the disk +two times greater than the logical space provided. +Different RAID levels +have a different ratio disk-usage / logical space offered. + +Normally the file contents are stored in the Data chunks; however +small files (which fit into a btree leaf) are stored in the +metadata chunks. So the computation of the \fIfree space\fP +and \fIused space\fP +is complex: depending by the file size different +allocation policies are used. + +The command \fBbtrfs filesystem df\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem df\fP shows: + +.RS +.IP \fBDisk\ size\fP +the total size of the disks which compose the filesystem. + +.IP \fBDisk\ allocated\fP\ or\ \fBSize_(disk)\fP +the size of the area of the disks used by the chunks. + +.IP \fBDisk\ unallocated\fP +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP \fBLogical\ size\fP\ or\ \fBSize_(logical)\fP +the available logical space of chunk. + +.IP \fBUsed\fP +the portion of the logical space used by the file and metadata. + +.IP \fBFree\ (estimated)\fP +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP \fBData\ to\ disk\ ratio\fP +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP \fBMode\fP +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.IP \fBType\fP +the kind of chunk (Data, Metdata, System...) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH][BTRFS-PROGS][V6] btrfs filesystem df @ 2012-10-13 19:14 Goffredo Baroncelli 2012-10-13 19:14 ` [PATCH 2/2] Update help page Goffredo Baroncelli 0 siblings, 1 reply; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-13 19:14 UTC (permalink / raw) To: Chris Mason Cc: Goffredo Baroncelli, Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, linux-btrfs, Martin Steigerwald Hi Chris, this serie of patches updated the command "btrfs filesystem df". I update this command because it is not so easy to get the information about the disk usage from the command "fi df" and "fi show". This patch was the result of some discussions on the btrfs mailing list. Many thanks to all the contributors. from the man page (see 2nd patch): [...] The command btrfs filesystem df is used to query the status of the chunks, how many space on the disk(s) are used by the chunks, how many space are available in the chunks, and an estimation of the free space of the filesystem. [...] $ ./btrfs filesystem df --help usage: btrfs filesystem disk-usage [-k] <path> [<path>..] Show space usage information for a mount point(s). -k Set KB (1024 bytes) as unit $ ./btrfs filesystem df / Path: / Summary: Disk_size: 72.57GB Disk_allocated: 25.10GB Disk_unallocated: 47.48GB Logical_size: 23.06GB Used: 11.01GB Free_(Estimated): 55.66GB (Max: 59.52GB, Min: 35.78GB) Data_to_disk_ratio: 92 % Allocated_area: Type Mode Size_(disk) Size_(logical) Used Data Single 21.01GB 21.01GB 12.77GB System DUP 80.00MB 40.00MB 4.00KB System Single 4.00MB 4.00MB 0.00 Metadata DUP 4.00GB 2.00GB 709.63MB Metadata Single 8.00MB 8.00MB 0.00 Where: Disk_size -> sum of sizes of teh disks Disk_allocated -> sum of chunk sizes Disk_unallocated -> Disk_size - Disk_allocated Logical_size -> sum of logical area sizes Used -> logical area used Free_(Estimated) -> on the basis of allocated chunk, an estrapolation of the free space Data_to_disk_ratio -> ration between the space occuped by a chunk and the real space available ( due to duplication and/or RAID level) Type -> kind of chunk Mode -> allocation policy of a chunk Size_(disk) -> area of disk(s) occuped by the chunk (see it as raw space used) Size_(logical) -> logical area size of the chunk Used -> portion of the logical area used by the filesystem You can pull this change from http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git branch disk_free Please pull. Signed-off-by: Goffredo Baroncelli <kreijack@gmail.com> BR Goffredo Baroncelli Changelog: V5->V6 Th V5 was a wrong patch, please discard it. V4->V5 Add a close(fd) to avoid file descriptor leaking V3->V4 Removed the switch -d -s from getopt(), aligned the column Size_(logical), renamed the fields: - Details -> Allocated_area - Chunk_type -> Type V2->V3 Removed the options '-s' and '-d'; replaced Chunk-size and Logical-size with Size_(disk) and Size_(logical). Update the man page. V1->V2 Uses getopt(); replace "-" with "_"; change the behaviour of the switches '-s' and '-d'. V0->V1 Change the name of command from disk-usage to df ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] Update help page 2012-10-13 19:14 [PATCH][BTRFS-PROGS][V6] btrfs filesystem df Goffredo Baroncelli @ 2012-10-13 19:14 ` Goffredo Baroncelli 0 siblings, 0 replies; 14+ messages in thread From: Goffredo Baroncelli @ 2012-10-13 19:14 UTC (permalink / raw) To: Chris Mason Cc: Goffredo Baroncelli, Hugo Mills, Roman Mamedov, Sébastien Maury, Ilya Dryomov, linux-btrfs, Martin Steigerwald, Goffredo Baroncelli From: Goffredo Baroncelli <kreijack@inwind.it> --- man/btrfs.8.in | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 9222580..7048273 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -27,6 +27,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP .PP +\fBbtrfs\fP \fBfilesystem df\fP\fI [-k] \fIpath [path..]\fR\fP +.PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP @@ -242,6 +244,104 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP +\fBfilesystem df\fP [-k] \fIpath [path..]\fR + +Show space usage information for a mount point. + +\fIOptions\fP + +\fB-k\fP Set KB (1024 bytes) as unit + +\fIUsage information\fP + +.\" +.\" this section is extract from +.\" http://en.wikipedia.org/wiki/Btrfs#Chunk_and_device_trees +The disk(s) of a btrfs filesystem are divided into chunks of 256 MB or more. +Chunks may be mirrored or striped across multiple devices, depending by +the allocation policy. +The mirroring/striping arrangement is transparent to the rest of the +file system, which simply sees the single, logical address space that +chunks are mapped into. +Chunks are allocated on demand. In the default allocation policy +the data chunks are not duplicated and the metadata chunks +are duplicated. This default can be changed during the filesystem +creation, and in general the chunks allocation policy may change +during the filesystem life. + +Depending by the allocation policy a chunk may require a space on +the disk greater than the logical space that it provides. E.g. +a chunk DUPlicated or with a RAID1/RAID10 level +requires a space on the disk +two times greater than the logical space provided. +Different RAID levels +have a different ratio disk-usage / logical space offered. + +Normally the file contents are stored in the Data chunks; however +small files (which fit into a btree leaf) are stored in the +metadata chunks. So the computation of the \fIfree space\fP +and \fIused space\fP +is complex: depending by the file size different +allocation policies are used. + +The command \fBbtrfs filesystem df\fP is used to query the status +of the chunks, how many space on the disk(s) are used by the chunks, +how many space are available in the chunks, and an estimation of the free +space of the filesystem. +The output of the command \fBbtrfs filesystem df\fP shows: + +.RS +.IP \fBDisk\ size\fP +the total size of the disks which compose the filesystem. + +.IP \fBDisk\ allocated\fP\ or\ \fBSize_(disk)\fP +the size of the area of the disks used by the chunks. + +.IP \fBDisk\ unallocated\fP +the size of the area of the disks which is free (i.e. +the differences of the values above). + +.IP \fBLogical\ size\fP\ or\ \fBSize_(logical)\fP +the available logical space of chunk. + +.IP \fBUsed\fP +the portion of the logical space used by the file and metadata. + +.IP \fBFree\ (estimated)\fP +the estimated free space available. The evaluation +cannot be rigorous because it depends by the allocation policy (DUP,Single, +RAID1...) of the metadata and data chunks. If every chunks is stored as +"Single" the sum of the \fBfree (estimated)\fP space and the \fBused\fP +space is equal to the \fBdisk size\fP. +Otherwise if all the chunk are mirrored (raid1 or raid10) or duplicated +the sum of the \fBfree (estimated)\fP space and the \fBused\fP space is +half of the \fBdisk size\fP. Normally the \fBfree (estimated)\fP is between +these two limits. + +.IP \fBData\ to\ disk\ ratio\fP +the ratio betwen the \fBlogical size\fP and the \fBdisk allocated\fP. + +.IP \fBMode\fP +the kind of allocation policy used by the chunk (e.g. DUPlicated, +RAID1, RAID10, Single....) + +.IP \fBType\fP +the kind of chunk (Data, Metdata, System...) + +.RE +.RS +\fINOTE\fP + +When a chunk is allocated, its disk-area is used and its allocation +policy is fixed. +A rebalance operation could rearrange the chunks, moving data in the chunks +and resizing the allocated chunks. This causes the change of all the values +discussed above, with the exception of the \fBused\fP and +\fBdisk size\fP values. + +.RE +.TP + \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR Show the btrfs filesystem with some additional info. If no \fIUUID\fP or \fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem. -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-10-13 19:14 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-10-02 18:36 [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 1/2] Add btrfs filesystem disk-usage command Goffredo Baroncelli 2012-10-02 18:36 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-02 23:46 ` [PATCH][BTRFS-PROGS] btrfs filesystem disk-usage Chris Mason 2012-10-03 6:22 ` Goffredo Baroncelli 2012-10-03 6:34 ` Roman Mamedov 2012-10-03 6:40 ` Sébastien Maury 2012-10-03 9:14 ` Martin Steigerwald 2012-10-03 11:22 ` Chris Mason -- strict thread matches above, loose matches on Subject: below -- 2012-10-03 11:43 [PATCH][BTRFS-PROGS][V1] btrfs filesystem df Goffredo Baroncelli 2012-10-03 11:43 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-03 17:22 [PATCH][BTRFS-PROGS][V2] btrfs filesystem df Goffredo Baroncelli 2012-10-03 17:22 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-04 17:27 [PATCH][BTRFS-PROGS][V3] btrfs filesystem df Goffredo Baroncelli 2012-10-04 17:27 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-13 17:47 [PATCH][BTRFS-PROGS][V4] btrfs filesystem df Goffredo Baroncelli 2012-10-13 17:47 ` [PATCH 2/2] Update help page Goffredo Baroncelli 2012-10-13 19:14 [PATCH][BTRFS-PROGS][V6] btrfs filesystem df Goffredo Baroncelli 2012-10-13 19:14 ` [PATCH 2/2] Update help page Goffredo Baroncelli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).