[PATCH] btrfs-progs: add cli to forget one or all scanned devices

2018-08-05 Thread Anand Jain
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

[PATCH] btrfs: introduce feature to forget a btrfs device

2018-08-05 Thread Anand Jain
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

[PATCH] btrfs: handle the BUG_ON in btrfs_num_devices()

2018-08-03 Thread Anand Jain
-by: Nikolay Borisov Signed-off-by: Anand Jain --- Hi, As it fixes the BUG_ON I have spun a new patch for this. Instead of -EINVAL should we use ASSERT? fs/btrfs/volumes.c | 27 --- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs

[PATCH v4 4/4] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-08-03 Thread Anand Jain
will be wrong. Signed-off-by: Anand Jain --- v3->v4: add comment and drop the inline (sorry missed it before) v2->v3: update changelog with not so obvious balance and repalce co-existance secnario v1->v2: add comments fs/btrfs/volumes.c | 38 -- 1 file ch

Re: [PATCH] btrfs: btrfs_shrink_device should call commit transaction

2018-08-03 Thread Anand Jain
On 07/30/2018 10:18 PM, Nikolay Borisov wrote: On 25.07.2018 16:27, Anand Jain wrote: test case btrfs/164 reported UAF.. [ 6712.084324] general protection fault: [#1] PREEMPT SMP :: [ 6712.195423] btrfs_update_commit_device_size+0x75/0xf0 [btrfs] [ 6712.201424

Re: [PATCH] btrfs: revert fs_devices state on error of btrfs_init_new_device()

2018-08-03 Thread Anand Jain
On 08/03/2018 02:36 PM, Anand Jain wrote: On 07/31/2018 07:47 PM, Filipe Manana wrote: On Tue, Jul 31, 2018 at 11:12 AM, Anand Jain wrote: On 07/27/2018 08:04 AM, Naohiro Aota wrote: When btrfs hits error after modifying fs_devices in btrfs_init_new_device

Re: [PATCH] btrfs: revert fs_devices state on error of btrfs_init_new_device()

2018-08-03 Thread Anand Jain
On 07/31/2018 07:47 PM, Filipe Manana wrote: On Tue, Jul 31, 2018 at 11:12 AM, Anand Jain wrote: On 07/27/2018 08:04 AM, Naohiro Aota wrote: When btrfs hits error after modifying fs_devices in btrfs_init_new_device() (such as btrfs_add_dev_item() returns error), it leaves everything

Re: [PATCH v3 4/4] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-08-02 Thread Anand Jain
On 08/02/2018 08:21 PM, David Sterba wrote: On Thu, Aug 02, 2018 at 01:11:40PM +0300, Nikolay Borisov wrote: On 2.08.2018 13:09, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete

Re: [PATCH v2 4/4] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-08-02 Thread Anand Jain
On 08/01/2018 10:41 PM, David Sterba wrote: On Thu, Jul 26, 2018 at 02:53:34PM +0800, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without

[PATCH v3 4/4] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-08-02 Thread Anand Jain
will be wrong. Signed-off-by: Anand Jain --- v2->v3: update changelog with not so obvious balance and repalce co-existance secnario v1->v2: add comments fs/btrfs/volumes.c | 32 ++-- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs

Re: [PATCH v2 2/4] btrfs: fix race between free_stale_devices and close_fs_devices

2018-08-02 Thread Anand Jain
On 08/01/2018 10:29 PM, David Sterba wrote: On Thu, Jul 26, 2018 at 02:53:32PM +0800, Anand Jain wrote: From: Anand Jain %fs_devices can be free-ed by btrfs_free_stale_devices() when the close_fs_devices() drops fs_devices::opened to zero, but close_fs_devices tries to access

Re: [PATCH] btrfs: revert fs_devices state on error of btrfs_init_new_device()

2018-07-31 Thread Anand Jain
On 07/27/2018 08:04 AM, Naohiro Aota wrote: 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

[PATCH] btrfs-progs: add cli to forget one or all scanned devices

2018-07-26 Thread Anand Jain
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

[PATCH] btrfs: introduce feature to forget a btrfs device

2018-07-26 Thread Anand Jain
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

[PATCH v8] Add cli and ioctl to forget scanned device(s)

2018-07-26 Thread Anand Jain
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

Re: Lockdep splat with v4.18.6

2018-07-26 Thread Anand Jain
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

Re: [PATCH] btrfs: introduce feature to forget a btrfs device

2018-07-26 Thread Anand Jain
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

[PATCH] btrfs: introduce feature to forget a btrfs device

2018-07-26 Thread Anand Jain
. 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

[PATCH] btrfs-progs: add cli to forget one or all scanned devices

2018-07-26 Thread Anand Jain
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

[PATCH RESEND v7] Add cli and ioctl to forget scanned device(s)

2018-07-26 Thread Anand Jain
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

[PATCH v4 1/4] btrfs: drop uuid_mutex in btrfs_free_extra_devids()

2018-07-26 Thread Anand Jain
-by: Anand Jain Reviewed-by: David Sterba --- v3->v4: As we traverse through the seed device, fs_device gets updated with the child seed fs_devices, so make sure we use the same fs_devices pointer for the mutex_unlock as used for the mutex_lock. v2->v3: Update chan

[PATCH v2 0/4] Misc volume patch set part2

2018-07-26 Thread Anand Jain
In this set: v1->v2: 1/4 no changes. 2/4 no changes. 3/4 added new. Which shall replace the warn_on with bug_on. As the redundency is after this check. So I decided to keep bug_on for now. 4/4 added comments that btrfs_num_devices() will get num_devices excluding the repalce device. Anand Jain

[PATCH 3/4] btrfs: bug_on for num_devices below 0

2018-07-26 Thread Anand Jain
In preparation to add helper function to deduce the num_devices with replace running, use bug_on instead of warn_on. In btrfs_rm_device() the check for min devices happens in btrfs_check_raid_min_devices() but its after its been decremented so a check here is better. Signed-off-by: Anand Jain

[PATCH v2 2/4] btrfs: fix race between free_stale_devices and close_fs_devices

2018-07-26 Thread Anand Jain
From: Anand Jain %fs_devices can be free-ed by btrfs_free_stale_devices() when the close_fs_devices() drops fs_devices::opened to zero, but close_fs_devices tries to access the %fs_devices again without the device_list_mutex. Fix this by bringing the %fs_devices access

[PATCH v2 4/4] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-26 Thread Anand Jain
When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without the repalce devices, so now the function btrfs_num_devices() just provides that. Signed-off-by: Anand Jain

[PATCH] btrfs: btrfs_shrink_device should call commit transaction

2018-07-25 Thread Anand Jain
ure btrfs_shrink_device() calls the last needed btrfs_commit_transaction() before the return. Signed-off-by: Anand Jain --- I am bit skeptical about the condition when btrfs_commit_transaction() fails, can you pls be wary about it when reviewing. Thanks. Lu/David, As this issues isn't reproducible at my

Re: [PATCH v2 2/2] btrfs: fix missing superblock update in the device delete commit transaction

2018-07-25 Thread Anand Jain
On 07/24/2018 07:01 PM, David Sterba wrote: On Tue, Jul 24, 2018 at 05:28:03PM +0800, Lu Fengqi wrote: I can't reproduce the issue. Do you reproduce consistently? and I Sorry I've taken so long to reply. There are four virtual machines with the different storage backend here. And I can

Re: [PATCH 6/7] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-23 Thread Anand Jain
On 07/23/2018 09:57 PM, David Sterba wrote: On Fri, Jul 20, 2018 at 07:18:54PM +0800, Anand Jain wrote: On 07/19/2018 07:53 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:11PM +0800, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes

Re: [PATCH 5/7] btrfs: warn for num_devices below 0

2018-07-23 Thread Anand Jain
On 07/23/2018 10:01 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:10PM +0800, Anand Jain wrote: In preparation to de-duplicate a section of code where we deduce the num_devices, use warn instead of bug. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1

Re: [PATCH v2 2/2] btrfs: fix missing superblock update in the device delete commit transaction

2018-07-23 Thread Anand Jain
On 07/21/2018 02:01 PM, Lu Fengqi wrote: On Tue, Jul 03, 2018 at 05:07:24PM +0800, Anand Jain wrote: When a device is deleted, the btrfs_super_block::number_devices is reduced by 1, but we do that after the commit transaction, so this change did not made it to the disk and waits for the next

Re: [PATCH 7/7] btrfs: add helper function check device delete able

2018-07-20 Thread Anand Jain
On 07/20/2018 09:34 AM, Anand Jain wrote: On 07/19/2018 07:45 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:12PM +0800, Anand Jain wrote: Move the section of the code which performs the check if the device is indelible, move that into a helper function. Signed-off-by: Anand Jain

Re: [PATCH 6/7] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-20 Thread Anand Jain
On 07/19/2018 07:53 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:11PM +0800, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without

Re: [PATCH 3/7] btrfs: do device clone using the btrfs_scan_one_device

2018-07-20 Thread Anand Jain
On 07/20/2018 02:35 PM, Anand Jain wrote: On 07/19/2018 08:31 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:08PM +0800, Anand Jain wrote: When we add a device to the RO mounted seed device, it becomes a RW sprout FS. The following steps are used to hold the seed and sprout

Re: [bug report] btrfs: add helper function check device delete able

2018-07-20 Thread Anand Jain
Noted. Thanks Dan. -Anand On 07/19/2018 04:10 PM, Dan Carpenter wrote: Hello Anand Jain, The patch a6500c9ef8ac: "btrfs: add helper function check device delete able" from Jul 10, 2018, leads to the following static checker warning: fs/btrfs/volumes.c:1871 btrfs_device_d

Re: [PATCH 3/7] btrfs: do device clone using the btrfs_scan_one_device

2018-07-20 Thread Anand Jain
On 07/19/2018 08:31 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:08PM +0800, Anand Jain wrote: When we add a device to the RO mounted seed device, it becomes a RW sprout FS. The following steps are used to hold the seed and sprout fs_devices. (first two steps are not mandatory

Re: [PATCH 6/7] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-19 Thread Anand Jain
On 07/19/2018 07:53 PM, David Sterba wrote: On Mon, Jul 16, 2018 at 10:58:11PM +0800, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without

[PULL] uuid_mutex fixes and cleanups part2

2018-07-17 Thread Anand Jain
patches. Anand Jain (7): 1. btrfs: drop uuid_mutex in btrfs_free_extra_devids() 2. btrfs: fix race between free_stale_devices and close_fs_devices 3. btrfs: do device clone using the btrfs_scan_one_device 4. btrfs: use the assigned fs_devices instead of the dereference 5. btrfs: warn for num_devices

[PATCH FIXED v7] Add cli and ioctl to forget scanned device(s)

2018-07-17 Thread Anand Jain
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

[PATCH FIXED v7] btrfs: introduce feature to forget a btrfs device

2018-07-17 Thread Anand Jain
. 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

[PATCH FIXED v7] btrfs-progs: add cli to forget one or all scanned devices

2018-07-17 Thread Anand Jain
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

Re: [PATCH v7] Add cli and ioctl to forget scanned device(s)

2018-07-17 Thread Anand Jain
Please ignore this. There is a line of code which is un-commit. I am sending this series again. Sorry for the noise. Thanks, Anand On 07/18/2018 11:07 AM, Anand Jain wrote: v7: Availalbe for pull from btrfs-progs: g...@github.com:asj/btrfs-progs.git forget btrfs.ko: g

[PATCH v7] Add cli and ioctl to forget scanned device(s)

2018-07-17 Thread Anand Jain
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

[PATCH v7] btrfs-progs: add cli to forget one or all scanned devices

2018-07-17 Thread Anand Jain
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

[PATCH v7] btrfs: introduce feature to forget a btrfs device

2018-07-17 Thread Anand Jain
. 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

Re: [PATCH v5 2/2] btrfs: get device pointer from btrfs_scan_one_device

2018-07-16 Thread Anand Jain
:: @@ -1561,12 +1564,15 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, goto error_fs_info; } - error = btrfs_scan_one_device(device_name, mode, fs_type, _devices); - if (error) { + device =

Re: [PATCH 0/7] Misc volume patch set part2

2018-07-16 Thread Anand Jain
On 07/16/2018 10:58 PM, Anand Jain wrote: As the last set if the pull wasn't integrated due to its pending review corrections. Here, I have done them (not much except for adding comments and function renames) and so sending it again. Also this set clubs other independent patches which

Re: [PATCH] btrfs: rename btrfs_parse_early_options

2018-07-16 Thread Anand Jain
On 07/16/2018 10:18 PM, Anand Jain wrote: Rename btrfs_parse_early_options() to btrfs_parse_device_options(). As btrfs_parse_early_options() parses the -o device options and scan the device provided. So this rename specifies its action. Also the function name is inline

[PATCH 7/7] btrfs: add helper function check device delete able

2018-07-16 Thread Anand Jain
Move the section of the code which performs the check if the device is indelible, move that into a helper function. Signed-off-by: Anand Jain --- v1->v2: Rename function to btrfs_get_device_for_delete(), thanks Nikolay. fs/btrfs/volumes.c |

[PATCH 6/7] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-16 Thread Anand Jain
When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without the repalce devices, so now the function btrfs_num_devices() just provides that. Signed-off-by: Anand Jain

[PATCH 4/7] btrfs: use the assigned fs_devices instead of the dereference

2018-07-16 Thread Anand Jain
We have assigned the %fs_info->fs_devices in %fs_devices as its not modified just use it for the mutex_lock(). Signed-off-by: Anand Jain --- I don't see this in the ML at all, I remember sending this. Anyway I am marking this as V1. fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 inserti

[PATCH 5/7] btrfs: warn for num_devices below 0

2018-07-16 Thread Anand Jain
In preparation to de-duplicate a section of code where we deduce the num_devices, use warn instead of bug. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 7f4973fc2b52

[PATCH 3/7] btrfs: do device clone using the btrfs_scan_one_device

2018-07-16 Thread Anand Jain
ice remains scanned after the sprouting. So use the btrfs_scan_one_device() code instead. And do it at the end of the sprouting. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/bt

[PATCH v4 1/7] btrfs: drop uuid_mutex in btrfs_free_extra_devids()

2018-07-16 Thread Anand Jain
-by: Anand Jain Reviewed-by: David Sterba --- v3->v4: As we traverse through the seed device, fs_device gets updated with the child seed fs_devices, so make sure we use the same fs_devices pointer for the mutex_unlock as used for the mutex_lock. v2->v3: Update chan

[PATCH v2 2/7] btrfs: fix race between free_stale_devices and close_fs_devices

2018-07-16 Thread Anand Jain
From: Anand Jain %fs_devices can be free-ed by btrfs_free_stale_devices() when the close_fs_devices() drops fs_devices::opened to zero, but close_fs_devices tries to access the %fs_devices again without the device_list_mutex. Fix this by bringing the %fs_devices access

[PATCH 0/7] Misc volume patch set part2

2018-07-16 Thread Anand Jain
of the individual patches in its change list. And most of it still remains at v1. This can also be pulled from: g...@github.com:asj/btrfs-devel.git misc-next-for-kdave-16jul Anand Jain (7): btrfs: drop uuid_mutex in btrfs_free_extra_devids() btrfs: fix race between free_stale_devices

Re: [PATCH 2nd try v4] btrfs: drop uuid_mutex in btrfs_free_extra_devids()

2018-07-16 Thread Anand Jain
On 05/29/2018 07:19 PM, David Sterba wrote: On Tue, May 29, 2018 at 01:40:34PM +0800, Anand Jain wrote: v3->v4: As we traverse through the seed device, fs_device gets updated with the child seed fs_devices, so make sure we use the same fs_devices pointer for the mutex_unl

[PATCH] btrfs: rename btrfs_parse_early_options

2018-07-16 Thread Anand Jain
-by: Anand Jain --- fs/btrfs/super.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 9d340f8d3457..9dc56d3eaa66 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -465,9 +465,9 @@ int btrfs_parse_options(struct

Re: [PATCH v4 1/2] btrfs: make fs_devices to be a local variable

2018-07-15 Thread Anand Jain
. btrfs_mount_root -> btrfs_parse_early_options ->btrfs_scan_one_device So, there is no necessary to pass fs_devices from btrfs_mount_root, use a local variable in btrfs_parse_early_options is enough. Signed-off-by: Gu Jinxiang Reviewed-by: Anand Jain --- Changel

Re: [PATCH 2/3] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-15 Thread Anand Jain
On 07/13/2018 07:17 PM, Nikolay Borisov wrote: On 13.07.2018 14:17, Anand Jain wrote: On 07/12/2018 03:31 PM, Nikolay Borisov wrote: On 10.07.2018 21:22, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some

Re: [PATCH 3/3] btrfs: add helper function check device delete able

2018-07-15 Thread Anand Jain
On 07/13/2018 07:28 PM, Nikolay Borisov wrote: On 13.07.2018 14:27, Anand Jain wrote: On 07/12/2018 03:43 PM, Nikolay Borisov wrote: On 10.07.2018 21:22, Anand Jain wrote: Move the section of the code which performs the check if the device is indelible, move that into a helper

Re: [PATCH 3/3] btrfs: add helper function check device delete able

2018-07-13 Thread Anand Jain
On 07/12/2018 03:43 PM, Nikolay Borisov wrote: On 10.07.2018 21:22, Anand Jain wrote: Move the section of the code which performs the check if the device is indelible, move that into a helper function. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 49

Re: [PATCH 2/3] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-13 Thread Anand Jain
On 07/12/2018 03:31 PM, Nikolay Borisov wrote: On 10.07.2018 21:22, Anand Jain wrote: When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without the repalce

Re: [PATCH 1/3] btrfs: warn for num_devices below 0

2018-07-13 Thread Anand Jain
On 07/12/2018 03:13 PM, Nikolay Borisov wrote: On 10.07.2018 21:22, Anand Jain wrote: In preparation to de-duplicate a section of code where we deduce the num_devices, use warn instead of bug. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1

Re: [DOC] BTRFS Volume operations, Device Lists and Locks all in one page

2018-07-13 Thread Anand Jain
On 07/13/2018 01:39 PM, Qu Wenruo wrote: On 2018年07月13日 13:32, Anand Jain wrote: But if you are planning to    record and start at transaction [14] then its an overkill because    transaction [19 and [20] are already in the disk. Yes, I'm doing it overkilled.  Ah. Ok

Re: [DOC] BTRFS Volume operations, Device Lists and Locks all in one page

2018-07-12 Thread Anand Jain
But if you are planning to   record and start at transaction [14] then its an overkill because   transaction [19 and [20] are already in the disk. Yes, I'm doing it overkilled. Ah. Ok. But it's already much better than scrub all block groups (my original plan). That's true.

Re: [DOC] BTRFS Volume operations, Device Lists and Locks all in one page

2018-07-12 Thread Anand Jain
On 07/12/2018 08:59 PM, Qu Wenruo wrote: On 2018年07月12日 20:33, Anand Jain wrote: On 07/12/2018 01:43 PM, Qu Wenruo wrote: On 2018年07月11日 15:50, Anand Jain wrote: BTRFS Volume operations, Device Lists and Locks all in one page: Devices are managed in two contexts, the scan context

Re: [DOC] BTRFS Volume operations, Device Lists and Locks all in one page

2018-07-12 Thread Anand Jain
On 07/12/2018 01:43 PM, Qu Wenruo wrote: On 2018年07月11日 15:50, Anand Jain wrote: BTRFS Volume operations, Device Lists and Locks all in one page: Devices are managed in two contexts, the scan context and the mounted context. In scan context the threads originate from the btrfs_control

Re: [PATCH v3 2/2] btrfs: get fs_devices pointer form btrfs_scan_one_device

2018-07-11 Thread Anand Jain
On 07/11/2018 09:22 AM, Gu Jinxiang wrote: Instead of pointer to btrfs_fs_devices as an arg in btrfs_scan_one_device, better to make it as a return value. Yep this was in the list to fix. However I didn't like the idea to return the btrfs_fs_devices pointer, instead return the btrfs_device

Re: [PATCH v3 1/2] btrfs: make fs_devices to be a local variable

2018-07-11 Thread Anand Jain
. btrfs_mount_root -> btrfs_parse_early_options ->btrfs_scan_one_device So, there is no necessary to pass fs_devices from btrfs_mount_root, use a local variable in btrfs_parse_early_options is enough. Signed-off-by: Gu Jinxiang Other than two nit below. Reviewed-by:

[PULL] volume and uuid_mutex cleanups

2018-07-11 Thread Anand Jain
Hi David, Here I have put together a set of volume related patches which were sent to the ML as independent patches earlier. These have been reviewed and tested. Please pull. g...@github.com:asj/btrfs-devel.git misc-next-for-kdave - [Anand:2] 6049bd5e9694 btrfs: add helper

[DOC] BTRFS Volume operations, Device Lists and Locks all in one page

2018-07-11 Thread Anand Jain
BTRFS Volume operations, Device Lists and Locks all in one page: Devices are managed in two contexts, the scan context and the mounted context. In scan context the threads originate from the btrfs_control ioctl and in the mounted context the threads originates from the mount point ioctl.

lockdep warning is impractical

2018-07-10 Thread Anand Jain
Hi, I can reproduce the below circular locking warning [1] using the test case btrfs/161. It can also be reproduced with 4.1 kernel so its not due to any of the recent patches. And this warning is unreasonable too .. here is why. From [1], Thread #0 is when mounting the sprout device, and

[PATCH] btrfs: do device clone using the btrfs_scan_one_device

2018-07-10 Thread Anand Jain
ice remains scanned after the sprouting. So use the btrfs_scan_one_device() code instead. And do it at the end of the sprouting. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/bt

Re: general protection fault in open_fs_devices

2018-07-10 Thread Anand Jain
#syz test: https://github.com/asj/btrfs-devel.git misc-next On 06/06/2018 09:17 PM, syzbot wrote: Hello, syzbot found the following crash on: HEAD commit:    af6c5d5e01ad Merge branch 'for-4.18' of git://git.kernel.o.. git tree:   upstream console output:

Re: general protection fault in open_fs_devices

2018-07-10 Thread Anand Jain
#syz test: git://g...@github.com:asj/btrfs-devel.git misc-next On 06/06/2018 09:17 PM, syzbot wrote: Hello, syzbot found the following crash on: HEAD commit:    af6c5d5e01ad Merge branch 'for-4.18' of git://git.kernel.o.. git tree:   upstream console output:

[PATCH 2nd try] btrfs: do device clone using the btrfs_scan_one_device

2018-07-10 Thread Anand Jain
ice remains scanned after the sprouting. So use the btrfs_scan_one_device() code instead. And do it at the end of the sprouting. Signed-off-by: Anand Jain --- As I don't this patch in the ML. I am sending this again, with no change. fs/btrfs/volumes.c | 21 - 1 file changed,

[PATCH 1/3] btrfs: warn for num_devices below 0

2018-07-10 Thread Anand Jain
In preparation to de-duplicate a section of code where we deduce the num_devices, use warn instead of bug. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index eb78bb8d1108

[PATCH 3/3] btrfs: add helper function check device delete able

2018-07-10 Thread Anand Jain
Move the section of the code which performs the check if the device is indelible, move that into a helper function. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 49 ++--- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/fs/btrfs

[PATCH 2/3] btrfs: add helper btrfs_num_devices() to deduce num_devices

2018-07-10 Thread Anand Jain
When the replace is running the fs_devices::num_devices also includes the replace device, however in some operations like device delete and balance it needs the actual num_devices without the repalce devices, so now the function btrfs_num_devices() just provides that. Signed-off-by: Anand Jain

Re: [PATCH 1/2] btrfs: code reorder in btrfs_prepare_sprout

2018-07-10 Thread Anand Jain
On 07/10/2018 06:41 PM, David Sterba wrote: On Mon, Jul 09, 2018 at 04:33:52PM +0800, Anand Jain wrote: No functional change, bring the clone of fs_devices and its operations closer, so that it indicates its purpose. Also add a comment to indicate why we clone the fs_devices. Signed-off

[PATCH 2/2] btrfs: use fs_devices instead of the dereference

2018-07-09 Thread Anand Jain
We have assigned the %fs_info->fs_devices in %fs_devices as its not modified just use it for the mutex_lock(). Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0e92969b1

[PATCH 1/2] btrfs: code reorder in btrfs_prepare_sprout

2018-07-09 Thread Anand Jain
No functional change, bring the clone of fs_devices and its operations closer, so that it indicates its purpose. Also add a comment to indicate why we clone the fs_devices. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 13 - 1 file changed, 8 insertions(+), 5 deletions

[PATCH v2] fstests: btrfs/168 verify device ready after device delete

2018-07-05 Thread Anand Jain
This test case verifies if the device ready return success after the device delete. Signed-off-by: Anand Jain --- v1->v2: use _run_btrfs_util_prog instead of open coding it. tests/btrfs/168 | 68 + tests/btrfs/168.out | 2 ++ tests/bt

Re: [PATCH] fstests: btrfs/168 verify device ready after device delete

2018-07-05 Thread Anand Jain
On 07/06/2018 12:40 PM, Eryu Guan wrote: On Tue, Jul 03, 2018 at 04:47:53PM +0800, Anand Jain wrote: This test case verifies if the device ready return success after the device delete. Signed-off-by: Anand Jain Looks fine to me overall, but I may need some helps from btrfs folks

Re: [PATCH 7/7] btrfs: fix mount and ioctl device scan ioctl race

2018-07-04 Thread Anand Jain
+ceb2606025ec1cc34...@syzkaller.appspotmail.com Signed-off-by: David Sterba As I said, the fsids concurrency scan/mount are coming up on top these patches so.. Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/super.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions

Re: [PATCH 4/7] btrfs: lift uuid_mutex to callers of btrfs_open_devices

2018-07-04 Thread Anand Jain
in the meantime. Signed-off-by: David Sterba Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/super.c | 2 ++ fs/btrfs/volumes.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 735402ed3154..ee82d02f5453 100644 --- a/fs/btrfs

Re: [PATCH 6/7] btrfs: reorder initialization before the mount locks uuid_mutex

2018-07-04 Thread Anand Jain
Signed-off-by: David Sterba Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/super.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index e3324ddf2777..1780eb41f203 100644 --- a/fs/btrfs/super.c +++ b

Re: [PATCH 5/7] btrfs: lift uuid_mutex to callers of btrfs_parse_early_options

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Prepartory work to fix race between mount and device scan. btrfs_parse_early_options calls the device scan from mount and we'll need to let mount completely manage the critical section. Signed-off-by: David Sterba Reviewed-by: Anand Jain

Re: [PATCH 3/7] btrfs: lift uuid_mutex to callers of btrfs_scan_one_device

2018-07-04 Thread Anand Jain
. Signed-off-by: David Sterba Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/super.c | 12 +++- fs/btrfs/volumes.c | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 81107ad49f3a..735402ed3154 100644 --- a/fs

Re: [PATCH 2/7] btrfs: extend critical section when scanning a new device

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: The stale device list removal needs to be protected by device_list_mutex too as this could delete from the list and could race with another list modification and cause crash. The device needs to be fully initialized before it's added to the list so

Re: [PATCH 1/7] btrfs: restore uuid_mutex in btrfs_open_devices

2018-07-04 Thread Anand Jain
es::opened to be consistent with other users of that item. CC: Anand Jain Signed-off-by: David Sterba I am optimize the uuid_mutex for fsids concurrency on top these set of patches, so. Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertion

[PATCH v2 2/2] btrfs: fix missing superblock update in the device delete commit transaction

2018-07-03 Thread Anand Jain
commit transaction. Also align the local variable declarations in the function btrfs_rm_dev_item() Delete a todo comment about transient inconsistent state Signed-off-by: Anand Jain --- v1->v2: Delete a todo comment Refactor btrfs_rm_dev_item to use trans->fs_info and drop fs_info in the ar

[PATCH v2 1/2] btrfs: fix parent in memory total_devices after seed delete

2018-07-03 Thread Anand Jain
updating its corresponding on-disk btrfs_super_block::number_devices value. Signed-off-by: Anand Jain --- v1->v2: no change fs/btrfs/volumes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8b34af7c217c..b5a60ab37a1c 100644 --- a/fs/bt

Re: [PATCH 2/2] btrfs: fix missing superblock update in the device delete commit transaction

2018-07-03 Thread Anand Jain
On 07/03/2018 01:56 PM, Nikolay Borisov wrote: On 3.07.2018 08:12, Anand Jain wrote: When a device is deleted, the btrfs_super_block::number_devices is reduced by 1, but we do that after the commit transaction, so this change did not made it to the disk and waits for the next commit

[PATCH] fstests: btrfs/168 verify device ready after device delete

2018-07-03 Thread Anand Jain
This test case verifies if the device ready return success after the device delete. Signed-off-by: Anand Jain --- tests/btrfs/168 | 68 + tests/btrfs/168.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 71 insertions(+) create

[PATCH 2/2] btrfs: drop devices declare in btrfs_init_new_device()

2018-07-02 Thread Anand Jain
There is only one usage of the declared devices variable, instead use its value directly. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f7fa0ea26e9c..124bd8728c37 100644

[PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device()

2018-07-02 Thread Anand Jain
There are many instances of the %fs_info->fs_devices pointer de-reference, so declare a %fs_devices pointer instead. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/bt

[PATCH RESEND 1/2] btrfs: fix parent in memory total_devices after seed delete

2018-07-02 Thread Anand Jain
updating its corresponding on-disk btrfs_super_block::number_devices value. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5bd6f3a40f9c..6b807b166ca3 100644 --- a/fs/btrfs/volumes.c +++ b/fs

[PATCH 2/2] btrfs: fix missing superblock update in the device delete commit transaction

2018-07-02 Thread Anand Jain
commit transaction. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 38 ++ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6b807b166ca3..18cd73703951 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/vol

Re: [PATCH 3/3] btrfs: fix race between mkfs and mount

2018-06-29 Thread Anand Jain
On 06/29/2018 08:06 PM, David Sterba wrote: On Tue, Jun 26, 2018 at 10:42:32PM +0800, Anand Jain wrote: Last version of the proposed fix is to extend the uuid_mutex over the whole mount callback and use it around calls to btrfs_scan_one_device. That way we'll be sure the mount will always

<    1   2   3   4   5   6   7   8   9   10   >