Re: [PATCH] btrfs: qgroup: Init flags with RESCAN bit at quota enable time
On 2018/07/27 15:09, Qu Wenruo wrote: > > > On 2018年07月27日 09:43, Misono Tomohiro wrote: >> On 2018/07/27 10:19, Qu Wenruo wrote: >>> >>> >>> On 2018年07月27日 09:10, Misono Tomohiro wrote: On 2018/07/26 18:15, Qu Wenruo wrote: > Between btrfs_quota_enable() finished and rescan kicked in, there is a > small window that quota status has (ON | INCONSISTENT) bits set but > without RESCAN bits set. > > And transaction is committed inside the window and then power loss > happens, we will have a quota tree with all qgroup numbers set to 0, and > not RESCAN bit set. > > At next mount time, qgroup rescan will not kick in due to the missing of > RESCAN bit, user needs to kick in rescan manually. > > This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), > so even after power loss we will still kick in rescan automatically. > > Suggested-by: Misono Tomohiro > Signed-off-by: Qu Wenruo > --- > fs/btrfs/qgroup.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index c25dc47210a3..13c1c7dd278d 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle > *trans, > btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); > btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); > fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | > - BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; > + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | > + BTRFS_QGROUP_STATUS_FLAG_RESCAN; > btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); > btrfs_set_qgroup_status_rescan(leaf, ptr, 0); > > @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle > *trans, > fs_info->quota_root = quota_root; > set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); > spin_unlock(&fs_info->qgroup_lock); > - ret = qgroup_rescan_init(fs_info, 0, 1); > + ret = qgroup_rescan_init(fs_info, 0, 0); > if (!ret) { > qgroup_rescan_zero_tracking(fs_info); > btrfs_queue_work(fs_info->qgroup_rescan_workers, > This is what I think at first, but is it ok not holding fs_info->qgroup_ioctl_lock in brfs_qgroup_rescan() as you concerned in previous thread? >>> >>> I think it's OK, since we have larger mutex (subvol_sem) for >>> quota_enable/disable() so there will be no concurrency modifying flags. >>> And we're holding trans handler from btrfs_ioctl_quota_ctl(), >>> transaction won't be committed in btrfs_quota_enable(). >> >> Ok, but nikolay's patch in misc-next moves transaction commit in >> btrfs_quota_enable(): >> https://patchwork.kernel.org/patch/10508819/ >> ("btrfs: qgroups: Move transaction management inside >> btrfs_quota_enable/disable") > > Since qgroup_rescan_init() has nothing do to with transaction, it looks > OK even with Nikolay's patch. > Understood. Thanks for your explanation. Misono >> >> This is related to https://marc.info/?l=linux-btrfs&m=152999289017582. >> However, it seems that other people does not see the problem, >> so I'm not sure how the above patch ends up... > > IIRC I also failed to reproduce it, thus can't provide much help for > that thread. > > Thanks, > Qu > > > >> >> Thanks, >> Tomohiro Misono >> >>> >>> So I think it's OK. >>> >>> Thanks, >>> Qu >>> >>> >> > -- 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: qgroup: Init flags with RESCAN bit at quota enable time
On 2018年07月27日 09:43, Misono Tomohiro wrote: > On 2018/07/27 10:19, Qu Wenruo wrote: >> >> >> On 2018年07月27日 09:10, Misono Tomohiro wrote: >>> On 2018/07/26 18:15, Qu Wenruo wrote: Between btrfs_quota_enable() finished and rescan kicked in, there is a small window that quota status has (ON | INCONSISTENT) bits set but without RESCAN bits set. And transaction is committed inside the window and then power loss happens, we will have a quota tree with all qgroup numbers set to 0, and not RESCAN bit set. At next mount time, qgroup rescan will not kick in due to the missing of RESCAN bit, user needs to kick in rescan manually. This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), so even after power loss we will still kick in rescan automatically. Suggested-by: Misono Tomohiro Signed-off-by: Qu Wenruo --- fs/btrfs/qgroup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index c25dc47210a3..13c1c7dd278d 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | - BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | + BTRFS_QGROUP_STATUS_FLAG_RESCAN; btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); btrfs_set_qgroup_status_rescan(leaf, ptr, 0); @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, fs_info->quota_root = quota_root; set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); spin_unlock(&fs_info->qgroup_lock); - ret = qgroup_rescan_init(fs_info, 0, 1); + ret = qgroup_rescan_init(fs_info, 0, 0); if (!ret) { qgroup_rescan_zero_tracking(fs_info); btrfs_queue_work(fs_info->qgroup_rescan_workers, >>> >>> This is what I think at first, but is it ok not holding >>> fs_info->qgroup_ioctl_lock >>> in brfs_qgroup_rescan() as you concerned in previous thread? >> >> I think it's OK, since we have larger mutex (subvol_sem) for >> quota_enable/disable() so there will be no concurrency modifying flags. >> And we're holding trans handler from btrfs_ioctl_quota_ctl(), >> transaction won't be committed in btrfs_quota_enable(). > > Ok, but nikolay's patch in misc-next moves transaction commit in > btrfs_quota_enable(): > https://patchwork.kernel.org/patch/10508819/ > ("btrfs: qgroups: Move transaction management inside > btrfs_quota_enable/disable") Since qgroup_rescan_init() has nothing do to with transaction, it looks OK even with Nikolay's patch. > > This is related to https://marc.info/?l=linux-btrfs&m=152999289017582. > However, it seems that other people does not see the problem, > so I'm not sure how the above patch ends up... IIRC I also failed to reproduce it, thus can't provide much help for that thread. Thanks, Qu > > Thanks, > Tomohiro Misono > >> >> So I think it's OK. >> >> Thanks, >> Qu >> >> > signature.asc Description: OpenPGP digital signature
Re: [PATCH] btrfs: qgroup: Init flags with RESCAN bit at quota enable time
On 2018/07/27 10:19, Qu Wenruo wrote: > > > On 2018年07月27日 09:10, Misono Tomohiro wrote: >> On 2018/07/26 18:15, Qu Wenruo wrote: >>> Between btrfs_quota_enable() finished and rescan kicked in, there is a >>> small window that quota status has (ON | INCONSISTENT) bits set but >>> without RESCAN bits set. >>> >>> And transaction is committed inside the window and then power loss >>> happens, we will have a quota tree with all qgroup numbers set to 0, and >>> not RESCAN bit set. >>> >>> At next mount time, qgroup rescan will not kick in due to the missing of >>> RESCAN bit, user needs to kick in rescan manually. >>> >>> This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), >>> so even after power loss we will still kick in rescan automatically. >>> >>> Suggested-by: Misono Tomohiro >>> Signed-off-by: Qu Wenruo >>> --- >>> fs/btrfs/qgroup.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c >>> index c25dc47210a3..13c1c7dd278d 100644 >>> --- a/fs/btrfs/qgroup.c >>> +++ b/fs/btrfs/qgroup.c >>> @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, >>> btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); >>> btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); >>> fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | >>> - BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; >>> + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | >>> + BTRFS_QGROUP_STATUS_FLAG_RESCAN; >>> btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); >>> btrfs_set_qgroup_status_rescan(leaf, ptr, 0); >>> >>> @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, >>> fs_info->quota_root = quota_root; >>> set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); >>> spin_unlock(&fs_info->qgroup_lock); >>> - ret = qgroup_rescan_init(fs_info, 0, 1); >>> + ret = qgroup_rescan_init(fs_info, 0, 0); >>> if (!ret) { >>> qgroup_rescan_zero_tracking(fs_info); >>> btrfs_queue_work(fs_info->qgroup_rescan_workers, >>> >> >> This is what I think at first, but is it ok not holding >> fs_info->qgroup_ioctl_lock >> in brfs_qgroup_rescan() as you concerned in previous thread? > > I think it's OK, since we have larger mutex (subvol_sem) for > quota_enable/disable() so there will be no concurrency modifying flags. > And we're holding trans handler from btrfs_ioctl_quota_ctl(), > transaction won't be committed in btrfs_quota_enable(). Ok, but nikolay's patch in misc-next moves transaction commit in btrfs_quota_enable(): https://patchwork.kernel.org/patch/10508819/ ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable") This is related to https://marc.info/?l=linux-btrfs&m=152999289017582. However, it seems that other people does not see the problem, so I'm not sure how the above patch ends up... Thanks, Tomohiro Misono > > So I think it's OK. > > Thanks, > Qu > > -- 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: qgroup: Init flags with RESCAN bit at quota enable time
On 2018年07月27日 09:10, Misono Tomohiro wrote: > On 2018/07/26 18:15, Qu Wenruo wrote: >> Between btrfs_quota_enable() finished and rescan kicked in, there is a >> small window that quota status has (ON | INCONSISTENT) bits set but >> without RESCAN bits set. >> >> And transaction is committed inside the window and then power loss >> happens, we will have a quota tree with all qgroup numbers set to 0, and >> not RESCAN bit set. >> >> At next mount time, qgroup rescan will not kick in due to the missing of >> RESCAN bit, user needs to kick in rescan manually. >> >> This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), >> so even after power loss we will still kick in rescan automatically. >> >> Suggested-by: Misono Tomohiro >> Signed-off-by: Qu Wenruo >> --- >> fs/btrfs/qgroup.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c >> index c25dc47210a3..13c1c7dd278d 100644 >> --- a/fs/btrfs/qgroup.c >> +++ b/fs/btrfs/qgroup.c >> @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, >> btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); >> btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); >> fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | >> -BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; >> +BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | >> +BTRFS_QGROUP_STATUS_FLAG_RESCAN; >> btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); >> btrfs_set_qgroup_status_rescan(leaf, ptr, 0); >> >> @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, >> fs_info->quota_root = quota_root; >> set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); >> spin_unlock(&fs_info->qgroup_lock); >> -ret = qgroup_rescan_init(fs_info, 0, 1); >> +ret = qgroup_rescan_init(fs_info, 0, 0); >> if (!ret) { >> qgroup_rescan_zero_tracking(fs_info); >> btrfs_queue_work(fs_info->qgroup_rescan_workers, >> > > This is what I think at first, but is it ok not holding > fs_info->qgroup_ioctl_lock > in brfs_qgroup_rescan() as you concerned in previous thread? I think it's OK, since we have larger mutex (subvol_sem) for quota_enable/disable() so there will be no concurrency modifying flags. And we're holding trans handler from btrfs_ioctl_quota_ctl(), transaction won't be committed in btrfs_quota_enable(). So I think it's OK. Thanks, Qu signature.asc Description: OpenPGP digital signature
Re: [PATCH] btrfs: qgroup: Init flags with RESCAN bit at quota enable time
On 2018/07/26 18:15, Qu Wenruo wrote: > Between btrfs_quota_enable() finished and rescan kicked in, there is a > small window that quota status has (ON | INCONSISTENT) bits set but > without RESCAN bits set. > > And transaction is committed inside the window and then power loss > happens, we will have a quota tree with all qgroup numbers set to 0, and > not RESCAN bit set. > > At next mount time, qgroup rescan will not kick in due to the missing of > RESCAN bit, user needs to kick in rescan manually. > > This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), > so even after power loss we will still kick in rescan automatically. > > Suggested-by: Misono Tomohiro > Signed-off-by: Qu Wenruo > --- > fs/btrfs/qgroup.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index c25dc47210a3..13c1c7dd278d 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, > btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); > btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); > fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | > - BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; > + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | > + BTRFS_QGROUP_STATUS_FLAG_RESCAN; > btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); > btrfs_set_qgroup_status_rescan(leaf, ptr, 0); > > @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, > fs_info->quota_root = quota_root; > set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); > spin_unlock(&fs_info->qgroup_lock); > - ret = qgroup_rescan_init(fs_info, 0, 1); > + ret = qgroup_rescan_init(fs_info, 0, 0); > if (!ret) { > qgroup_rescan_zero_tracking(fs_info); > btrfs_queue_work(fs_info->qgroup_rescan_workers, > This is what I think at first, but is it ok not holding fs_info->qgroup_ioctl_lock in brfs_qgroup_rescan() as you concerned in previous thread? -- 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: add cli to forget one or all scanned devices
This patch adds cli btrfs device forget [dev] to remove the given device structure in the kernel if the device is unmounted. If no argument is given it shall remove all stale (device which are not mounted) from the kernel. Signed-off-by: Anand Jain --- cmds-device.c | 58 ++ ioctl.h | 2 ++ 2 files changed, 60 insertions(+) diff --git a/cmds-device.c b/cmds-device.c index 86459d1b9564..49cfd4b41adb 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -326,6 +326,63 @@ out: return !!ret; } +static const char * const cmd_device_forget_usage[] = { + "btrfs device forget []", + "Forget a stale device or all stale devices in btrfs.ko", + NULL +}; + +static int btrfs_forget_devices(char *path) +{ + struct btrfs_ioctl_vol_args args; + int ret; + int fd; + + fd = open("/dev/btrfs-control", O_RDWR); + if (fd < 0) + return -errno; + + memset(&args, 0, sizeof(args)); + if (path) + strncpy_null(args.name, path); + ret = ioctl(fd, BTRFS_IOC_FORGET_DEV, &args); + if (ret) + ret = -errno; + close(fd); + return ret; +} + +static int cmd_device_forget(int argc, char **argv) +{ + char *path; + int ret = 0; + + if (check_argc_max(argc - optind, 1)) + usage(cmd_device_forget_usage); + + if (argc == 1) { + ret = btrfs_forget_devices(NULL); + if (ret) + error("Can't forget: %s", strerror(-ret)); + return ret; + } + + path = canonicalize_path(argv[1]); + if (!path) { + error("Could not canonicalize path '%s': %s", + argv[1], strerror(errno)); + return -ENOENT; + } + + ret = btrfs_forget_devices(path); + if (ret) + error("Can't forget '%s': %s", path, strerror(-ret)); + + free(path); + + return ret; +} + static const char * const cmd_device_ready_usage[] = { "btrfs device ready ", "Check device to see if it has all of its devices in cache for mounting", @@ -601,6 +658,7 @@ const struct cmd_group device_cmd_group = { CMD_ALIAS }, { "remove", cmd_device_remove, cmd_device_remove_usage, NULL, 0 }, { "scan", cmd_device_scan, cmd_device_scan_usage, NULL, 0 }, + { "forget", cmd_device_forget, cmd_device_forget_usage, NULL, 0 }, { "ready", cmd_device_ready, cmd_device_ready_usage, NULL, 0 }, { "stats", cmd_device_stats, cmd_device_stats_usage, NULL, 0 }, { "usage", cmd_device_usage, diff --git a/ioctl.h b/ioctl.h index 709e996f401c..e27d80e09392 100644 --- a/ioctl.h +++ b/ioctl.h @@ -721,6 +721,8 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ struct btrfs_ioctl_vol_args) +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ + struct btrfs_ioctl_vol_args) /* trans start and trans end are dangerous, and only for * use by applications that know how to avoid the * resulting deadlocks -- 2.7.0 -- 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: introduce feature to forget a btrfs device
Support for a new command 'btrfs dev forget [dev]' is proposed here to undo the effects of 'btrfs dev scan [dev]'. For this purpose this patch proposes to use ioctl #5 as it was empty. IOW(BTRFS_IOCTL_MAGIC, 5, ..) This patch adds new ioctl BTRFS_IOC_FORGET_DEV which can be sent from the /dev/btrfs-control to forget one or all devices, (devices which are not mounted) from the btrfs kernel. The argument it takes is struct btrfs_ioctl_vol_args, and ::name can be set to specify the device path. And all unmounted devices can be removed from the kernel if no device path is provided. Again, the devices are removed only if the relevant fsid aren't mounted. This new cli can provide.. . Release of unwanted btrfs_fs_devices and btrfs_devices memory if the device is not going to be mounted. . Ability to mount the device in degraded mode when one of the other device is corrupted like in split brain raid1. . Running test cases which requires btrfs.ko-reload if the rootfs is btrfs. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 3 +++ fs/btrfs/volumes.c | 9 + fs/btrfs/volumes.h | 1 + include/uapi/linux/btrfs.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 67de3c0fc85b..470a32af474e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2244,6 +2244,9 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ret = PTR_ERR_OR_ZERO(device); mutex_unlock(&uuid_mutex); break; + case BTRFS_IOC_FORGET_DEV: + ret = btrfs_forget_devices(vol->name); + break; case BTRFS_IOC_DEVICES_READY: mutex_lock(&uuid_mutex); device = btrfs_scan_one_device(vol->name, FMODE_READ, diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8844904f9009..cd54a926141a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1208,6 +1208,15 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr, return 0; } +int btrfs_forget_devices(const char *path) +{ + mutex_lock(&uuid_mutex); + btrfs_free_stale_devices(strlen(path) ? path:NULL, NULL); + mutex_unlock(&uuid_mutex); + + return 0; +} + /* * Look for a btrfs signature on a device. This may be called out of the mount path * and we are not allowed to call set_blocksize during the scan. The superblock diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 049619176831..1602b5faa7e7 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -405,6 +405,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fmode_t flags, void *holder); struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, void *holder); +int btrfs_forget_devices(const char *path); int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step); void btrfs_assign_next_active_device(struct btrfs_device *device, diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index 5ca1d21fc4a7..b1be7f828cb4 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -836,6 +836,8 @@ enum btrfs_err_code { struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ struct btrfs_ioctl_vol_args) +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ + struct btrfs_ioctl_vol_args) /* trans start and trans end are dangerous, and only for * use by applications that know how to avoid the * resulting deadlocks -- 2.7.0 -- 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 v8] Add cli and ioctl to forget scanned device(s)
[based on latest misc-next] v8: Change log update in the kernel patch. v7: Use struct btrfs_ioctl_vol_args (instead of struct btrfs_ioctl_vol_args_v2) as its inline with other ioctl btrfs-control The CLI usage remains same. However internally the ioctl flag is not required to delete all the unmounted devices. Instead leave btrfs_ioctl_vol_args::name NULL. v6: Use the changed fn name btrfs_free_stale_devices(). Change in title: Old v5: Cover-letter: [PATCH v5] Add cli and ioctl to ignore a scanned device Kernel: [PATCH v5] btrfs: introduce feature to ignore a btrfs device Progs: [PATCH v5] btrfs-progs: add 'btrfs device ignore' cli v5: Adds feature to delete all stale devices Reuses btrfs_free_stale_devices() fn and so depends on the patch-set [1] in the ML. Uses struct btrfs_ioctl_vol_args_v2 instead of struct btrfs_ioctl_vol_args as arg Does the device path matching instead of btrfs_device matching (we won't delete the mounted device as btrfs_free_stale_devices() checks for it) v4: No change. But as the ML thread may be confusing, so resend. v3: No change. Send to correct ML. v2: Accepts review from Nikolay, details are in the specific patch. Patch 1/2 is renamed from [PATCH 1/2] btrfs: refactor btrfs_free_stale_device() to get device list delete to [PATCH 1/2] btrfs: add function to device list delete Adds cli and ioctl to forget a scanned device or forget all stale devices in the kernel. Anand Jain (1): btrfs: introduce feature to forget a btrfs device fs/btrfs/super.c | 3 +++ fs/btrfs/volumes.c | 9 + fs/btrfs/volumes.h | 1 + include/uapi/linux/btrfs.h | 2 ++ 4 files changed, 15 insertions(+) Anand Jain (1): btrfs-progs: add cli to forget one or all scanned devices cmds-device.c | 58 ++ ioctl.h | 2 ++ 2 files changed, 60 insertions(+) -- 2.7.0 -- 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: Lockdep splat with v4.18.6
Hi Ross, Thanks for the report. I have analyzed it here [1] earlier and is harmless since lockdep checks doesn't seem to account for the difference in the lock time-space, there is similar fix in block layer as well (which I am unable to pull the ref as of now, but will try again). And this happened after we have added [2] [1] https://www.spinics.net/lists/linux-btrfs/msg79708.html [2] 542c5908abfe84f7 btrfs: replace uuid_mutex by device_list_mutex in btrfs_open_devices I am consolidating the locks in parts, will be fixed. Thanks, Anand On 07/27/2018 06:09 AM, Ross Zwisler wrote: I was testing my new xfstest posted here: https://lists.01.org/pipermail/linux-nvdimm/2018-July/016850.html against a btrfs test device + scrach device setup, and hit a lockdep splat. I'm using vanilla v4.18.6. I've attached the splats to this mail, one just as it happened in dmesg and one passed through kasan_symbolize.py for files, line numbers, etc. Thanks, - Ross -- 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: revert fs_devices state on error of btrfs_init_new_device()
When btrfs hits error after modifying fs_devices in btrfs_init_new_device() (such as btrfs_add_dev_item() returns error), it leaves everything as is, but frees allocated btrfs_device. As a result, fs_devices->devices and fs_devices->alloc_list contain already freed btrfs_device, leading to later use-after-free bug. Error path also messes the things like ->num_devices. While they go backs to the original value by unscanning btrfs devices, it is safe to revert them here. Fixes: 79787eaab461 ("btrfs: replace many BUG_ONs with proper error handling") Signed-off-by: Naohiro Aota --- fs/btrfs/volumes.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) This patch applies on master, but not on kdave/for-next because of 74b9f4e186eb ("btrfs: declare fs_devices in btrfs_init_new_device()") diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1da162928d1a..5f0512fffa52 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2410,7 +2410,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path struct list_head *devices; struct super_block *sb = fs_info->sb; struct rcu_string *name; - u64 tmp; + u64 orig_super_total_bytes, orig_super_num_devices; int seeding_dev = 0; int ret = 0; bool unlocked = false; @@ -2509,12 +2509,14 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path if (!blk_queue_nonrot(q)) fs_info->fs_devices->rotating = 1; - tmp = btrfs_super_total_bytes(fs_info->super_copy); + orig_super_total_bytes = btrfs_super_total_bytes(fs_info->super_copy); btrfs_set_super_total_bytes(fs_info->super_copy, - round_down(tmp + device->total_bytes, fs_info->sectorsize)); + round_down(orig_super_total_bytes + device->total_bytes, + fs_info->sectorsize)); - tmp = btrfs_super_num_devices(fs_info->super_copy); - btrfs_set_super_num_devices(fs_info->super_copy, tmp + 1); + orig_super_num_devices = btrfs_super_num_devices(fs_info->super_copy); + btrfs_set_super_num_devices(fs_info->super_copy, + orig_super_num_devices + 1); /* add sysfs device entry */ btrfs_sysfs_add_device_link(fs_info->fs_devices, device); @@ -2594,6 +2596,22 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path error_sysfs: btrfs_sysfs_rm_device_link(fs_info->fs_devices, device); + mutex_lock(&fs_info->fs_devices->device_list_mutex); + mutex_lock(&fs_info->chunk_mutex); + list_del_rcu(&device->dev_list); + list_del(&device->dev_alloc_list); + fs_info->fs_devices->num_devices--; + fs_info->fs_devices->open_devices--; + fs_info->fs_devices->rw_devices--; + fs_info->fs_devices->total_devices--; + fs_info->fs_devices->total_rw_bytes -= device->total_bytes; + atomic64_sub(device->total_bytes, &fs_info->free_chunk_space); + btrfs_set_super_total_bytes(fs_info->super_copy, + orig_super_total_bytes); + btrfs_set_super_num_devices(fs_info->super_copy, + orig_super_num_devices); + mutex_unlock(&fs_info->chunk_mutex); + mutex_unlock(&fs_info->fs_devices->device_list_mutex); error_trans: if (seeding_dev) sb->s_flags |= SB_RDONLY; -- 2.18.0 -- 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: introduce feature to forget a btrfs device
On 07/26/2018 11:25 PM, Filipe Manana wrote: On Thu, Jul 26, 2018 at 12:32 PM, Anand Jain wrote: Support for a new command 'btrfs dev forget [dev]' is proposed here, to undo the effects of 'btrfs dev scan [dev]'. For this purpose, this patch proposes to use ioctl #5 as it was empty. IOW(BTRFS_IOCTL_MAGIC, 5, ..) This patch adds new ioctl BTRFS_IOC_FORGET_DEV which can be sent from the /dev/btrfs-control to forget one or all devices, (devices which are not mounted) from the btrfs kernel. The argument it takes is struct btrfs_ioctl_vol_args, and ::name can be set to specify the device path. And all unmounted devices can be removed from the kernel if no device path is provided. Again, the devices are removed only if the relevant fsid aren't mounted. And why is the feature needed? What problems does it solve? That is missing from the changelog, no matter how obvious it is to you (or anyone else), it should be mentioned in the changelog. There are few reasons.. . Release of unwanted btrfs_fs_devices and btrfs_devices memory if the device is not going to be mounted. . Ability to mount the device in degraded mode when one of the other device is corrupted (patch [1] in the ML explained this). [1] btrfs: handle volume split brain scenario . Running test cases which requires btrfs.ko-reload if the rootfs is btrfs. Thanks, Anand Thanks. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 3 +++ fs/btrfs/volumes.c | 9 + fs/btrfs/volumes.h | 1 + include/uapi/linux/btrfs.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 67de3c0fc85b..470a32af474e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2244,6 +2244,9 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ret = PTR_ERR_OR_ZERO(device); mutex_unlock(&uuid_mutex); break; + case BTRFS_IOC_FORGET_DEV: + ret = btrfs_forget_devices(vol->name); + break; case BTRFS_IOC_DEVICES_READY: mutex_lock(&uuid_mutex); device = btrfs_scan_one_device(vol->name, FMODE_READ, diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8844904f9009..cd54a926141a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1208,6 +1208,15 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr, return 0; } +int btrfs_forget_devices(const char *path) +{ + mutex_lock(&uuid_mutex); + btrfs_free_stale_devices(strlen(path) ? path:NULL, NULL); + mutex_unlock(&uuid_mutex); + + return 0; +} + /* * Look for a btrfs signature on a device. This may be called out of the mount path * and we are not allowed to call set_blocksize during the scan. The superblock diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 049619176831..1602b5faa7e7 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -405,6 +405,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fmode_t flags, void *holder); struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, void *holder); +int btrfs_forget_devices(const char *path); int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step); void btrfs_assign_next_active_device(struct btrfs_device *device, diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index 5ca1d21fc4a7..b1be7f828cb4 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -836,6 +836,8 @@ enum btrfs_err_code { struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ struct btrfs_ioctl_vol_args) +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ + struct btrfs_ioctl_vol_args) /* trans start and trans end are dangerous, and only for * use by applications that know how to avoid the * resulting deadlocks -- 2.7.0 -- 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
Lockdep splat with v4.18.6
I was testing my new xfstest posted here: https://lists.01.org/pipermail/linux-nvdimm/2018-July/016850.html against a btrfs test device + scrach device setup, and hit a lockdep splat. I'm using vanilla v4.18.6. I've attached the splats to this mail, one just as it happened in dmesg and one passed through kasan_symbolize.py for files, line numbers, etc. Thanks, - Ross btrfs_splat Description: Binary data btrfs_splat_symbolized Description: Binary data
[PATCH v2 2/2] btrfs-progs: add --disable-shared and --disable-static
From: Omar Sandoval The build system mentioned in the previous commit builds libraries in both PIC and non-PIC mode. Shared libraries don't work in PIC mode, so it expects a --disable-shared configure option, which most open source libraries using autoconf have. Let's add it, too. Signed-off-by: Omar Sandoval --- Makefile| 17 ++--- Makefile.inc.in | 2 ++ configure.ac| 18 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 24aa8234..f4ab14ea 100644 --- a/Makefile +++ b/Makefile @@ -275,6 +275,13 @@ libs_shared = libbtrfs.so.0.1 libbtrfsutil.so.$(libbtrfsutil_version) libs_static = libbtrfs.a libbtrfsutil.a libs = $(libs_shared) $(libs_static) lib_links = libbtrfs.so.0 libbtrfs.so libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so +libs_build = +ifeq ($(BUILD_SHARED_LIBRARIES),1) +libs_build += $(libs_shared) $(lib_links) +endif +ifeq ($(BUILD_STATIC_LIBRARIES),1) +libs_build += $(libs_static) +endif # make C=1 to enable sparse ifdef C @@ -311,7 +318,7 @@ endif $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \ $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) -all: $(progs_build) $(libs) $(lib_links) $(BUILDDIRS) +all: $(progs_build) $(libs_build) $(BUILDDIRS) ifeq ($(PYTHON_BINDINGS),1) all: libbtrfsutil_python endif @@ -635,7 +642,7 @@ $(CLEANDIRS): @echo "Cleaning $(patsubst clean-%,%,$@)" $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean -install: $(libs) $(progs_install) $(INSTALLDIRS) +install: $(libs_build) $(progs_install) $(INSTALLDIRS) ifeq ($(BUILD_PROGRAMS),1) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs_install) $(DESTDIR)$(bindir) @@ -647,12 +654,16 @@ ifneq ($(udevdir),) $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir) endif endif +ifneq ($(libs_build),) $(INSTALL) -m755 -d $(DESTDIR)$(libdir) - $(INSTALL) $(libs) $(DESTDIR)$(libdir) + $(INSTALL) $(libs_build) $(DESTDIR)$(libdir) +ifeq ($(BUILD_SHARED_LIBRARIES),1) cp -d $(lib_links) $(DESTDIR)$(libdir) +endif $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir) +endif ifeq ($(PYTHON_BINDINGS),1) install_python: libbtrfsutil_python diff --git a/Makefile.inc.in b/Makefile.inc.in index 5c8d1297..a86c528e 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -13,6 +13,8 @@ INSTALL = @INSTALL@ DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@ DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@ BUILD_PROGRAMS = @BUILD_PROGRAMS@ +BUILD_SHARED_LIBRARIES = @BUILD_SHARED_LIBRARIES@ +BUILD_STATIC_LIBRARIES = @BUILD_STATIC_LIBRARIES@ BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@ BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@ BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@ diff --git a/configure.ac b/configure.ac index 230f37fa..df02f206 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,20 @@ AC_ARG_ENABLE([programs], AS_IF([test "x$enable_programs" = xyes], [BUILD_PROGRAMS=1], [BUILD_PROGRAMS=0]) AC_SUBST([BUILD_PROGRAMS]) +AC_ARG_ENABLE([shared], + AS_HELP_STRING([--disable-shared], [do not build shared libraries]), + [], [enable_shared=yes] +) +AS_IF([test "x$enable_shared" = xyes], [BUILD_SHARED_LIBRARIES=1], [BUILD_SHARED_LIBRARIES=0]) +AC_SUBST([BUILD_SHARED_LIBRARIES]) + +AC_ARG_ENABLE([static], + AS_HELP_STRING([--disable-static], [do not build static libraries]), + [], [enable_static=yes] +) +AS_IF([test "x$enable_static" = xyes], [BUILD_STATIC_LIBRARIES=1], [BUILD_STATIC_LIBRARIES=0]) +AC_SUBST([BUILD_STATIC_LIBRARIES]) + AC_ARG_ENABLE([convert], AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]), [], [enable_convert=$enable_programs] @@ -222,7 +236,7 @@ AC_SUBST(BTRFSRESTORE_ZSTD) AC_ARG_ENABLE([python], AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]), - [], [enable_python=yes] + [], [enable_python=$enable_shared] ) if test "x$enable_python" = xyes; then @@ -285,6 +299,8 @@ AC_MSG_RESULT([ ldflags:${LDFLAGS} programs: ${enable_programs} + shared libraries: ${enable_shared} + static libraries: ${enable_static} documentation: ${enable_documentation} doc generator: ${ASCIIDOC_TOOL} backtrace support: ${enable_backtrace} -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/2] btrfs-progs: add --disable-programs
From: Omar Sandoval We have a build system internally which only needs to build and install the libraries out of a repository, not any binaries. There's no easy way to do this in btrfs-progs currently. Add --disable-programs to ./configure to support this. Signed-off-by: Omar Sandoval --- Makefile| 43 ++- Makefile.inc.in | 1 + configure.ac| 10 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index d53f6c1d..24aa8234 100644 --- a/Makefile +++ b/Makefile @@ -207,23 +207,31 @@ endif MAKEOPTS = --no-print-directory Q=$(Q) -# build all by default -progs = $(progs_install) btrfsck btrfs-corrupt-block -# install only selected +# Programs to install. progs_install = btrfs mkfs.btrfs btrfs-map-logical btrfs-image \ - btrfs-find-root btrfstune \ - btrfs-select-super + btrfs-find-root btrfstune btrfs-select-super -# other tools, not built by default -progs_extra = btrfs-fragments +# Programs to build. +progs_build = $(progs_install) btrfsck btrfs-corrupt-block -progs_static = $(foreach p,$(progs),$(p).static) +# All programs. Use := instead of = so that this is expanded before we reassign +# progs_build below. +progs := $(progs_build) btrfs-convert btrfs-fragments ifneq ($(DISABLE_BTRFSCONVERT),1) progs_install += btrfs-convert endif +# Static programs to build. Use := instead of = because `make static` should +# still build everything even if --disable-programs was passed to ./configure. +progs_static := $(foreach p,$(progs_build),$(p).static) + +ifneq ($(BUILD_PROGRAMS),1) +progs_install = +progs_build = +endif + # external libs required by various binaries; for btrfs-foo, # specify btrfs_foo_libs = ; see $($(subst...)) rules below btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2) @@ -234,7 +242,7 @@ cmds_restore_cflags = -DBTRFSRESTORE_ZSTD=$(BTRFSRESTORE_ZSTD) CHECKER_FLAGS += $(btrfs_convert_cflags) # collect values of the variables above -standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs) $(progs_extra,$($(dep))) +standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs,$($(dep))) SUBDIRS = BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) @@ -303,7 +311,7 @@ endif $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \ $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) -all: $(progs) $(libs) $(lib_links) $(BUILDDIRS) +all: $(progs_build) $(libs) $(lib_links) $(BUILDDIRS) ifeq ($(PYTHON_BINDINGS),1) all: libbtrfsutil_python endif @@ -570,9 +578,8 @@ test-build-pre: test-build-real: $(MAKE) $(MAKEOPTS) library-test -$(MAKE) $(MAKEOPTS) library-test.static - $(MAKE) $(MAKEOPTS) -j 8 all + $(MAKE) $(MAKEOPTS) -j 8 $(progs) $(libs) $(lib_links) $(BUILDDIRS) -$(MAKE) $(MAKEOPTS) -j 8 static - $(MAKE) $(MAKEOPTS) -j 8 $(progs_extra) manpages: $(Q)$(MAKE) $(MAKEOPTS) -C Documentation @@ -604,7 +611,7 @@ clean: $(CLEANDIRS) mktables btrfs.static mkfs.btrfs.static fssum \ $(check_defs) \ $(libs) $(lib_links) \ - $(progs_static) $(progs_extra) \ + $(progs_static) \ libbtrfsutil/*.o libbtrfsutil/*.o.d ifeq ($(PYTHON_BINDINGS),1) $(Q)cd libbtrfsutil/python; \ @@ -629,21 +636,23 @@ $(CLEANDIRS): $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean install: $(libs) $(progs_install) $(INSTALLDIRS) +ifeq ($(BUILD_PROGRAMS),1) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs_install) $(DESTDIR)$(bindir) $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir) # btrfsck is a link to btrfs in the src tree, make it so for installed file as well $(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck +ifneq ($(udevdir),) + $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir) + $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir) +endif +endif $(INSTALL) -m755 -d $(DESTDIR)$(libdir) $(INSTALL) $(libs) $(DESTDIR)$(libdir) cp -d $(lib_links) $(DESTDIR)$(libdir) $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir) -ifneq ($(udevdir),) - $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir) - $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir) -endif ifeq ($(PYTHON_BINDINGS),1) install_python: libbtrfsutil_python diff --git a/Makefile.inc.in b/Makefile.inc.in index fb324614..5c8d1297 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -12,6 +12,7 @@ RMDIR = @RMDIR@ INSTALL = @INSTALL@ DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@ DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@ +BUILD_PROGRAMS = @BUILD_PROGRAMS@ BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@ BTRF
[PATCH v2 0/2] btrfs-progs: build improvements
From: Omar Sandoval Hi, Dave, Here's v2 of "btrfs-progs: make all programs and libraries optional", this time much less overkill. Now, it's just --disable-programs, --disable-shared, and --disable-static. Based on your devel branch. Please consider these for the next progs release. Thanks! Omar Sandoval (2): btrfs-progs: add --disable-programs btrfs-progs: add --disable-shared and --disable-static Makefile| 56 + Makefile.inc.in | 3 +++ configure.ac| 28 +++-- 3 files changed, 67 insertions(+), 20 deletions(-) -- 2.18.0 -- 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: introduce feature to forget a btrfs device
On Thu, Jul 26, 2018 at 12:32 PM, Anand Jain wrote: > Support for a new command 'btrfs dev forget [dev]' is proposed here, > to undo the effects of 'btrfs dev scan [dev]'. For this purpose, > this patch proposes to use ioctl #5 as it was empty. > IOW(BTRFS_IOCTL_MAGIC, 5, ..) > This patch adds new ioctl BTRFS_IOC_FORGET_DEV which can be sent from > the /dev/btrfs-control to forget one or all devices, (devices which are > not mounted) from the btrfs kernel. > > The argument it takes is struct btrfs_ioctl_vol_args, and ::name can be > set to specify the device path. And all unmounted devices can be removed > from the kernel if no device path is provided. > > Again, the devices are removed only if the relevant fsid aren't mounted. And why is the feature needed? What problems does it solve? That is missing from the changelog, no matter how obvious it is to you (or anyone else), it should be mentioned in the changelog. Thanks. > > Signed-off-by: Anand Jain > --- > fs/btrfs/super.c | 3 +++ > fs/btrfs/volumes.c | 9 + > fs/btrfs/volumes.h | 1 + > include/uapi/linux/btrfs.h | 2 ++ > 4 files changed, 15 insertions(+) > > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index 67de3c0fc85b..470a32af474e 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -2244,6 +2244,9 @@ static long btrfs_control_ioctl(struct file *file, > unsigned int cmd, > ret = PTR_ERR_OR_ZERO(device); > mutex_unlock(&uuid_mutex); > break; > + case BTRFS_IOC_FORGET_DEV: > + ret = btrfs_forget_devices(vol->name); > + break; > case BTRFS_IOC_DEVICES_READY: > mutex_lock(&uuid_mutex); > device = btrfs_scan_one_device(vol->name, FMODE_READ, > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 8844904f9009..cd54a926141a 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -1208,6 +1208,15 @@ static int btrfs_read_disk_super(struct block_device > *bdev, u64 bytenr, > return 0; > } > > +int btrfs_forget_devices(const char *path) > +{ > + mutex_lock(&uuid_mutex); > + btrfs_free_stale_devices(strlen(path) ? path:NULL, NULL); > + mutex_unlock(&uuid_mutex); > + > + return 0; > +} > + > /* > * Look for a btrfs signature on a device. This may be called out of the > mount path > * and we are not allowed to call set_blocksize during the scan. The > superblock > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > index 049619176831..1602b5faa7e7 100644 > --- a/fs/btrfs/volumes.h > +++ b/fs/btrfs/volumes.h > @@ -405,6 +405,7 @@ int btrfs_open_devices(struct btrfs_fs_devices > *fs_devices, >fmode_t flags, void *holder); > struct btrfs_device *btrfs_scan_one_device(const char *path, >fmode_t flags, void *holder); > +int btrfs_forget_devices(const char *path); > int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); > void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step); > void btrfs_assign_next_active_device(struct btrfs_device *device, > diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h > index 5ca1d21fc4a7..b1be7f828cb4 100644 > --- a/include/uapi/linux/btrfs.h > +++ b/include/uapi/linux/btrfs.h > @@ -836,6 +836,8 @@ enum btrfs_err_code { >struct btrfs_ioctl_vol_args) > #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ >struct btrfs_ioctl_vol_args) > +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ > + struct btrfs_ioctl_vol_args) > /* trans start and trans end are dangerous, and only for > * use by applications that know how to avoid the > * resulting deadlocks > -- > 2.7.0 > > -- > 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 -- Filipe David Manana, “Whether you think you can, or you think you can't — you're right.” -- 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: qgroup: Auto kick in rescan if qgroup tree is initialized without rescan initialized
On 2018年07月26日 14:59, Qu Wenruo wrote: > Under certain case, btrfs/166 could cause power loss just after quota > tree initialized but rescan not kicked in. > > In this case, since flags of qgroup status item is just ON | > INCONSISTENT, without RESCAN flag, rescan won't be kicked in in next > mount. > > Now kick in rescan automatically for such situation, so user won't need > to do rescan manually. Please ignore this patch, as just suggested by Misono, it's addressed by later patch "btrfs: qgroup: Init flags with RESCAN bit at quota enable time". Thanks, Qu > > Signed-off-by: Qu Wenruo > --- > fs/btrfs/qgroup.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index c25dc47210a3..e62598fc354f 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -392,6 +392,17 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info > *fs_info) > fs_info->qgroup_flags = btrfs_qgroup_status_flags(l, > ptr); > rescan_progress = btrfs_qgroup_status_rescan(l, ptr); > + > + /* > + * Qgroup is enabled but rescan hans't kicked in and > + * power loss happened, kick rescan in > + */ > + if (rescan_progress == 0 && > + (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | > + BTRFS_QGROUP_STATUS_FLAG_ON) == > + fs_info->qgroup_flags) > + fs_info->qgroup_flags |= > + BTRFS_QGROUP_STATUS_FLAG_RESCAN; > goto next1; > } > > signature.asc Description: OpenPGP digital signature
[PATCH] btrfs: introduce feature to forget a btrfs device
Support for a new command 'btrfs dev forget [dev]' is proposed here, to undo the effects of 'btrfs dev scan [dev]'. For this purpose, this patch proposes to use ioctl #5 as it was empty. IOW(BTRFS_IOCTL_MAGIC, 5, ..) This patch adds new ioctl BTRFS_IOC_FORGET_DEV which can be sent from the /dev/btrfs-control to forget one or all devices, (devices which are not mounted) from the btrfs kernel. The argument it takes is struct btrfs_ioctl_vol_args, and ::name can be set to specify the device path. And all unmounted devices can be removed from the kernel if no device path is provided. Again, the devices are removed only if the relevant fsid aren't mounted. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 3 +++ fs/btrfs/volumes.c | 9 + fs/btrfs/volumes.h | 1 + include/uapi/linux/btrfs.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 67de3c0fc85b..470a32af474e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2244,6 +2244,9 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ret = PTR_ERR_OR_ZERO(device); mutex_unlock(&uuid_mutex); break; + case BTRFS_IOC_FORGET_DEV: + ret = btrfs_forget_devices(vol->name); + break; case BTRFS_IOC_DEVICES_READY: mutex_lock(&uuid_mutex); device = btrfs_scan_one_device(vol->name, FMODE_READ, diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8844904f9009..cd54a926141a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1208,6 +1208,15 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr, return 0; } +int btrfs_forget_devices(const char *path) +{ + mutex_lock(&uuid_mutex); + btrfs_free_stale_devices(strlen(path) ? path:NULL, NULL); + mutex_unlock(&uuid_mutex); + + return 0; +} + /* * Look for a btrfs signature on a device. This may be called out of the mount path * and we are not allowed to call set_blocksize during the scan. The superblock diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 049619176831..1602b5faa7e7 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -405,6 +405,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fmode_t flags, void *holder); struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, void *holder); +int btrfs_forget_devices(const char *path); int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, int step); void btrfs_assign_next_active_device(struct btrfs_device *device, diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index 5ca1d21fc4a7..b1be7f828cb4 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -836,6 +836,8 @@ enum btrfs_err_code { struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ struct btrfs_ioctl_vol_args) +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ + struct btrfs_ioctl_vol_args) /* trans start and trans end are dangerous, and only for * use by applications that know how to avoid the * resulting deadlocks -- 2.7.0 -- 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: add cli to forget one or all scanned devices
This patch adds cli btrfs device forget [dev] to remove the given device structure in the kernel if the device is unmounted. If no argument is given it shall remove all stale (device which are not mounted) from the kernel. Signed-off-by: Anand Jain --- cmds-device.c | 58 ++ ioctl.h | 2 ++ 2 files changed, 60 insertions(+) diff --git a/cmds-device.c b/cmds-device.c index 86459d1b9564..49cfd4b41adb 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -326,6 +326,63 @@ out: return !!ret; } +static const char * const cmd_device_forget_usage[] = { + "btrfs device forget []", + "Forget a stale device or all stale devices in btrfs.ko", + NULL +}; + +static int btrfs_forget_devices(char *path) +{ + struct btrfs_ioctl_vol_args args; + int ret; + int fd; + + fd = open("/dev/btrfs-control", O_RDWR); + if (fd < 0) + return -errno; + + memset(&args, 0, sizeof(args)); + if (path) + strncpy_null(args.name, path); + ret = ioctl(fd, BTRFS_IOC_FORGET_DEV, &args); + if (ret) + ret = -errno; + close(fd); + return ret; +} + +static int cmd_device_forget(int argc, char **argv) +{ + char *path; + int ret = 0; + + if (check_argc_max(argc - optind, 1)) + usage(cmd_device_forget_usage); + + if (argc == 1) { + ret = btrfs_forget_devices(NULL); + if (ret) + error("Can't forget: %s", strerror(-ret)); + return ret; + } + + path = canonicalize_path(argv[1]); + if (!path) { + error("Could not canonicalize path '%s': %s", + argv[1], strerror(errno)); + return -ENOENT; + } + + ret = btrfs_forget_devices(path); + if (ret) + error("Can't forget '%s': %s", path, strerror(-ret)); + + free(path); + + return ret; +} + static const char * const cmd_device_ready_usage[] = { "btrfs device ready ", "Check device to see if it has all of its devices in cache for mounting", @@ -601,6 +658,7 @@ const struct cmd_group device_cmd_group = { CMD_ALIAS }, { "remove", cmd_device_remove, cmd_device_remove_usage, NULL, 0 }, { "scan", cmd_device_scan, cmd_device_scan_usage, NULL, 0 }, + { "forget", cmd_device_forget, cmd_device_forget_usage, NULL, 0 }, { "ready", cmd_device_ready, cmd_device_ready_usage, NULL, 0 }, { "stats", cmd_device_stats, cmd_device_stats_usage, NULL, 0 }, { "usage", cmd_device_usage, diff --git a/ioctl.h b/ioctl.h index 709e996f401c..e27d80e09392 100644 --- a/ioctl.h +++ b/ioctl.h @@ -721,6 +721,8 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ struct btrfs_ioctl_vol_args) +#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ + struct btrfs_ioctl_vol_args) /* trans start and trans end are dangerous, and only for * use by applications that know how to avoid the * resulting deadlocks -- 2.7.0 -- 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 RESEND v7] Add cli and ioctl to forget scanned device(s)
[based on latest misc-next] v7: Use struct btrfs_ioctl_vol_args (instead of struct btrfs_ioctl_vol_args_v2) as its inline with other ioctl btrfs-control The CLI usage remains same. However internally the ioctl flag is not required to delete all the unmounted devices. Instead leave btrfs_ioctl_vol_args::name NULL. v6: Use the changed fn name btrfs_free_stale_devices(). Change in title: Old v5: Cover-letter: [PATCH v5] Add cli and ioctl to ignore a scanned device Kernel: [PATCH v5] btrfs: introduce feature to ignore a btrfs device Progs: [PATCH v5] btrfs-progs: add 'btrfs device ignore' cli v5: Adds feature to delete all stale devices Reuses btrfs_free_stale_devices() fn and so depends on the patch-set [1] in the ML. Uses struct btrfs_ioctl_vol_args_v2 instead of struct btrfs_ioctl_vol_args as arg Does the device path matching instead of btrfs_device matching (we won't delete the mounted device as btrfs_free_stale_devices() checks for it) v4: No change. But as the ML thread may be confusing, so resend. v3: No change. Send to correct ML. v2: Accepts review from Nikolay, details are in the specific patch. Patch 1/2 is renamed from [PATCH 1/2] btrfs: refactor btrfs_free_stale_device() to get device list delete to [PATCH 1/2] btrfs: add function to device list delete Adds cli and ioctl to forget a scanned device or forget all stale devices in the kernel. Anand Jain (1): btrfs: introduce feature to forget a btrfs device fs/btrfs/super.c | 3 +++ fs/btrfs/volumes.c | 9 + fs/btrfs/volumes.h | 1 + include/uapi/linux/btrfs.h | 2 ++ 4 files changed, 15 insertions(+) Anand Jain (1): btrfs-progs: add cli to forget one or all scanned devices cmds-device.c | 58 ++ ioctl.h | 2 ++ 2 files changed, 60 insertions(+) -- 2.7.0 -- 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: qgroup: Init flags with RESCAN bit at quota enable time
Between btrfs_quota_enable() finished and rescan kicked in, there is a small window that quota status has (ON | INCONSISTENT) bits set but without RESCAN bits set. And transaction is committed inside the window and then power loss happens, we will have a quota tree with all qgroup numbers set to 0, and not RESCAN bit set. At next mount time, qgroup rescan will not kick in due to the missing of RESCAN bit, user needs to kick in rescan manually. This patch will fix it by setting RESCAN bit at btrfs_quota_enable(), so even after power loss we will still kick in rescan automatically. Suggested-by: Misono Tomohiro Signed-off-by: Qu Wenruo --- fs/btrfs/qgroup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index c25dc47210a3..13c1c7dd278d 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -930,7 +930,8 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, btrfs_set_qgroup_status_generation(leaf, ptr, trans->transid); btrfs_set_qgroup_status_version(leaf, ptr, BTRFS_QGROUP_STATUS_VERSION); fs_info->qgroup_flags = BTRFS_QGROUP_STATUS_FLAG_ON | - BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | + BTRFS_QGROUP_STATUS_FLAG_RESCAN; btrfs_set_qgroup_status_flags(leaf, ptr, fs_info->qgroup_flags); btrfs_set_qgroup_status_rescan(leaf, ptr, 0); @@ -987,7 +988,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, fs_info->quota_root = quota_root; set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); spin_unlock(&fs_info->qgroup_lock); - ret = qgroup_rescan_init(fs_info, 0, 1); + ret = qgroup_rescan_init(fs_info, 0, 0); if (!ret) { qgroup_rescan_zero_tracking(fs_info); btrfs_queue_work(fs_info->qgroup_rescan_workers, -- 2.18.0 -- 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: qgroup: Auto kick in rescan if qgroup tree is initialized without rescan initialized
On 2018年07月26日 15:21, Misono Tomohiro wrote: > On 2018/07/26 15:59, Qu Wenruo wrote: >> Under certain case, btrfs/166 could cause power loss just after quota >> tree initialized but rescan not kicked in. >> >> In this case, since flags of qgroup status item is just ON | >> INCONSISTENT, without RESCAN flag, rescan won't be kicked in in next >> mount. >> >> Now kick in rescan automatically for such situation, so user won't need >> to do rescan manually. > > How about setting all of BTRFS_QGROUP_STATUS_FLAG_ON/INCONSISTENT/RESCAN > at first place and calling qgroup_rescan_init(fs_info, 0, 0) > (currently it is (fs_info, 0, 1)) in btrfs_quota_enable()? I'm wondering if there will any race window between we set RESCAN flag and we really kick in rescan. But the idea looks doable and I'll look into it. > > I think with this approach, current btrfs-progs can work as expected too. In theory, we still need to fix btrfs check/kernel since we may need to handle old fs. But since it's pretty rare, I think if we could fix kernel using the idea you purposed, it would be enough for this case. Thanks, Qu > >> >> Signed-off-by: Qu Wenruo >> --- >> fs/btrfs/qgroup.c | 11 +++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c >> index c25dc47210a3..e62598fc354f 100644 >> --- a/fs/btrfs/qgroup.c >> +++ b/fs/btrfs/qgroup.c >> @@ -392,6 +392,17 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info >> *fs_info) >> fs_info->qgroup_flags = btrfs_qgroup_status_flags(l, >>ptr); >> rescan_progress = btrfs_qgroup_status_rescan(l, ptr); >> + >> +/* >> + * Qgroup is enabled but rescan hans't kicked in and >> + * power loss happened, kick rescan in >> + */ >> +if (rescan_progress == 0 && >> +(BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | >> + BTRFS_QGROUP_STATUS_FLAG_ON) == >> +fs_info->qgroup_flags) >> +fs_info->qgroup_flags |= >> +BTRFS_QGROUP_STATUS_FLAG_RESCAN; >> goto next1; >> } >> >> > > -- > 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 > signature.asc Description: OpenPGP digital signature
Re: [PATCH] btrfs: qgroup: Auto kick in rescan if qgroup tree is initialized without rescan initialized
On 2018/07/26 15:59, Qu Wenruo wrote: > Under certain case, btrfs/166 could cause power loss just after quota > tree initialized but rescan not kicked in. > > In this case, since flags of qgroup status item is just ON | > INCONSISTENT, without RESCAN flag, rescan won't be kicked in in next > mount. > > Now kick in rescan automatically for such situation, so user won't need > to do rescan manually. How about setting all of BTRFS_QGROUP_STATUS_FLAG_ON/INCONSISTENT/RESCAN at first place and calling qgroup_rescan_init(fs_info, 0, 0) (currently it is (fs_info, 0, 1)) in btrfs_quota_enable()? I think with this approach, current btrfs-progs can work as expected too. > > Signed-off-by: Qu Wenruo > --- > fs/btrfs/qgroup.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index c25dc47210a3..e62598fc354f 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -392,6 +392,17 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info > *fs_info) > fs_info->qgroup_flags = btrfs_qgroup_status_flags(l, > ptr); > rescan_progress = btrfs_qgroup_status_rescan(l, ptr); > + > + /* > + * Qgroup is enabled but rescan hans't kicked in and > + * power loss happened, kick rescan in > + */ > + if (rescan_progress == 0 && > + (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | > + BTRFS_QGROUP_STATUS_FLAG_ON) == > + fs_info->qgroup_flags) > + fs_info->qgroup_flags |= > + BTRFS_QGROUP_STATUS_FLAG_RESCAN; > goto next1; > } > > -- 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