Re: [PATCH 1/2] Btrfs: rescan for qgroups
Hello Jan, On Mon, April 15, 2013 at 07:44 (+0200), Jan Schmidt wrote: Thanks, v2 to come. Uh, but not immediately. I didn't get tracking of exclusive right. That will need some time to fix and test. 'exclusive' adds the complexity of btrfs qgroup. So if you send V2. I'd like you add more lines in changelog. Besides, i have a question in my mind.(I have not seen you code).. When qgroup rescan will happen? 1 when quota is enabled 2 if a new qgroup relations is created, rescan should happen? 2 user call qgroup rescan.. Thanks, Wang -Jan -- 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
[PATCH 00/11 v2] a bunch of miscellaneous bug fixes
v1-v2: Accepts the review comments from David Accepts the review comments from Stefan Rebase changes Adds the 10/11 and 11/11 which was outside this patch-set Anand Jain (11): btrfs-progs: root_item generation_v2 is out of sync after btrfsck btrfs-progs: no pending balance is not an error btrfs-progs: mkfs should first check all disks before writing to a disk btrfs-progs: cmd replace should check target-dev fully btrfs-progs: mkfs stdout print to match chronology btrfs-progs: check if btrfs kernel module is loaded btrfs-progs: delete unused function get_mountpt btrfs-progs: btrfs-select-super output is confusing when it fails btrfs-progs: fix btrfs scrub start help btrfs-progs: avoid ioctl for multipath-dev with its non-multipath path btrfs-progs: a copy of superblock is zero may not mean btrfs is not there btrfs-select-super.c | 6 +- cmds-balance.c | 16 +++- cmds-device.c| 60 ++ cmds-replace.c | 23 +- cmds-scrub.c | 4 +- disk-io.c| 9 ++- mkfs.c | 219 - root-tree.c | 13 +++ utils.c | 225 ++- utils.h | 3 +- 10 files changed, 327 insertions(+), 251 deletions(-) -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: root_item generation_v2 is out of sync after btrfsck
reproducing steps: mkfs.btrfs /dev/dm-2 -f mount /dev/dm-2 /btrfs umount /btrfs btrfs check /dev/dm-2 --repair mount /dev/dm-2 /btrfs btrfs: mismatching generation and generation_v2 found in root item. This root was probably mounted with an older kernel. Resetting all new fields. btrfs-debug-tree shows change in uuid root data bytenr 29425664 level 0 dirid 0 refs 1 gen 43 uuid 293596e8-7888-eb4c-9134-6df9db996fe5 Signed-off-by: Anand Jain anand.j...@oracle.com --- root-tree.c | 13 + 1 file changed, 13 insertions(+) diff --git a/root-tree.c b/root-tree.c index c10d068..4454147 100644 --- a/root-tree.c +++ b/root-tree.c @@ -69,6 +69,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root int ret; int slot; unsigned long ptr; + u32 old_size; path = btrfs_alloc_path(); BUG_ON(!path); @@ -79,6 +80,18 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root l = path-nodes[0]; slot = path-slots[0]; ptr = btrfs_item_ptr_offset(l, slot); + /* + * If the btrfs-progs is newer and kernel is at + * generation_v1 then we don't touch v2 items + * otherwise when kernel is at same or greater + * version compared with btrfs-progs then update + * the needed + */ + old_size = btrfs_item_size_nr(l, slot); + if (old_size = sizeof(*item)) { + btrfs_set_root_generation_v2(item, + btrfs_root_generation(item)); + } write_extent_buffer(l, item, ptr, sizeof(*item)); btrfs_mark_buffer_dirty(path-nodes[0]); out: -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: no pending balance is not an error
Having no balance running/ paused/completed is a normal situation, so the current output message should be positive with return val zero. Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-balance.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmds-balance.c b/cmds-balance.c index f5dc317..a968e0d 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -616,6 +616,12 @@ static const char * const cmd_balance_status_usage[] = { NULL }; +/* Checks the status of the balance if any + * return codes: + * -1 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed + */ static int cmd_balance_status(int argc, char **argv) { struct btrfs_ioctl_balance_args args; @@ -662,9 +668,13 @@ static int cmd_balance_status(int argc, char **argv) close(fd); if (ret 0) { + if (e == ENOTCONN) { + printf(No balance found on '%s'\n, path); + return 0; + } fprintf(stderr, ERROR: balance status on '%s' failed - %s\n, - path, (e == ENOTCONN) ? Not in progress : strerror(e)); - return 19; + path, strerror(e)); + return -1; } if (args.state BTRFS_BALANCE_STATE_RUNNING) { @@ -688,7 +698,7 @@ static int cmd_balance_status(int argc, char **argv) if (verbose) dump_ioctl_balance_args(args); - return 0; + return 1; } const struct cmd_group balance_cmd_group = { -- 1.8.1.227.g44fe835 -- 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 03/11 v2] btrfs-progs: mkfs should first check all disks before writing to a disk
In the cases where one of the disk is not suitable for btrfs, then we would fail the mkfs, however we determine that after we have written btrfs to the preceding disks. At this time if user changes mind for not to use btrfs will left with no choice. So this patch will check if all the provided disks are suitable for the btrfs at once before proceeding to create btrfs on a disk. Further this patch also removed duplicate code to check device suitability for the btrfs. Next, there is an existing bug about the -r mkfs option, which this patch would carry forward most of it. Ref: [PATCH 2/2, RFC] btrfs-progs: overhaul mkfs.btrfs -r option Signed-off-by: Anand Jain anand.j...@oracle.com to merg prev Signed-off-by: Anand Jain anand.j...@oracle.com --- mkfs.c | 192 +++- utils.c | 128 +++ utils.h | 1 + 3 files changed, 161 insertions(+), 160 deletions(-) diff --git a/mkfs.c b/mkfs.c index c8cb395..a58b313 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1261,86 +1261,6 @@ static int is_ssd(const char *file) return !atoi((const char *)rotational); } -/* - * Check for existing filesystem or partition table on device. - * Returns: - * 1 for existing fs or partition - * 0 for nothing found - * -1 for internal error - */ -static int -check_overwrite( - char*device) -{ - const char *type; - blkid_probe pr = NULL; - int ret; - blkid_loff_tsize; - - if (!device || !*device) - return 0; - - ret = -1; /* will reset on success of all setup calls */ - - pr = blkid_new_probe_from_filename(device); - if (!pr) - goto out; - - size = blkid_probe_get_size(pr); - if (size 0) - goto out; - - /* nothing to overwrite on a 0-length device */ - if (size == 0) { - ret = 0; - goto out; - } - - ret = blkid_probe_enable_partitions(pr, 1); - if (ret 0) - goto out; - - ret = blkid_do_fullprobe(pr); - if (ret 0) - goto out; - - /* -* Blkid returns 1 for nothing found and 0 when it finds a signature, -* but we want the exact opposite, so reverse the return value here. -* -* In addition print some useful diagnostics about what actually is -* on the device. -*/ - if (ret) { - ret = 0; - goto out; - } - - if (!blkid_probe_lookup_value(pr, TYPE, type, NULL)) { - fprintf(stderr, - %s appears to contain an existing - filesystem (%s).\n, device, type); - } else if (!blkid_probe_lookup_value(pr, PTTYPE, type, NULL)) { - fprintf(stderr, - %s appears to contain a partition - table (%s).\n, device, type); - } else { - fprintf(stderr, - %s appears to contain something weird - according to blkid\n, device); - } - ret = 1; - -out: - if (pr) - blkid_free_probe(pr); - if (ret == -1) - fprintf(stderr, - probe of %s failed, cannot detect - existing filesystem.\n, device); - return ret; -} - int main(int ac, char **av) { char *file; @@ -1378,6 +1298,9 @@ int main(int ac, char **av) char *pretty_buf; struct btrfs_super_block *super; u64 flags; + int dev_cnt = 0; + int saved_optind; + char estr[100]; while(1) { int c; @@ -1442,51 +1365,38 @@ int main(int ac, char **av) exit(1); if (check_leaf_or_node_size(nodesize, sectorsize)) exit(1); - ac = ac - optind; - if (ac == 0) + saved_optind = optind; + dev_cnt = ac - optind; + if (dev_cnt == 0) print_usage(); - printf(\nWARNING! - %s IS EXPERIMENTAL\n, BTRFS_BUILD_VERSION); - printf(WARNING! - see http://btrfs.wiki.kernel.org before using\n\n); - - if (source_dir == 0) { + if (source_dir_set dev_cnt 1) { + fprintf(stderr, + The -r option is limited to a single device\n); + exit(1); + } + while (dev_cnt-- 0) { file = av[optind++]; - ret = is_swap_device(file); - if (ret 0) { - fprintf(stderr, error checking %s status: %s\n, file, - strerror(-ret)); - exit(1); - } - if (ret == 1) { - fprintf(stderr, %s is a swap device\n, file); - exit(1); - } - if (!force_overwrite) { - if
[PATCH 07/11, RESEND] btrfs-progs: delete unused function get_mountpt
and get_btrfs_mount has replaced it Signed-off-by: Anand Jain anand.j...@oracle.com --- utils.c | 35 --- 1 file changed, 35 deletions(-) diff --git a/utils.c b/utils.c index 67419da..926421c 100644 --- a/utils.c +++ b/utils.c @@ -977,41 +977,6 @@ out_mntloop_err: return ret; } -/* Gets the mount point of btrfs filesystem that is using the specified device. - * Returns 0 is everything is good, 0 if we have an error. - * TODO: Fix this fucntion and check_mounted to work with multiple drive BTRFS - * setups. - */ -int get_mountpt(char *dev, char *mntpt, size_t size) -{ - struct mntent *mnt; - FILE *f; - int ret = 0; - - f = setmntent(/proc/mounts, r); - if (f == NULL) - return -errno; - - while ((mnt = getmntent(f)) != NULL ) - { - if (strcmp(dev, mnt-mnt_fsname) == 0) - { - strncpy(mntpt, mnt-mnt_dir, size); - if (size) -mntpt[size-1] = 0; - break; - } - } - - if (mnt == NULL) - { - /* We didn't find an entry so lets report an error */ - ret = -1; - } - - return ret; -} - struct pending_dir { struct list_head list; char name[PATH_MAX]; -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: fix btrfs scrub start help
a very trivial fix Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-scrub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmds-scrub.c b/cmds-scrub.c index 5922361..c0dc584 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1465,7 +1465,7 @@ out: } static const char * const cmd_scrub_start_usage[] = { - btrfs scrub start Bdqr] [-c ioprio_class -n ioprio_classdata] path|device\n, + btrfs scrub start [-Bdqr] [-c ioprio_class -n ioprio_classdata] path|device, Start a new scrub, , -B do not background, @@ -1526,7 +1526,7 @@ out: } static const char * const cmd_scrub_resume_usage[] = { - btrfs scrub resume [-Bdqr] [-c ioprio_class -n ioprio_classdata] path|device\n, + btrfs scrub resume [-Bdqr] [-c ioprio_class -n ioprio_classdata] path|device, Resume previously canceled or interrupted scrub, , -B do not background, -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: a copy of superblock is zero may not mean btrfs is not there
If one of the copy of the superblock is zero it does not confirm to us that btrfs isn't there on that disk. When we are having more than one copy of superblock we should rather let the for loop to continue to check other copies. the following test case and results would justify the fix mkfs.btrfs /dev/sdb /dev/sdc -f mount /dev/sdb /btrfs dd if=/dev/zero bs=1 count=8 of=/dev/sdc seek=$((64*1024+64)) ~/before/btrfs-select-super -s 1 /dev/sdc using SB copy 1, bytenr 67108864 here btrfs-select-super just wrote superblock to a mounted btrfs with the fix: ./btrfs-select-super -s 1 /dev/sdc /dev/sdc is currently mounted. Aborting. Signed-off-by: Anand Jain anand.j...@oracle.com --- disk-io.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/disk-io.c b/disk-io.c index 589b37a..3f85c21 100644 --- a/disk-io.c +++ b/disk-io.c @@ -1138,9 +1138,12 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr, if (btrfs_super_bytenr(buf) != bytenr ) continue; - /* if magic is NULL, the device was removed */ - if (buf.magic == 0 i == 0) - return -1; + /* if magic is NULL, either the device was removed + * OR user / application inflected the disk albeit + * with the most common zeros. + * so only this doesn't confirm that this disk + * isn't part of btrfs + */ if (buf.magic != cpu_to_le64(BTRFS_MAGIC)) continue; -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: avoid ioctl for multipath-dev with its non-multipath path
We should avoid using non multi-path (mp) path for mp disks As of now there is no good way (like api) to check that. A workaround way is to check if the O_EXCL open is unsuccessful. This is safe since otherwise the BTRFS_IOC_SCAN_DEV ioctl would fail if the disk-path can not be opened with the flag O_EXCL set. Signed-off-by: Anand Jain anand.j...@oracle.com --- utils.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 926421c..158912c 100644 --- a/utils.c +++ b/utils.c @@ -1105,6 +1105,13 @@ again: if (!S_ISBLK(st.st_mode)) { continue; } + + /* Do not test for O_EXCL here since btrfs when + * mounted will open with O_EXCL, and if we don't + * allow btrfs_scan_one_device pass thru + * btrfs fi show will not show the btrfs fs which + * are mounted + */ fd = open(fullpath, O_RDONLY); if (fd 0) { /* ignore the following errors: @@ -1122,10 +1129,18 @@ again: num_devices, BTRFS_SUPER_INFO_OFFSET, 0ull); + close(fd); + if (ret == 0 flags BTRFS_SCAN_REGISTER) { + /* Test if the dev is already opened with O_EXCL flag + * if yes then no need to call ioctl since the + * ioctl will anyway fail. + */ + fd = open(fullpath, O_RDONLY|O_EXCL); + if (fd 0) continue; + close(fd); btrfs_register_one_device(fullpath); } - close(fd); } if (!list_empty(pending_list)) { free(pending); @@ -1444,6 +1459,12 @@ scan_again: continue; } + /* Do not test for O_EXCL here since btrfs when + * mounted will open with O_EXCL, and if we don't + * allow btrfs_scan_one_device pass thru + * btrfs fi show will not show the btrfs fs which + * are mounted + */ fd = open(fullpath, O_RDONLY); if (fd 0) { fprintf(stderr, failed to open %s: %s\n, @@ -1455,6 +1476,13 @@ scan_again: BTRFS_SUPER_INFO_OFFSET, 0ull); if (ret == 0 flags BTRFS_SCAN_REGISTER) { + /* Test if the dev is already opened with O_EXCL flag + * if yes then no need to call ioctl since the + * ioctl will anyway fail. + */ + fd = open(fullpath, O_RDONLY|O_EXCL); + if (fd 0) continue; + close(fd); btrfs_register_one_device(fullpath); } close(fd); -- 1.8.1.227.g44fe835 -- 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/11, v2] btrfs-progs: check if btrfs kernel module is loaded
when we have to report no such file error for /dev/btrfs-control we could confirm if btrfs kernel is present and report it and skip registration where appropriate v1-v2: use /proc/filesystems to check if the btrfs is present Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-device.c | 60 --- mkfs.c| 13 +++-- utils.c | 32 +++ utils.h | 2 +- 4 files changed, 89 insertions(+), 18 deletions(-) diff --git a/cmds-device.c b/cmds-device.c index a90fb67..4a134fa 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -185,9 +185,10 @@ static const char * const cmd_scan_dev_usage[] = { static int cmd_scan_dev(int argc, char **argv) { - int i, fd, e; + int i, fd = -1, e, ret = 0; int checklist = 1; int devstart = 1; + u64 flag_reg = 0ull; if( argc 1 !strcmp(argv[1],--all-devices)){ if (check_argc_max(argc, 2)) @@ -197,33 +198,57 @@ static int cmd_scan_dev(int argc, char **argv) devstart += 1; } + if (is_btrfs_kernel_loaded()) + flag_reg = BTRFS_SCAN_REGISTER; + else + fprintf(stderr, btrfs kernel module is not loaded\n); + if(argc=devstart){ int ret; - printf(Scanning for Btrfs filesystems\n); + printf(Scanning for Btrfs filesystems ); if(checklist) - ret = btrfs_scan_block_devices(BTRFS_SCAN_REGISTER); + ret = btrfs_scan_block_devices(flag_reg); else - ret = btrfs_scan_one_dir(/dev, BTRFS_SCAN_REGISTER); + ret = btrfs_scan_one_dir(/dev, flag_reg); if (ret){ fprintf(stderr, ERROR: error %d while scanning\n, ret); return 18; } + printf(..done\n); return 0; } - fd = open(/dev/btrfs-control, O_RDWR); - if (fd 0) { - perror(failed to open /dev/btrfs-control); - return 10; + if (!flag_reg) + return -1; + + if ((fd = open(/dev/btrfs-control, O_RDWR)) 0) { + fprintf(stderr, ERROR: failed to open \ + /dev/btrfs-control - %s\n, strerror(errno)); + return -1; } + printf(Scanning for Btrfs in\n); for( i = devstart ; i argc ; i++ ){ + int fdt; struct btrfs_ioctl_vol_args args; - int ret; + printf( %s , argv[i]); + fflush(stdout); - printf(Scanning for Btrfs filesystems in '%s'\n, argv[i]); + /* +* If for a multipath (mp) disk user provides the +* non-mp path then open with flag O_EXCL will fail, +* (also ioctl opens with O_EXCL), So test it before +* calling ioctl. +*/ + fdt = open(argv[i], O_RDONLY|O_EXCL); + if (fdt 0) { + perror(ERROR); + ret = -1; + continue; + } + close(fdt); strncpy_null(args.name, argv[i]); /* @@ -235,15 +260,16 @@ static int cmd_scan_dev(int argc, char **argv) e = errno; if( ret 0 ){ - close(fd); - fprintf(stderr, ERROR: unable to scan the device '%s' - %s\n, - argv[i], strerror(e)); - return 11; + fprintf(stderr, ERROR: unable to scan - %s\n, + strerror(e)); + ret = -1; + } else { + printf(found\n); } } close(fd); - return 0; + return ret; } static const char * const cmd_ready_dev_usage[] = { @@ -261,6 +287,10 @@ static int cmd_ready_dev(int argc, char **argv) if (check_argc_min(argc, 2)) usage(cmd_ready_dev_usage); + if (!is_btrfs_kernel_loaded()) { + fprintf(stderr, btrfs kernel module is not loaded\n); + return 10; + } fd = open(/dev/btrfs-control, O_RDWR); if (fd 0) { perror(failed to open /dev/btrfs-control); diff --git a/mkfs.c b/mkfs.c index 2eb3087..e8b22cc 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1301,6 +1301,7 @@ int main(int ac, char **av) int dev_cnt = 0; int saved_optind; char estr[100]; + int flag_reg = 1; while(1) { int c; @@ -1391,6 +1392,12 @@ int main(int ac, char **av) printf(\nWARNING! - %s IS EXPERIMENTAL\n, BTRFS_BUILD_VERSION); printf(WARNING! - see http://btrfs.wiki.kernel.org before
[PATCH 08/11, RESEND] btrfs-progs: btrfs-select-super output is confusing when it fails
Trivial patch: ./btrfs-progs/btrfs-select-super -s 0 /dev/sdc using SB copy 0, bytenr 65536 No valid Btrfs found on /dev/sdc Open ctree failed The line 'using..' is confusing which gives an indication that command is successful This patch will avoid that when command fails Signed-off-by: Anand Jain anand.j...@oracle.com --- btrfs-select-super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/btrfs-select-super.c b/btrfs-select-super.c index 0c4f5c0..6a458b8 100644 --- a/btrfs-select-super.c +++ b/btrfs-select-super.c @@ -43,7 +43,7 @@ int main(int ac, char **av) { struct btrfs_root *root; int ret; - int num; + int num = 0; u64 bytenr = 0; while(1) { @@ -55,8 +55,6 @@ int main(int ac, char **av) case 's': num = atol(optarg); bytenr = btrfs_sb_offset(num); - printf(using SB copy %d, bytenr %llu\n, num, - (unsigned long long)bytenr); break; default: print_usage(); @@ -97,5 +95,7 @@ int main(int ac, char **av) * transaction commit. We just want the super copy we pulled off the * disk to overwrite all the other copies */ + printf(using SB copy %d, bytenr %llu\n, num, + (unsigned long long)bytenr); return ret; } -- 1.8.1.227.g44fe835 -- 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/11 v2] btrfs-progs: cmd replace should check target-dev fully
as of now in replace command target dev is being checked for mounted and for existing fs, however there is newly introduced test_dev_for_mkfs in mkfs.c which is suitable for this job, and further it also checks if dev can be opened for with O_EXCL. Its better to use test_dev_for_mkfs Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-replace.c | 23 --- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/cmds-replace.c b/cmds-replace.c index ab34388..4e881b7 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -137,12 +137,11 @@ static int cmd_start_replace(int argc, char **argv) char *dstdev; int avoid_reading_from_srcdev = 0; int force_using_targetdev = 0; - u64 total_devs = 1; - struct btrfs_fs_devices *fs_devices_mnt = NULL; struct stat st; u64 dstdev_block_count; int do_not_background = 0; int mixed = 0; + char estr[100]; while ((c = getopt(argc, argv, Brf)) != -1) { switch (c) { @@ -263,30 +262,16 @@ static int cmd_start_replace(int argc, char **argv) start_args.start.srcdevid = 0; } - ret = check_mounted(dstdev); - if (ret 0) { - fprintf(stderr, Error checking %s mount status\n, dstdev); - goto leave_with_error; - } - if (ret == 1) { - fprintf(stderr, - Error, target device %s is in use and currently mounted!\n, - dstdev); + if (test_dev_for_mkfs(dstdev, force_using_targetdev, estr)) { + fprintf(stderr, Error: %s, estr); goto leave_with_error; } + fddstdev = open(dstdev, O_RDWR); if (fddstdev 0) { fprintf(stderr, Unable to open %s\n, dstdev); goto leave_with_error; } - ret = btrfs_scan_one_device(fddstdev, dstdev, fs_devices_mnt, - total_devs, BTRFS_SUPER_INFO_OFFSET, 0ull); - if (ret = 0 !force_using_targetdev) { - fprintf(stderr, - Error, target device %s contains filesystem, use '-f' to force overwriting.\n, - dstdev); - goto leave_with_error; - } ret = fstat(fddstdev, st); if (ret) { fprintf(stderr, Error: Unable to stat '%s'\n, dstdev); -- 1.8.1.227.g44fe835 -- 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/11, RESEND] btrfs-progs: mkfs stdout print to match chronology
A trivial fix: To match the events inside to what being printed out before: :: adding device /dev/dm-3 id 2 adding device /dev/dm-4 id 3 adding device /dev/dm-5 id 4 fs created label (null) on /dev/dm-2 nodesize 4096 leafsize 4096 sectorsize 4096 size 213.20GB Btrfs v0.20-rc1-235-gdd21bc1 After: :: fs created label (null) on /dev/dm-2 id 1 nodesize 4096 leafsize 4096 sectorsize 4096 size 59.99GB adding device /dev/dm-3 id 2 adding device /dev/dm-4 id 3 adding device /dev/dm-5 id 4 Btrfs v0.20-rc1-235-gdd21bc1 Signed-off-by: Anand Jain anand.j...@oracle.com --- mkfs.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mkfs.c b/mkfs.c index a58b313..2eb3087 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1472,6 +1472,12 @@ int main(int ac, char **av) exit(1); } + printf(fs created label %s on %s id 1\n\tnodesize %u leafsize %u + sectorsize %u size %s\n, + label, first_file, nodesize, leafsize, sectorsize, + pretty_buf = pretty_sizes(btrfs_super_total_bytes(root-fs_info-super_copy))); + free(pretty_buf); + trans = btrfs_start_transaction(root, 1); if (dev_cnt == 0) @@ -1545,13 +1551,7 @@ raid_groups: printf(Setting RAID5/6 feature flag\n); } - printf(fs created label %s on %s\n\tnodesize %u leafsize %u - sectorsize %u size %s\n, - label, first_file, nodesize, leafsize, sectorsize, - pretty_buf = pretty_sizes(btrfs_super_total_bytes(root-fs_info-super_copy))); - free(pretty_buf); - - printf(%s\n, BTRFS_BUILD_VERSION); + printf(\n%s\n, BTRFS_BUILD_VERSION); btrfs_commit_transaction(trans, root); if (source_dir_set) { -- 1.8.1.227.g44fe835 -- 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 02/11, v2] btrfs-progs: no pending balance is not an error
Oh. this title prefix should be v2 not RESEND. v1-v2 Accepts David review comments Thanks, Anand On 04/15/2013 02:38 PM, Anand Jain wrote: Having no balance running/ paused/completed is a normal situation, so the current output message should be positive with return val zero. Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-balance.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmds-balance.c b/cmds-balance.c index f5dc317..a968e0d 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -616,6 +616,12 @@ static const char * const cmd_balance_status_usage[] = { NULL }; +/* Checks the status of the balance if any + * return codes: + * -1 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed + */ static int cmd_balance_status(int argc, char **argv) { struct btrfs_ioctl_balance_args args; @@ -662,9 +668,13 @@ static int cmd_balance_status(int argc, char **argv) close(fd); if (ret 0) { + if (e == ENOTCONN) { + printf(No balance found on '%s'\n, path); + return 0; + } fprintf(stderr, ERROR: balance status on '%s' failed - %s\n, - path, (e == ENOTCONN) ? Not in progress : strerror(e)); - return 19; + path, strerror(e)); + return -1; } if (args.state BTRFS_BALANCE_STATE_RUNNING) { @@ -688,7 +698,7 @@ static int cmd_balance_status(int argc, char **argv) if (verbose) dump_ioctl_balance_args(args); - return 0; + return 1; } const struct cmd_group balance_cmd_group = { -- 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 3/9] btrfs-progs: mkfs should first check all disks before writing to a disk
On 04/13/2013 12:06 AM, David Sterba wrote: On Fri, Apr 05, 2013 at 01:54:57PM +0800, Anand Jain wrote: In the cases where one of the disk is not suitable for btrfs, then we would fail the mkfs, however we determine that after we have written btrfs to the preceding disks. At this time if user changes mind for not to use btrfs will left with no choice. So this patch will check if all the provided disks are suitable for the btrfs at once before proceeding to create btrfs on a disk. Good fix and cleanup. +void __test_dev_for_mkfs(char *file, int force_overwrite) +{ + int ret, fd; + + ret = is_swap_device(file); + if (ret 0) { + fprintf(stderr, error checking %s status: %s\n, file, + strerror(-ret)); + exit(1); The exit()s were ok when this code was in main(), but should be converted to return for a helper function. I got this integrated in v2. + } int main(int ac, char **av) { char *file; @@ -1378,6 +1418,8 @@ int main(int ac, char **av) char *pretty_buf; struct btrfs_super_block *super; u64 flags; + int dev_cnt=0; int dev_cnt = 0; + int saved_optind; while(1) { int c; + dev_cnt = ac - optind; + if (dev_cnt == 0) print_usage(); + if (source_dir_set dev_cnt 1) { + fprintf(stderr, + The -r option is limited to a single device\n); + exit(1); + } + while (dev_cnt-- 0) { + file = av[optind++]; + /* following func would exit on error */ + if (is_block_device(file)) + __test_dev_for_mkfs(file, force_overwrite); Catch errors here and exit() eventually. + } + -- 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
Re: [PATCH 1/2] Btrfs: rescan for qgroups
On Mon, April 15, 2013 at 08:08 (+0200), Wang Shilong wrote: Hello Jan, On Mon, April 15, 2013 at 07:44 (+0200), Jan Schmidt wrote: Thanks, v2 to come. Uh, but not immediately. I didn't get tracking of exclusive right. That will need some time to fix and test. 'exclusive' adds the complexity of btrfs qgroup. So if you send V2. I'd like you add more lines in changelog. Yes, the commit message will be longer as you requested previously. This does not include a complete description on how exclusive works. The qgroup pdf explains that. Besides, i have a question in my mind.(I have not seen you code).. When qgroup rescan will happen? 1 when quota is enabled That's what the second patch does, yes. Your patches should be merged in a way that we first create the level 0 qgroups for all subvolumes and then start the rescan, obviously. 2 if a new qgroup relations is created, rescan should happen? With your patches, there will be no subvolume qgroups missing. For the higher level groups, one needs expert knowledge anyway. I think it's best to leave that decision to the administrator configuring those qgroups. 2 user call qgroup rescan.. Of course, yes. -Jan -- 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/11 v3] btrfs-progs: check if btrfs kernel module is loaded
when we have to report no such file error for /dev/btrfs-control we could confirm if btrfs kernel is present and report it and skip registration where appropriate v2-v3: accept review comments from David v1-v2: use /proc/filesystems to check if the btrfs is present Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-device.c | 62 --- mkfs.c| 13 +++-- utils.c | 34 utils.h | 2 +- 4 files changed, 92 insertions(+), 19 deletions(-) diff --git a/cmds-device.c b/cmds-device.c index a90fb67..f5dce8d 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -185,9 +185,10 @@ static const char * const cmd_scan_dev_usage[] = { static int cmd_scan_dev(int argc, char **argv) { - int i, fd, e; + int i, fd = -1, e, ret = 0; int checklist = 1; int devstart = 1; + u64 flag_reg = 0ull; if( argc 1 !strcmp(argv[1],--all-devices)){ if (check_argc_max(argc, 2)) @@ -197,33 +198,57 @@ static int cmd_scan_dev(int argc, char **argv) devstart += 1; } + if (is_btrfs_kernel_loaded()) + flag_reg = BTRFS_SCAN_REGISTER; + else + fprintf(stderr, btrfs kernel module is not loaded\n); + if(argc=devstart){ int ret; - printf(Scanning for Btrfs filesystems\n); + printf(Scanning for Btrfs filesystems ); if(checklist) - ret = btrfs_scan_block_devices(BTRFS_SCAN_REGISTER); + ret = btrfs_scan_block_devices(flag_reg); else - ret = btrfs_scan_one_dir(/dev, BTRFS_SCAN_REGISTER); + ret = btrfs_scan_one_dir(/dev, flag_reg); if (ret){ fprintf(stderr, ERROR: error %d while scanning\n, ret); return 18; } + printf(..done\n); return 0; } - fd = open(/dev/btrfs-control, O_RDWR); - if (fd 0) { - perror(failed to open /dev/btrfs-control); - return 10; + if (!flag_reg) + return -1; + + if ((fd = open(/dev/btrfs-control, O_RDWR)) 0) { + fprintf(stderr, ERROR: failed to open \ + /dev/btrfs-control - %s\n, strerror(errno)); + return -1; } + printf(Scanning for Btrfs filesystem in\n); for( i = devstart ; i argc ; i++ ){ + int fdt; struct btrfs_ioctl_vol_args args; - int ret; + printf( %s , argv[i]); + fflush(stdout); - printf(Scanning for Btrfs filesystems in '%s'\n, argv[i]); + /* +* If for a multipath (mp) disk user provides the +* non-mp path then open with flag O_EXCL will fail, +* (also ioctl opens with O_EXCL), So test it before +* calling ioctl. +*/ + fdt = open(argv[i], O_RDONLY|O_EXCL); + if (fdt 0) { + perror(ERROR); + ret = -1; + continue; + } + close(fdt); strncpy_null(args.name, argv[i]); /* @@ -235,15 +260,16 @@ static int cmd_scan_dev(int argc, char **argv) e = errno; if( ret 0 ){ - close(fd); - fprintf(stderr, ERROR: unable to scan the device '%s' - %s\n, - argv[i], strerror(e)); - return 11; + fprintf(stderr, ERROR: unable to scan - %s\n, + strerror(e)); + ret = -1; + } else { + printf(found\n); } } close(fd); - return 0; + return ret; } static const char * const cmd_ready_dev_usage[] = { @@ -261,10 +287,14 @@ static int cmd_ready_dev(int argc, char **argv) if (check_argc_min(argc, 2)) usage(cmd_ready_dev_usage); + if (!is_btrfs_kernel_loaded()) { + fprintf(stderr, Error: btrfs kernel module is not loaded\n); + return -1; + } fd = open(/dev/btrfs-control, O_RDWR); if (fd 0) { perror(failed to open /dev/btrfs-control); - return 10; + return -1; } strncpy(args.name, argv[argc - 1], BTRFS_PATH_NAME_MAX); diff --git a/mkfs.c b/mkfs.c index 2eb3087..e8b22cc 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1301,6 +1301,7 @@ int main(int ac, char **av) int dev_cnt = 0; int saved_optind; char estr[100]; + int flag_reg = 1; while(1) { int c;
Re: [PATCH 1/2] Btrfs: rescan for qgroups
Hello Jan, On Mon, April 15, 2013 at 08:08 (+0200), Wang Shilong wrote: Hello Jan, On Mon, April 15, 2013 at 07:44 (+0200), Jan Schmidt wrote: Thanks, v2 to come. Uh, but not immediately. I didn't get tracking of exclusive right. That will need some time to fix and test. 'exclusive' adds the complexity of btrfs qgroup. So if you send V2. I'd like you add more lines in changelog. Yes, the commit message will be longer as you requested previously. This does not include a complete description on how exclusive works. The qgroup pdf explains that. Yeah, changelog really helps for newbies(like me ^_^) Besides, i have a question in my mind.(I have not seen you code).. When qgroup rescan will happen? 1 when quota is enabled That's what the second patch does, yes. Your patches should be merged in a way that we first create the level 0 qgroups for all subvolumes and then start the rescan, obviously. 2 if a new qgroup relations is created, rescan should happen? With your patches, there will be no subvolume qgroups missing. For the higher level groups, one needs expert knowledge anyway. I think it's best to leave that decision to the administrator configuring those qgroups. IMO, it is better that qgroup rescan automatically if a qgroup relation is added. Thank, Wang 2 user call qgroup rescan.. Of course, yes. -Jan -- 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
[PATCH] Btrfs: do not continue if out of memory happens
If out of memory happens, we should return -ENOMEM directly to the caller rather than continue the work. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com --- fs/btrfs/backref.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index bd605c8..2fd5703 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -352,6 +352,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, err = __resolve_indirect_ref(fs_info, search_commit_root, time_seq, ref, parents, extent_item_pos); + if (err == -ENOMEM) + goto out; if (err) continue; @@ -367,7 +369,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, new_ref = kmalloc(sizeof(*new_ref), GFP_NOFS); if (!new_ref) { ret = -ENOMEM; - break; + goto out; } memcpy(new_ref, ref, sizeof(*ref)); new_ref-parent = node-val; @@ -377,7 +379,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, } ulist_reinit(parents); } - +out: ulist_free(parents); return ret; } -- 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
Re: [PATCH RFC] Btrfs: fix confusing edquot happening case
On 15.04.2013 12:37, Wang Shilong wrote: Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or referenced is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com --- This confusing edquot may also happen after Jan's qgroup rescan has been implemented. --- fs/btrfs/qgroup.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..0178223 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) - qg-reserved + qg-rfer + num_bytes + qg-reserved + (signed long long)qg-rfer + num_bytes why not use s64 instead of signed long long? Otherwise this is the right way to solve this. Thanks, Arne qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) - qg-reserved + qg-excl + num_bytes + qg-reserved + (signed long long)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 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 RFC] Btrfs: fix confusing edquot happening case
Hello Arne, On 15.04.2013 12:37, Wang Shilong wrote: Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or referenced is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com --- This confusing edquot may also happen after Jan's qgroup rescan has been implemented. --- fs/btrfs/qgroup.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..0178223 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) -qg-reserved + qg-rfer + num_bytes +qg-reserved + (signed long long)qg-rfer + num_bytes why not use s64 instead of signed long long? Otherwise this is the right way to solve this. Yeah,V2 is coming. By the way, do you mind that i add Acked-by: Arne Jasen sensi...@gmx.net? Thanks, Wang Thanks, Arne qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) -qg-reserved + qg-excl + num_bytes +qg-reserved + (signed long long)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 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
Re: [PATCH RFC] Btrfs: fix confusing edquot happening case
On 15.04.2013 13:43, Wang Shilong wrote: Hello Arne, On 15.04.2013 12:37, Wang Shilong wrote: Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or referenced is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com --- This confusing edquot may also happen after Jan's qgroup rescan has been implemented. --- fs/btrfs/qgroup.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..0178223 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) - qg-reserved + qg-rfer + num_bytes + qg-reserved + (signed long long)qg-rfer + num_bytes why not use s64 instead of signed long long? Otherwise this is the right way to solve this. Yeah,V2 is coming. By the way, do you mind that i add Acked-by: Arne Jasen sensi...@gmx.net? You can add a Reviewed-by: Arne Jansen sensi...@gmx.net Thanks, Arne Thanks, Wang Thanks, Arne qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) - qg-reserved + qg-excl + num_bytes + qg-reserved + (signed long long)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 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 -- 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-progs: add a free space cache checker to fsck V2
On Thu, 4 Apr 2013 09:57:50 -0400, Josef Bacik wrote: In trying to track down a weird tree log problem I wanted to make sure that the free space cache was actually valid, which we currently have no way of doing. So this patch adds a bunch of support for the free space cache code and then a checker to fsck. Basically we go through and if we can actually load the free space cache then we will walk the extent tree and verify that the free space cache exactly matches what is in the extent tree. Hopefully this will always be correct, the only time it wouldn't is if the extent tree is corrupt or we have some sort of awful bug in the free space cache. Thanks, Signed-off-by: Josef Bacik jba...@fusionio.com --- V1-V2: - fix ret == 1 from btrfs_search_slot leaking out of verify_space_cache - check the last bit of free space from the last extent to the end of the block group - unlink any entries we find so we can check and make sure the free space cache tree is empty once we're done. Josef, xfstests 013, 068 and 113 fail with your new fsck free space cache checker, see below. $TEST_DEV /dev/sdc is a 50GB SSD, $SCRATCH_DEV /dev/sds is a 100GB SSD. Default mount options. # mkfs.btrfs -f -n 16384 $SCRATCH_DEV # mkfs.btrfs -f -n 16384 $TEST_DEV # ./check 013 # btrfsck $TEST_DEV Checking filesystem on /dev/sdc UUID: 1c91dbb9-2495-4324-bb53-f96e15cff0dc checking extents checking free space cache Wanted bytes 606208, found 16384 for off 191184896 Wanted bytes 911917056, found 16384 for off 191184896 cache appears valid but isnt 29360128 btrfs: unable to add free space :-17 btrfsck: free-space-cache.c:815: btrfs_add_free_space: Assertion `!(ret == -17)' failed. Aborted # mkfs.btrfs -f -n 16384 $SCRATCH_DEV # mkfs.btrfs -f -n 16384 $TEST_DEV # ./check 013 # btrfsck $TEST_DEV Checking filesystem on /dev/sdc UUID: 18046b2a-9c98-4b34-9294-954d094049c2 checking extents checking free space cache Wanted bytes 16203776, found 9355264 for off 168624128 Wanted bytes 934477824, found 9355264 for off 168624128 cache appears valid but isnt 29360128 There is no free space entry for 1115480064-1115504640 There is no free space entry for 1115480064-2176843776 cache appears valid but isnt 1103101952 found 380784640 bytes used err is -22 total csum bytes: 87084 total tree bytes: 4833280 total fs tree bytes: 4390912 total extent tree bytes: 245760 btree space waste bytes: 952741 file data blocks allocated: 500023296 referenced 363667456 Btrfs v0.20-rc1-298-gf65141e # mkfs.btrfs -f -n 16384 $SCRATCH_DEV # mkfs.btrfs -f -n 16384 $TEST_DEV # ./check 068 _check_btrfs_filesystem: filesystem on /dev/sds is inconsistent *** fsck.btrfs output *** checking extents checking free space cache Wanted bytes 490909696, found 536870912 for off 1103101952 Wanted bytes 1073741824, found 536870912 for off 1103101952 cache appears valid but isnt 1103101952 Checking filesystem on /dev/sds UUID: d5340e2c-d1e5-4155-afc2-70afb6bbbe85 found 638976 bytes used err is -22 total csum bytes: 0 total tree bytes: 114688 total fs tree bytes: 32768 total extent tree bytes: 16384 btree space waste bytes: 107558 file data blocks allocated: 524288 referenced 524288 Btrfs v0.20-rc1-298-gf65141e *** end fsck.btrfs output # mkfs.btrfs -f -n 16384 $SCRATCH_DEV # mkfs.btrfs -f -n 16384 $TEST_DEV # ./check 113 _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent *** fsck.btrfs output *** checking extents checking free space cache btrfs: unable to add free space :-17 btrfsck: free-space-cache.c:815: btrfs_add_free_space: Assertion `!(ret == -17)' failed. Checking filesystem on /dev/sdc UUID: 9fef532c-2cf2-4bad-8b00-aa997403b415 *** end fsck.btrfs output -- 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] Btrfs: fix confusing edquot happening case
From: Wang Shilong wangsl-f...@fujitsu.com Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or exclusive is negative,but user can not continue to write data! a workaround way is to cast u64 to s64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Reviewed-by: Arne Jansen sensi...@gmx.net --- Changelog v1-v2: -use s64 instead of signed long long --- fs/btrfs/qgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..ab364a2 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) - qg-reserved + qg-rfer + num_bytes + qg-reserved + (s64)qg-rfer + num_bytes qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) - qg-reserved + qg-excl + num_bytes + qg-reserved + (s64)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 1.7.11.7 -- 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 V2] Btrfs: fix confusing edquot happening case
I am sorry, please ignore this…I will resend it.. From: Wang Shilong wangsl-f...@fujitsu.com Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or exclusive is negative,but user can not continue to write data! a workaround way is to cast u64 to s64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Reviewed-by: Arne Jansen sensi...@gmx.net --- Changelog v1-v2: -use s64 instead of signed long long --- fs/btrfs/qgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..ab364a2 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) - qg-reserved + qg-rfer + num_bytes + qg-reserved + (s64)qg-rfer + num_bytes qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) - qg-reserved + qg-excl + num_bytes + qg-reserved + (s64)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 1.7.11.7 -- 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 RESEND] Btrfs: fix confusing edquot happening case
From: Wang Shilong wangsl-f...@cn.fujitsu.com Step to reproduce: mkfs.btrfs disk mount disk mnt dd if=/dev/zero of=/mnt/data bs=1M count=10 sync btrfs quota enable mnt btrfs qgroup create 0/5 mnt btrfs qgroup limit 5M 0/5 mnt rm -f /mnt/data sync btrfs qgroup show mnt dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or exclusive is negative,but user can not continue to write data! a workaround way is to cast u64 to s64 when doing qgroup reservation. Signed-off-by: Wang Shilong wangsl-f...@cn.fujitsu.com Reviewed-by: Arne Jansen sensi...@gmx.net --- Changelog v1-v2: -use s64 instead of signed long long --- fs/btrfs/qgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..ab364a2 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode-aux; if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_RFER) - qg-reserved + qg-rfer + num_bytes + qg-reserved + (s64)qg-rfer + num_bytes qg-max_rfer) { ret = -EDQUOT; goto out; } if ((qg-lim_flags BTRFS_QGROUP_LIMIT_MAX_EXCL) - qg-reserved + qg-excl + num_bytes + qg-reserved + (s64)qg-excl + num_bytes qg-max_excl) { ret = -EDQUOT; goto out; -- 1.7.11.7 -- 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
How to rescue my data from raid1 metadata with raid0 data ?
Hi all, When I created my btrfs filesystem, I use the command: mkfs.btrfs -m raid1 -d raid0 /dev/sda5 /dev/sdb5 # btrfs fi df /srv/raid0/ Data, RAID0: total=1.92TB, used=1.46TB System, RAID1: total=32.00MB, used=164.00KB System: total=4.00MB, used=0.00 Metadata, RAID1: total=39.26GB, used=8.84GB Today, my first disk broken, I want to copy all integrated files to /dev/sdb5 which not have data on /dev/sda5, then remove /dev/sda5 from this btrfs file system, is it possible ? # btrfs fi show Label: 'dre log files' uuid: d14f42ca-8784-463e-b85a-b94a5b9f70a2 Total devices 2 FS bytes used 1.46TB devid1 size 1.00TB used 1.00TB path /dev/sdb5 *** Some devices missing With the latest btrfs-progs v0.20-rc1 and kernel 3.7.5, I try to delete the missing device, but failed: # ./btrfs device delete missing /srv/raid0 ERROR: error removing the device 'missing' - Invalid argument [6191459.658962] btrfs: bdev /dev/sda5 errs: wr 96543, rd 1, flush 0, corrupt 0, gen 0 [6191459.665981] btrfs: bdev /dev/sda5 errs: wr 96544, rd 1, flush 0, corrupt 0, gen 0 [6191459.668319] btrfs: bdev /dev/sda5 errs: wr 96545, rd 1, flush 0, corrupt 0, gen 0 [6191459.682605] btrfs: bdev /dev/sda5 errs: wr 96546, rd 1, flush 0, corrupt 0, gen 0 [6191459.684672] btrfs: bdev /dev/sda5 errs: wr 96547, rd 1, flush 0, corrupt 0, gen 0 [6191459.699748] btrfs: bdev /dev/sda5 errs: wr 96548, rd 1, flush 0, corrupt 0, gen 0 [6191459.702150] btrfs: bdev /dev/sda5 errs: wr 96549, rd 1, flush 0, corrupt 0, gen 0 [6191459.704791] btrfs: bdev /dev/sda5 errs: wr 96550, rd 1, flush 0, corrupt 0, gen 0 [6191459.707257] btrfs: bdev /dev/sda5 errs: wr 96551, rd 1, flush 0, corrupt 0, gen 0 [6191459.749754] lost page write due to I/O error on /dev/sda5 [6191459.749763] btrfs: bdev /dev/sda5 errs: wr 96552, rd 1, flush 0, corrupt 0, gen 0 [6191459.751572] lost page write due to I/O error on /dev/sda5 [6191459.751585] lost page write due to I/O error on /dev/sda5 [6191468.705857] btrfs: unable to go below two devices on raid1 Thanks, Dongsheng -- 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: No-op when called as fsck.btrfsck
Hi, I thought that I would attempt a quick little patch that will make btrfsck into a No-op when called as fsck.btrfsck. The reasoning is that the FAQ states that it is recommended and safe to do so, and the current 12.04 version of Ubuntu just symlinks fsck.btrfsck to btrfsck instead of /bin/true. PS - Apologies if I mess this git send-email up! Dan McGrath (1): btrfs-progs: No-op when called as fsck.btrfsck btrfs.c |2 ++ 1 file changed, 2 insertions(+) -- 1.7.9.5 -- 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: No-op when called as fsck.btrfsck
As per FAQ: It is safe to and recommended to turn fsck.btrfs into a no-op Signed-off-by: Dan McGrath danmcgrath...@gmail.com --- btrfs.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs.c b/btrfs.c index 691adef..78161a9 100644 --- a/btrfs.c +++ b/btrfs.c @@ -272,6 +272,8 @@ int main(int argc, char **argv) if (!strcmp(bname, btrfsck)) { argv[0] = check; + } else if (!strcmp(bname, fsck.btrfsck)) { + exit(0); } else { argc--; argv++; -- 1.7.9.5 -- 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-progs: No-op when called as fsck.btrfsck
On Mon, Apr 15, 2013 at 3:47 PM, Dan McGrath danmcgrath...@gmail.com wrote: As per FAQ: It is safe to and recommended to turn fsck.btrfs into a no-op Signed-off-by: Dan McGrath danmcgrath...@gmail.com --- btrfs.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs.c b/btrfs.c index 691adef..78161a9 100644 --- a/btrfs.c +++ b/btrfs.c @@ -272,6 +272,8 @@ int main(int argc, char **argv) if (!strcmp(bname, btrfsck)) { argv[0] = check; + } else if (!strcmp(bname, fsck.btrfsck)) { + exit(0); } else { argc--; argv++; -- 1.7.9.5 -- 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 Shouldn't it be fsck.btrfs, not fsck.btrfsck? Also, fsck.xfs does a bit more than just an exit(0), maybe there's some merit to what it does. It's a simple shellscript, so check it out. -- 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-progs: No-op when called as fsck.btrfsck
My sincere apologies. It would appear that I was overly careful about checking the binary functioned when called as a symlink, but not the correct filename: # ls -l `which fsck.btrfs` lrwxrwxrwx 1 root root 7 Aug 25 2011 /sbin/fsck.btrfs - btrfsck So yes, the patch incorrectly assumed a symlink name of 'fsck.btrfsck', instead of 'fsck.btrfs'. As for fsck.xfs, I will take a look, thanks! On Mon, Apr 15, 2013 at 10:03 AM, Jan Alexander Steffens jan.steff...@gmail.com wrote: On Mon, Apr 15, 2013 at 3:47 PM, Dan McGrath danmcgrath...@gmail.com wrote: As per FAQ: It is safe to and recommended to turn fsck.btrfs into a no-op Signed-off-by: Dan McGrath danmcgrath...@gmail.com --- btrfs.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs.c b/btrfs.c index 691adef..78161a9 100644 --- a/btrfs.c +++ b/btrfs.c @@ -272,6 +272,8 @@ int main(int argc, char **argv) if (!strcmp(bname, btrfsck)) { argv[0] = check; + } else if (!strcmp(bname, fsck.btrfsck)) { + exit(0); } else { argc--; argv++; -- 1.7.9.5 -- 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 Shouldn't it be fsck.btrfs, not fsck.btrfsck? Also, fsck.xfs does a bit more than just an exit(0), maybe there's some merit to what it does. It's a simple shellscript, so check it out. -- 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 v2] Btrfs: allow file data clone within a file
On Mon, Apr 15, 2013 at 10:55:45AM +0800, Liu Bo wrote: @@ -2563,6 +2568,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, !IS_ALIGNED(destoff, bs)) goto out_unlock; + /* verify if ranges are overlapped within the same file */ + if (same_inode) { + if (destoff + len off destoff off + len) + goto out_unlock; Although I find the condition hard to read, it's correct. Reviewed-by: David Sterba dste...@suse.cz -- 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 02/11, RESEND] btrfs-progs: no pending balance is not an error
On Mon, Apr 15, 2013 at 02:38:08PM +0800, Anand Jain wrote: +/* Checks the status of the balance if any + * return codes: + * -1 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed The error code will become the return code of the 'btrfs balance status' command in the end: btrfs.c:main() 295 exit(cmd-fn(argc, argv)); and that's why I've suggested to return 1 or 2, though -1 matches shell error code 255 but I'd rathe avoid using it. david -- 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-progs: No-op when called as fsck.btrfsck
On 4/15/13 9:03 AM, Jan Alexander Steffens wrote: On Mon, Apr 15, 2013 at 3:47 PM, Dan McGrath danmcgrath...@gmail.com wrote: As per FAQ: It is safe to and recommended to turn fsck.btrfs into a no-op Signed-off-by: Dan McGrath danmcgrath...@gmail.com --- btrfs.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs.c b/btrfs.c index 691adef..78161a9 100644 --- a/btrfs.c +++ b/btrfs.c @@ -272,6 +272,8 @@ int main(int argc, char **argv) if (!strcmp(bname, btrfsck)) { argv[0] = check; + } else if (!strcmp(bname, fsck.btrfsck)) { + exit(0); } else { argc--; argv++; -- 1.7.9.5 -- 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 Shouldn't it be fsck.btrfs, not fsck.btrfsck? Also, fsck.xfs does a bit more than just an exit(0), maybe there's some merit to what it does. It's a simple shellscript, so check it out. Yup I think the idea for xfs was that if called by initscripts w/ common initscript options, be nice and quiet, but if it looks like it was invoked by someone expecting something to happen, be more informative. Git blame of the shell script is at http://oss.sgi.com/cgi-bin/gitweb.cgi?p=xfs/cmds/xfsprogs.git;a=blame;f=fsck/xfs_fsck.sh;h=c5a96e688b994c36d9ab1b0206225f2f5e7b12e8;hb=HEAD - it hasn't changed in forever but you might get some hints at why it does what it does. Expecting fsck.$FS in initscripts is just a leftover from pre-journaling-fs days, I think. -Eric -- 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-progs: No-op when called as fsck.btrfsck
Jan, I got a chance to sit down and dig a little bit deeper into `fsck.xfs`. Here is what I discovered. The (a|A|y|p) options in the XFS script appear to be nothing more than the expected `fsck` options that imply automated checks (as is clearly implied by the use of AUTO). While I have yet to specifically test the capitalized A, my guess is that it matches the -A options from fsck(8) for when the system is going through the fstab. The syntax itself appears to assume that the dev name is the last param (as indicated by the argc/$#, which gets eval'd into the DEV variable). After doing some tests with a hacked up version of the `fsck.xfs` script, it would appear that the generic `fsck` script calls each script in order and passes it some parameters to test, since if I pass `fsck` some random/btrfsck switches: # fsck --repair /dev/storage/lv_btrfs I get an error back from `fsck.ext4`: fsck from util-linux 2.20.1 fsck.ext4: invalid option -- 'e' Since the man page for fsck(8) hints that there are no real standards for calling conventions, but most support (a|n|r|y), and as how unknown options cause an error with fsck (thanks to ext4), perhaps it would be a good idea for btrfsck to align itself with the standard options for fsck (a/n/r/y/A)? If anything, the A option (for fstab based) would appear to be the real target of a noop style exit(0) that I had originally tested. Also, thanks for the link Eric, just came in as I am typing this reply :) Anyways, thought I would reply back with some insight on the matter and see what others had to say, since I am in no position to dictate the direction that brtfsck/fsck.btrfs should take as far as wrapper script or no is concerned. Look forward to your replies! o/ Dan On Mon, Apr 15, 2013 at 10:03 AM, Jan Alexander Steffens jan.steff...@gmail.com wrote: On Mon, Apr 15, 2013 at 3:47 PM, Dan McGrath danmcgrath...@gmail.com wrote: As per FAQ: It is safe to and recommended to turn fsck.btrfs into a no-op Signed-off-by: Dan McGrath danmcgrath...@gmail.com --- btrfs.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/btrfs.c b/btrfs.c index 691adef..78161a9 100644 --- a/btrfs.c +++ b/btrfs.c @@ -272,6 +272,8 @@ int main(int argc, char **argv) if (!strcmp(bname, btrfsck)) { argv[0] = check; + } else if (!strcmp(bname, fsck.btrfsck)) { + exit(0); } else { argc--; argv++; -- 1.7.9.5 -- 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 Shouldn't it be fsck.btrfs, not fsck.btrfsck? Also, fsck.xfs does a bit more than just an exit(0), maybe there's some merit to what it does. It's a simple shellscript, so check it out. -- 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: introduce noextiref mount option
On Fri, Apr 12, 2013 at 12:01:19PM -0500, Eric Sandeen wrote: On 4/11/13 5:35 AM, Miao Xie wrote: Now, we set incompat flag EXTEND_IREF when we actually need insert a extend inode reference, not when making a fs. But some users may hope that the fs still can be mounted on the old kernel, and don't hope we insert any extend inode references. So we introduce noextiref mount option to close this function. I'd really rather not have yet another work-around mount option. Wouldn't it be better to say: if you don't want extended irefs, turn that feature off on the filesystem itself, either at mkfs time or via btrfstune after the fact. So rather than opportunistically turning it on, and then adding another patch to disable that behavior with a mount option, why not just teach btrfstune to turn off the flag, if it's not desired by the admin? It'd save a mount option, and 50 or so lines of new kernel code, and make things simpler overall, IMHO. I don't like this so much either - in particular I don't like the fs to silently turn on incompat flags based on some heuristic or random number that the user won't likely know (in this case, the number of bytes that would fit in a standard btrfs hard link). Tunefs can already turn the flag on, I don't see why we don't add the reverse functionality. Also making it optional on mkfs time is easy enough... --Mark -- Mark Fasheh -- 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-progs: No-op when called as fsck.btrfsck
On 4/15/13 11:45 AM, Dan McGrath wrote: Jan, I got a chance to sit down and dig a little bit deeper into `fsck.xfs`. Here is what I discovered. The (a|A|y|p) options in the XFS script appear to be nothing more than the expected `fsck` options that imply automated checks (as is clearly implied by the use of AUTO). While I have yet to specifically test the capitalized A, my guess is that it matches the -A options from fsck(8) for when the system is going through the fstab. The syntax itself appears to assume that the dev name is the last param (as indicated by the argc/$#, which gets eval'd into the DEV variable). After doing some tests with a hacked up version of the `fsck.xfs` script, it would appear that the generic `fsck` script calls each script in order and passes it some parameters to test, since if I pass `fsck` some random/btrfsck switches: # fsck --repair /dev/storage/lv_btrfs I get an error back from `fsck.ext4`: fsck from util-linux 2.20.1 fsck.ext4: invalid option -- 'e' 2 things; from the fsck manpage: fsck [-sAVRTMNP] [-C [fd]] [-t fstype] [filesys...] [--] [fs-specific-options] so I think you need: fsck -- --repair /dev/storage/lv_btrfs But the other issues seems to be that fsck blkid are autodetecting the device as ext4, not btrfs; a separate issue. -Eric -- 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: introduce noextiref mount option
On Fri, Apr 12, 2013 at 12:01:19PM -0500, Eric Sandeen wrote: On 4/11/13 5:35 AM, Miao Xie wrote: Now, we set incompat flag EXTEND_IREF when we actually need insert a extend inode reference, not when making a fs. But some users may hope that the fs still can be mounted on the old kernel, and don't hope we insert any extend inode references. So we introduce noextiref mount option to close this function. I'd really rather not have yet another work-around mount option. Wouldn't it be better to say: if you don't want extended irefs, turn that feature off on the filesystem itself, either at mkfs time or via btrfstune after the fact. I agree with this, and hope the inconsistency around extref is only temporary so the mount options is not required in the long term. The code reverting extref set by default in mkfs is in integration branch. The preferred solution is the -O option where we can put all the fs features in one go at mkfs time. david -- 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-progs: No-op when called as fsck.btrfsck
Jan, It would appear that: # fsck -- --repair /dev/storage/lv_btrfs doesn't work, but if I put the fs-specific-options at the end: # fsck /dev/storage/lv_btrfs -- --repair it works fine. As we were/are discussing on irc, I also have no idea where the ext4 lines come from. *scratcheshead* And to save you guys some testing, here is the script I used and some sample output: fsck.btrfs: #!/bin/sh -f # fsck exit codes for convenience # 0- No errors # 1- Filesystem errors corrected # 2- System should be rebooted # 4- Filesystem errors left uncorrected # 8- Operational error # 16 - Usage or syntax error # 32 - Fsck canceled by user request # 128 - Shared-library error AUTO=false while getopts :aApy c do case $c in a|A|p|y)AUTO=true; echo DEBUG: $c;; esac done eval DEV=\${$#} if [ ! -e $DEV ]; then echo $0: $DEV does not exist exit 8 fi if $AUTO; then echo $0: BTRFS file system. else echo If you wish to check the consistency of an BTRFS filesystem or echo repair a damaged filesystem, see btrfsck(8). fi exit 0 Output: == # fsck /dev/storage/lv_btrfs -- --repair fsck from util-linux 2.20.1 DEBUG: p DEBUG: a /sbin/fsck.btrfs: BTRFS file system. # fsck /dev/storage/lv_btrfs fsck from util-linux 2.20.1 If you wish to check the consistency of an BTRFS filesystem or repair a damaged filesystem, see btrfsck(8). Note the p and a switches when called with custom fs switches, but not when called standalone. On Mon, Apr 15, 2013 at 1:01 PM, Eric Sandeen sand...@redhat.com wrote: On 4/15/13 11:45 AM, Dan McGrath wrote: Jan, I got a chance to sit down and dig a little bit deeper into `fsck.xfs`. Here is what I discovered. The (a|A|y|p) options in the XFS script appear to be nothing more than the expected `fsck` options that imply automated checks (as is clearly implied by the use of AUTO). While I have yet to specifically test the capitalized A, my guess is that it matches the -A options from fsck(8) for when the system is going through the fstab. The syntax itself appears to assume that the dev name is the last param (as indicated by the argc/$#, which gets eval'd into the DEV variable). After doing some tests with a hacked up version of the `fsck.xfs` script, it would appear that the generic `fsck` script calls each script in order and passes it some parameters to test, since if I pass `fsck` some random/btrfsck switches: # fsck --repair /dev/storage/lv_btrfs I get an error back from `fsck.ext4`: fsck from util-linux 2.20.1 fsck.ext4: invalid option -- 'e' 2 things; from the fsck manpage: fsck [-sAVRTMNP] [-C [fd]] [-t fstype] [filesys...] [--] [fs-specific-options] so I think you need: fsck -- --repair /dev/storage/lv_btrfs But the other issues seems to be that fsck blkid are autodetecting the device as ext4, not btrfs; a separate issue. -Eric -- 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-progs: No-op when called as fsck.btrfsck
Anyways, thought I would reply back with some insight on the matter and see what others had to say, since I am in no position to dictate the direction that brtfsck/fsck.btrfs should take as far as wrapper script or no is concerned. Look forward to your replies! o/ FWIW: debian has been carrying a patch to ignore fsck args to help it run as fsck.btrfs. I think modern versions of their btrfs-tools package that are based on more recent btrfs-progs also include the hunk to recognize being called as fsck.btrfs. It might be worth finding someone who knows the history of the debian package. I'm certainly not that person :). Here's the result of some light googling: http://ftp.de.debian.org/debian/pool/main/b/btrfs-tools/btrfs-tools_0.19+20130131-3+really20121004-1.debian.tar.xz debian/patches/08-fsck.patch: Author: Sten Heinze s...@gmx.de Description: Ignore all arguments starting with -a in btrfsck for the time being (Closes: #567681, #571300, #612809, #668832). diff -Naurp btrfs-tools.orig/btrfsck.c btrfs-tools/btrfsck.c --- btrfs-tools.orig/btrfsck.c 2012-12-10 10:44:57.283351955 +0100 +++ btrfs-tools/btrfsck.c 2012-12-10 10:56:20.971516720 +0100 @@ -3477,6 +3477,12 @@ static void print_usage(void) exit(1); } +static void print_info(void) +{ + fprintf(stderr, %s\n, BTRFS_BUILD_VERSION); + exit(0); +} + static struct option long_options[] = { { super, 1, NULL, 's' }, { repair, 0, NULL, 0 }, @@ -3501,7 +3507,7 @@ int main(int ac, char **av) while(1) { int c; - c = getopt_long(ac, av, s:, long_options, + c = getopt_long(ac, av, s:anry, long_options, option_index); if (c 0) break; @@ -3514,6 +3520,12 @@ int main(int ac, char **av) break; case '?': print_usage(); + break; + case 'a': + case 'n': + case 'r': + case 'y': + print_info(); } if (option_index == 1) { printf(enabling repair mode\n); -- 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
Activating space_cache after read-only snapshots without space_cache have been taken
Hello everyone, I've ran into problems with _very_ slow unmounting of my btrfs-formatted backup volume. I have a suspicion what might be the cause but maybe someone with more experience with the btrfs code could enlighten me whether it is actually correct. The situation is the following: I have created a backup-volume to which I regularly rsync a backup of my system into a subvolume. After rsync'ing, I take a _read-only_ snapshot of that subvolume with a timestamp added to its name. Now at the time I started using this backup volume, I was _not_ using the space_cache mount option and two read-only snapshots were taken during this time. Then I started using the space_cache option and continued doing snapshots. A bit later, I started having very long lags when unmounting the backup volume (both during shutdown and when unmounting manually). I scrubbed and fsck'd the volume but this didn't show any errors. Defragmenting the root and subvolumes took a long time but didn't improve the situation much. Now I started having the suspicion that maybe the space cache possibly couldn't be written to disk for the readonly subvolumes/snapshots that were created during the time when I wasn't using the space_cache option, forcing the cache to be rebuilt every time. Clearing the cache didn't help. But when I deleted the two snapshots that I think were taken during the time without the mount option, the unmounting time seems to have improved considerably. I will have to observe whether unmounting stays quick now but my question is whether it is possible that the read-only snapshots taken during the time when I wasn't using space_cache might actually have been the culprits. Best, Sebastian -- 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: Activating space_cache after read-only snapshots without space_cache have been taken
On Tue, Apr 16, 2013 at 02:28:51AM +0200, Ochi wrote: Hello everyone, I've ran into problems with _very_ slow unmounting of my btrfs-formatted backup volume. I have a suspicion what might be the cause but maybe someone with more experience with the btrfs code could enlighten me whether it is actually correct. The situation is the following: I have created a backup-volume to which I regularly rsync a backup of my system into a subvolume. After rsync'ing, I take a _read-only_ snapshot of that subvolume with a timestamp added to its name. Now at the time I started using this backup volume, I was _not_ using the space_cache mount option and two read-only snapshots were taken during this time. Then I started using the space_cache option and continued doing snapshots. A bit later, I started having very long lags when unmounting the backup volume (both during shutdown and when unmounting manually). I scrubbed and fsck'd the volume but this didn't show any errors. Defragmenting the root and subvolumes took a long time but didn't improve the situation much. So are you using '-o nospace_cache' when creating two RO snapshots? Now I started having the suspicion that maybe the space cache possibly couldn't be written to disk for the readonly subvolumes/snapshots that were created during the time when I wasn't using the space_cache option, forcing the cache to be rebuilt every time. Clearing the cache didn't help. But when I deleted the two snapshots that I think were taken during the time without the mount option, the unmounting time seems to have improved considerably. I don't know why this happens, but maybe you can observe the umount process's very slow behaviour by using 'cat /proc/{umount-pid}/stack' or 'perf top'. thanks, liubo I will have to observe whether unmounting stays quick now but my question is whether it is possible that the read-only snapshots taken during the time when I wasn't using space_cache might actually have been the culprits. Best, Sebastian -- 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
[PATCH 02/11 v3] btrfs-progs: no pending balance is not an error
Having no balance running/ paused/completed is a normal situation, so the current output message should be positive with return val zero. Signed-off-by: Anand Jain anand.j...@oracle.com --- cmds-balance.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmds-balance.c b/cmds-balance.c index f5dc317..cffa807 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -616,6 +616,12 @@ static const char * const cmd_balance_status_usage[] = { NULL }; +/* Checks the status of the balance if any + * return codes: + * 2 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed + */ static int cmd_balance_status(int argc, char **argv) { struct btrfs_ioctl_balance_args args; @@ -654,7 +660,7 @@ static int cmd_balance_status(int argc, char **argv) fd = open_file_or_dir(path); if (fd 0) { fprintf(stderr, ERROR: can't access to '%s'\n, path); - return 12; + return 2; } ret = ioctl(fd, BTRFS_IOC_BALANCE_PROGRESS, args); @@ -662,9 +668,13 @@ static int cmd_balance_status(int argc, char **argv) close(fd); if (ret 0) { + if (e == ENOTCONN) { + printf(No balance found on '%s'\n, path); + return 0; + } fprintf(stderr, ERROR: balance status on '%s' failed - %s\n, - path, (e == ENOTCONN) ? Not in progress : strerror(e)); - return 19; + path, strerror(e)); + return 2; } if (args.state BTRFS_BALANCE_STATE_RUNNING) { @@ -688,7 +698,7 @@ static int cmd_balance_status(int argc, char **argv) if (verbose) dump_ioctl_balance_args(args); - return 0; + return 1; } const struct cmd_group balance_cmd_group = { -- 1.8.1.227.g44fe835 -- 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 02/11, RESEND] btrfs-progs: no pending balance is not an error
On 04/16/2013 12:21 AM, David Sterba wrote: On Mon, Apr 15, 2013 at 02:38:08PM +0800, Anand Jain wrote: +/* Checks the status of the balance if any + * return codes: + * -1 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed The error code will become the return code of the 'btrfs balance status' command in the end: btrfs.c:main() 295 exit(cmd-fn(argc, argv)); and that's why I've suggested to return 1 or 2, though -1 matches shell error code 255 but I'd rathe avoid using it. makes sense. v3 is out. -- 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/4] Btrfs: remove unused argument of fixup_low_keys()
Argument 'trans' is not used in fixup_low_keys(). So, remove it. Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com --- fs/btrfs/ctree.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index ca9d8f1..b5eec7c 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2902,8 +2902,7 @@ again: * higher levels * */ -static void fixup_low_keys(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct btrfs_path *path, +static void fixup_low_keys(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, int level) { int i; @@ -2951,7 +2950,7 @@ void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, btrfs_set_item_key(eb, disk_key, slot); btrfs_mark_buffer_dirty(eb); if (slot == 0) - fixup_low_keys(trans, root, path, disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); } /* @@ -3687,7 +3686,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, clean_tree_block(trans, root, right); btrfs_item_key(right, disk_key, 0); - fixup_low_keys(trans, root, path, disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); /* then fixup the leaf pointer in the path */ if (path-slots[0] push_items) { @@ -4047,8 +4046,7 @@ again: path-nodes[0] = right; path-slots[0] = 0; if (path-slots[1] == 0) - fixup_low_keys(trans, root, path, - disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); } btrfs_mark_buffer_dirty(right); return ret; @@ -4367,7 +4365,7 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans, btrfs_set_disk_key_offset(disk_key, offset + size_diff); btrfs_set_item_key(leaf, disk_key, slot); if (slot == 0) - fixup_low_keys(trans, root, path, disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); } item = btrfs_item_nr(leaf, slot); @@ -4531,7 +4529,7 @@ void setup_items_for_insert(struct btrfs_trans_handle *trans, if (slot == 0) { btrfs_cpu_key_to_disk(disk_key, cpu_key); - fixup_low_keys(trans, root, path, disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); } btrfs_unlock_up_safe(path, 1); btrfs_mark_buffer_dirty(leaf); @@ -4642,7 +4640,7 @@ static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_node_key(parent, disk_key, 0); - fixup_low_keys(trans, root, path, disk_key, level + 1); + fixup_low_keys(root, path, disk_key, level + 1); } btrfs_mark_buffer_dirty(parent); } @@ -4744,7 +4742,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_item_key(leaf, disk_key, 0); - fixup_low_keys(trans, root, path, disk_key, 1); + fixup_low_keys(root, path, disk_key, 1); } /* delete the leaf if it is mostly empty */ -- 1.7.12.2 -- 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/4] Btrfs: cleanup of function where fixup_low_keys() is called
If argument 'trans' is unnecessary in the function where fixup_low_keys() is called, 'trans' is deleted. Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com --- fs/btrfs/ctree.c | 28 fs/btrfs/ctree.h | 10 +++--- fs/btrfs/delayed-inode.c | 11 +-- fs/btrfs/dir-item.c | 3 +-- fs/btrfs/extent-tree.c | 9 - fs/btrfs/file-item.c | 11 +-- fs/btrfs/file.c | 8 fs/btrfs/inode-item.c| 4 ++-- fs/btrfs/inode.c | 3 +-- fs/btrfs/tree-log.c | 4 ++-- 10 files changed, 39 insertions(+), 52 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index b5eec7c..76e11d7 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -37,8 +37,8 @@ static int balance_node_right(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *dst_buf, struct extent_buffer *src_buf); -static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct btrfs_path *path, int level, int slot); +static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, + int level, int slot); static void tree_mod_log_free_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb); struct extent_buffer *read_old_tree_block(struct btrfs_root *root, u64 bytenr, @@ -1818,7 +1818,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(right) == 0) { clean_tree_block(trans, root, right); btrfs_tree_unlock(right); - del_ptr(trans, root, path, level + 1, pslot + 1); + del_ptr(root, path, level + 1, pslot + 1); root_sub_used(root, right-len); btrfs_free_tree_block(trans, root, right, 0, 1); free_extent_buffer_stale(right); @@ -1862,7 +1862,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(mid) == 0) { clean_tree_block(trans, root, mid); btrfs_tree_unlock(mid); - del_ptr(trans, root, path, level + 1, pslot); + del_ptr(root, path, level + 1, pslot); root_sub_used(root, mid-len); btrfs_free_tree_block(trans, root, mid, 0, 1); free_extent_buffer_stale(mid); @@ -2927,8 +2927,7 @@ static void fixup_low_keys(struct btrfs_root *root, struct btrfs_path *path, * This function isn't completely safe. It's the caller's responsibility * that the new key won't break the order */ -void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, -struct btrfs_root *root, struct btrfs_path *path, +void btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *new_key) { struct btrfs_disk_key disk_key; @@ -4262,7 +4261,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, return ret; path-slots[0]++; - setup_items_for_insert(trans, root, path, new_key, item_size, + setup_items_for_insert(root, path, new_key, item_size, item_size, item_size + sizeof(struct btrfs_item), 1); leaf = path-nodes[0]; @@ -4279,9 +4278,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, * off the end of the item or if we shift the item to chop bytes off * the front. */ -void btrfs_truncate_item(struct btrfs_trans_handle *trans, -struct btrfs_root *root, -struct btrfs_path *path, +void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path, u32 new_size, int from_end) { int slot; @@ -4452,8 +4449,7 @@ void btrfs_extend_item(struct btrfs_trans_handle *trans, * to save stack depth by doing the bulk of the work in a function * that doesn't call btrfs_search_slot */ -void setup_items_for_insert(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct btrfs_path *path, +void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *cpu_key, u32 *data_size, u32 total_data, u32 total_size, int nr) { @@ -4569,7 +4565,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, slot = path-slots[0]; BUG_ON(slot 0); - setup_items_for_insert(trans, root, path, cpu_key, data_size, + setup_items_for_insert(root, path, cpu_key, data_size, total_data, total_size, nr); return 0; } @@ -4607,8 +4603,8 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans,
[PATCH 3/4] Btrfs: remove unused argument of btrfs_extend_item()
Argument 'trans' is not used in btrfs_extend_item(). Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com --- fs/btrfs/ctree.c | 3 +-- fs/btrfs/ctree.h | 3 +-- fs/btrfs/dir-item.c| 2 +- fs/btrfs/extent-tree.c | 4 ++-- fs/btrfs/file-item.c | 2 +- fs/btrfs/inode-item.c | 4 ++-- fs/btrfs/tree-log.c| 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 76e11d7..d5f22db 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -4378,8 +4378,7 @@ void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path, /* * make the item pointed to by the path bigger, data_size is the new size. */ -void btrfs_extend_item(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct btrfs_path *path, +void btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path, u32 data_size) { int slot; diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 7da1b74..de3b483 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3197,8 +3197,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, struct extent_buffer **cow_ret, u64 new_root_objectid); int btrfs_block_can_be_shared(struct btrfs_root *root, struct extent_buffer *buf); -void btrfs_extend_item(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct btrfs_path *path, +void btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path, u32 data_size); void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path, u32 new_size, int from_end); diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index 47cab8d..71fa113 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c @@ -49,7 +49,7 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle di = btrfs_match_dir_item_name(root, path, name, name_len); if (di) return ERR_PTR(-EEXIST); - btrfs_extend_item(trans, root, path, data_size); + btrfs_extend_item(root, path, data_size); } else if (ret 0) return ERR_PTR(ret); WARN_ON(ret 0); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index d265625..151b0ad 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1001,7 +1001,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle *trans, return ret; BUG_ON(ret); /* Corruption */ - btrfs_extend_item(trans, root, path, new_size); + btrfs_extend_item(root, path, new_size); leaf = path-nodes[0]; item = btrfs_item_ptr(leaf, path-slots[0], struct btrfs_extent_item); @@ -1614,7 +1614,7 @@ void setup_inline_extent_backref(struct btrfs_trans_handle *trans, type = extent_ref_type(parent, owner); size = btrfs_extent_inline_ref_size(type); - btrfs_extend_item(trans, root, path, size); + btrfs_extend_item(root, path, size); ei = btrfs_item_ptr(leaf, path-slots[0], struct btrfs_extent_item); refs = btrfs_extent_refs(leaf, ei); diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index def004f..da9edca 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -834,7 +834,7 @@ again: diff /= csum_size; diff *= csum_size; - btrfs_extend_item(trans, root, path, diff); + btrfs_extend_item(root, path, diff); goto csum; } diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index cb44398..1640e03 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c @@ -361,7 +361,7 @@ static int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans, name, name_len, NULL)) goto out; - btrfs_extend_item(trans, root, path, ins_len); + btrfs_extend_item(root, path, ins_len); ret = 0; } if (ret 0) @@ -417,7 +417,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, goto out; old_size = btrfs_item_size_nr(path-nodes[0], path-slots[0]); - btrfs_extend_item(trans, root, path, ins_len); + btrfs_extend_item(root, path, ins_len); ref = btrfs_item_ptr(path-nodes[0], path-slots[0], struct btrfs_inode_ref); ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index c2d55ed..0a5601b 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -410,7 +410,7 @@ insert: if (found_size item_size) btrfs_truncate_item(root, path, item_size, 1); else if (found_size
[PATCH 4/4] Btrfs: cleanup of function where btrfs_extend_item() is called
Argument 'trans' became unnecessary from setup_inline_extent_backref() that called btrfs_extend_item(). Signed-off-by: Tsutomu Itoh t-i...@jp.fujitsu.com --- fs/btrfs/extent-tree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 151b0ad..f3ff02a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1590,8 +1590,7 @@ out: * helper to add new inline back ref */ static noinline_for_stack -void setup_inline_extent_backref(struct btrfs_trans_handle *trans, -struct btrfs_root *root, +void setup_inline_extent_backref(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_extent_inline_ref *iref, u64 parent, u64 root_objectid, @@ -1764,7 +1763,7 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans, update_inline_extent_backref(root, path, iref, refs_to_add, extent_op); } else if (ret == -ENOENT) { - setup_inline_extent_backref(trans, root, path, iref, parent, + setup_inline_extent_backref(root, path, iref, parent, root_objectid, owner, offset, refs_to_add, extent_op); ret = 0; -- 1.7.12.2 -- 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