[PATCH 1/5] btrfs: make btrfs_extent_readonly() static

2021-02-10 Thread Anand Jain
btrfs_extent_readonly() is used by can_nocow_extent() in inode.c. So move btrfs_extent_readonly() from extent-tree.c to inode.c and declare it as static. Signed-off-by: Anand Jain --- fs/btrfs/ctree.h | 1 - fs/btrfs/extent-tree.c | 13 - fs/btrfs/inode.c | 13

[PATCH 3/5] btrfs: scrub drop few function declarations

2021-02-10 Thread Anand Jain
Drop function declarations at the beginning of the file scrub.c. These functions are defined before they are used in the same file. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/scrub.c | 8 1 file changed, 8 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs

[PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration

2021-02-10 Thread Anand Jain
Move the static function scrub_checksum_tree_block() before its use in the scrub.c, and drop its declaration. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/scrub.c | 133 +++ 1 file changed, 66 insertions(+), 67 deletions(-) diff

[PATCH 5/5] btrfs: scrub_checksum_data() drop its function declaration

2021-02-10 Thread Anand Jain
Move scrub_checksum_data() before its use, and drop its declaration. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/scrub.c | 61 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c

[RFC][PATCH] btrfs: random read fio test for read policy

2021-02-18 Thread Anand Jain
the result is in the $seqresfull-file. I find tests/btrfs as the placeholder for this test case. As it contains many things which are btrfs specific and didn't fit well under perf. Feedback/suggestions welcome. Signed-off-by: Anand Jain --- tests/btrfs/231

[RFC][PATCH] btrfs: sysfs for chunk layout hint

2021-02-18 Thread Anand Jain
added on top of this when we have a consensus. Signed-off-by: Anand Jain --- This + sequential chunk layout hint (experimental) (patch not yet sent) helped me get consistent performance numbers for read_policy pid. As chunk layout hint is not set at mkfs, a balance after setting the desired chunk l

Re: [RFC][PATCH] btrfs: sysfs for chunk layout hint

2021-02-18 Thread Anand Jain
On 19/02/2021 03:11, Goffredo Baroncelli wrote: On 2/18/21 6:20 PM, Anand Jain wrote: btrfs_chunk_alloc() uses dev_alloc_list to allocate new chunks. The function's stack leading to btrfs_cmp_device_info() sorts the dev_alloc_list in the descending order of unallocated space. This sorting

[PATCH] fstest: random read fio test for read policy

2021-02-22 Thread Anand Jain
study of the read policy performance. I find tests/btrfs as the placeholder for this test case. As it contains many things which are btrfs specific and didn't fit well under perf. Signed-off-by: Anand Jain --- tests/btrfs/231 | 145 tests/

Re: 5.11.0: open ctree failed: devide total_bytes should be at most X but found Y

2021-02-23 Thread Anand Jain
On 24/02/2021 01:35, Johannes Thumshirn wrote: On 23/02/2021 18:20, Steven Davies wrote: On 2021-02-23 14:30, David Sterba wrote: On Tue, Feb 23, 2021 at 09:43:04AM +, Johannes Thumshirn wrote: On 23/02/2021 10:13, Johannes Thumshirn wrote: On 22/02/2021 21:07, Steven Davies wrote: [+

Re: [PATCH 1/4] btrfs: add ioctl BTRFS_IOC_DEV_PROPERTIES.

2021-02-23 Thread Anand Jain
On 23/02/2021 21:53, David Sterba wrote: On Mon, Feb 22, 2021 at 10:19:06PM +0100, Goffredo Baroncelli wrote: From: Goffredo Baroncelli This ioctl is a base for returning / setting information from / to the fields of the btrfs_dev_item object. Please don't add a new ioctl for properties, th

Re: xfstests seems broken on btrfs with multi-dev TEST_DEV

2021-02-24 Thread Anand Jain
On 25/02/2021 05:39, Eric Sandeen wrote: On 2/24/21 10:12 AM, Eric Sandeen wrote: Last week I was curious to just see how btrfs is faring with RAID5 in xfstests, so I set it up for a quick run with devices configured as: Whoops this was supposed to cc: fstests, not fsdevel, sorry. -Eric TES

Re: [PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration

2021-02-24 Thread Anand Jain
On 12/02/2021 22:36, David Sterba wrote: On Wed, Feb 10, 2021 at 09:25:18PM -0800, Anand Jain wrote: Move the static function scrub_checksum_tree_block() before its use in the scrub.c, and drop its declaration. No functional changes. We've rejected patches that move static function w

Re: xfstests seems broken on btrfs with multi-dev TEST_DEV

2021-02-25 Thread Anand Jain
On 25/02/2021 11:18, Qu Wenruo wrote: On 2021/2/25 上午11:15, Eric Sandeen wrote: On 2/24/21 9:13 PM, Qu Wenruo wrote: Now this makes way more sense, Sorry for the earlier mistake. as your previous comment on _btrfs_forget_or_module_reload is completely correct. _btrfs_forget_or_module

Re: [report] lockdep warning when mounting seed device

2021-02-25 Thread Anand Jain
On 25/02/2021 12:39, Su Yue wrote: While playing with seed device(misc/next and v5.11), lockdep complains the following: To reproduce: dev1=/dev/sdb1 dev2=/dev/sdb2 umount /mnt mkfs.btrfs -f $dev1 btrfstune -S 1 $dev1 mount $dev1 /mnt btrfs device add $dev2 /mnt/ -f umount /mnt m

Re: [PATCH] fstests: make sure we rescan all devices after unregistering

2021-02-26 Thread Anand Jain
-by: Eric Sandeen Signed-off-by: Qu Wenruo Reviewed-by: Anand Jain Thanks. --- common/btrfs| 8 tests/btrfs/124 | 2 ++ tests/btrfs/125 | 2 ++ tests/btrfs/163 | 2 ++ tests/btrfs/164 | 2 ++ tests/btrfs/219 | 2 ++ tests/btrfs/225 | 3 +++ 7 files changed, 21 insertions

Re: [report] lockdep warning when mounting seed device

2021-03-02 Thread Anand Jain
On 26/02/2021 23:10, David Sterba wrote: On Fri, Feb 26, 2021 at 01:01:02PM +0800, Anand Jain wrote: On 25/02/2021 12:39, Su Yue wrote: While playing with seed device(misc/next and v5.11), lockdep complains the following: To reproduce: dev1=/dev/sdb1 dev2=/dev/sdb2 umount /mnt mkfs.btrfs

[PATCH v2] btrfs: fix lockdep warning while mounting sprout fs

2021-03-03 Thread Anand Jain
ice_list_mutex in clone_fs_devices(). And adds a lockdep_assert_held(&uuid_mutex) in clone_fs_devices(). Reported-by: Su Yue Signed-off-by: Anand Jain --- v2: Remove Martin's Reported-by and Tested-by. Add Su's Reported-by. Add lockdep_assert_held check. Update the change

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. Whic

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: [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: [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 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 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 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 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

[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 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_unlock

[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
Signed-off-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: U

[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 with in the

[PATCH 0/7] Misc volume patch set part2

2018-07-16 Thread Anand Jain
anges 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_device

[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 in

[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 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 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 |

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 with

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 a

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, &fs_devices); - if (error) { + device = btrfs_scan_one_device(device

[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
ice 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 in

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

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

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 FIXED v7] Add cli and ioctl to forget scanned device(s)

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

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

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

[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

[PULL] uuid_mutex fixes and cleanups part2

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

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

2018-07-19 Thread Anand Jain
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 --- v1->v2: Rename function

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

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

2018-07-19 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 for

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

2018-07-19 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/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: [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 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 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 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 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 the

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 rep

[PATCH] btrfs: btrfs_shrink_device should call commit transaction

2018-07-25 Thread Anand Jain
ng sure 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 rep

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

2018-07-25 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 3/4] btrfs: bug_on for num_devices below 0

2018-07-25 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 v4 1/4] btrfs: drop uuid_mutex in btrfs_free_extra_devids()

2018-07-25 Thread Anand Jain
Signed-off-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: U

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

2018-07-25 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 with in the

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

2018-07-25 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 RESEND v7] Add cli and ioctl to forget scanned device(s)

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

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

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

[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

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 ioct

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 thi

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

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

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

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

[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

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 contai

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 the

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

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

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 and

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

2018-08-02 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 as

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() (such as

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

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

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

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

2018-08-03 Thread Anand Jain
: 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 RESEND v8] Add cli and ioctl to forget scanned device(s)

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

[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
er 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/linu

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

2018-08-06 Thread Anand Jain
On 08/03/2018 09:33 PM, Nikolay Borisov wrote: On 3.08.2018 15:45, Anand Jain wrote: Its a logical bug if we hit fs_devices::num_devices == 1 and if the replace is running because, as fs_devices::num_devices counts the in memory devices, so it should include the replace target which is

[PATCH v2] btrfs: btrfs_shrink_device should call commit transaction

2018-08-06 Thread Anand Jain
ng sure btrfs_shrink_device() calls the last needed btrfs_commit_transaction() before the return. Reported-by: Lu Fengqi Signed-off-by: Anand Jain Tested-by: Lu Fengqi --- v1->v2: cleanup the dirty and new meta block group before ending the transaction when btrfs_update_device fails. fs/btrfs

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

2018-08-07 Thread Anand Jain
On 08/07/2018 11:02 PM, David Sterba wrote: On Thu, Aug 02, 2018 at 09:07:00PM +0800, Anand Jain wrote: - num_devices = fs_devices->num_devices; - btrfs_dev_replace_read_lock(&fs_info->dev_replace); - if (btrfs_dev_replace_is_ongoing(&fs_inf

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

2018-08-07 Thread Anand Jain
On 08/08/2018 01:09 AM, David Sterba wrote: On Mon, Aug 06, 2018 at 04:57:45PM +0800, Anand Jain wrote: On 08/03/2018 09:33 PM, Nikolay Borisov wrote: On 3.08.2018 15:45, Anand Jain wrote: Its a logical bug if we hit fs_devices::num_devices == 1 and if the replace is running because

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

2018-08-07 Thread Anand Jain
On 08/08/2018 01:51 AM, David Sterba wrote: On Mon, Aug 06, 2018 at 09:09:47AM +0800, Anand Jain wrote: Adds cli and ioctl to forget a scanned device or forget all stale devices in the kernel. Please provide more details about your idea of the usecase, ie. how excactly and when the command

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

2018-08-08 Thread Anand Jain
On 08/07/2018 10:59 PM, David Sterba wrote: On Thu, Aug 02, 2018 at 05:29:12PM +0800, Anand Jain wrote: 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

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

2018-08-09 Thread Anand Jain
ecting so much of the concerns about the use of BUG_ON/-EINVAL as its trivial because fundamentally a FS can't be in the mounted state when num_device < 1. Anand Jain (3): btrfs: drop uuid_mutex in btrfs_free_extra_devids() btrfs: assert for num_devices below 0 btrfs: add helper

[PATCH 1/2] btrfs: assert for num_devices below 0

2018-08-09 Thread Anand Jain
In preparation to add helper function to deduce the num_devices with replace running, use assert instead of bug_on and warn_on. 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

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

2018-08-09 Thread Anand Jain
Signed-off-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: U

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

2018-08-09 Thread Anand Jain
calculation will be wrong. Signed-off-by: Anand Jain --- v4->v5: uses assert. 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/vo

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

2018-08-13 Thread Anand Jain
Hi David, Just a gentle ping.. Thanks, Anand On 08/08/2018 07:33 AM, Anand Jain wrote: On 08/08/2018 01:51 AM, David Sterba wrote: On Mon, Aug 06, 2018 at 09:09:47AM +0800, Anand Jain wrote: Adds cli and ioctl to forget a scanned device or forget all stale devices in the kernel

Re: [PATCH 1/2] btrfs: assert for num_devices below 0

2018-08-15 Thread Anand Jain
On 08/15/2018 08:11 PM, David Sterba wrote: On Fri, Aug 10, 2018 at 01:53:20PM +0800, Anand Jain wrote: In preparation to add helper function to deduce the num_devices with replace running, use assert instead of bug_on and warn_on. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 4

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

2018-08-15 Thread Anand Jain
On 08/15/2018 08:20 PM, David Sterba wrote: On Fri, Aug 10, 2018 at 01:53:18PM +0800, Anand Jain wrote: The patch set (2/3 and 3/3) adds helper function to deduce the num_device (which is the number of the devices when device is mounted, this excludes the seed device however includes the

[PATCH] fstests: btrfs/149 make it sectorsize independent

2018-09-04 Thread Anand Jain
. Don't log the md5sum results to the output file as the data size vary by the sectorsize. Signed-off-by: Anand Jain --- common/btrfs| 7 +++ common/filter | 5 + tests/btrfs/149 | 29 - tests/btrfs/149.out | 12 ++-- 4 files change

Re: [PATCH] fstests: btrfs/149 make it sectorsize independent

2018-09-09 Thread anand . jain
On 09/09/2018 11:24 PM, Eryu Guan wrote: On Wed, Sep 05, 2018 at 02:35:12PM +0800, Anand Jain wrote: Originally this test case was designed to work with only 4K sectorsize. Now enhance it to work with any sector sizes and makes the following changes: Output file not to contain any traces of

[PATCH v2] fstests: btrfs/149 make it sectorsize independent

2018-09-09 Thread Anand Jain
. Don't log the md5sum results to the output file as the data size vary by the sectorsize. Signed-off-by: Anand Jain --- v1->v2: rename _scratch_sectorsize() to _scratch_btrfs_sectorsize() add _require_btrfs_command inspect-internal dump-super common/btrfs| 7 +++ commo

<    6   7   8   9   10   11   12   13   14   15   >