[PATCH 2/2] btrfs: reset SB MOVED_ON flag for dynamically reappearing missing device

2017-11-12 Thread Anand Jain
-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 4 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ba32e2d73fbe..8bac1cf17048 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -798,6 +798,10 @@ static noinline int device_li

[PATCH 1/2] btrfs: handle volume split brain scenario

2017-11-12 Thread Anand Jain
BTRFS_SUPER_FLAG_VOL_MOVED_ON. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 53 - fs/btrfs/volumes.c | 14 +-- include/uapi/linux/btrfs_tree.h | 1 + 3 files changed, 65 insertions(+), 3 deletions(-) diff --gi

[PATCH 1/2] btrfs: refactor btrfs_free_stale_device() to get device list delete

2017-11-12 Thread Anand Jain
We need to delete a device from the dev_list, so refactor btrfs_free_stale_device() for delete_device_from_list(). Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 27 +-- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/fs

[PATCH] btrfs-progs: add 'btrfs device ignore' cli

2017-11-12 Thread Anand Jain
which is added here. At which it shall report 'Inappropriate ioctl for device'. And will report 'Operation not permitted' on mounted device. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- cmds-device.c | 54 ++ ioctl.h | 2 ++ 2

[PATCH 2/2] btrfs: introduce feature to ignore a btrfs device

2017-11-12 Thread Anand Jain
conditions. This patch proposes to use ioctl #5 as it was empty. IOW(BTRFS_IOCTL_MAGIC, 5, ..) If #5 is reserved for some other purpose, I think I should change this. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 4 +++ fs/btrfs/vol

[PATCH 0/2] Add cli and ioctl to ignore a scanned device

2017-11-12 Thread Anand Jain
Patch 1/2 is preparatory patch to get a function to delete a device from the list. Patch 2/2 adds the ioctl and feature to delete a device from the device list. Anand Jain (2): btrfs: refactor btrfs_free_stale_device() to get device list delete btrfs: introduce feature to ignore a btrfs

[PATCH] btrfs/154: test for device dynamic rescan

2017-11-12 Thread Anand Jain
scanned won't appear in the alloc_list. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- tests/btrfs/154 | 188 tests/btrfs/154.out | 10 +++ tests/btrfs/group | 1 + 3 files changed, 199 insertions(+) create mode 100755 tests

[PATCH] btrfs: handle dynamically reappearing missing device

2017-11-12 Thread Anand Jain
to the device alloc list. So now with this patch, to bring back the missing device user can run, btrfs dev scan Signed-off-by: Anand Jain <anand.j...@oracle.com> --- This patch needs: [PATCH 0/4] factor __btrfs_open_devices() fs/btrfs/volumes.

[PATCH 0/4] factor __btrfs_open_devices()

2017-11-09 Thread Anand Jain
no-functional changes patches, which can be merged together if needed. Anand Jain (4): btrfs: set fs_devices->seed directly btrfs: let variable required be declared inside the loop btrfs: move check for device generation to the last btrfs: factor __btrfs_open_devices() to cre

[PATCH 2/4] btrfs: let variable required be declared inside the loop

2017-11-09 Thread Anand Jain
A preparation patch to create the actual device open in a new function. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ab2f34

[PATCH 3/4] btrfs: move check for device generation to the last

2017-11-09 Thread Anand Jain
No functional changes. This helps to move the entire section into a new function. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ea6e54

[PATCH 4/4] btrfs: factor __btrfs_open_devices() to create btrfs_open_one_device()

2017-11-09 Thread Anand Jain
No functional changes, create btrfs_open_one_device() from __btrfs_open_devices(). This is a preparatory work to add dynamic device scan. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 126 + 1 file chang

[PATCH 1/4] btrfs: set fs_devices->seed directly

2017-11-09 Thread Anand Jain
This is in preparation to move a section of code in __btrfs_open_devices() into a new function so that it can be reused. As we set seeding if any of the device is having SB flag BTRFS_SUPER_FLAG_SEEDING, so do it in the device list loop itself. No functional changes. Signed-off-by: Anand Jain

Re: [PATCH 2/4] Btrfs: fix data corruption in raid6

2017-11-09 Thread Anand Jain
On 11/09/2017 03:53 AM, Liu Bo wrote: On Tue, Nov 07, 2017 at 04:32:55PM +0800, Anand Jain wrote: On 11/02/2017 08:54 AM, Liu Bo wrote: With raid6 profile, btrfs can end up with data corruption by the following steps. Say we have a 5 disks that are set up with raid6 profile, 1) mount

Re: [PATCH 1/4] Btrfs: introduce device flags

2017-11-07 Thread Anand Jain
On 11/02/2017 08:54 AM, Liu Bo wrote: Here we have defined two flags, - Fautly - In_sync Currently only In_sync is in use, it only matters when device serves as part of a raid profile. The flag In_sync is decided when mounting a btrfs and opening a device, by default every device is set with

Re: [PATCH 2/4] Btrfs: fix data corruption in raid6

2017-11-07 Thread Anand Jain
On 11/02/2017 08:54 AM, Liu Bo wrote: With raid6 profile, btrfs can end up with data corruption by the following steps. Say we have a 5 disks that are set up with raid6 profile, 1) mount this btrfs 2) one disk gets pulled out 3) write something to btrfs and sync 4) another disk gets pulled

Re: [PATCH v2] btrfs: cleanup btrfs_async_submit_limit to return the final limit value

2017-11-06 Thread Anand Jain
1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very generic. 2. Consider RAID1 devices at different speed (SSD and iscsi LUN) not too sure if this approach

[PATCH v3] btrfs: cleanup btrfs_async_submit_limit to return the final limit value

2017-11-06 Thread Anand Jain
btrfs_async_submit_limit() will return 256 * 2/3. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: add more change log. v3: don't compute 256 * 2/3. I didn't know compiler will do it anyway, thats nice. So keeping that open coded. And comment removed. fs/btrfs/disk-io.c | 4 ++

Re: [PATCH 5/7] btrfs: btrfs_rm_device() does not need uuid_mutex

2017-11-06 Thread Anand Jain
On 11/07/2017 01:02 AM, David Sterba wrote: On Mon, Nov 06, 2017 at 04:36:16PM +0800, Anand Jain wrote: Signed-off-by: Anand Jain <anand.j...@oracle.com> No changelog at all? Oh. This patch is wrong. I thought I deleted this from my workspace. Now I notice this ended up in the ML

Re: [PATCH 3/7] btrfs: use i_size_read() instead of open code

2017-11-06 Thread Anand Jain
On 11/07/2017 12:52 AM, David Sterba wrote: On Mon, Nov 06, 2017 at 04:36:14PM +0800, Anand Jain wrote: As i_size_read() takes care of 32bit smp or preempt cases as well. Can bdev->bd_inode->i_size change so that we need to use the i_size_read()? My answer is 'no'. Hm. R

[PATCH 1/7] btrfs: optimize use of volume_mutex in btrfs_ioctl_resize()

2017-11-06 Thread Anand Jain
We can push volume_mutex lock further down after the memory operation. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ioctl.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 09c95f

[PATCH 2/7] btrfs: move user provided string checks outside of volume_mutex

2017-11-06 Thread Anand Jain
Do string check for the device's new size before volume_mutex is held. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ioctl.c | 37 +++-- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c

[PATCH 3/7] btrfs: use i_size_read() instead of open code

2017-11-06 Thread Anand Jain
As i_size_read() takes care of 32bit smp or preempt cases as well. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b0465020972a..86e7f5abd740 100644 --

[PATCH 4/7] btrfs: rename btrfs_add_device to btrfs_add_dev_item

2017-11-06 Thread Anand Jain
Function btrfs_add_device() is about adding the device item so rename to reflect that in the function. Similarly we have btrfs_rm_dev_item(). Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs

[PATCH 6/7] btrfs: move volume_mutex into btrfs_init_new_device()

2017-11-06 Thread Anand Jain
By moving the volume_mutex into btrfs_init_new_device() it will be much closer to the items to be protected. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ioctl.c | 2 -- fs/btrfs/volumes.c | 10 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --gi

[PATCH 7/7] btrfs: rename btrfs_init_new_device() to btrfs_add_device()

2017-11-06 Thread Anand Jain
No functional changes this patch renames btrfs_init_new_device() to btrfs_add_device(), so that it matches to the btrfs_rm_device() naming. And further it will help to further cleanup device init part from btrfs_add_device() and btrfs_init_dev_replace(). Signed-off-by: Anand Jain <anan

[PATCH 5/7] btrfs: btrfs_rm_device() does not need uuid_mutex

2017-11-06 Thread Anand Jain
Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 4 1 file changed, 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 2329f429ce40..3d5ed4518f20 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1914,7 +1914,6

[PATCH 0/8] Misc device cleanup patches: part1

2017-11-06 Thread Anand Jain
A miscellaneous device management related cleanup patches. The core objective of this and upcoming patches is to able to have a clear clarity on mutex usages and remove redundant codes. And few good to have fixes. Anand Jain (7): btrfs: optimize use of volume_mutex in btrfs_ioctl_resize

Re: [PATCH 06/11] btrfs: document device locking

2017-11-05 Thread Anand Jain
On 11/03/2017 07:13 PM, Anand Jain wrote: Thanks for writing this. + * - fs_devices::device_list_mutex (per-fs, with RCU) + * + * protects updates to fs_devices::devices, ie. adding and deleting + * + * simple list traversal with read-only actions can be done with RCU + * protection

[PATCH] btrfs: move volume_mutex into the btrfs_rm_device()

2017-11-05 Thread Anand Jain
A cleanup patch no functional change, we hold volume_mutex before calling btrfs_rm_device, so move it into the function itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- David, This patch is based on your workspace/for-next plus your recent patchset '[PATCH 00/11] Device

Re: [PATCH 05/11] btrfs: simplify exit paths in btrfs_init_new_device

2017-11-05 Thread Anand Jain
looks good. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand On 11/01/2017 01:44 AM, David Sterba wrote: Signed-off-by: David Sterba <dste...@suse.com> --- fs/btrfs/volumes.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/vo

Re: [PATCH 06/11] btrfs: document device locking

2017-11-03 Thread Anand Jain
Thanks for writing this. + * - fs_devices::device_list_mutex (per-fs, with RCU) + * + * protects updates to fs_devices::devices, ie. adding and deleting + * + * simple list traversal with read-only actions can be done with RCU + * protection + * + * may be used to exclude some

Re: [PATCH 04/11] btrfs: use free_device where opencoded

2017-11-02 Thread Anand Jain
Looks good. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand On 11/01/2017 01:44 AM, David Sterba wrote: Signed-off-by: David Sterba <dste...@suse.com> --- fs/btrfs/volumes.c | 39 +++ 1 file changed, 11 insertions(+),

Re: [PATCH 01/11] btrfs: add missing device::flush_bio puts

2017-11-02 Thread Anand Jain
), so it at least it's not that easy to hit the leak, but it's still possible through the path that frees stale devices. Fixes: e0ae99941423 ("btrfs: preallocate device flush bio") Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.

[PATCH v3 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-11-02 Thread Anand Jain
This patch maintains consistency of mode in device get and put. And is just a cleanup patch. There isn't any problem that was noticed, so no functional changes. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: commit update v3: commit update fs/btrfs/volumes.c | 16 -

[PATCH v2] btrfs: cleanup btrfs_async_submit_limit to return the final limit value

2017-11-02 Thread Anand Jain
btrfs_async_submit_limit() will return 170 itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- IMO: 1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very gene

Re: [PATCH v2 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-11-01 Thread Anand Jain
On 10/31/2017 10:21 PM, Nikolay Borisov wrote: On 31.10.2017 04:11, Anand Jain wrote: On 10/30/2017 10:39 PM, David Sterba wrote: On Fri, Oct 20, 2017 at 10:07:15PM +0800, Anand Jain wrote: We aren't setting the FMODE_WRITE when initializing btrfs_device structure and when calling

Re: [PATCH] btrfs: cleanup btrfs_async_submit_limit to return the final limit value

2017-11-01 Thread Anand Jain
On 10/31/2017 10:18 PM, Nikolay Borisov wrote: On 31.10.2017 14:59, Anand Jain wrote: btrfs_async_submit_limit() would return the q depth to be 256, however when we are using it we are making it 2/3 times of it. So instead let the function return the final computed value. Signed-off

[PATCH] btrfs: cleanup btrfs_async_submit_limit to return the final limit value

2017-10-31 Thread Anand Jain
btrfs_async_submit_limit() would return the q depth to be 256, however when we are using it we are making it 2/3 times of it. So instead let the function return the final computed value. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 6 -- fs/btrfs/volumes

Re: [PATCH v2 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-10-30 Thread Anand Jain
On 10/30/2017 10:39 PM, David Sterba wrote: On Fri, Oct 20, 2017 at 10:07:15PM +0800, Anand Jain wrote: We aren't setting the FMODE_WRITE when initializing btrfs_device structure and when calling blkdev_put, however we are setting it only when calling blkdev_get_by_path(). But this still

[PATCH v2] btrfs-progs: reserve < 0 return value for errnos

2017-10-27 Thread Anand Jain
btrfs_read_dev_super() returns -1 / -EPERM upon not finding a suitable SB, change that to return -ENOENT instead, which is much closer to the actual possible errors. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: use -ENOENT instead of 1. disk-io.c | 2 +- utils.c | 2 +- vol

Re: [PATCH] btrfs-progs: reserve < 0 return value for errnos

2017-10-27 Thread Anand Jain
On 10/27/2017 04:04 PM, Qu Wenruo wrote: On 2017年10月27日 15:54, Nikolay Borisov wrote: On 27.10.2017 10:31, Anand Jain wrote: btrfs_read_dev_super() returns -1 upon not finding a suitable SB, change that to return 1 instead, so that it can reserve the < 0 values for the er

[PATCH] btrfs-progs: reserve < 0 return value for errnos

2017-10-27 Thread Anand Jain
btrfs_read_dev_super() returns -1 upon not finding a suitable SB, change that to return 1 instead, so that it can reserve the < 0 values for the errno communications. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- An independent patch, not related to any recent patch sent to M

[PATCH] btrfs-progs: when unable to find out fsid of a dev just skip

2017-10-27 Thread Anand Jain
dev_to_fsid() which can fail if the user is not root OR if the device has media errors as well. So skip the seed check altogether if we fail to know the device superblock and thus the fsid. With this now we are able to view the btrfs fi usage when the device is bad. Signed-off-by: Anand Jain <anan

Re: [PATCH 2/2] btrfs-progs: fi: enable fi usage for filesystem top of seed device

2017-10-23 Thread Anand Jain
proach. Since only the size of non-seed devices is matter, fix this by just skipping seed device by checking device's fsid and comparing it to the fsid obtained by FS_INFO ioctl. Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> Reviewed-by: Anand Jain <anand.j.

Re: [PATCH 1/2] btrfs-progs: fi: move dev_to_fsid() to cmds-fi-usage for later use

2017-10-23 Thread Anand Jain
On 10/23/2017 12:44 PM, Misono, Tomohiro wrote: Move dev_to_fsid() from cmds-filesystem.c to cmds-fi-usage.c in order to call it from both "fi show" and "fi usage". Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> Reviewed-by: Anand Jain <anand.j.

[PATCH v2] btrfs: clean up btrfs_dev_stat_inc() usage

2017-10-20 Thread Anand Jain
unction btrfs_dev_stat_inc_and_print() and which can be renamed as needed. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index efaf85dd91b0..d1d8aa226bff 100644 --- a/fs/bt

Re: [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage

2017-10-20 Thread Anand Jain
On 10/20/2017 11:27 PM, David Sterba wrote: On Fri, Oct 20, 2017 at 05:50:59PM +0800, Anand Jain wrote: btrfs_end_bio() is using btrfs_dev_stat_inc() and then btrfs_dev_stat_print_on_error() separately instead use btrfs_dev_stat_inc_and_print() directly. No need to worry about print lines

[PATCH v2 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-10-20 Thread Anand Jain
We aren't setting the FMODE_WRITE when initializing btrfs_device structure and when calling blkdev_put, however we are setting it only when calling blkdev_get_by_path(). Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: Reword commit log. fs/btrfs/volumes.c | 16

Re: [PATCH 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-10-20 Thread Anand Jain
On 10/20/2017 08:26 PM, Nikolay Borisov wrote: On 20.10.2017 13:33, Anand Jain wrote: We aren't saving the fmode_t flags at %struct btrfs_device->mode same as it used to open the device at device replace, so fix that. I think this could use a bit of rewording to better explain w

[PATCH 1/2] btrfs: match btrfs_device->mode same as it used for open

2017-10-20 Thread Anand Jain
We aren't saving the fmode_t flags at %struct btrfs_device->mode same as it used to open the device at device replace, so fix that. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff -

[PATCH 2/2] btrfs: maintain consistent fmode flags for device open

2017-10-20 Thread Anand Jain
Devices opened through replace/add would have FMODE_WRITE | FMODE_EXCL, as compared with devices opened through the mount which will have FMODE_READ | FMODE_WRITE | FMODE_EXCL. So maintain consistency. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 4 ++--

[PATCH] btrfs: clean up btrfs_dev_stat_inc() usage

2017-10-20 Thread Anand Jain
] btrfs: REQ_PREFLUSH does not use btrfs_end_bio() completion callback there isn't any IO which is doing that. This consolidation is a preparatory patch to add device critical error handling in btrfs_dev_stat_inc_and_print() and can be renamed as needed. Signed-off-by: Anand Jain <anan

Re: [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()

2017-10-16 Thread Anand Jain
On 10/16/2017 10:45 PM, David Sterba wrote: On Thu, Oct 12, 2017 at 05:00:41PM +0800, Anand Jain wrote: That was only an extra check to tackle few bugs around this area, now its save to remove it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8 ++

[PATCH v2] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()

2017-10-16 Thread Anand Jain
Use ASSERT instead of BUG_ON. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- V2: Accepts David suggestion to keep the check as ASSERT. Adds more comments to explain the context. fs/btrfs/volumes.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --gi

Re: [PATCH v2 3/3] btrfs-progs: device: add remove missing-all

2017-10-16 Thread Anand Jain
On 10/16/2017 12:35 PM, Misono, Tomohiro wrote: On 2017/10/16 12:30, Anand Jain wrote: On 10/13/2017 01:27 PM, Duncan wrote: Misono, Tomohiro posted on Wed, 11 Oct 2017 11:18:50 +0900 as excerpted: Add 'btrfs remove missing-all' to remove all the missing devices at once for improving

Re: [PATCH v8 1/2] btrfs: introduce device dynamic state transition to failed

2017-10-16 Thread Anand Jain
On 10/14/2017 02:47 AM, Liu Bo wrote: On Tue, Oct 03, 2017 at 11:59:19PM +0800, Anand Jain wrote: From: Anand Jain <anand.j...@oracle.com> This patch provides helper functions to force a device to failed, and we need it for the following reasons, 1) a. It can be reported that devi

Re: [PATCH v8 2/2] btrfs: check device for critical errors and mark failed

2017-10-16 Thread Anand Jain
On 10/14/2017 02:46 AM, Liu Bo wrote: On Sun, Oct 08, 2017 at 10:23:58PM +0800, Anand Jain wrote: On 10/07/2017 07:56 AM, Liu Bo wrote: On Thu, Oct 05, 2017 at 09:56:59PM +0800, Anand Jain wrote: On 10/05/2017 04:11 AM, Liu Bo wrote: On Tue, Oct 03, 2017 at 11:59:20PM +0800, Anand Jain

Re: [PATCH v2] Btrfs: avoid losing data raid profile when deleting a device

2017-10-15 Thread Anand Jain
On 10/14/2017 04:51 AM, Liu Bo wrote: On Wed, Oct 11, 2017 at 10:38:50AM +0300, Nikolay Borisov wrote: On 10.10.2017 20:53, Liu Bo wrote: We've avoided data losing raid profile when doing balance, but it turns out that deleting a device could also result in the same problem This fixes the

Re: [PATCH v2 3/3] btrfs-progs: device: add remove missing-all

2017-10-15 Thread Anand Jain
On 10/13/2017 01:27 PM, Duncan wrote: Misono, Tomohiro posted on Wed, 11 Oct 2017 11:18:50 +0900 as excerpted: Add 'btrfs remove missing-all' to remove all the missing devices at once for improving usability. Example: sudo mkfs.btrfs -f -d raid1 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4

[PATCH] btrfs: use BLK_STS defines where needed

2017-10-13 Thread Anand Jain
At few places we could use BLK_STS_OK and BLK_STS_NOSUPP. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/compression.c | 3 ++- fs/btrfs/inode.c | 4 ++-- fs/btrfs/volumes.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/compressi

Re: [PATCH] btrfs: fix false EIO for missing device

2017-10-13 Thread Anand Jain
- bio->bi_status = BLK_STS_IOERR; + if (atomic_read(>error) > bbio->max_errors) + bio->bi_status = BLK_STS_IOERR; + else + bio->bi_status = 0; Thanks for the fix, I'd prefer BLK_STS_OK rather than 0. With

[PATCH v2] btrfs: fix false EIO for missing device

2017-10-13 Thread Anand Jain
v_nr=0 must be completed so that the below condition is true if (atomic_dec_and_test(>stripes_pending)) { Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Liu Bo <bo.li@oracle.com> --- v2: Use BLK_STS_OK instead of 0. fs/btrfs/volumes.c | 5 - 1 file

[PATCH] btrfs: fix false EIO for missing device

2017-10-13 Thread Anand Jain
v_nr=0 must be completed so that the below condition is true if (atomic_dec_and_test(>stripes_pending)) { Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/

Re: btrfs seed question

2017-10-12 Thread Anand Jain
Not quite. While the seed device is still connected I would like to force some files over to the rw device. The use case is basically a much slower link to a seed device holding significantly more data than we currently need. An example would be a slower iscsi link to the seed device and a

[PATCH] btrfs: fix call to btrfs_end_transaction without a transaction handler

2017-10-12 Thread Anand Jain
In btrfs_init_new_device() when btrfs_attach_transaction() fails we shouldn't call btrfs_end_transaction(). Fix it. Signed-off-by: Anand Jain <anand.j...@oracle.com> Fixes: btrfs: error out if btrfs_attach_transaction() fails --- Hi David, Can you pls squash this changes to the patch

Re: [bug report] btrfs: error out if btrfs_attach_transaction() fails

2017-10-12 Thread Anand Jain
Thanks Dan! You are right. Will fix it. Anand On 10/13/2017 04:39 AM, Dan Carpenter wrote: Hello Anand Jain, The patch 1eea2715ca9b: "btrfs: error out if btrfs_attach_transaction() fails" from Sep 28, 2017, leads to the following static checker warning: fs/btrfs/volu

[PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()

2017-10-12 Thread Anand Jain
That was only an extra check to tackle few bugs around this area, now its save to remove it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c

[PATCH] btrfs: use need_full_stripe() in __btrfs_map_block()

2017-10-12 Thread Anand Jain
A cleanup patch, use need_full_stripe() to replace the open code. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3b3ba1

Re: btrfs seed question

2017-10-11 Thread Anand Jain
On 10/12/2017 08:47 AM, Joseph Dunn wrote: After seeing how btrfs seeds work I wondered if it was possible to push specific files from the seed to the rw device. I know that removing the seed device will flush all the contents over to the rw device, but what about flushing individual files on

Re: [PATCH] Btrfs-progs: do not add stale device into fs_devices

2017-10-11 Thread Anand Jain
On 10/11/2017 05:33 PM, Nikolay Borisov wrote: On 11.10.2017 03:28, Liu Bo wrote: If one of btrfs's devices was pulled out and we've replaced it with a new one, then they have the same uuid. If that device gets reconnected, 'btrfs filesystem show' will show the stale one instead of the new

Re: [PATCH] Btrfs: remove rcu_barrier in btrfs_close_devices

2017-10-11 Thread Anand Jain
On 10/11/2017 02:11 PM, Anand Jain wrote: On 10/11/2017 05:51 AM, Liu Bo wrote: It was introduced because btrfs used to do blkdev_put in a deferred work, now that btrfs has put blkdev in place, this rcu_barrier can be removed. On the 2nd thought, modprobe -r btrfs would still need

Re: [PATCH] Btrfs: free btrfs_device in place

2017-10-11 Thread Anand Jain
On 10/11/2017 05:51 AM, Liu Bo wrote: It's pointless to defer it to a kthread helper as we're not under any special context. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 14 ++-

Re: [PATCH] Btrfs-progs: do not add stale device into fs_devices

2017-10-11 Thread Anand Jain
to not include the stale one, this could confuse users as people may monitor btrfs by running that cli. This does the similar thing to what kernel side has done. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand Signed-off-by: Liu Bo <bo.li@oracle.com> --- vo

Re: [PATCH] Btrfs: remove rcu_barrier in btrfs_close_devices

2017-10-11 Thread Anand Jain
On 10/11/2017 05:51 AM, Liu Bo wrote: It was introduced because btrfs used to do blkdev_put in a deferred work, now that btrfs has put blkdev in place, this rcu_barrier can be removed. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand Signed-off-by: Liu Bo

[PATCH v3 1/4] btrfs: add_missing_dev() should return the actual error

2017-10-10 Thread Anand Jain
add_missing_dev() can return device pointer so that IS_ERR/ PTR_ERR can be used to check for the actual error occurred in the function. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Liu Bo <bo.li@oracle.com> --- v2: add btrfs_err in read_one_dev too v3: fix wro

[PATCH v2.1 1/4] btrfs: add_missing_dev() should return the actual error

2017-10-10 Thread Anand Jain
add_missing_dev() can return device pointer so that IS_ERR/ PTR_ERR can be used to check for the actual error occurred in the function. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 17 - 1 file

[PATCH v2 4/4] btrfs: fix use of error or warning for missing device

2017-10-08 Thread Anand Jain
When device is missing without the -o degraded option then its an error so report it as an error instead of warning. And when -o degraded option is provided, log the missing device as warning. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: Rename from [PATCH 2/2] btrfs: cl

[PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error

2017-10-08 Thread Anand Jain
add_missing_dev() can return device pointer so that IS_ERR/ PTR_ERR can be used to check for the actual error occurred in the function. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: This patch is a split from [PATCH 1/2] btrfs: fix read_one_chunk() return error code fs

[PATCH v2 2/4] btrfs: fix EIO misuse to report missing degraded option

2017-10-08 Thread Anand Jain
EIO is only for the IO failure to the device, avoid it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: This patch is renamed from [PATCH 1/2] btrfs: fix read_one_chunk() return error code fs/btrfs/volumes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[PATCH v2 3/4] btrfs: declare btrfs_report_missing_device() static

2017-10-08 Thread Anand Jain
Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: This patch is a split from [PATCH 2/2] btrfs: clean up btrfs_report_missing_device() usage fs/btrfs/volumes.c | 12 ++-- fs/btrfs/volumes.h | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/fs

Re: [PATCH v8 2/2] btrfs: check device for critical errors and mark failed

2017-10-08 Thread Anand Jain
On 10/07/2017 07:56 AM, Liu Bo wrote: On Thu, Oct 05, 2017 at 09:56:59PM +0800, Anand Jain wrote: On 10/05/2017 04:11 AM, Liu Bo wrote: On Tue, Oct 03, 2017 at 11:59:20PM +0800, Anand Jain wrote: From: Anand Jain <anand.j...@oracle.com> Write and flush errors are critical errors

[PATCH 2/2] btrfs: clean up btrfs_report_missing_device() usage

2017-10-06 Thread Anand Jain
as static. And to print warning, just open code it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 41 +++-- fs/btrfs/volumes.h | 3 --- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs

[PATCH 1/2] btrfs: fix read_one_chunk() return error code

2017-10-06 Thread Anand Jain
EIO is for IO (RW) failures, use correct error return codes at two locations with in read_one_chunk(). Also adds a small cleanup. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 17 ++--- fs/btrfs/volumes.h | 3 +-- 2 files changed, 11 insertions

Re: [PATCH v8 2/2] btrfs: check device for critical errors and mark failed

2017-10-05 Thread Anand Jain
On 10/05/2017 04:11 AM, Liu Bo wrote: On Tue, Oct 03, 2017 at 11:59:20PM +0800, Anand Jain wrote: From: Anand Jain <anand.j...@oracle.com> Write and flush errors are critical errors, upon which the device fd must be closed and marked as failed. Can we defer the job of closing

[PATCH v8.1 2/2] btrfs: mark device failed for write and flush errors

2017-10-05 Thread Anand Jain
to RDONLY. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- This patch is to replace [PATCH v8 2/2] btrfs: check device for critical errors and mark failed fs/btrfs/volumes.h | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h

Re: [PATCH v4] btrfs: Remove received_uuid during received snapshot ro->rw switch

2017-10-05 Thread Anand Jain
On 10/05/2017 04:22 PM, Nikolay Borisov wrote: Currently when a read-only snapshot is received and subsequently its ro property is set to false i.e. switched to rw-mode the received_uuid of that subvol remains intact. However, once the received volume is switched to RW mode we cannot

[PATCH v8 2/2] btrfs: check device for critical errors and mark failed

2017-10-03 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> Write and flush errors are critical errors, upon which the device fd must be closed and marked as failed. There are two type of device close in btrfs, one, close as part of clean up where we shall release the struct btrfs_device and or btrfs_fs_d

[PATCH v8 1/2] btrfs: introduce device dynamic state transition to failed

2017-10-03 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> This patch provides helper functions to force a device to failed, and we need it for the following reasons, 1) a. It can be reported that device has failed when it does and b. Close the device when it goes offline so that blocklayer can cle

[PATCH v8 0/2] [RFC] Introduce device state 'failed'

2017-10-03 Thread Anand Jain
ices then its a split brain scenario where user intervention will be required. On the sysfs part there are patches in the ML which was sent before, I shall be reviving them as well. Thanks, Anand Anand Jain (2): btrfs: introduce device dynamic state transition to failed btrfs: check device for crit

Re: [PATCH] btrfs: take the error path out if btrfs_attach_transaction() fails

2017-09-28 Thread Anand Jain
On 09/27/2017 10:17 PM, David Sterba wrote: On Wed, Sep 27, 2017 at 05:50:52PM +0800, Anand Jain wrote: btrfs_init_new_device() calls btrfs_attach_transaction() to commit sys chunks, however take the error path out if it fails. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs

Re: [PATCH v3 0/2] fix bug in btrfs_init_new_device()

2017-09-28 Thread Anand Jain
On 09/27/2017 10:26 PM, Nikolay Borisov wrote: On 27.09.2017 17:22, David Sterba wrote: On Tue, Sep 26, 2017 at 03:14:27PM +0300, Nikolay Borisov wrote: On 26.09.2017 11:47, Anand Jain wrote: 1/2 fixes a bug which failed to reset writable when sprouting failed 2/2 fixes BUG_ON

[PATCH v4 3/3] btrfs: error out if btrfs_attach_transaction() fails

2017-09-28 Thread Anand Jain
btrfs_init_new_device() calls btrfs_attach_transaction() to commit sys chunks, and it should error out if it fails. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Qu Wenruo <quwenruo.bt...@gmx.com> --- v4: make this patch as part of this set. avoid double mutex

[PATCH v4 2/3] btrfs: fix BUG_ON in btrfs_init_new_device()

2017-09-28 Thread Anand Jain
Instead of BUG_ON return error to the caller. And handle the fail condition by calling the abort transaction and going through the error path. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...@suse.com> --- v4: none; v3: meld this with bt

[PATCH v4 1/3] btrfs: undo writable when sprouting fails

2017-09-28 Thread Anand Jain
When new device is being added to seed FS, seed FS is marked writable, but when we fail to bring in the new device, we missed to undo the writable part. This patch fixes it. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...@suse.com> --- v4: none

Re: [PATCH v3 1/2] btrfs: undo writable when sprouting fails

2017-09-27 Thread Anand Jain
On 09/27/2017 01:49 AM, David Sterba wrote: On Tue, Sep 26, 2017 at 08:57:47PM +0800, Qu Wenruo wrote: On 2017年09月26日 16:41, Anand Jain wrote: When new device is being added to seed FS, seed FS is marked writable, but when we fail to bring in the new device, we missed to undo the writable

[PATCH] btrfs: take the error path out if btrfs_attach_transaction() fails

2017-09-27 Thread Anand Jain
btrfs_init_new_device() calls btrfs_attach_transaction() to commit sys chunks, however take the error path out if it fails. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs

[PATCH v3 2/2] btrfs: fix BUG_ON in btrfs_init_new_device()

2017-09-26 Thread Anand Jain
Instead of BUG_ON return error to the caller. And handle the fail condition by calling the abort transaction and going through the error path. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2: do not consolidate btrfs_abort_transaction() v3: meld 2/3 and 3/3 from v2 fs/btrfs/vol

[PATCH v3 1/2] btrfs: undo writable when sprouting fails

2017-09-26 Thread Anand Jain
When new device is being added to seed FS, seed FS is marked writable, but when we fail to bring in the new device, we missed to undo the writable part. This patch fixes it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v3: none v2: add commit log fs/btrfs/volumes.c | 2 ++

[PATCH v3 0/2] fix bug in btrfs_init_new_device()

2017-09-26 Thread Anand Jain
1/2 fixes a bug which failed to reset writable when sprouting failed 2/2 fixes BUG_ON in btrfs_init_new_device() Anand Jain (2): btrfs: undo writable when sprouting fails btrfs: fix BUG_ON in btrfs_init_new_device() fs/btrfs/volumes.c | 16 +++- 1 file changed, 11 insertions

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