[PATCH 0/2] btrfs-progs: prevent mkfs from aborting with small volume
I found that mkfs.btrfs aborts when one of assigned volume is too small. Here are 2 patches to fix 2 independent problems. Both are based on top of Chris's btrfs-progs.git: git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git Thanks, H.Seto Hidetoshi Seto (2): btrfs-progs: treat reserved 1MB for superblock properly btrfs-progs: exit if there is not enough free space for mkfs ctree.h |3 +++ mkfs.c|4 volumes.c |7 ++- 3 files changed, 13 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] btrfs-progs: treat reserved 1MB for superblock properly
I found that mkfs.btrfs aborts when assigned multi volumes contain a small volume: # parted /dev/sdf p Model: LSI MegaRAID SAS RMB (scsi) Disk /dev/sdf: 72.8GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End SizeType File system Flags 1 32.3kB 72.4GB 72.4GB primary 2 72.4GB 72.8GB 461MB primary # ./mkfs.btrfs -f /dev/sdf1 /dev/sdf2 : SMALL VOLUME: forcing mixed metadata/data groups adding device /dev/sdf2 id 2 mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) This failure of btrfs_alloc_chunk was caused by following steps: 1) since there is only small space in the small device, mkfs was going to allocate a chunk from free space as much as available. So mkfs called btrfs_alloc_chunk with size = device->total_bytes - device->used_bytes. 2) To avoid overwriting superblock, btrfs_alloc_chunk starts taking chunks at an offset of 1MB. It means that the layout of a disk will be like: [[1MB at begging for sb][allocated chunks]* ... free space ... ] and you can see that the available free space for allocation is: avail = device->total_bytes - device->used_bytes - 1MB. 3) Therefore there is only free space 1MB less than requested. damn. So this fix let mkfs know how much spaces are really there. Signed-off-by: Hidetoshi Seto --- ctree.h |3 +++ volumes.c |7 ++- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/ctree.h b/ctree.h index 0b0d701..791bd14 100644 --- a/ctree.h +++ b/ctree.h @@ -811,6 +811,9 @@ struct btrfs_csum_item { u8 csum; } __attribute__ ((__packed__)); +/* we have reserved 1M for superblock at the begging of device */ +#define BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ((u64)1024 * 1024) + /* tag for the radix tree of block groups in ram */ #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) diff --git a/volumes.c b/volumes.c index 0ff2283..bf6b2e1 100644 --- a/volumes.c +++ b/volumes.c @@ -283,7 +283,7 @@ static int find_free_dev_extent(struct btrfs_trans_handle *trans, /* we don't want to overwrite the superblock on the drive, * so we make sure to start at an offset of at least 1MB */ - search_start = max((u64)1024 * 1024, search_start); + search_start = max(BTRFS_BLOCK_RESERVED_1M_FOR_SUPER, search_start); if (root->fs_info->alloc_start + num_bytes <= device->total_bytes) search_start = max(root->fs_info->alloc_start, search_start); @@ -783,6 +783,11 @@ again: while(index < num_stripes) { device = list_entry(cur, struct btrfs_device, dev_list); avail = device->total_bytes - device->bytes_used; + /* we have reserved 1M for superblock at the head of device */ + if (avail > BTRFS_BLOCK_RESERVED_1M_FOR_SUPER) + avail -= BTRFS_BLOCK_RESERVED_1M_FOR_SUPER; + else + avail = 0; cur = cur->next; if (avail >= min_free) { list_move_tail(&device->dev_list, &private_devs); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] btrfs-progs: exit if there is not enough free space for mkfs
Again, while playing mkfs with small volumes, I found that mkfs.btrfs aborts if there is really no spaces for a brand-new filesystem: # ./mkfs.btrfs -f /dev/sdf1 /dev/sdf2 : SMALL VOLUME: forcing mixed metadata/data groups adding device /dev/sdf2 id 2 mkfs.btrfs: mkfs.c:184: create_one_raid_group: Assertion `!(ret)' failed. Aborted (core dumped) This fix let mkfs prints error message if it cannot make filesystem due to a lack of free spaces. Signed-off-by: Hidetoshi Seto --- mkfs.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/mkfs.c b/mkfs.c index b412b7e..3c0bc60 100644 --- a/mkfs.c +++ b/mkfs.c @@ -181,6 +181,10 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans, ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root, &chunk_start, &chunk_size, type); + if (ret == -ENOSPC) { + fprintf(stderr, "not enough free space\n"); + exit(1); + } BUG_ON(ret); ret = btrfs_make_block_group(trans, root->fs_info->extent_root, 0, type, BTRFS_FIRST_CHUNK_TREE_OBJECTID, -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] btrfs-progs: prevent mkfs from aborting with small volume
(2013/08/26 23:23), Eric Sandeen wrote: > Thanks for looking into this - how small of a device did you test? > > I tried a 2MB device w/ these 2 patches and still got: > > [btrfs-progs]# truncate --size=2m testfile > [btrfs-progs]# ./mkfs.btrfs testfile > > WARNING! - Btrfs v0.20-rc1-360-geeeb4e9 IS EXPERIMENTAL > WARNING! - see http://btrfs.wiki.kernel.org before using > > SMALL VOLUME: forcing mixed metadata/data groups > mkfs.btrfs: volumes.c:857: btrfs_alloc_chunk: Assertion `!(ret)' failed. > Aborted (core dumped) > > which was at: > > ret = btrfs_alloc_dev_extent(trans, device, > info->chunk_root->root_key.objectid, > BTRFS_FIRST_CHUNK_TREE_OBJECTID, key.offset, > calc_size, &dev_offset); > BUG_ON(ret); > > :( Wow... It seems that this abort is different problem from the bug which my patches are going to fix. I'll try to make new patch to fix this problem. > > Also, I'm curious - I know the code existed before your patch 2/2, > but I don't understand why it reserves 1MB for the first superblock > when the first superblock is actually at 64k. Any idea? > > -Eric I'm not sure... According to the git-log, this 1M trick is in the following old commit by Chris: commit a6de0bd778475504f42a142c83b8077993cbddfe Author: Chris Mason Date: Thu Apr 3 16:35:48 2008 -0400 Add mirroring support across multiple drives Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/3] btrfs-progs: prevent mkfs from aborting with small volume
Here are 3 patches to avoid undesired aborts of mkfs.btrfs. These are based on top of Chris's btrfs-progs.git: git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git Thanks, H.Seto Hidetoshi Seto (3): btrfs-progs: error if device for mkfs is too small btrfs-progs: error if device have no space to make primary chunks btrfs-progs: calculate available blocks on device properly ctree.h |8 + mkfs.c| 23 + volumes.c | 104 +--- 3 files changed, 129 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/3] btrfs-progs: error if device for mkfs is too small
Eric pointed out that mkfs abort if specified volume is too small: # truncate --size=2m testfile # ./mkfs.btrfs testfile : SMALL VOLUME: forcing mixed metadata/data groups mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) As the first step to fix problems around there, let mkfs to report error if the size of target volume is less than the size of the first system block group, BTRFS_MKFS_SYSTEM_GROUP_SIZE (= 4MB). Reported-by: Eric Sandeen Signed-off-by: Hidetoshi Seto --- mkfs.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/mkfs.c b/mkfs.c index b412b7e..a98fe54 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1422,6 +1422,12 @@ int main(int ac, char **av) } } + /* To create the first block group and chunk 0 in make_btrfs */ + if (dev_block_count < BTRFS_MKFS_SYSTEM_GROUP_SIZE) { + fprintf(stderr, "device is too small to make filesystem\n"); + exit(1); + } + blocks[0] = BTRFS_SUPER_INFO_OFFSET; for (i = 1; i < 7; i++) { blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 + -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/3] btrfs-progs: error if device have no space to make primary chunks
The previous patch works fine if the size of specified volume to mkfs is less than 4MB. However usually btrfs requires more than 4MB to work, and the minimum preferred size is depending on the raid setting etc. This patch let mkfs print error message if it cannot allocate one of chunks should be there at first. [before] # truncate --size=4500K testfile # ./mkfs.btrfs -f testfile : SMALL VOLUME: forcing mixed metadata/data groups mkfs.btrfs: mkfs.c:84: make_root_dir: Assertion `!(ret)' failed. Aborted (core dumped) [After] # truncate --size=4500K testfile # ./mkfs.btrfs -f testfile : SMALL VOLUME: forcing mixed metadata/data groups no space to alloc data/metadata chunk failed to setup the root directory TBD is calculate minimum size for setting and put it in the error message to let user know how large amount of volume is required. Signed-off-by: Hidetoshi Seto --- mkfs.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/mkfs.c b/mkfs.c index a98fe54..bac122f 100644 --- a/mkfs.c +++ b/mkfs.c @@ -81,6 +81,11 @@ static int make_root_dir(struct btrfs_root *root, int mixed) &chunk_start, &chunk_size, BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA); + if (ret == -ENOSPC) { + fprintf(stderr, + "no space to alloc data/metadata chunk\n"); + goto err; + } BUG_ON(ret); ret = btrfs_make_block_group(trans, root, 0, BTRFS_BLOCK_GROUP_METADATA | @@ -93,6 +98,10 @@ static int make_root_dir(struct btrfs_root *root, int mixed) ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root, &chunk_start, &chunk_size, BTRFS_BLOCK_GROUP_METADATA); + if (ret == -ENOSPC) { + fprintf(stderr, "no space to alloc metadata chunk\n"); + goto err; + } BUG_ON(ret); ret = btrfs_make_block_group(trans, root, 0, BTRFS_BLOCK_GROUP_METADATA, @@ -110,6 +119,10 @@ static int make_root_dir(struct btrfs_root *root, int mixed) ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root, &chunk_start, &chunk_size, BTRFS_BLOCK_GROUP_DATA); + if (ret == -ENOSPC) { + fprintf(stderr, "no space to alloc data chunk\n"); + goto err; + } BUG_ON(ret); ret = btrfs_make_block_group(trans, root, 0, BTRFS_BLOCK_GROUP_DATA, @@ -181,6 +194,10 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans, ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root, &chunk_start, &chunk_size, type); + if (ret == -ENOSPC) { + fprintf(stderr, "not enough free space\n"); + exit(1); + } BUG_ON(ret); ret = btrfs_make_block_group(trans, root->fs_info->extent_root, 0, type, BTRFS_FIRST_CHUNK_TREE_OBJECTID, -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] btrfs-progs: calculate available blocks on device properly
I found that mkfs.btrfs aborts when assigned multi volumes contain a small volume: # parted /dev/sdf p Model: LSI MegaRAID SAS RMB (scsi) Disk /dev/sdf: 72.8GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End SizeType File system Flags 1 32.3kB 72.4GB 72.4GB primary 2 72.4GB 72.8GB 461MB primary # ./mkfs.btrfs -f /dev/sdf1 /dev/sdf2 : SMALL VOLUME: forcing mixed metadata/data groups adding device /dev/sdf2 id 2 mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) This failure of btrfs_alloc_chunk was caused by following steps: 1) since there is only small space in the small device, mkfs was going to allocate a chunk from free space as much as available. So mkfs called btrfs_alloc_chunk with size = device->total_bytes - device->used_bytes. 2) (According to the comment in source code, to avoid overwriting superblock,) btrfs_alloc_chunk starts taking chunks at an offset of 1MB. It means that the layout of a disk will be like: [[1MB at beginning for sb][allocated chunks]* ... free space ... ] and you can see that the available free space for allocation is: avail = device->total_bytes - device->used_bytes - 1MB. 3) Therefore there is only free space 1MB less than requested. damn. >From further investigations I also found that this issue is easily reproduced by using -A, --alloc-start option: # truncate --size=1G testfile # ./mkfs.btrfs -A900M -f testfile : mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) In this case there is only 100MB for allocation but btrfs_alloc_chunk was going to allocate more than the 100MB. The root cause of both of above troubles is a same simple bug: btrfs_chunk_alloc does not calculate available bytes properly even though it researches how many devices have enough room to have a chunk to be allocated. So this patch introduces new function btrfs_device_avail_bytes() which returns available bytes for allocation in specified device. Signed-off-by: Hidetoshi Seto --- ctree.h |8 + volumes.c | 104 +--- 2 files changed, 106 insertions(+), 6 deletions(-) diff --git a/ctree.h b/ctree.h index 0b0d701..90be7ab 100644 --- a/ctree.h +++ b/ctree.h @@ -811,6 +811,14 @@ struct btrfs_csum_item { u8 csum; } __attribute__ ((__packed__)); +/* + * We don't want to overwrite 1M at the beginning of device, even though + * there is our 1st superblock at 64k. Some possible reasons: + * - the first 64k blank is useful for some boot loader/manager + * - the first 1M could be scratched by buggy partitioner or somesuch + */ +#define BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ((u64)1024 * 1024) + /* tag for the radix tree of block groups in ram */ #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) diff --git a/volumes.c b/volumes.c index 0ff2283..e8d7f25 100644 --- a/volumes.c +++ b/volumes.c @@ -268,7 +268,7 @@ static int find_free_dev_extent(struct btrfs_trans_handle *trans, struct btrfs_dev_extent *dev_extent = NULL; u64 hole_size = 0; u64 last_byte = 0; - u64 search_start = 0; + u64 search_start = root->fs_info->alloc_start; u64 search_end = device->total_bytes; int ret; int slot = 0; @@ -283,10 +283,12 @@ static int find_free_dev_extent(struct btrfs_trans_handle *trans, /* we don't want to overwrite the superblock on the drive, * so we make sure to start at an offset of at least 1MB */ - search_start = max((u64)1024 * 1024, search_start); + search_start = max(BTRFS_BLOCK_RESERVED_1M_FOR_SUPER, search_start); - if (root->fs_info->alloc_start + num_bytes <= device->total_bytes) - search_start = max(root->fs_info->alloc_start, search_start); + if (search_start >= search_end) { + ret = -ENOSPC; + goto error; + } key.objectid = device->devid; key.offset = search_start; @@ -660,6 +662,94 @@ static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target) return 64 * 1024; } +/* + * btrfs_device_avail_bytes - count bytes available for alloc_chunk + * + * It is not equal to "device->total_bytes - device->bytes_used". + * We do not allocate any chunk in 1M at beginning of device, and not + * allowed to allocate any chunk before alloc_start if it is specified. + * So search holes from max(1M, alloc_start) to device->total_bytes. + */ +static int btrfs_device_avail_bytes(struct btrfs_trans_handle *trans, + struct btrfs_device *device, + u64 *avail_bytes) +{ + struct
[PATCH] Btrfs: skip submitting barrier for missing device
I got an error on v3.13: BTRFS error (device sdf1) in write_all_supers:3378: errno=-5 IO failure (errors while submitting device barriers.) how to reproduce: > mkfs.btrfs -f -d raid1 /dev/sdf1 /dev/sdf2 > wipefs -a /dev/sdf2 > mount -o degraded /dev/sdf1 /mnt > btrfs balance start -f -sconvert=single -mconvert=single -dconvert=single /mnt The reason of the error is that barrier_all_devices() failed to submit barrier to the missing device. However it is clear that we cannot do anything on missing device, and also it is not necessary to care chunks on the missing device. This patch stops sending/waiting barrier if device is missing. Signed-off-by: Hidetoshi Seto Cc: --- fs/btrfs/disk-io.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8072cfa..7eb50f3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3238,6 +3238,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info) /* send down all the barriers */ head = &info->fs_devices->devices; list_for_each_entry_rcu(dev, head, dev_list) { + if (dev->missing) + continue; if (!dev->bdev) { errors_send++; continue; @@ -3252,6 +3254,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info) /* wait for all the barriers */ list_for_each_entry_rcu(dev, head, dev_list) { + if (dev->missing) + continue; if (!dev->bdev) { errors_wait++; continue; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] btrfs: fix null pointer deference at btrfs_sysfs_add_one+0x105
I still see this trouble on v3.14-rc2. I confirmed that we cannot do mount with -o degraded without this patch. Could you pick this up, Chris? Thanks, H.Seto Feel free to add: Tested-by: Hidetoshi Seto (2014/01/15 18:22), Anand Jain wrote: > bdev is null when disk has disappeared and mounted with > the degrade option > > stack trace > - > btrfs_sysfs_add_one+0x105/0x1c0 [btrfs] > open_ctree+0x15f3/0x1fe0 [btrfs] > btrfs_mount+0x5db/0x790 [btrfs] > ? alloc_pages_current+0xa4/0x160 > mount_fs+0x34/0x1b0 > vfs_kern_mount+0x62/0xf0 > do_mount+0x22e/0xa80 > ? __get_free_pages+0x9/0x40 > ? copy_mount_options+0x31/0x170 > SyS_mount+0x7e/0xc0 > system_call_fastpath+0x16/0x1b > - > > reproducer: > --- > mkfs.btrfs -draid1 -mraid1 /dev/sdc /dev/sdd > (detach a disk) > devmgt detach /dev/sdc [1] > mount -o degrade /dev/sdd /btrfs > --- > > [1] github.com/anajain/devmgt.git > > Signed-off-by: Anand Jain > --- > fs/btrfs/sysfs.c | 10 -- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c > index ba94b27..f20bc1f 100644 > --- a/fs/btrfs/sysfs.c > +++ b/fs/btrfs/sysfs.c > @@ -578,8 +578,14 @@ static int add_device_membership(struct btrfs_fs_info > *fs_info) > return -ENOMEM; > > list_for_each_entry(dev, &fs_devices->devices, dev_list) { > - struct hd_struct *disk = dev->bdev->bd_part; > - struct kobject *disk_kobj = &part_to_dev(disk)->kobj; > + struct hd_struct *disk; > + struct kobject *disk_kobj; > + > + if (!dev->bdev) > + continue; > + > + disk = dev->bdev->bd_part; > + disk_kobj = &part_to_dev(disk)->kobj; > > error = sysfs_create_link(fs_info->device_dir_kobj, > disk_kobj, disk_kobj->name); > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] btrfs-progs: Copyright string update
Fix corporate name for copyright. Signed-off-by: Hidetoshi Seto --- btrfs-list.h |2 +- btrfsck.h |2 +- chunk-recover.c|2 +- man/btrfs-convert.8.in |2 +- man/btrfs-debug-tree.8.in |2 +- man/btrfs-find-root.8.in |2 +- man/btrfs-map-logical.8.in |2 +- man/btrfs-show-super.8.in |2 +- man/btrfs-zero-log.8.in|2 +- man/btrfstune.8.in |2 +- math.h |2 +- super-recover.c|2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/btrfs-list.h b/btrfs-list.h index 724e973..8ead9da 100644 --- a/btrfs-list.h +++ b/btrfs-list.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Fujitsu. All rights reserved. + * Copyright (C) 2012 FUJITSU LIMITED. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/btrfsck.h b/btrfsck.h index f73c605..356c767 100644 --- a/btrfsck.h +++ b/btrfsck.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Fujitsu. All rights reserved. + * Copyright (C) 2013 FUJITSU LIMITED. All rights reserved. * Written by Miao Xie * * This program is free software; you can redistribute it and/or diff --git a/chunk-recover.c b/chunk-recover.c index 69f5854..a05e644 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Fujitsu. All rights reserved. + * Copyright (C) 2013 FUJITSU LIMITED. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/man/btrfs-convert.8.in b/man/btrfs-convert.8.in index 9d4c642..85cfa61 100644 --- a/man/btrfs-convert.8.in +++ b/man/btrfs-convert.8.in @@ -24,7 +24,7 @@ If any problems happened, 1 will be returned. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/man/btrfs-debug-tree.8.in b/man/btrfs-debug-tree.8.in index 9b0420b..eed7097 100644 --- a/man/btrfs-debug-tree.8.in +++ b/man/btrfs-debug-tree.8.in @@ -27,7 +27,7 @@ If any problems happened, 1 will be returned. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/man/btrfs-find-root.8.in b/man/btrfs-find-root.8.in index 398aa41..c1f48a0 100644 --- a/man/btrfs-find-root.8.in +++ b/man/btrfs-find-root.8.in @@ -22,7 +22,7 @@ If any problems happened, 1 will be returned. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/man/btrfs-map-logical.8.in b/man/btrfs-map-logical.8.in index d50ac96..a253051 100644 --- a/man/btrfs-map-logical.8.in +++ b/man/btrfs-map-logical.8.in @@ -25,7 +25,7 @@ If any problems happened, 1 will be returned. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/man/btrfs-show-super.8.in b/man/btrfs-show-super.8.in index ad04a42..3fe8bde 100644 --- a/man/btrfs-show-super.8.in +++ b/man/btrfs-show-super.8.in @@ -22,7 +22,7 @@ If any problems happened, 1 will be returned. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/man/btrfs-zero-log.8.in b/man/btrfs-zero-log.8.in index 80aaa9a..0ccfb0e 100644 --- a/man/btrfs-zero-log.8.in +++ b/man/btrfs-zero-log.8.in @@ -15,7 +15,7 @@ Other exit code means some problems happened. Written by Shilong Wang and Wenruo Qu. .SH COPYRIGHT -Copyright \(co 2013 Fujitsu, Inc. +Copyright \(co 2013 FUJITSU LIMITED. License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY,
[PATCH] btrfs: Copyright string update
Fix corporate name for copyright. Signed-off-by: Hidetoshi Seto --- fs/btrfs/delayed-inode.c |2 +- fs/btrfs/delayed-inode.h |2 +- fs/btrfs/math.h |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 451b00c..483b918 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Fujitsu. All rights reserved. + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. * Written by Miao Xie * * This program is free software; you can redistribute it and/or diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h index f70119f..a07746d 100644 --- a/fs/btrfs/delayed-inode.h +++ b/fs/btrfs/delayed-inode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Fujitsu. All rights reserved. + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. * Written by Miao Xie * * This program is free software; you can redistribute it and/or diff --git a/fs/btrfs/math.h b/fs/btrfs/math.h index b7816ce..1ce7e18 100644 --- a/fs/btrfs/math.h +++ b/fs/btrfs/math.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2012 Fujitsu. All rights reserved. + * Copyright (C) 2012 FUJITSU LIMITED. All rights reserved. * Written by Miao Xie * * This program is free software; you can redistribute it and/or -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] btrfs-progs: provide better error message for raid profile mismatch
Current error messages are like following: Error: unable to create FS with metadata profile 32 (have 2 devices) Error: unable to create FS with metadata profile 256 (have 2 devices) Obviously it is hard for users to interpret "profile XX" to proper meaning, such as "raidN". So use recongizable string instead of internal numerical value. In case of "dup", use an explicit message. Plus this patch fix a bug that message mistake metadata profile for data profile. After applying this patch, messages will be like: Error: dup is not allowed when FS have multiple devices Error: unable to create FS with metadata profile RAID6 (have 2 devices but 3 devices are required) Signed-off-by: Hidetoshi Seto --- cmds-filesystem.c | 22 -- utils.c | 63 +++- utils.h |1 + 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index bd9ba66..400e8d9 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -134,28 +134,6 @@ static char *group_type_str(u64 flag) } } -static char *group_profile_str(u64 flag) -{ - switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) { - case 0: - return "single"; - case BTRFS_BLOCK_GROUP_RAID0: - return "RAID0"; - case BTRFS_BLOCK_GROUP_RAID1: - return "RAID1"; - case BTRFS_BLOCK_GROUP_RAID5: - return "RAID5"; - case BTRFS_BLOCK_GROUP_RAID6: - return "RAID6"; - case BTRFS_BLOCK_GROUP_DUP: - return "DUP"; - case BTRFS_BLOCK_GROUP_RAID10: - return "RAID10"; - default: - return "unknown"; - } -} - static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret) { u64 count = 0; diff --git a/utils.c b/utils.c index 3e9c527..3f5d328 100644 --- a/utils.c +++ b/utils.c @@ -1943,6 +1943,47 @@ out: return ret; } +char *group_profile_str(u64 flag) +{ + switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) { + case 0: + return "single"; + case BTRFS_BLOCK_GROUP_RAID0: + return "RAID0"; + case BTRFS_BLOCK_GROUP_RAID1: + return "RAID1"; + case BTRFS_BLOCK_GROUP_RAID5: + return "RAID5"; + case BTRFS_BLOCK_GROUP_RAID6: + return "RAID6"; + case BTRFS_BLOCK_GROUP_DUP: + return "DUP"; + case BTRFS_BLOCK_GROUP_RAID10: + return "RAID10"; + default: + return "unknown"; + } +} + +static int group_profile_devs_min(u64 flag) +{ + switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) { + case 0: /* single */ + case BTRFS_BLOCK_GROUP_DUP: + return 1; + case BTRFS_BLOCK_GROUP_RAID0: + case BTRFS_BLOCK_GROUP_RAID1: + case BTRFS_BLOCK_GROUP_RAID5: + return 2; + case BTRFS_BLOCK_GROUP_RAID6: + return 3; + case BTRFS_BLOCK_GROUP_RAID10: + return 4; + default: + return -1; + } +} + int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, u64 dev_cnt, int mixed, char *estr) { @@ -1963,16 +2004,26 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, allowed |= BTRFS_BLOCK_GROUP_DUP; } + if (dev_cnt > 1 && + ((metadata_profile | data_profile) & BTRFS_BLOCK_GROUP_DUP)) { + snprintf(estr, sz, + "dup is not allowed when FS have multiple devices\n"); + return 1; + } if (metadata_profile & ~allowed) { - snprintf(estr, sz, "unable to create FS with metadata " - "profile %llu (have %llu devices)\n", - metadata_profile, dev_cnt); + snprintf(estr, sz, + "unable to create FS with metadata profile %s " + "(have %llu devices but %d devices are required)\n", + group_profile_str(metadata_profile), dev_cnt, + group_profile_devs_min(metadata_profile)); return 1; } if (data_profile & ~allowed) { - snprintf(estr, sz, "unable to create FS with data " - "profile %llu (have %llu devices)\n", - metadata_profile, dev_cnt); + snprintf(estr, sz, + "unable to create FS with data profile %s " + "(have %llu devices but %d devices are required)\n", +
Re: [PATCH 2/2] Btrfs: fix the snapshot that should not exist
(2012/07/26 15:57), Miao Xie wrote: > The snapshot should be the image of the fs tree before it was created, > so the metadata of the snapshot should not exist in the its tree. But now, we > found the directory item and directory name index is in both the snapshot tree > and the fs tree. It introduces some problem and makes the users feel strange: > > # mkfs.btrfs /dev/sda1 > # mount /dev/sda1 /mnt > # mkdir /mnt/1 > # cd /mnt/1 > # btrfs subvolume snapshot /mnt snap0 > # ll /mnt/1 > total 0 > drwxr-xr-x 1 root root 10 Ju1 24 12:11 1 > ^^^ > # ll /mnt/1/snap0/ > total 0 > drwxr-xr-x 1 root root 10 Ju1 24 12:11 1 > ^^^ > It is also 10, but... > # ll /mnt/1/snap0/1 > total 0 > [None] > # cd /mnt/1/snap0/1/snap0 > [Enter a unexisted directory successfully...] I confirmed that "mkdir snap0" failed with "File exists" and that rmdir can remove the directory snap0. So it is a kind of "invisible" rather than "unexisted". > > There is nothing in the directory 1 in snap0, but btrfs told the length of > this directory is 10. Beside that, we can enter an unexisted directory, it is > very strange to the users. > > # btrfs subvolume snapshot /mnt/1/snap0 /mnt/snap1 > # ll /mnt/1/snap0/1/ > total 0 > [None] > # ll /mnt/snap1/1/ > total 0 > drwxr-xr-x 1 root root 0 Ju1 24 12:14 snap0 > > And the source of snap1 did have any directory in Directory 1, but snap1 have > a snap0, it is different between the source and the snapshot. > > So I think we should insert directory item and directory name index and update > the parent inode as the last step of snapshot creation, and do not leave the > useless metadata in the tree. > > Signed-off-by: Miao Xie > --- (snip) > @@ -1062,17 +1068,33 @@ static noinline int create_pending_snapshot(struct > btrfs_trans_handle *trans, > ret = btrfs_reloc_post_snapshot(trans, pending); > if (ret) > goto abort_trans; > + > + ret = btrfs_insert_dir_item(trans, parent_root, > + dentry->d_name.name, dentry->d_name.len, > + parent_inode, &key, > + BTRFS_FT_DIR, index); > + /* We have check the name at the beginning, so it is impossible. */ > + BUG_ON(ret == -EEXIST); > + if (ret) > + goto abort_trans; > + > + btrfs_i_size_write(parent_inode, parent_inode->i_size + > + dentry->d_name.len * 2); > + ret = btrfs_update_inode(trans, parent_root, parent_inode); > + if (ret) > + goto abort_trans; > fail: > dput(parent); > trans->block_rsv = rsv; > no_free_objectid: > kfree(new_root_item); > root_item_alloc_fail: > + btrfs_free_path(path); > +path_alloc_fail: > btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); > return ret; > > abort_trans: > - dput(parent); I think you can remove this line in your 1/2 patch. > btrfs_abort_transaction(trans, root, ret); > goto fail; > } > @@ -1386,13 +1408,13 @@ int btrfs_commit_transaction(struct > btrfs_trans_handle *trans, >*/ > mutex_lock(&root->fs_info->reloc_mutex); > > - ret = btrfs_run_delayed_items(trans, root); > + ret = create_pending_snapshots(trans, root->fs_info); > if (ret) { > mutex_unlock(&root->fs_info->reloc_mutex); > goto cleanup_transaction; > } > > - ret = create_pending_snapshots(trans, root->fs_info); > + ret = btrfs_run_delayed_items(trans, root); > if (ret) { > mutex_unlock(&root->fs_info->reloc_mutex); > goto cleanup_transaction; It would be nice to have a patch description to tell why you have to change the order here. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] Btrfs: set mount options permanently
Following patches are going to implement one of unclaimed features listed in the btrfs wiki: https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set_mount_options_permanently Special thanks to Kazuhiro Yamashita for his time and efforts. Your comments/reviews are welcomed. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] Btrfs: make space to keep default mount options
This patch create space to hold default mount option, and to use saved default mount option change super.c to read default mount option first when mount devices. Signed-off-by: Hidetoshi Seto --- fs/btrfs/ctree.h |5 - fs/btrfs/super.c |2 ++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index fa5c45b..3eb0551 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -458,8 +458,11 @@ struct btrfs_super_block { __le64 cache_generation; + /* default mount options */ + unsigned long default_mount_opt; + /* future expansion */ - __le64 reserved[31]; + __le64 reserved[30]; u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; } __attribute__ ((__packed__)); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index e239915..7ef4a2e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -340,6 +340,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) char *compress_type; bool compress_force = false; + info->mount_opt = info->super_copy->default_mount_opt; + cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); if (cache_gen) btrfs_set_opt(info->mount_opt, SPACE_CACHE); -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] Btrfs-progs: add mount-option command
This patch adds mount-option command. The command can set/get default mount options. Now, the command can set/get 24 options. These options are equal to mount options which store in fs_info/mount-opt. Signed-off-by: Hidetoshi Seto --- Makefile |5 +- btrfs-parse-mntopt.c | 111 + btrfs-parse-mntopt.h | 65 ++ btrfs.c |1 + cmds-mount.c | 150 ++ commands.h |2 + ctree.h | 41 +- 7 files changed, 372 insertions(+), 3 deletions(-) create mode 100644 btrfs-parse-mntopt.c create mode 100644 btrfs-parse-mntopt.h create mode 100644 cmds-mount.c diff --git a/Makefile b/Makefile index c0aaa3d..6f67f4c 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,10 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o \ inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \ volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \ - send-stream.o send-utils.o + send-stream.o send-utils.o btrfs-parse-mntopt.o cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ - cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o + cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ + cmds-mount.o CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ -Wuninitialized -Wshadow -Wundef diff --git a/btrfs-parse-mntopt.c b/btrfs-parse-mntopt.c new file mode 100644 index 000..87b341c --- /dev/null +++ b/btrfs-parse-mntopt.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include "ctree.h" +#include "btrfs-parse-mntopt.h" + +void btrfs_parse_string2mntopt(struct btrfs_root *root, char **options) +{ + struct btrfs_super_block *sb = &root->fs_info->super_copy; + char *p = NULL; + int i = 0; + + memset(&sb->default_mount_opt, 0, sizeof(unsigned long)); + while ((p = strsep(options, ",")) != NULL) { + int token = DEF_MNTOPT_NUM + 1; + + if (!*p) + continue; + for (i = 0; i < DEF_MNTOPT_NUM; i++) { + if (!strcmp(p, toke[i].pattern)) { + token = toke[i].token; + break; + } + } + if (token > DEF_MNTOPT_NUM) { + printf("error: %s\n", p); + return; + } + + switch (token) { + case Opt_degraded: + btrfs_set_opt(sb->default_mount_opt, DEGRADED); + break; + + case Opt_nodatasum: + btrfs_set_opt(sb->default_mount_opt, NODATASUM); + break; + case Opt_nodatacow: + btrfs_set_opt(sb->default_mount_opt, NODATACOW); + btrfs_set_opt(sb->default_mount_opt, NODATASUM); + break; + case Opt_ssd: + btrfs_set_opt(sb->default_mount_opt, SSD); + break; + case Opt_ssd_spread: + btrfs_set_opt(sb->default_mount_opt, SSD); + btrfs_set_opt(sb->default_mount_opt, SSD_SPREAD); + break; + case Opt_nossd: + btrfs_set_opt(sb->default_mount_opt, NOSSD); + btrfs_clear_opt(sb->default_mount_opt, SSD); + btrfs_clear_opt(sb->default_mount_opt, SSD_SPREAD); + break; + case Opt_nobarrier: + btrfs_set_opt(sb->default_mount_opt, NOBARRIER); + break; + case Opt_notreelog: + btrfs_set_opt(sb->default_mount_opt, NOTREELOG); + break; + case Opt_flushoncommit: + btrfs_set_opt(sb->default_mount_opt, FLUSHONCOMMIT); + break; + case Opt_discard: + btrfs_set_opt(sb->default_mount_opt, DISCARD); + break; + case Opt_space_cache: + btrfs_set_opt(sb->default_mount_opt, SPACE_CACHE); + break; + case Opt_no_space_cache: + btrfs_clear_opt(sb->default_mount_opt, SPACE_CACHE); + break; + case Opt_inode_cache: + btrfs_set_opt(sb->default_mount_opt, INODE_MAP_CACHE); + break; + case Opt_clear_cache: + btrfs_set_opt(s
Re: [PATCH 1/2] Btrfs: make space to keep default mount options
(2012/09/18 21:10), David Sterba wrote: > On Tue, Sep 18, 2012 at 10:28:48AM +0900, Hidetoshi Seto wrote: >> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h >> index fa5c45b..3eb0551 100644 >> --- a/fs/btrfs/ctree.h >> +++ b/fs/btrfs/ctree.h >> @@ -458,8 +458,11 @@ struct btrfs_super_block { >> >> __le64 cache_generation; >> >> +/* default mount options */ >> +unsigned long default_mount_opt; > > you need to use __le64 here, unsigned long has not fixed size Indeed. I'll use __le64 next time. >> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c >> index e239915..7ef4a2e 100644 >> --- a/fs/btrfs/super.c >> +++ b/fs/btrfs/super.c >> @@ -340,6 +340,8 @@ int btrfs_parse_options(struct btrfs_root *root, char >> *options) >> char *compress_type; >> bool compress_force = false; >> >> +info->mount_opt = info->super_copy->default_mount_opt; > > the options have to respect some priority, eg. when I set default > options to a filesystem, but mount with a different set, I expect that > the explicit flags apply and override the defaults. > > I don't remember if this was discussed in the mailinglist or on IRC > only, should be easy to dig up if needed. At least I don't know whether this was already disscussed or not. Now my code gives priority to the default options, and it would not be so difficult in case if we have opposing options like "ssd" vs "nossd", and "space_cache" vs "no_space_cache"... Or we could use the default options only if there is no options specified when it is being mount, but it will make the default options useless. Humm, I'll try to pull together my thoughts prior to my next post. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: R: [PATCH 2/2] Btrfs-progs: add mount-option command
(2012/09/18 19:03), Goffredo Baroncelli wrote: > Hi Seto, > > please could you update also the man page too ? Sure. I'll update it next time. > Why it was not provided a way to clear a *single* flag ? To me it seems a bit > too long to clear all the flag (btrfs mount-option clear) and then set the > right one. Good point. We should have a way to clear defaults, by "clear" or "set none" or so on. > > As user interface I suggest something like chmod: > >btrfs mount-option set +ssd,skip_balance -nodatacow /dev/sdX > > or > >btrfs mount-option set =ssd,skip_balance,nodatacow /dev/sdX Interesting. I guess you mean that "=" will reset defaults by specified options, while "+" and "-" will be used to add/delete option to/from current defaults. > > Finally I have some small concern about two macro (see below) > >> Messaggio originale >> Da: seto.hideto...@jp.fujitsu.com >> Data: 18/09/2012 3.30 >> A: >> Ogg: [PATCH 2/2] Btrfs-progs: add mount-option command >> > [...] >> +/* >> + * Flags for mount options. >> + * >> + * Note: don't forget to add new options to btrfs_show_options() >> + */ >> +#define BTRFS_MOUNT_NODATASUM (1 << 0) >> +#define BTRFS_MOUNT_NODATACOW (1 << 1) >> +#define BTRFS_MOUNT_NOBARRIER (1 << 2) >> +#define BTRFS_MOUNT_SSD (1 << 3) >> +#define BTRFS_MOUNT_DEGRADED(1 << 4) >> +#define BTRFS_MOUNT_COMPRESS(1 << 5) >> +#define BTRFS_MOUNT_NOTREELOG (1 << 6) >> +#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7) >> +#define BTRFS_MOUNT_SSD_SPREAD (1 << 8) >> +#define BTRFS_MOUNT_NOSSD (1 << 9) >> +#define BTRFS_MOUNT_DISCARD (1 << 10) >> +#define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11) >> +#define BTRFS_MOUNT_SPACE_CACHE (1 << 12) >> +#define BTRFS_MOUNT_CLEAR_CACHE (1 << 13) >> +#define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14) >> +#define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) >> +#define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) >> +#define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) >> +#define BTRFS_MOUNT_RECOVERY(1 << 18) >> +#define BTRFS_MOUNT_SKIP_BALANCE(1 << 19) >> +#define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) >> +#define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) >> +#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR(1 << 22) >> + >> +#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) >> +#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) >> +#define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt& \ >> + BTRFS_MOUNT_##opt) > > I think that the macro names are too generic, I suggest to rename the three > macros above as > > #define btrfs_mount__opt > > Also, the last one should be > > #define btrfs_test_opt(o, opt)( o & BTRFS_MOUNT_##opt) > > Or better the other two > > #define btrfs_mount_clear_opt(root, opt) > (((root)->fs_info->mount_opt) &= > ~BTRFS_MOUNT_##opt) > #define btrfs_mount_set_opt(root, opt) > (((root)->fs_info->mount_opt) |= > BTRFS_MOUNT_##opt) Right. I'll fix it. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] Btrfs-progs: add mount-option command
(2012/09/18 11:31), Miao Xie wrote: > On tue, 18 Sep 2012 10:30:17 +0900, Hidetoshi Seto wrote: >> This patch adds mount-option command. >> The command can set/get default mount options. >> Now, the command can set/get 24 options. >> These options are equal to mount options which store >> in fs_info/mount-opt. > > I don't think we need implement a separate command to do this, > we can add it into btrfstune just like ext3/4. If so, the users > who used ext3/4 before can be familiar with btrfs command as soon > as possible. As some people already pointed out, I also think that the btrfstune command is a kind of obsolete, and therefore it would be better to improve the btrfs command as centralized utility. > > Beside that, why not add a option into mkfs.btrfs? It is planned. Once we can fix a way how to save default options, modifying mkfs.btfs would be easy. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] Btrfs-progs: add mount-option command
(2012/09/18 21:30), David Sterba wrote: > On Tue, Sep 18, 2012 at 10:30:17AM +0900, Hidetoshi Seto wrote: ... > > So, you're basically implementing subset of the whole-filesystem > options. As has been mentioned, alternate way is to use the 'properties' > interface as a global entry point from the management tool. It would be > great if you base your patches on top of it. > > (The props haven't been acked, but we've reached a wider consensus on > irc, patches are in the mailinglist, so we can bring it up again and > discuss outstanding issues or objections. I'm mainly concerned about > priority of setting the defaults and not-bloating the 'btrfs' interface > too much.) Thank you very much for your review! I'll rework my patch to reflect all comments. Please let me know if there are still outstanding issues or objections about/against this feature. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/4] Btrfs: set mount options permanently
Following patches are going to implement one of unclaimed features listed in the btrfs wiki: https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set_mount_options_permanently Previous v1 post and discussion can be referred from: http://lwn.net/Articles/516898/ v2: - Allow operator [+-=] like chmod for setting options - Save options by words instead of internal bits. (e.g. kernel code will translate a word "ssd_spread" to 2 internal bits "SSD" and "SSD_SPREAD". However this behavior might be changed if kernel updates.) Special thanks to Kazuhiro Yamashita for his time and efforts. Again, your comments/reviews are welcomed. Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/4] Btrfs-progs: add mount-option command
This patch adds mount-option command that can set/get/clear default mount options. Signed-off-by: Hidetoshi Seto --- Makefile |4 +- btrfs-parse-mntopt.c | 109 + btrfs-parse-mntopt.h | 66 ++ btrfs.c |1 + cmds-mount.c | 185 ++ commands.h |2 + ctree.h |7 ++- 7 files changed, 371 insertions(+), 3 deletions(-) create mode 100644 btrfs-parse-mntopt.c create mode 100644 btrfs-parse-mntopt.h create mode 100644 cmds-mount.c diff --git a/Makefile b/Makefile index 4894903..c25d982 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,10 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o \ inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \ volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \ - send-stream.o send-utils.o qgroup.o + send-stream.o send-utils.o qgroup.o btrfs-parse-mntopt.o cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ - cmds-quota.o cmds-qgroup.o + cmds-quota.o cmds-qgroup.o cmds-mount.o CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ -Wuninitialized -Wshadow -Wundef diff --git a/btrfs-parse-mntopt.c b/btrfs-parse-mntopt.c new file mode 100644 index 000..66a924d --- /dev/null +++ b/btrfs-parse-mntopt.c @@ -0,0 +1,109 @@ +#include +#include +#include +#include "ctree.h" +#include "btrfs-parse-mntopt.h" + +void btrfs_parse_string2mntopt(u64 *optval, int optnum, char **options) +{ + char *p, *opts; + int i, j; + u64 newval = *optval; + char overwrite = 0; + + for (i = 0; i < optnum; i++) { + char *token, *save_ptr; + char revert = 0; + u64 orders = 0; + + opts = options[i]; + + switch (*opts) { + case '=': + if (overwrite) { + fprintf(stderr, "'=' operator may only be specified once.\n"); + return; + } + if (i) { + fprintf(stderr, "cannot use operator '=' with '+/-'.\n"); + return; + } + if (!*(opts + 1)) { + fprintf(stderr, "no options after '='.\n"); + return; + } + overwrite = 1; + opts++; + break; + case '-': + revert = 1; + case '+': + if (overwrite) { + fprintf(stderr, "cannot use operator '=' with '+/-'.\n"); + return; + } + if (!*(opts + 1)) { + fprintf(stderr, "no options after '%c'.\n", *opts); + return; + } + opts++; + break; + default: + fprintf(stderr, "options must be specified with '+/-/='.\n"); + return; + } + + for (token = strtok_r(opts, ",", &save_ptr); token != NULL; +token = strtok_r(NULL, ",", &save_ptr)) { + char *arg; + + arg = strchr(token, '='); + if (arg) { + /* TBD: compress= */ + fprintf(stderr, "format 'option=arg' is not supported.\n"); + return; + } + + for (j = 0; tokens[j].pattern != NULL; j++) { + if (!strcmp(token, tokens[j].pattern)) { + orders |= (1 << tokens[j].token); + break; + } + } + if (!tokens[j].pattern) { + fprintf(stderr, "unknown option '%s'.\n", token); + printf("supported options : "); + btrfs_parse_mntopt2string(-1); + return; + } + } + + if (overwrite) +
[PATCH v2 2/4] Btrfs-progs: add mount-option command man page
Add mount-option command man page. Signed-off-by: Hidetoshi Seto --- man/btrfs.8.in | 25 + 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..85d5030 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -52,6 +52,12 @@ btrfs \- control a btrfs filesystem \fBbtrfs\fP \fBinspect-internal logical-resolve\fP [-Pv] \fI\fP \fI\fP .PP +\fBbtrfs\fP \fBmount-option set\fP \fI[[<+/-/=>,...]...]\fP \fI\fP +.PP +\fBbtrfs\fP \fBmount-option get\fP \fI\fP +.PP +\fBbtrfs\fP \fBmount-option clear\fP \fI\fP +.PP \fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP .PP \fBbtrfs\fP \fB \-\-help \fP\fI\fP @@ -319,6 +325,25 @@ skip the path resolving and print the inodes instead .IP -v 5 verbose mode. print count of returned paths and all ioctl() return values .RE +.TP + +\fBmount-option set\fP \fI[<+/-/=>,...]...]\fP \fI\fP +With some operators \fB+\fP,\fB-\fP,\fB=\fP and some options, +set default mount options to the \fI\fP. +These \fB+\fP,\fB-\fP,\fB=\fP operators mean like \fBchmod\fP operators. +The operator \fB+\fP causes the selected mount options to be added to existing +default mount options of the \fI\fP; \fB-\fP causes them to be removed; +and \fB=\fP causes them to be added and causes unmentioned options to be removed. +Without options, print default mount options of the \fI\fR. +.TP + +\fBmount-option get\fP \fI\fP +Print default mount options of the \fI\fR. +.TP + +\fBmount-option clear\fP \fI\fP +Clear default mount options of the \fI\fR. +.TP .SH EXIT STATUS \fBbtrfs\fR returns a zero exist status if it succeeds. Non zero is returned in -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/4] btrfs: make subroutine __btrfs_parse_options
Separate long switch statement to be reused. Signed-off-by: Hidetoshi Seto --- fs/btrfs/super.c | 431 +++--- 1 files changed, 214 insertions(+), 217 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 83d6f9f..d51aaee 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -349,6 +349,214 @@ static match_table_t tokens = { {Opt_err, NULL}, }; +static int __btrfs_parse_options(struct btrfs_fs_info *info, int token, +substring_t *args) +{ + bool compress_force = false; + char *compress_type; + char *num; + int intarg; + + switch (token) { + case Opt_degraded: + pr_info("btrfs: allowing degraded mounts\n"); + btrfs_set_opt(info->mount_opt, DEGRADED); + break; + case Opt_subvol: + case Opt_subvolid: + case Opt_subvolrootid: + case Opt_device: + /* +* These are parsed by btrfs_parse_early_options +* and can be happily ignored here. +*/ + break; + case Opt_nodatasum: + pr_info("btrfs: setting nodatasum\n"); + btrfs_set_opt(info->mount_opt, NODATASUM); + break; + case Opt_nodatacow: + pr_info("btrfs: setting nodatacow\n"); + btrfs_set_opt(info->mount_opt, NODATACOW); + btrfs_set_opt(info->mount_opt, NODATASUM); + break; + case Opt_compress_force: + case Opt_compress_force_type: + compress_force = true; + case Opt_compress: + case Opt_compress_type: + if (token == Opt_compress || + token == Opt_compress_force || + strcmp(args[0].from, "zlib") == 0) { + compress_type = "zlib"; + info->compress_type = BTRFS_COMPRESS_ZLIB; + btrfs_set_opt(info->mount_opt, COMPRESS); + } else if (strcmp(args[0].from, "lzo") == 0) { + compress_type = "lzo"; + info->compress_type = BTRFS_COMPRESS_LZO; + btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_set_fs_incompat(info, COMPRESS_LZO); + } else if (strncmp(args[0].from, "no", 2) == 0) { + compress_type = "no"; + info->compress_type = BTRFS_COMPRESS_NONE; + btrfs_clear_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); + compress_force = false; + } else + return -EINVAL; + + if (compress_force) { + btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); + pr_info("btrfs: force %s compression\n", compress_type); + } else + pr_info("btrfs: use %s compression\n", compress_type); + break; + case Opt_ssd: + pr_info("btrfs: use ssd allocation scheme\n"); + btrfs_set_opt(info->mount_opt, SSD); + break; + case Opt_ssd_spread: + pr_info("btrfs: use spread ssd allocation scheme\n"); + btrfs_set_opt(info->mount_opt, SSD); + btrfs_set_opt(info->mount_opt, SSD_SPREAD); + break; + case Opt_nossd: + pr_info("btrfs: not using ssd allocation scheme\n"); + btrfs_set_opt(info->mount_opt, NOSSD); + btrfs_clear_opt(info->mount_opt, SSD); + btrfs_clear_opt(info->mount_opt, SSD_SPREAD); + break; + case Opt_nobarrier: + pr_info("btrfs: turning off barriers\n"); + btrfs_set_opt(info->mount_opt, NOBARRIER); + break; + case Opt_thread_pool: + intarg = 0; + match_int(&args[0], &intarg); + if (intarg) + info->thread_pool_size = intarg; + break; + case Opt_max_inline: + num = match_strdup(&args[0]); + if (num) { + info->max_inline = memparse(num, NULL); + kfree(num); + + if (info->max_inline) { + info->max_inline = max_t(u64, + info->max_inline, + info->tree_root->sectorsize); + } + pr_info("btrfs: max_inline at %llu\n", + (unsigned long long)info-&g
[PATCH v2 4/4] btrfs: support default mount options
Make space to save default mount options in super block. Parse saved default mount options first and then parse mount options given when the file system is mounted. Signed-off-by: Hidetoshi Seto --- fs/btrfs/ctree.h |7 ++- fs/btrfs/super.c | 16 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d195b5..eea6bd0 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -461,8 +461,11 @@ struct btrfs_super_block { __le64 cache_generation; + /* default mount options */ + __le64 default_mount_opt; + /* future expansion */ - __le64 reserved[31]; + __le64 reserved[30]; u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; } __attribute__ ((__packed__)); @@ -2581,6 +2584,8 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, csum_type, 16); BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, cache_generation, 64); +BTRFS_SETGET_STACK_FUNCS(super_default_mount_opt, struct btrfs_super_block, +default_mount_opt, 64); static inline int btrfs_super_csum_size(struct btrfs_super_block *s) { diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d51aaee..1cadf0e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -567,13 +567,25 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) struct btrfs_fs_info *info = root->fs_info; substring_t args[MAX_OPT_ARGS]; char *p, *orig = NULL; - u64 cache_gen; + u64 cache_gen, default_opt; int ret = 0; - cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); + cache_gen = btrfs_super_cache_generation(info->super_copy); if (cache_gen) btrfs_set_opt(info->mount_opt, SPACE_CACHE); + default_opt = btrfs_super_default_mount_opt(info->super_copy); + if (default_opt) { + int token; + for (token = 0; token < Opt_err; token++) { + if (default_opt & (1ul << token)) { + ret = __btrfs_parse_options(info, token, args); + if (ret) + return ret; + } + } + } + if (!options) goto out; -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] btrfs: fix d_off in the first dirent
Since the d_off in the first dirent for "." (that originates from the 4th argument "offset" of filldir() for the 2nd dirent for "..") is wrongly assigned in btrfs_real_readdir(), telldir returns same offset for different locations. | # mkfs.btrfs /dev/sdb1 | # mount /dev/sdb1 fs0 | # cd fs0 | # touch file0 file1 | # ../test | telldir: 0 | readdir: d_off = 2, d_name = "." | telldir: 2 | readdir: d_off = 2, d_name = ".." | telldir: 2 | readdir: d_off = 3, d_name = "file0" | telldir: 3 | readdir: d_off = 2147483647, d_name = "file1" | telldir: 2147483647 To fix this problem, pass filp->f_pos (which is loff_t) instead of the wrong constant value. | # ../test | telldir: 0 | readdir: d_off = 1, d_name = "." | telldir: 1 | readdir: d_off = 2, d_name = ".." | telldir: 2 | readdir: d_off = 3, d_name = "file0" : At the moment the "offset" for "." is unused because there is no preceding dirent, however it is better to pass filp->f_pos to follow grammatical usage. Signed-off-by: Hidetoshi Seto --- fs/btrfs/inode.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15fceef..9c1297b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4125,7 +4125,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, /* special case for "." */ if (filp->f_pos == 0) { - over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); + over = filldir(dirent, ".", 1, + filp->f_pos, inode->i_ino, DT_DIR); if (over) return 0; filp->f_pos = 1; @@ -4134,7 +4135,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, if (filp->f_pos == 1) { u64 pino = parent_ino(filp->f_path.dentry); over = filldir(dirent, "..", 2, - 2, pino, DT_DIR); + filp->f_pos, pino, DT_DIR); if (over) return 0; filp->f_pos = 2; -- 1.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] btrfs: fix d_off in the first dirent
(2011/08/18 11:12), Li Zefan wrote: >> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c >> index 15fceef..9c1297b 100644 >> --- a/fs/btrfs/inode.c >> +++ b/fs/btrfs/inode.c >> @@ -4125,7 +4125,8 @@ static int btrfs_real_readdir(struct file *filp, void >> *dirent, >> >> /* special case for "." */ >> if (filp->f_pos == 0) { >> -over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); >> +over = filldir(dirent, ".", 1, >> + filp->f_pos, inode->i_ino, DT_DIR); > > please stick to btrfs_ino(). Wow, I made a misstep on rebase... Here is the updated one. Thanks, H.Seto = Since the d_off in the first dirent for "." (that originates from the 4th argument "offset" of filldir() for the 2nd dirent for "..") is wrongly assigned in btrfs_real_readdir(), telldir returns same offset for different locations. | # mkfs.btrfs /dev/sdb1 | # mount /dev/sdb1 fs0 | # cd fs0 | # touch file0 file1 | # ../test | telldir: 0 | readdir: d_off = 2, d_name = "." | telldir: 2 | readdir: d_off = 2, d_name = ".." | telldir: 2 | readdir: d_off = 3, d_name = "file0" | telldir: 3 | readdir: d_off = 2147483647, d_name = "file1" | telldir: 2147483647 To fix this problem, pass filp->f_pos (which is loff_t) instead. | # ../test | telldir: 0 | readdir: d_off = 1, d_name = "." | telldir: 1 | readdir: d_off = 2, d_name = ".." | telldir: 2 | readdir: d_off = 3, d_name = "file0" : At the moment the "offset" for "." is unused because there is no preceding dirent, however it is better to pass filp->f_pos to follow grammatical usage. Signed-off-by: Hidetoshi Seto --- fs/btrfs/inode.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15fceef..addf025 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4125,7 +4125,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, /* special case for "." */ if (filp->f_pos == 0) { - over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); + over = filldir(dirent, ".", 1, + filp->f_pos, btrfs_ino(inode), DT_DIR); if (over) return 0; filp->f_pos = 1; @@ -4134,7 +4135,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, if (filp->f_pos == 1) { u64 pino = parent_ino(filp->f_path.dentry); over = filldir(dirent, "..", 2, - 2, pino, DT_DIR); + filp->f_pos, pino, DT_DIR); if (over) return 0; filp->f_pos = 2; -- 1.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] btrfs-progs: fix btrfs man page
Hi, Following patch set fixes/cleanups the man page of btrfs command. Based on for-chris branch. Thanks, H.Seto Hidetoshi Seto (3): btrfs-progs: Update/clean up btrfs help and man page V2 (cont.) btrfs-progs: Misc fix for btrfs man page btrfs-progs: Sort commands/descriptions in btrfs man page man/btrfs.8.in | 50 +- 1 files changed, 25 insertions(+), 25 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] btrfs-progs: Update/clean up btrfs help and man page V2 (cont.)
The commit 6f81e1197015ab2dc41beec92c347919feb26967 in for-chris branch is strange; somehow it does not apply a part of fixes and contains the dropped hunk in its patch description. This patch is to apply the dropped hunk. Signed-off-by: Hidetoshi Seto --- man/btrfs.8.in | 12 ++-- 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index faa7bf8..24bd933 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -195,21 +195,21 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP -\fBfilesystem show\fR [|]\fR -Show the btrfs filesystem with some additional info. If no UUID or label is -passed, \fBbtrfs\fR show info of all the btrfs filesystem. +\fBfilesystem show\fR [||]\fR +Show the btrfs filesystem with some additional info. If no argument is +passed, \fBbtrfs\fR shows info of all the btrfs filesystems. .TP -\fBdevice balance\fR \fI\fR +\fBfilesystem balance\fR \fI\fR Balance the chunks of the filesystem identified by \fI\fR across the devices. .TP -\fBdevice add\fR\fI [..] \fR +\fBdevice add\fR\fI [..] \fR Add device(s) to the filesystem identified by \fI\fR. .TP -\fBdevice delete\fR\fI [..] \fR +\fBdevice delete\fR\fI [..] \fR Remove device(s) from a filesystem identified by \fI\fR. .PP -- 1.7.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] btrfs-progs: Misc fix for btrfs man page
Remove duplicated entry for filesystem defrag, finish renaming device show to filesystem show, fix some minor misdescriptions and fix some format tokens. Signed-off-by: Hidetoshi Seto --- man/btrfs.8.in | 22 +++--- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 24bd933..e40de6f 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -21,17 +21,15 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem label\fP\fI [newlabel]\fP .PP -\fBbtrfs\fP \fBfilesystem defrag\fP\fI [options] | [|...]\fP +\fBbtrfs\fP \fBfilesystem defragment\fP\fI [options] | [|...]\fP .PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI \fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI \fP .PP -\fBbtrfs\fP \fBfilesystem defragment\fP\fI | [|...]\fP -.PP \fBbtrfs\fP \fBdevice scan\fP\fI [...]\fP .PP -\fBbtrfs\fP \fBdevice show\fP\fI [||]\fP +\fBbtrfs\fP \fBfilesystem show\fP\fI [||]\fP .PP \fBbtrfs\fP \fBdevice add\fP\fI [...] \fP .PP @@ -71,7 +69,7 @@ and as .I filesystem sync. In this case .I btrfs -returnsfilesystem sync +returns an error. If a command is terminated by .I --help , the detailed help is showed. If the passed command matches more commands, @@ -120,7 +118,7 @@ Set the subvolume of the filesystem \fI\fR which is mounted as is returned by the \fBsubvolume list\fR command. .TP -\fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] [-s \fIstart\fR] [-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...] +\fBfilesystem defragment\fP [-vf] [-c[zlib|lzo]] [-l \fIlen\fR] [-s \fIstart\fR] [-t \fIsize\fR] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...] Defragment file data and/or directory metadata. To defragment all files in a directory you have to specify each one on its own or use your shell wildcards. @@ -141,9 +139,11 @@ The start position and the number of bytes to deframention can be specified by \ NOTE: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of data, don't use it if you use snapshots, have de-duplicated your data or made copies with -\fBcp --reflink\fP. +\fBcp --reflink\fR. +.TP + \fBsubvolume find-new\fR\fI \fR -List the recently modified files in a subvolume, after \fI\fR ID. +List the recently modified files in a \fI\fR, after \fI\fR ID. .TP \fBdevice scan\fR \fI[...]\fR @@ -178,7 +178,7 @@ can expand the partition before enlarging the filesystem and shrink the partition after reducing the size of the filesystem. .TP -\fBbtrfs\fP \fBfilesystem label\fP\fI [newlabel]\fP +\fBfilesystem label\fP\fI [newlabel]\fP Show or update the label of a filesystem. \fI\fR is used to identify the filesystem. If a \fInewlabel\fR optional argument is passed, the label is changed. The @@ -195,7 +195,7 @@ NOTE: Currently there are the following limitations: - the filesystem should not have more than one device. .TP -\fBfilesystem show\fR [||]\fR +\fBfilesystem show\fR\fI [||]\fR Show the btrfs filesystem with some additional info. If no argument is passed, \fBbtrfs\fR shows info of all the btrfs filesystems. .TP @@ -211,7 +211,7 @@ Add device(s) to the filesystem identified by \fI\fR. \fBdevice delete\fR\fI [..] \fR Remove device(s) from a filesystem identified by \fI\fR. -.PP +.TP \fBscrub start\fP [-Bdqru] {\fI\fP|\fI\fP} Start a scrub on all devices of the filesystem identified by \fI\fR or on -- 1.7.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] btrfs-progs: Sort commands/descriptions in btrfs man page
Sort items in man page, to put together items in the same group, and to put sequences of SYSNOPSIS and COMMANDS in same order. Signed-off-by: Hidetoshi Seto --- man/btrfs.8.in | 28 ++-- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index e40de6f..0cb51ca 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -15,22 +15,22 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBsubvolume set-default\fP\fI \fP .PP +\fBbtrfs\fP \fBsubvolume find-new\fP\fI \fP +.PP +\fBbtrfs\fP \fBfilesystem defragment\fP\fI [options] | [|...]\fP +.PP \fBbtrfs\fP \fBfilesystem sync\fP\fI \fP .PP \fBbtrfs\fP \fBfilesystem resize\fP\fI [+/\-][gkm]|max \fP .PP \fBbtrfs\fP \fBfilesystem label\fP\fI [newlabel]\fP .PP -\fBbtrfs\fP \fBfilesystem defragment\fP\fI [options] | [|...]\fP -.PP -\fBbtrfs\fP \fBsubvolume find-new\fP\fI \fP +\fBbtrfs\fP \fBfilesystem show\fP\fI [||]\fP .PP \fBbtrfs\fP \fBfilesystem balance\fP\fI \fP .PP \fBbtrfs\fP \fBdevice scan\fP\fI [...]\fP .PP -\fBbtrfs\fP \fBfilesystem show\fP\fI [||]\fP -.PP \fBbtrfs\fP \fBdevice add\fP\fI [...] \fP .PP \fBbtrfs\fP \fBdevice delete\fP\fI [...] \fP @@ -118,6 +118,10 @@ Set the subvolume of the filesystem \fI\fR which is mounted as is returned by the \fBsubvolume list\fR command. .TP +\fBsubvolume find-new\fR\fI \fR +List the recently modified files in a \fI\fR, after \fI\fR ID. +.TP + \fBfilesystem defragment\fP [-vf] [-c[zlib|lzo]] [-l \fIlen\fR] [-s \fIstart\fR] [-t \fIsize\fR] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...] Defragment file data and/or directory metadata. To defragment all files in a @@ -142,15 +146,6 @@ use it if you use snapshots, have de-duplicated your data or made copies with \fBcp --reflink\fR. .TP -\fBsubvolume find-new\fR\fI \fR -List the recently modified files in a \fI\fR, after \fI\fR ID. -.TP - -\fBdevice scan\fR \fI[...]\fR -Scan devices for a btrfs filesystem. If no devices are passed, \fBbtrfs\fR scans -all the block devices. -.TP - \fBfilesystem sync\fR\fI \fR Force a sync for the filesystem identified by \fI\fR. .TP @@ -205,6 +200,11 @@ Balance the chunks of the filesystem identified by \fI\fR across the devices. .TP +\fBdevice scan\fR \fI[...]\fR +Scan devices for a btrfs filesystem. If no devices are passed, \fBbtrfs\fR scans +all the block devices. +.TP + \fBdevice add\fR\fI [..] \fR Add device(s) to the filesystem identified by \fI\fR. .TP -- 1.7.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] 254: disable space cache
(2011/11/18 17:43), Li Zefan wrote: > I can't pass 254, and below is the output: > > 254 3s ... - output mismatch (see 254.out.bad) > ... > ID 256 top level 5 path snap > -ID 257 top level 5 path subvol > +ID 258 top level 5 path subvol > > When space cache is enabled (and now mkfs.btrfs always enables it), > there will be some space cache inodes in the root tree, and they > consume some IDs, and that's why "subvol" has the ID 258 but not 257. > > Just disable space cache for this test case. > > Signed-off-by: Li Zefan > --- > 254 |2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/254 b/254 > index 5216120..1cd4832 100755 > --- a/254 > +++ b/254 > @@ -48,7 +48,7 @@ _supported_os Linux > _require_scratch > > _scratch_mkfs > /dev/null 2>&1 > -_scratch_mount > +_scratch_mount -o nospace_cache > > # First test basic snapshotting > echo "Creating file foo in root dir" I got following error on fedora 16 with your patch: @@ -1,40 +1,36 @@ QA output created by 254 +mount: wrong fs type, bad option, bad superblock on /dev/sdc2, + missing codepage or helper program, or other error + In some cases useful info is found in syslog - try + dmesg | tail or so + Creating file foo in root dir List root dir foo Creating snapshot of root dir -Create a snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap' +ERROR: '/mnt2' is not a subvolume List root dir after snapshot foo -snap List snapshot dir -foo +ls: cannot access /mnt2/snap: No such file or directory : : And in dmesg: [246554.739092] btrfs: unrecognized mount option 'nospace_cache' Thanks, H.Seto -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] perf: parser fix for btrfs tracepoints
After playing with v3.2-rc4, I found that the perf command failed to parse record contain data from (relatively new) btrfs tracepoints. This patch set will improve parser code of perf command and allow it to handle these data from btrfs tracepoints well. Thanks, H.Seto Hidetoshi Seto (3): perf: parse greater/less than or equal perf: allow processing single op args perf: allow typecast for signed value tools/perf/util/trace-event-parse.c | 25 +++-- 1 files changed, 23 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] perf: parse greater/less than or equal
Some btrfs tracepoints have complex format like following, but perf command failed to parse it: print fmt: "%s", ((REC->id >= min) || (REC->id <= max )) ? __print_symbolic(REC->id, { 1ULL, "ROOT_TREE" }, ... ) : "-" $ perf script Warning: unknown op '>=' Warning: Error: expected type 5 but read 1 Warning: failed to read event print fmt for btrfs_transaction_commit This patch allow perf command to parse operation tokens, '>=' and '<='. Signed-off-by: Hidetoshi Seto --- tools/perf/util/trace-event-parse.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 0a7ed5b..c2adc76 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1229,6 +1229,8 @@ process_op(struct event *event, struct print_arg *arg, char **tok) strcmp(token, "/") == 0 || strcmp(token, "<") == 0 || strcmp(token, ">") == 0 || + strcmp(token, "<=") == 0 || + strcmp(token, ">=") == 0 || strcmp(token, "==") == 0 || strcmp(token, "!=") == 0) { -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] perf: allow processing single op args
I got following error from record with btrfs tracepoints: $ perf script Fatal: unknown op '-' It seems that perf failed to handle '-' in the following format: print fmt: "%s", ((REC->id >= -9) || (REC->id <= 7)) ? "x" : "y" ~ process_arg() have code to parse '-9' as a "single op" arg, which is PRINT_OP as type, '-' as op and have '9' as right arg but no left arg. However arg_num_eval() have no code to handle this "single op" arg even it is parsed successfully. This patch allow perf to process such "single op" args. Signed-off-by: Hidetoshi Seto --- tools/perf/util/trace-event-parse.c | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index c2adc76..b709f78 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1355,6 +1355,24 @@ static long long arg_num_eval(struct print_arg *arg) val = arg_num_eval(arg->typecast.item); break; case PRINT_OP: + if (!arg->op.left || arg->op.left->type == PRINT_NULL) { + /* handle single op */ + right = arg_num_eval(arg->op.right); + switch (arg->op.op[0]) { + case '!': + val = !right; + break; + case '+': + val = right; + break; + case '-': + val = -right; + break; + default: + die("unknown single op %s", arg->op.op); + } + break; + } switch (arg->op.op[0]) { case '|': left = arg_num_eval(arg->op.left); -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] perf: allow typecast for signed value
Still I got following warning with btrfs tracepoints: $ perf script Warning: Error: expected type 5 but read 4 Warning: Error: expected type 5 but read 0 I found that the complained format is: print fmt: "%s", (REC->val >= (u64)-4) ? "-" : __print_symbolic(...) ~ In perf's parser, the typecast, which is processed in process_paren(), only expects that (unsigned) token or another parenthesis will follow to the typecast. It should expect signed tokens can be there too. Signed-off-by: Hidetoshi Seto --- tools/perf/util/trace-event-parse.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index b709f78..032f3de 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1645,10 +1645,11 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) type = read_token_item(&token); /* -* If the next token is an item or another open paren, then -* this was a typecast. +* If the next token is an item (might be signed, with single op "-") +* or another open paren, then this was a typecast. */ if (event_item_type(type) || + (type == EVENT_OP && strcmp(token, "-") == 0) || (type == EVENT_DELIM && strcmp(token, "(") == 0)) { /* make this a typecast and contine */ -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html