Re: btrfs: failed to read chunk tree on vde1 (f18 anaconda crash)
On Sat, Jan 19, 2013 at 07:53:08PM -0300, Reartes Guillermo wrote: Hi, I reported a bug to anaconda (rhbz 901905), but it might be btfs related. Anaconda does this: 18:49:10,317 INFO program: Running... mkfs.btrfs --data=single --label=fedora /dev/vdb1 /dev/vdc1 /dev/vdd1 /dev/vde1 18:49:10,742 INFO program: 18:49:10,746 INFO program: WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL 18:49:10,746 INFO program: WARNING! - see http://btrfs.wiki.kernel.org before using 18:49:10,748 INFO program: 18:49:10,749 INFO program: SMALL VOLUME: forcing mixed metadata/data groups 18:49:10,750 INFO program: Created a data/metadata chunk of size 8388608 18:49:10,750 INFO program: adding device /dev/vdc1 id 2 18:49:10,751 INFO program: adding device /dev/vdd1 id 3 18:49:10,752 INFO program: adding device /dev/vde1 id 4 18:49:10,752 INFO program: fs created label fedora on /dev/vdb1 Out of interest, how big are these devices? Hugo. [snip] I booted again and did both the mk.btrfs and the mount manually and i got the same error. Is it a known issue? -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- We believe in free will because we have no choice. --- signature.asc Description: Digital signature
[PATCH 2/5] Btrfs: fix mutually exclusive op is running error code
The error code that is returned in response to starting a mutually exclusive operation when there is one already running got silently changed from EINVAL to EINPROGRESS by 5ac00add. Returning EINPROGRESS to, say, add_dev, when rm_dev is running is misleading. Furthermore, the operation itself may want to use EINPROGRESS for other purposes. Signed-off-by: Ilya Dryomov idryo...@gmail.com --- fs/btrfs/ioctl.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index ab82636..3aebb28 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1337,7 +1337,7 @@ static noinline int btrfs_ioctl_resize(struct file *file, 1)) { pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); mnt_drop_write_file(file); - return -EINPROGRESS; + return -EINVAL; } mutex_lock(root-fs_info-volume_mutex); @@ -2193,7 +2193,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) if (atomic_xchg(root-fs_info-mutually_exclusive_operation_running, 1)) { pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); - return -EINPROGRESS; + return -EINVAL; } ret = mnt_want_write_file(file); if (ret) { @@ -2267,7 +2267,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg) if (atomic_xchg(root-fs_info-mutually_exclusive_operation_running, 1)) { pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); - return -EINPROGRESS; + return -EINVAL; } mutex_lock(root-fs_info-volume_mutex); @@ -2304,7 +2304,7 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) 1)) { pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); mnt_drop_write_file(file); - return -EINPROGRESS; + return -EINVAL; } mutex_lock(root-fs_info-volume_mutex); -- 1.7.9.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 3/5] Btrfs: fix unlock order in btrfs_ioctl_resize
Fix unlock order in btrfs_ioctl_resize(). Signed-off-by: Ilya Dryomov idryo...@gmail.com --- fs/btrfs/ioctl.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3aebb28..b9a0190 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1447,8 +1447,8 @@ out_free: kfree(vol_args); out: mutex_unlock(root-fs_info-volume_mutex); - mnt_drop_write_file(file); atomic_set(root-fs_info-mutually_exclusive_operation_running, 0); + mnt_drop_write_file(file); return ret; } -- 1.7.9.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 4/5] Btrfs: fix unlock order in btrfs_ioctl_rm_dev
Fix unlock order in btrfs_ioctl_rm_dev(). Signed-off-by: Ilya Dryomov idryo...@gmail.com --- fs/btrfs/ioctl.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b9a0190..9c079dd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2320,8 +2320,8 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) kfree(vol_args); out: mutex_unlock(root-fs_info-volume_mutex); - mnt_drop_write_file(file); atomic_set(root-fs_info-mutually_exclusive_operation_running, 0); + mnt_drop_write_file(file); return ret; } -- 1.7.9.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 0/5] Mutually exclusive ops fixes
Hello, This is a set of fixes for mutually exclusive ops stuff added by Stefan as part of the dev-replace patchset. The main one here is the first patch, it fixes a regression in balancing interface. The second patch brings EINVAL error code back. The rest are relatively minor ordering fixes. Thanks, Ilya Ilya Dryomov (5): Btrfs: bring back balance pause/resume logic Btrfs: fix mutually exclusive op is running error code Btrfs: fix unlock order in btrfs_ioctl_resize Btrfs: fix unlock order in btrfs_ioctl_rm_dev Btrfs: reorder locks and sanity checks in btrfs_ioctl_defrag fs/btrfs/ioctl.c | 107 ++- fs/btrfs/volumes.c | 10 +++- 2 files changed, 86 insertions(+), 31 deletions(-) -- 1.7.9.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/5] Mutually exclusive ops fixes
On Sun, Jan 20, 2013 at 05:22:27PM +0200, Ilya Dryomov wrote: Hello, This is a set of fixes for mutually exclusive ops stuff added by Stefan as part of the dev-replace patchset. The main one here is the first patch, it fixes a regression in balancing interface. The second patch brings EINVAL error code back. The rest are relatively minor ordering fixes. You can pull from git://github.com/idryomov/btrfs-unstable.git mutex-ops@next-master top commit 2f68aafa90fedb3cdb80f0a8517a2130c5c035b0 Thanks, Ilya -- 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/5] Btrfs: bring back balance pause/resume logic
Balance pause/resume logic got broken by 5ac00add (went in into 3.8-rc1 as part of dev-replace merge). Offending commit took a stab at making mutually exclusive volume operations (add_dev, rm_dev, resize, balance, replace_dev) not block behind volume_mutex if another such operation is in progress and instead return an error right away. Balancing front-end relied on the blocking behaviour, so the fix is ugly, but short of a complete rework, it's the best we can do. Reported-by: Liu Bo bo.li@oracle.com Signed-off-by: Ilya Dryomov idryo...@gmail.com --- fs/btrfs/ioctl.c | 78 ++- fs/btrfs/volumes.c | 10 -- 2 files changed, 71 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 171786a..ab82636 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3441,8 +3441,8 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) struct btrfs_fs_info *fs_info = root-fs_info; struct btrfs_ioctl_balance_args *bargs; struct btrfs_balance_control *bctl; + bool need_unlock; /* for mut. excl. ops lock */ int ret; - int need_to_clear_lock = 0; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -3451,14 +3451,61 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) if (ret) return ret; - mutex_lock(fs_info-volume_mutex); +again: + if (!atomic_xchg(fs_info-mutually_exclusive_operation_running, 1)) { + mutex_lock(fs_info-volume_mutex); + mutex_lock(fs_info-balance_mutex); + need_unlock = true; + goto locked; + } + + /* +* mut. excl. ops lock is locked. Three possibilites: +* (1) some other op is running +* (2) balance is running +* (3) balance is paused -- special case (think resume) +*/ mutex_lock(fs_info-balance_mutex); + if (fs_info-balance_ctl) { + /* this is either (2) or (3) */ + if (!atomic_read(fs_info-balance_running)) { + mutex_unlock(fs_info-balance_mutex); + if (!mutex_trylock(fs_info-volume_mutex)) + goto again; + mutex_lock(fs_info-balance_mutex); + + if (fs_info-balance_ctl + !atomic_read(fs_info-balance_running)) { + /* this is (3) */ + need_unlock = false; + goto locked; + } + + mutex_unlock(fs_info-balance_mutex); + mutex_unlock(fs_info-volume_mutex); + goto again; + } else { + /* this is (2) */ + mutex_unlock(fs_info-balance_mutex); + ret = -EINPROGRESS; + goto out; + } + } else { + /* this is (1) */ + mutex_unlock(fs_info-balance_mutex); + pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); + ret = -EINVAL; + goto out; + } + +locked: + BUG_ON(!atomic_read(fs_info-mutually_exclusive_operation_running)); if (arg) { bargs = memdup_user(arg, sizeof(*bargs)); if (IS_ERR(bargs)) { ret = PTR_ERR(bargs); - goto out; + goto out_unlock; } if (bargs-flags BTRFS_BALANCE_RESUME) { @@ -3478,13 +3525,10 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) bargs = NULL; } - if (atomic_xchg(root-fs_info-mutually_exclusive_operation_running, - 1)) { - pr_info(btrfs: dev add/delete/balance/replace/resize operation in progress\n); + if (fs_info-balance_ctl) { ret = -EINPROGRESS; goto out_bargs; } - need_to_clear_lock = 1; bctl = kzalloc(sizeof(*bctl), GFP_NOFS); if (!bctl) { @@ -3505,11 +3549,17 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) } do_balance: - ret = btrfs_balance(bctl, bargs); /* -* bctl is freed in __cancel_balance or in free_fs_info if -* restriper was paused all the way until unmount +* Ownership of bctl and mutually_exclusive_operation_running +* goes to to btrfs_balance. bctl is freed in __cancel_balance, +* or, if restriper was paused all the way until unmount, in +* free_fs_info. mutually_exclusive_operation_running is +* cleared in __cancel_balance. */ + need_unlock = false; + + ret = btrfs_balance(bctl, bargs); + if (arg) {
scrub fails, any way to recover?
I have a ~350 GB Btrfs filesystem that is corrupted. I think the damage was caused by a bad SATA cable. I can mount the filesystem and read most of the data (I already have backups of most everything). The scrub is aborted after a few seconds with the following error in the kernel log: parent transid verify failed on 795639808 wanted 102145 found 101462 parent transid verify failed on 795639808 wanted 102145 found 101462 verify_parent_transid: 16273 callbacks suppressed ... Trying to remove the corrupted directory tree results in the following: device label DATA devid 1 transid 102169 /dev/sda2 btrfs: enabling auto recovery btrfs: disk space caching is enabled verify_parent_transid: 12197 callbacks suppressed parent transid verify failed on 795062272 wanted 102145 found 101462 ... [ cut here ] WARNING: at fs/btrfs/super.c:256 __btrfs_abort_transaction+0x43/0xb6() Hardware name: MS-7388 btrfs: Transaction aborted ... Pid: 24332, comm: rm Not tainted 3.8.0-rc4 #66 Call Trace: [81162000] ? __btrfs_abort_transaction+0x39/0xb6 [8102cf85] warn_slowpath_common+0x7e/0x97 [8102d032] warn_slowpath_fmt+0x41/0x43 [81198d6e] ? set_extent_dirty+0x1b/0x1d [8116200a] __btrfs_abort_transaction+0x43/0xb6 [81170db9] __btrfs_free_extent+0x612/0x64e [811950eb] ? btrfs_get_token_32+0x79/0xc7 [811b8fa9] ? btrfs_merge_delayed_refs+0x24b/0x266 [81173cfe] run_clustered_refs+0x7e3/0x8b9 [81176b20] btrfs_run_delayed_refs+0xde/0x268 [811843f8] __btrfs_end_transaction+0xd8/0x2cf [8118461a] btrfs_end_transaction+0xb/0xd [81186b15] __unlink_end_trans+0x5e/0x63 [8118baf1] btrfs_unlink+0x86/0xa0 [810bc29f] vfs_unlink+0x6f/0xdc [810bc3f9] do_unlinkat+0xed/0x199 [810b1d2e] ? vfs_write+0x100/0x127 [810b1f32] ? sys_write+0x44/0x75 [810bdf8a] sys_unlinkat+0x1d/0x29 [8147f9d2] system_call_fastpath+0x16/0x1b ---[ end trace ce4d352b0ec7d230 ]--- BTRFS error (device sda2) in __btrfs_free_extent:5184: IO failure btrfs is forced readonly btrfs: run_one_delayed_ref returned -5 I've tried btrfsck but it fails as well. Is there some way I can remove the damaged data and save the good or is a re-format the only solution? Neil -- 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 00/13] Btrfs-progs: more patches for integration
I have done some additional scraping of the mailing list to identify some low hanging fruit which I consider should be merged into the btrfs-progs repository. All of the patches below were applied on top of the 19 bugfix patches pulled together by David Sterba and the 6 patches now part of the Fedora 18 btrfs-progs package. All of this compiles but further testing is obviously needed. For the most part, these patches are bugfixes and they all appeared resonable but inspection by other eyes would be appreciated. There is also one simple function addition in the form or the btrfs-show-super command. Arvin Schnell (1): trivial patch for btrfs-progs Chen Yang (1): Btrfs-progs: Fix a segmentation fault in btrfstune when device is invalid. Gene Czarcinski (1): btrfs-show-super.c Goffredo Baroncelli (1): Add btrfs-show-super Jan Schmidt (2): Btrfs-progs: correcting misnamed parameter options for btrfs send Btrfs-progs: bugfix for subvolume parent determination in btrfs send Nageswara R Sastry (1): btrfs-progs: btrfs-image.c: Added NULL pointer check. Nirbheek Chauhan (1): Btrfs-progs: fix resolving of loop devices Ulrik (1): Btrfs-progs: correct btrfs receive usage string Wang Shilong (4): Btrfs-progs: fix arg parsing for btrfs qgroup limit commands Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with strtoull Btrfs-progs: check the relation of two group by real level numbers Btrfs-progs: disable qgroupid 0 for quota_tree -- 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 01/13] btrfs-progs: btrfs-image.c: Added NULL pointer check.
From: Nageswara R Sastry nasas...@in.ibm.com Check for the return value of 'open_ctree()' before dereferencing it. Signed-off-by: Nageswara R Sastry nasas...@in.ibm.com Signed-off-by: Gene Czarcinski g...@czarc.net --- btrfs-image.c | 1 + 1 file changed, 1 insertion(+) diff --git a/btrfs-image.c b/btrfs-image.c index f2bbcc8..2a33a55 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -491,6 +491,7 @@ static int create_metadump(const char *input, FILE *out, int num_threads, int ret; root = open_ctree(input, 0, 0); + BUG_ON(!root); BUG_ON(root-nodesize != root-leafsize); ret = metadump_init(metadump, root, out, num_threads, -- 1.8.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 06/13] btrfs-show-super.c
remove extra blank line at EOF Signed-off-by: Gene Czarcinski g...@czarc.net --- btrfs-show-super.c | 1 - man/Makefile | 14 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/btrfs-show-super.c b/btrfs-show-super.c index a9e2524..7c66d84 100644 --- a/btrfs-show-super.c +++ b/btrfs-show-super.c @@ -281,4 +281,3 @@ static void dump_superblock(struct btrfs_super_block *sb) printf(dev_item.generation\t%llu\n, (unsigned long long) btrfs_stack_device_generation(sb-dev_item)); } - diff --git a/man/Makefile b/man/Makefile index 4a90b75..f7b57f7 100644 --- a/man/Makefile +++ b/man/Makefile @@ -1,4 +1,4 @@ -GZIP=gzip +GZIPCMD=gzip INSTALL= install prefix ?= /usr/local @@ -12,22 +12,22 @@ MANPAGES = mkfs.btrfs.8.gz btrfsctl.8.gz btrfsck.8.gz btrfs-image.8.gz \ all: $(MANPAGES) mkfs.btrfs.8.gz: mkfs.btrfs.8.in - $(GZIP) -n -c mkfs.btrfs.8.in mkfs.btrfs.8.gz + $(GZIPCMD) -n -c mkfs.btrfs.8.in mkfs.btrfs.8.gz btrfs.8.gz: btrfs.8.in - $(GZIP) -n -c btrfs.8.in btrfs.8.gz + $(GZIPCMD) -n -c btrfs.8.in btrfs.8.gz btrfsctl.8.gz: btrfsctl.8.in - $(GZIP) -n -c btrfsctl.8.in btrfsctl.8.gz + $(GZIPCMD) -n -c btrfsctl.8.in btrfsctl.8.gz btrfsck.8.gz: btrfsck.8.in - $(GZIP) -n -c btrfsck.8.in btrfsck.8.gz + $(GZIPCMD) -n -c btrfsck.8.in btrfsck.8.gz btrfs-image.8.gz: btrfs-image.8.in - $(GZIP) -n -c btrfs-image.8.in btrfs-image.8.gz + $(GZIPCMD) -n -c btrfs-image.8.in btrfs-image.8.gz btrfs-show.8.gz: btrfs-show.8.in - $(GZIP) -n -c btrfs-show.8.in btrfs-show.8.gz + $(GZIPCMD) -n -c btrfs-show.8.in btrfs-show.8.gz clean : rm -f $(MANPAGES) -- 1.8.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 05/13] Add btrfs-show-super
From: Goffredo Baroncelli kreij...@inwind.it Signed-off-by: Goffredo Baroncelli kreij...@inwind.it Signed-off-by: Gene Czarcinski g...@czarc.net --- Makefile | 5 +- btrfs-show-super.c | 284 + 2 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 btrfs-show-super.c diff --git a/Makefile b/Makefile index c7fd97d..d524f69 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ RESTORE_LIBS=-lz progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \ btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ - btrfs-find-root btrfs-restore btrfstune + btrfs-find-root btrfs-restore btrfstune btrfs-show-super # make C=1 to enable sparse ifdef C @@ -75,6 +75,9 @@ btrfs-debug-tree: $(objects) debug-tree.o btrfs-zero-log: $(objects) btrfs-zero-log.o $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS) +btrfs-show-super: $(objects) btrfs-show-super.o + $(CC) $(CFLAGS) -o btrfs-show-super $(objects) btrfs-show-super.o $(LDFLAGS) $(LIBS) + btrfs-select-super: $(objects) btrfs-select-super.o $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS) diff --git a/btrfs-show-super.c b/btrfs-show-super.c new file mode 100644 index 000..a9e2524 --- /dev/null +++ b/btrfs-show-super.c @@ -0,0 +1,284 @@ +/* + * Copyright (C) 2012 STRATO AG. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#define _XOPEN_SOURCE 500 +#define _GNU_SOURCE 1 +#include stdio.h +#include stdlib.h +#include unistd.h +#include fcntl.h +#include sys/stat.h +#include ctype.h +#include uuid/uuid.h +#include errno.h + +#include kerncompat.h +#include ctree.h +#include disk-io.h +#include print-tree.h +#include transaction.h +#include list.h +#include version.h +#include utils.h +#include crc32c.h + +static void print_usage(void); +static void dump_superblock(struct btrfs_super_block *sb); +int main(int argc, char **argv); +static int load_and_dump_sb(char *, int fd, u64 sb_bytenr); + + +static void print_usage(void) +{ + fprintf(stderr, + usage: btrfs-show-super [-i super_mirror|-a] dev [dev..]\n); + fprintf(stderr, \tThe super_mirror number is between 0 and %d.\n, + BTRFS_SUPER_MIRROR_MAX - 1); + fprintf(stderr, \tIf -a is passed all the superblocks are showed.\n, + BTRFS_SUPER_MIRROR_MAX - 1); + fprintf(stderr, %s\n, BTRFS_BUILD_VERSION); +} + +int main(int argc, char **argv) +{ + int opt; + int all = 0; + char *filename; + int fd = -1; + int arg, i; + u64 sb_bytenr = btrfs_sb_offset(0); + + while ((opt = getopt(argc, argv, ai:)) != -1) { + switch (opt) { + case 'i': + arg = atoi(optarg); + + if (arg 0 || arg = BTRFS_SUPER_MIRROR_MAX) { + fprintf(stderr, + Illegal super_mirror %d\n, + arg); + print_usage(); + exit(1); + } + sb_bytenr = btrfs_sb_offset(arg); + break; + + case 'a': + all = 1; + break; + + default: + print_usage(); + exit(1); + } + } + + if (argc optind + 1) { + print_usage(); + exit(1); + } + + for (i = optind ; i argc ; i++) { + filename = argv[i]; + fd = open(filename, O_RDONLY, 0666); + if (fd 0) { + fprintf(stderr, Could not open %s\n, filename); + close(fd); + exit(1); + } + + if (all) { + int idx; + for (idx = 0 ; idx BTRFS_SUPER_MIRROR_MAX ; idx++) { + sb_bytenr = btrfs_sb_offset(idx); + if (load_and_dump_sb(filename, fd, sb_bytenr)) { + close(fd); + exit(1); +
[PATCH 12/13] Btrfs-progs: disable qgroupid 0 for quota_tree
From: Wang Shilong wangsl-f...@cn.fujitsu.com In kernel, qgroupid 0 is a special number when we run the quota group limit command. So, we should not be able to create a quota group whose id is 0, otherwise the kernel can't deal with it. Fix it. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-qgroup.c | 4 1 file changed, 4 insertions(+) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index 70019d0..dfff1b9 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -86,6 +86,10 @@ static int qgroup_create(int create, int argc, char **argv) args.create = create; args.qgroupid = parse_qgroupid(argv[1]); + if (!args.qgroupid) { + fprintf(stderr, ERROR: qgroup 0 is not supported\n); + return 30; + } fd = open_file_or_dir(path); if (fd 0) { fprintf(stderr, ERROR: can't access '%s'\n, path); -- 1.8.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 13/13] trivial patch for btrfs-progs
From: Arvin Schnell aschn...@suse.de Hi, please find attached a trivial patch for btrfs-progs. Likely not strictly needed but I noticed valgrind complaining about uninitialised memory in the ioctl call. Regards, Arvin Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-send.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmds-send.c b/cmds-send.c index b33c802..595a5d0 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -273,6 +273,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root) goto out; } + memset(io_send, 0, sizeof(io_send)); io_send.send_fd = pipefd[1]; send-send_fd = pipefd[0]; -- 1.8.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 11/13] Btrfs-progs: check the relation of two group by real level numbers
From: Wang Shilong wangsl-f...@cn.fujitsu.com Comparing qgroupid is not good way to check the relationship of two groups, the right way is to compare the real level numbers. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-qgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index c4122bf..70019d0 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -50,7 +50,7 @@ static int qgroup_assign(int assign, int argc, char **argv) /* * FIXME src should accept subvol path */ - if (args.src = args.dst) { + if ((args.src 48) = (args.dst 48)) { fprintf(stderr, ERROR: bad relation requested '%s'\n, path); return 12; } -- 1.8.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 09/13] Btrfs-progs: fix arg parsing for btrfs qgroup limit commands
From: Wang Shilong wangsl-f...@cn.fujitsu.com We can use this command in two ways. 1. btrfs qgroup limit size qgroupid path 2. btrfs qgroup limit size path Before applying this patch, we differentiate them by check the parsing result of the second argument. It is not so good because it may make some mistakes, For example: btrfs qgroup limit 1M 123456 ^ It is a subvolume name. In fact, we can differentiate them just by the number of arguments, so fix it by this way. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-qgroup.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index 1525c11..129a4f0 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -383,7 +383,6 @@ static int cmd_qgroup_limit(int argc, char **argv) } memset(args, 0, sizeof(args)); - args.qgroupid = parse_qgroupid(argv[optind + 1]); if (size) { if (compressed) args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR | @@ -397,9 +396,8 @@ static int cmd_qgroup_limit(int argc, char **argv) } } - if (args.qgroupid == 0) { - if (check_argc_exact(argc - optind, 2)) - usage(cmd_qgroup_limit_usage); + if (argc - optind == 2) { + args.qgroupid = 0; path = argv[optind + 1]; ret = test_issubvolume(path); if (ret 0) { @@ -415,11 +413,11 @@ static int cmd_qgroup_limit(int argc, char **argv) * keep qgroupid at 0, this indicates that the subvolume the * fd refers to is to be limited */ - } else { - if (check_argc_exact(argc - optind, 3)) - usage(cmd_qgroup_limit_usage); + } else if (argc - optind == 3) { + args.qgroupid = parse_qgroupid(argv[optind + 1]); path = argv[optind + 2]; - } + } else + usage(cmd_qgroup_limit_usage); fd = open_file_or_dir(path); if (fd 0) { -- 1.8.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 10/13] Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with strtoull
From: Wang Shilong wangsl-f...@cn.fujitsu.com 1. parse_qgroupid() is implemented twice, clean up the reduplicate code. 2. atoi() can not detect errors, so use strtoull() instead of it. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-qgroup.c | 15 +-- qgroup.c | 22 ++ qgroup.h | 2 ++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index 129a4f0..c4122bf 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -24,26 +24,13 @@ #include ioctl.h #include commands.h +#include qgroup.h static const char * const qgroup_cmd_group_usage[] = { btrfs qgroup command [options] path, NULL }; -static u64 parse_qgroupid(char *p) -{ - char *s = strchr(p, '/'); - u64 level; - u64 id; - - if (!s) - return atoll(p); - level = atoll(p); - id = atoll(s + 1); - - return (level 48) | id; -} - static int qgroup_assign(int assign, int argc, char **argv) { int ret = 0; diff --git a/qgroup.c b/qgroup.c index 4083b57..dafde12 100644 --- a/qgroup.c +++ b/qgroup.c @@ -22,15 +22,29 @@ u64 parse_qgroupid(char *p) { char *s = strchr(p, '/'); + char *ptr_src_end = p + strlen(p); + char *ptr_parse_end = NULL; u64 level; u64 id; - if (!s) - return atoll(p); - level = atoll(p); - id = atoll(s + 1); + if (!s) { + id = strtoull(p, ptr_parse_end, 10); + if (ptr_parse_end != ptr_src_end) + goto err; + return id; + } + level = strtoull(p, ptr_parse_end, 10); + if (ptr_parse_end != s) + goto err; + + id = strtoull(s+1, ptr_parse_end, 10); + if (ptr_parse_end != ptr_src_end) + goto err; return (level 48) | id; +err: + fprintf(stderr, ERROR:invalid qgroupid\n); + exit(-1); } int qgroup_inherit_size(struct btrfs_qgroup_inherit *p) diff --git a/qgroup.h b/qgroup.h index f7af8c5..ad14c88 100644 --- a/qgroup.h +++ b/qgroup.h @@ -20,7 +20,9 @@ #define _BTRFS_QGROUP_H #include ioctl.h +#include kerncompat.h +u64 parse_qgroupid(char *p); int qgroup_inherit_size(struct btrfs_qgroup_inherit *p); int qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit, int incgroups, int inccopies); -- 1.8.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 08/13] Btrfs-progs: bugfix for subvolume parent determination in btrfs send
From: Jan Schmidt list.bt...@jan-o-sch.net We missed to add the default subvolume, because it has no ROOT_BACKREF_ITEM. This made get_parent always fail for direct decendants of the default subvolume, resulting in lots of full streams where incremental streams were requested. Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net Reviewed-by: Alexander Block abloc...@googlemail.com Signed-off-by: Gene Czarcinski g...@czarc.net --- send-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/send-utils.c b/send-utils.c index fcde5c2..d8d3972 100644 --- a/send-utils.c +++ b/send-utils.c @@ -240,7 +240,8 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s) memcpy(root_item, root_item_ptr, sizeof(root_item)); root_item_valid = 1; - } else if (sh-type == BTRFS_ROOT_BACKREF_KEY) { + } else if (sh-type == BTRFS_ROOT_BACKREF_KEY || + root_item_valid) { if (!root_item_valid) goto skip; @@ -274,7 +275,6 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s) subvol_uuid_search_add(s, si); root_item_valid = 0; } else { - root_item_valid = 0; goto skip; } -- 1.8.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 04/13] Btrfs-progs: Fix a segmentation fault in btrfstune when device is invalid.
From: Chen Yang chenyang.f...@cn.fujitsu.com When open_ctree(device, ...) failed, the return value should be checked. Signed-off-by: Cheng Yang chenyang.f...@cn.fujitsu.com Signed-off-by: Gene Czarcinski g...@czarc.net --- btrfstune.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfstune.c b/btrfstune.c index 47830c5..07648d5 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -107,6 +107,8 @@ int main(int argc, char *argv[]) } root = open_ctree(device, 0, 1); + if (!root) + return 1; if (seeding_flag) { ret = update_seeding_flag(root, seeding_value); -- 1.8.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 07/13] Btrfs-progs: correcting misnamed parameter options for btrfs send
From: Jan Schmidt list.bt...@jan-o-sch.net Unfortunately, the command line options for btrfs send were misnamed. The -i option should not be used to give clone sources, we'll be using -c instead. Compatibily note: -i option was broken anyway, which makes it less critical renaming it. For potential users of the old option style, we emit a fatal warning if the -i option is used. Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-send.c | 74 +++-- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index 9b47e70..3e2fcbe 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -234,7 +234,7 @@ out: return ERR_PTR(ret); } -static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root) +static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id) { int ret; pthread_t t_read; @@ -286,7 +286,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root) io_send.clone_sources = (__u64*)send-clone_sources; io_send.clone_sources_count = send-clone_sources_count; - io_send.parent_root = parent_root; + io_send.parent_root = parent_root_id; ret = ioctl(subvol_fd, BTRFS_IOC_SEND, io_send); if (ret) { ret = -errno; @@ -423,16 +423,17 @@ int cmd_send_start(int argc, char **argv) char *snapshot_parent = NULL; u64 root_id; u64 parent_root_id = 0; + int full_send = 1; memset(send, 0, sizeof(send)); send.dump_fd = fileno(stdout); - while ((c = getopt(argc, argv, vf:i:p:)) != -1) { + while ((c = getopt(argc, argv, vc:f:i:p:)) != -1) { switch (c) { case 'v': g_verbose++; break; - case 'i': { + case 'c': subvol = realpath(optarg, NULL); if (!subvol) { ret = -errno; @@ -454,12 +455,16 @@ int cmd_send_start(int argc, char **argv) } add_clone_source(send, root_id); free(subvol); + full_send = 0; break; - } case 'f': outname = optarg; break; case 'p': + if (snapshot_parent) { + fprintf(stderr, ERROR: you cannot have more than one parent (-p)\n); + return 1; + } snapshot_parent = realpath(optarg, NULL); if (!snapshot_parent) { ret = -errno; @@ -467,7 +472,12 @@ int cmd_send_start(int argc, char **argv) %s\n, optarg, strerror(-ret)); goto out; } + full_send = 0; break; + case 'i': + fprintf(stderr, + ERROR: -i was removed, use -c instead\n); + return 1; case '?': default: fprintf(stderr, ERROR: send args invalid.\n); @@ -573,10 +583,13 @@ int cmd_send_start(int argc, char **argv) goto out; } - if (!parent_root_id) { + if (!full_send !parent_root_id) { ret = find_good_parent(send, root_id, parent_root_id); - if (ret 0) - parent_root_id = 0; + if (ret 0) { + fprintf(stderr, ERROR: parent determination failed for %lld\n, + root_id); + goto out; + } } ret = is_subvol_ro(send, subvol); @@ -597,6 +610,7 @@ int cmd_send_start(int argc, char **argv) add_clone_source(send, root_id); parent_root_id = 0; + full_send = 0; free(subvol); } @@ -614,32 +628,28 @@ static const char * const send_cmd_group_usage[] = { }; static const char * const cmd_send_usage[] = { - btrfs send [-v] [-i subvol] [-p parent] subvol, + btrfs send [-v] [-p parent] [-c clone-src] subvol, Send the subvolume to stdout., Sends the subvolume specified by subvol to stdout., - By default, this will send the whole subvolume. To do, - an incremental send, one or multiple '-i clone_source', - arguments have to be specified. A 'clone source' is, - a subvolume that is known to exist on the receiving, - side in exactly the same state
[PATCH 03/13] Btrfs-progs: correct btrfs receive usage string
From: Ulrik ulrik.sverd...@gmail.com Fix the usage string to specify the correct '-f' option for input file, not '-i'. Signed-off-by: Ulrik Sverdrup ulrik.sverd...@gmail.com Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-receive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-receive.c b/cmds-receive.c index 37d07db..2fae299 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -882,7 +882,7 @@ static const char * const receive_cmd_group_usage[] = { }; static const char * const cmd_receive_usage[] = { - btrfs receive [-v] [-i infile] mount, + btrfs receive [-v] [-f infile] mount, Receive subvolumes from stdin., Receives one or more subvolumes that were previously , sent with btrfs send. The received subvolumes are stored, -- 1.8.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 02/13] Btrfs-progs: fix resolving of loop devices
From: Nirbheek Chauhan nirbheek.chau...@collabora.co.uk The LOOP_GET_STATUS ioctl truncates filenames to 64 characters. We should get the backing file for a given loop device from /sys/. This is how losetup does it as well. Signed-off-by: Gene Czarcinski g...@czarc.net --- utils.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/utils.c b/utils.c index 51b78d5..7953ef9 100644 --- a/utils.c +++ b/utils.c @@ -20,6 +20,7 @@ #define __USE_XOPEN2K #include stdio.h #include stdlib.h +#include string.h #ifndef __CHECKER__ #include sys/ioctl.h #include sys/mount.h @@ -653,21 +654,22 @@ int is_loop_device (const char* device) { * the associated file (e.g. /images/my_btrfs.img) */ int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len) { - int loop_fd; - int ret_ioctl; - struct loop_info loopinfo; + int ret; + FILE *f; + char fmt[20]; + char p[PATH_MAX]; + char real_loop_dev[PATH_MAX]; - if ((loop_fd = open(loop_dev, O_RDONLY)) 0) + if (!realpath(loop_dev, real_loop_dev)) + return -errno; + snprintf(p, PATH_MAX, /sys/block/%s/loop/backing_file, strrchr(real_loop_dev, '/')); + if (!(f = fopen(p, r))) return -errno; - ret_ioctl = ioctl(loop_fd, LOOP_GET_STATUS, loopinfo); - close(loop_fd); - - if (ret_ioctl == 0) { - strncpy(loop_file, loopinfo.lo_name, max_len); - if (max_len 0) - loop_file[max_len-1] = 0; - } else + snprintf(fmt, 20, %%%i[^\n], max_len-1); + ret = fscanf(f, fmt, loop_file); + fclose(f); + if (ret == EOF) return -errno; return 0; -- 1.8.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 07/13] Btrfs-progs: correcting misnamed parameter options for btrfs send
Bad patch ... working on fix On 01/20/2013 04:04 PM, Gene Czarcinski wrote: From: Jan Schmidt list.bt...@jan-o-sch.net Unfortunately, the command line options for btrfs send were misnamed. The -i option should not be used to give clone sources, we'll be using -c instead. Compatibily note: -i option was broken anyway, which makes it less critical renaming it. For potential users of the old option style, we emit a fatal warning if the -i option is used. Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net Signed-off-by: Gene Czarcinski g...@czarc.net snip -- 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: correcting misnamed parameter options for btrfs send
This is a hand refit of the patch but otherwise the same. Unfortunately, the command line options for btrfs send were misnamed. The -i option should not be used to give clone sources, we'll be using -c instead. Compatibily note: -i option was broken anyway, which makes it less critical renaming it. For potential users of the old option style, we emit a fatal warning if the -i option is used. Signed-off-by: Jan Schmidt list.bt...@jan-o-sch.net Signed-off-by: Gene Czarcinski g...@czarc.net --- cmds-send.c | 74 +++-- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index 5607f2a..d2f7691 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -236,7 +236,7 @@ out: return ERR_PTR(ret); } -static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root) +static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id) { int ret; pthread_t t_read; @@ -289,7 +289,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root) io_send.clone_sources = (__u64*)send-clone_sources; io_send.clone_sources_count = send-clone_sources_count; - io_send.parent_root = parent_root; + io_send.parent_root = parent_root_id; ret = ioctl(subvol_fd, BTRFS_IOC_SEND, io_send); if (ret) { ret = -errno; @@ -426,6 +426,7 @@ int cmd_send_start(int argc, char **argv) char *snapshot_parent = NULL; u64 root_id; u64 parent_root_id = 0; + int full_send = 1; memset(send, 0, sizeof(send)); send.dump_fd = fileno(stdout); @@ -435,12 +436,12 @@ int cmd_send_start(int argc, char **argv) return 1; } - while ((c = getopt(argc, argv, vf:i:p:)) != -1) { + while ((c = getopt(argc, argv, vc:f:i:p:)) != -1) { switch (c) { case 'v': g_verbose++; break; - case 'i': { + case 'c': subvol = realpath(optarg, NULL); if (!subvol) { ret = -errno; @@ -462,12 +463,16 @@ int cmd_send_start(int argc, char **argv) } add_clone_source(send, root_id); free(subvol); + full_send = 0; break; - } case 'f': outname = optarg; break; case 'p': + if (snapshot_parent) { + fprintf(stderr, ERROR: you cannot have more than one parent (-p)\n); + return 1; + } snapshot_parent = realpath(optarg, NULL); if (!snapshot_parent) { ret = -errno; @@ -475,7 +480,12 @@ int cmd_send_start(int argc, char **argv) %s\n, optarg, strerror(-ret)); goto out; } + full_send = 0; break; + case 'i': + fprintf(stderr, + ERROR: -i was removed, use -c instead\n); + return 1; case '?': default: fprintf(stderr, ERROR: send args invalid.\n); @@ -581,10 +591,13 @@ int cmd_send_start(int argc, char **argv) goto out; } - if (!parent_root_id) { + if (!full_send !parent_root_id) { ret = find_good_parent(send, root_id, parent_root_id); - if (ret 0) - parent_root_id = 0; + if (ret 0) { + fprintf(stderr, ERROR: parent determination failed for %lld\n, + root_id); + goto out; + } } ret = is_subvol_ro(send, subvol); @@ -605,6 +618,7 @@ int cmd_send_start(int argc, char **argv) add_clone_source(send, root_id); parent_root_id = 0; + full_send = 0; free(subvol); } @@ -622,32 +636,28 @@ static const char * const send_cmd_group_usage[] = { }; static const char * const cmd_send_usage[] = { - btrfs send [-v] [-i subvol] [-p parent] subvol, + btrfs send [-v] [-p parent] [-c clone-src] subvol, Send the subvolume to stdout., Sends the subvolume specified by subvol to stdout., - By default, this will send the whole subvolume. To do, - an incremental send, one or multiple '-i clone_source', - arguments have to be specified. A 'clone
Re: [PATCH 00/11 V3] add show command to the subvol sub command
On 01/10/2013 06:41 AM, Anand Jain wrote: This is an attempt to make btrfs cli more end user friendly. And adds show subcommand to display all known (as of now) information of the given subvol including its snapshot(s). The below patch: Btrfs-progs: accommodate different layout for printing subvol list obsoletes the previosuly submitted patch Btrfs-progs: make provision to print subvol list tree format Please provide your review comments. Thanks. An example output: First list out all the subvols/snapshots using the list subcommand. btrfs su list /btrfs ID 256 gen 10 top level 5 path sv1 ID 259 gen 6 top level 5 path sv1/snap ID 260 gen 7 top level 5 path snap ID 261 gen 8 top level 5 path sv2 ID 262 gen 9 top level 5 path sv1/snap2 ID 263 gen 10 top level 5 path sv1/snap3 Then use show subcommand to know all known information about the given subvol. btrfs su show /btrfs/sv1 /btrfs/sv1 uuid: 508b12a5-ed2a-3942-af63-830967201070 Parent uuid:- Creation time: 2013-01-07 13:53:30 Object ID: 256 Generation (Gen): 10 Gen at creation:5 Parent: 5 Top Level: 5 Snapshot(s): sv1/snap sv1/snap2 sv1/snap3 v2-v3: List snapshots of the given subvol if any. Uses a more simple approach to obtain the snapshots. You have certainly been busy. However, your patches need to be rebased considering some of the patch-sets currently sent to the mailing list. If nothing else, I would appreciate it if you could rebase to David Sterba's set. And then there are the two patch-sets I submitted. BTW, I do not claim anything except for the effort to scrapes these off the list to attempt getting btrfs-progs a bit more current with respect to bugfixes. I was going to include su show but your latest submission is a bit too much for now. Gene -- 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
A couple bugs with btrfs and 3.5.0 kernel
I upgraded to Ubuntu 12.10 and thought, Hey, that 3.5 kernel is relatively recent. And they seem to finally have implemented restriping. Maybe it's time to try btrfs again! So, first off, I backed up all my data. Next, I decided I would attempt to use btrfs's features for my benefit. Specifically (this part is less interesting except as setup): 1. I put a btrfs filesystem on top of dm-crypt on an external USB drive. 2. I copied data to it. 3. I unmounted the original partition, and then immediately mounted the btrfs partition in its place. Ok, now to the interesting bits: My goal here is to delete the usb device and just leave myself with my data, migrated back to the internal disk (with minimal downtime) So, I figured I could use restriping/device delete to live-migrate back onto the internal hard disk. 4. I did a btrfs device add on a partition (over lvm/dm-crypt) on the internal disk. Now I have 2 partitons in the fs. I attempted to btrfs device delete the usb disk, and it errored out (with somewhat inscrutable information) telling me that I can't reduce raid1 to dup this way. Note: Arguably, this is a bug. You really ought to do it, but with a -f option, and automatically reduce the chunks appropriately. Note: Also arguably, this is also a bug because it should not have changed the metadata profile from dup to raid1 without asking me. Maybe I don't want raid1. Anyway, I figure I can fix this up with a balance filter (this is primarily what made me think btrfs might be more usable now). 6. I attempt to balance with a filter -mconvert=dup. This immediately errors out with no real indication as to why. In the dmesg log I found: [52656.153908] btrfs: unable to start balance with target metadata profile 32 Clearly a bug. 7. After some random trial and error, I find that it accepts -mconvert=single, and the result appears to be metadata in dup state. Maybe. Ok now that's done, it's time to delete. 8. btrfs device delete /dev/dm-11 /btrfs Some hours later, it fails. I find stuff like this all over my dmesg log: [113936.300109] bio too big device dm-11 (1024 240) [113936.297242] btrfs: bdev /dev/dm-11 errs: wr 101, rd 10247, flush 0, corrupt 109, gen 0 [113935.425960] btrfs_dev_stat_print_on_error: 38 callbacks suppressed It also found 2 files with csum errors, which were left on the USB device. [92750.052638] btrfs csum failed ino 257 off 49278976 csum 948519347 private 2127080388 [95692.348662] btrfs: checksum error at logical 94682349568 on dev /dev/mapper/tempusb, sector 224788736, root 256, inode 114815, offset 14360576, length 4096, links 1 (path:...path to file) The csum errors appeared to have caused it to stop. Googling around seemed to indicate that someone had once experienced a similar problem with an external drive around the 3.0 kernel era. They suggested something about the filesystem not working when dealing with devices mixed between SATA and USB, which sounded a bit wacky to me. I initially assumed that maybe the USB drive was a bit flaky, but this sounds to me like the csum errors were probably btrfs causing silent corruption. I tried deleting the files with the csum errors and running the device delete again, but it immediately failed with invalid argument errors and nothing in the dmesg log. Clearly a bug. Then, I tried unmounting, remounting, and then re-running the delete. This time it started, but it's been running for a long time and spamming my kernel logs with the bio too big for device errors. I'm guessing I'll probably need to sysrq reboot or something. This is with Ubuntu's standard 3.5.0-22 generic kernel. Any ideas? I guess I could try to mount in degraded mode or try a 3.6 kernel or something, but this all seems like I should probably just restore from backups and move on. Thanks! -- 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: A couple bugs with btrfs and 3.5.0 kernel
On Sun, Jan 20, 2013 at 05:39:57PM -0800, Elladan wrote: I upgraded to Ubuntu 12.10 and thought, Hey, that 3.5 kernel is relatively recent. And they seem to finally have implemented restriping. Maybe it's time to try btrfs again! So, first off, I backed up all my data. Next, I decided I would attempt to use btrfs's features for my benefit. Specifically (this part is less interesting except as setup): 1. I put a btrfs filesystem on top of dm-crypt on an external USB drive. 2. I copied data to it. 3. I unmounted the original partition, and then immediately mounted the btrfs partition in its place. Ok, now to the interesting bits: My goal here is to delete the usb device and just leave myself with my data, migrated back to the internal disk (with minimal downtime) So, I figured I could use restriping/device delete to live-migrate back onto the internal hard disk. 4. I did a btrfs device add on a partition (over lvm/dm-crypt) on the internal disk. Now I have 2 partitons in the fs. I attempted to btrfs device delete the usb disk, and it errored out (with somewhat inscrutable information) telling me that I can't reduce raid1 to dup this way. Note: Arguably, this is a bug. You really ought to do it, but with a -f option, and automatically reduce the chunks appropriately. Note: Also arguably, this is also a bug because it should not have changed the metadata profile from dup to raid1 without asking me. Maybe I don't want raid1. Anyway, I figure I can fix this up with a balance filter (this is primarily what made me think btrfs might be more usable now). 6. I attempt to balance with a filter -mconvert=dup. This immediately errors out with no real indication as to why. In the dmesg log I found: [52656.153908] btrfs: unable to start balance with target metadata profile 32 Clearly a bug. 7. After some random trial and error, I find that it accepts -mconvert=single, and the result appears to be metadata in dup state. Maybe. Ok now that's done, it's time to delete. 8. btrfs device delete /dev/dm-11 /btrfs Some hours later, it fails. I find stuff like this all over my dmesg log: [113936.300109] bio too big device dm-11 (1024 240) [113936.297242] btrfs: bdev /dev/dm-11 errs: wr 101, rd 10247, flush 0, corrupt 109, gen 0 [113935.425960] btrfs_dev_stat_print_on_error: 38 callbacks suppressed It also found 2 files with csum errors, which were left on the USB device. [92750.052638] btrfs csum failed ino 257 off 49278976 csum 948519347 private 2127080388 [95692.348662] btrfs: checksum error at logical 94682349568 on dev /dev/mapper/tempusb, sector 224788736, root 256, inode 114815, offset 14360576, length 4096, links 1 (path:...path to file) The csum errors appeared to have caused it to stop. Googling around seemed to indicate that someone had once experienced a similar problem with an external drive around the 3.0 kernel era. They suggested something about the filesystem not working when dealing with devices mixed between SATA and USB, which sounded a bit wacky to me. I initially assumed that maybe the USB drive was a bit flaky, but this sounds to me like the csum errors were probably btrfs causing silent corruption. I tried deleting the files with the csum errors and running the device delete again, but it immediately failed with invalid argument errors and nothing in the dmesg log. Clearly a bug. Then, I tried unmounting, remounting, and then re-running the delete. This time it started, but it's been running for a long time and spamming my kernel logs with the bio too big for device errors. I'm guessing I'll probably need to sysrq reboot or something. This is with Ubuntu's standard 3.5.0-22 generic kernel. Any ideas? I guess I could try to mount in degraded mode or try a 3.6 kernel or something, but this all seems like I should probably just restore from backups and move on. Hi Elladan, For 'bio too big' issue, this patch is helpful, https://patchwork.kernel.org/patch/1619691/ thanks, liubo Thanks! -- 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 -- 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
BTRFS dmesg error
Hi there, I noticed in the dmesg logs that there seems to be a bug/issue with btrfs. Here is the trace/message from dmesg. Im going by the instructions from the https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#How_do_I_report_bugs_and_issues.3F . Let me know if you need anything else. Thanks, Skender Haxhimolla. skender@blackspider:~$ [655330.131113] [ cut here ] [655330.131123] WARNING: at fs/btrfs/super.c:246 __btrfs_abort_transaction+0x46/0xa0() [655330.131125] Hardware name: Precision WorkStation T3400 [655330.131126] btrfs: Transaction aborted [655330.131128] Modules linked in: xt_limit xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack ip6table_filter ip6_tables iptable_filter ip_tables x_tables rfcomm bnep bluetooth dm_crypt dvb_usb_cxusb snd_hda_codec_analog dib7000p dibx000_common dvb_usb snd_hda_intel snd_hda_codec snd_hwdep dvb_core snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event rc_core dib0070 snd_seq coretemp snd_timer snd_seq_device snd kvm_intel soundcore kvm psmouse snd_page_alloc microcode x38_edac lpc_ich dcdbas serio_raw edac_core ppdev parport_pc lp parport floppy firewire_ohci firewire_core crc_itu_t nouveau tg3 ttm drm_kms_helper drm i2c_algo_bit mxm_wmi video wmi [655330.131182] Pid: 5838, comm: btrfs-delalloc- Not tainted 3.6.11-custom #1 [655330.131183] Call Trace: [655330.131190] [810507dc] warn_slowpath_common+0x83/0x9c [655330.131193] [81050898] warn_slowpath_fmt+0x46/0x48 [655330.131197] [81231e0b] ? btrfs_reserve_extent+0xbd/0x1c6 [655330.131200] [812208a7] __btrfs_abort_transaction+0x46/0xa0 [655330.131203] [812468f4] submit_compressed_extents+0x1bd/0x415 [655330.131207] [81246bd2] async_cow_submit+0x86/0x8b [655330.131210] [8125ec27] run_ordered_completions+0x76/0xd5 [655330.131213] [8125f49e] worker_loop+0x183/0x4b9 [655330.131216] [8125f31b] ? btrfs_queue_worker+0x288/0x288 [655330.131220] [8106d9d0] kthread+0x6f/0x77 [655330.131225] [815b59c4] kernel_thread_helper+0x4/0x10 [655330.131228] [8106d961] ? kthread_freezable_should_stop+0x48/0x48 [655330.131231] [815b59c0] ? gs_change+0x13/0x13 [655330.131233] ---[ end trace bc2b68accbd79b9c ]--- -- 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: A couple bugs with btrfs and 3.5.0 kernel
On Sun, Jan 20, 2013 at 5:51 PM, Liu Bo bo.li@oracle.com wrote: On Sun, Jan 20, 2013 at 05:39:57PM -0800, Elladan wrote: Any ideas? I guess I could try to mount in degraded mode or try a 3.6 kernel or something, but this all seems like I should probably just restore from backups and move on. Hi Elladan, For 'bio too big' issue, this patch is helpful, https://patchwork.kernel.org/patch/1619691/ thanks, liubo Hi, After poking around, I determined that the 3.8 kernel is the first one with this patch. I installed it, and re-ran btrfs device delete. The delete ran to completion successfully. However, btrfs fi show still indicated that the deleted device was part of the filesystem. I don't know if that was a bug in my older btrfs binary or not. It mounts fine without the deleted device. Thanks! -- 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