Re: [PATCH 1/2] btrfs: improve balance kernel logs

2018-04-26 Thread Anand Jain
On 04/26/2018 10:51 PM, Nikolay Borisov wrote: On 26.04.2018 11:01, Anand Jain wrote: Kernel logs are very important for the forensic investigations of the issues in general. This patch adds 'balance:' prefix so that it can be easily be searched and uses the block group names instead of its

Re: [PATCH 0/3] enhance btrfs_raid_array[]

2018-04-26 Thread Anand Jain
On 04/26/2018 09:01 PM, David Sterba wrote: On Wed, Apr 25, 2018 at 07:01:41PM +0800, Anand Jain wrote: Cleanup patches as in the individual change log. These patches were sent independently as they aren't related as such, but as I am updating the 1/3 the 2/3 would endup with conflict. So

Re: [PATCH] btrfs: remove unused fs_info parameter

2018-04-26 Thread Anand Jain
On 04/26/2018 03:49 PM, Gu Jinxiang wrote: Since the commit below parameter fs_info in alloc_reloc_control be no used. So remove it. commit c6100a4b4e3d ("Btrfs: replace tree->mapping with tree->private_data") Signed-off-by: Gu Jinxiang <g...@cn.fujitsu.com> Reviewed-b

[PATCH 2/2] btrfs: add balance args info during start and resume

2018-04-26 Thread Anand Jain
Balance args info is an important information to be reviewed on the system under audit. So this patch adds that. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 153 +++-- 1 file changed, 150 insertions(+), 3 del

[PATCH 1/2] btrfs: improve balance kernel logs

2018-04-26 Thread Anand Jain
Kernel logs are very important for the forensic investigations of the issues in general. This patch adds 'balance:' prefix so that it can be easily be searched and uses the block group names instead of its bitmap. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.

[PATCH 0/2] improve balance logs

2018-04-26 Thread Anand Jain
Anand Jain (2): btrfs: improve balance kernel logs btrfs: add balance args info during start and resume fs/btrfs/volumes.c | 185 - 1 file changed, 169 insertions(+), 16 deletions(-) -- 2.7.0 -- To unsubscribe from this list: send

Re: [PATCH] btrfs: Change bit number of BTRFS_FS_BALANCE_RUNNING

2018-04-25 Thread Anand Jain
On 04/25/2018 09:16 PM, David Sterba wrote: On Wed, Apr 25, 2018 at 03:53:29PM +0300, Nikolay Borisov wrote: Commit ddd93ef3b9d6 ("btrfs: track running balance in a simpler way") which introduced this bit assigned it number 17. Unfortunately this bit is already occupied by the

Re: [PATCH v2] btrfs: kill btrfs_raid_type_names[]

2018-04-25 Thread Anand Jain
On 04/25/2018 05:45 PM, David Sterba wrote: On Wed, Apr 25, 2018 at 05:44:13PM +0800, Anand Jain wrote: Add a new member struct btrfs_raid_attr::raid_name so that btrfs_raid_array[] can maintain the name of the raid type, and so we can kill btrfs_raid_type_names[]. Signed-off-by: Anand Jain

[PATCH 2/3] btrfs: kill btrfs_raid_group[]

2018-04-25 Thread Anand Jain
Add a new member struct btrfs_raid_attr::bg_flag so that btrfs_raid_array[] can maintain the bit map flag of the raid type, and so we can kill btrfs_raid_group[]. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 2 +- fs

[PATCH v3 1/3] btrfs: kill btrfs_raid_type_names[]

2018-04-25 Thread Anand Jain
Add a new member struct btrfs_raid_attr::raid_name so that btrfs_raid_array[] can maintain the name of the raid type, and so we can kill btrfs_raid_type_names[]. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Qu Wenruo <w...@suse.com> Reviewed-by: Nikolay Bo

[PATCH 3/3] btrfs: kill btrfs_raid_mindev_error[]

2018-04-25 Thread Anand Jain
-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 24 fs/btrfs/volumes.h | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index de3eea8b393e..14efa98b7183 100644 --- a/fs/btrfs/volumes.c +++ b/fs

[PATCH 0/3] enhance btrfs_raid_array[]

2018-04-25 Thread Anand Jain
and 3/3 from its v1. Anand Jain (3): btrfs: kill btrfs_raid_type_names[] btrfs: kill btrfs_raid_group[] btrfs: kill btrfs_raid_mindev_error[] fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 20 +-- fs/btrfs/volumes.c | 54

[PATCH] btrfs: kill btrfs_raid_mindev_error[]

2018-04-25 Thread Anand Jain
-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 24 fs/btrfs/volumes.h | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index de3eea8b393e..14efa98b7183 100644 --- a/fs/btrfs/volumes.c +++ b/fs

[PATCH] btrfs: kill btrfs_raid_group[]

2018-04-25 Thread Anand Jain
Add a new member struct btrfs_raid_attr::bg_flag so that btrfs_raid_array[] can maintain the bit map flag of the raid type, and so we can kill btrfs_raid_group[]. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 2 +- fs

[PATCH v2] btrfs: kill btrfs_raid_type_names[]

2018-04-25 Thread Anand Jain
Add a new member struct btrfs_raid_attr::raid_name so that btrfs_raid_array[] can maintain the name of the raid type, and so we can kill btrfs_raid_type_names[]. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Qu Wenruo <w...@suse.com> Reviewed-by: Nikolay Bo

Re: [PATCH] btrfs: kill btrfs_raid_type_names[]

2018-04-25 Thread Anand Jain
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index ef220d541d4b..2acd32ce1573 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -342,6 +342,7 @@ struct btrfs_raid_attr { int tolerated_failures; /* max tolerated fail devs */ int devs_increment; /* ndevs

[PATCH] btrfs: kill btrfs_raid_type_names[]

2018-04-25 Thread Anand Jain
Add a new member struct btrfs_raid_attr::raid_name so that btrfs_raid_array[] can maintain the name of the raid type, and so we can kill btrfs_raid_type_names[]. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/extent-tree.c | 18 -- fs/btrfs/volumes.c

Re: [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid()

2018-04-20 Thread Anand Jain
On 04/21/2018 10:43 AM, Qu Wenruo wrote: On 2018年04月21日 10:38, Anand Jain wrote: On 04/20/2018 11:15 PM, David Sterba wrote: On Fri, Apr 20, 2018 at 10:32:03PM +0800, Anand Jain wrote: On 04/19/2018 05:38 PM, Qu Wenruo wrote: Although we have already checked incompat flags manually

Re: [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid()

2018-04-20 Thread Anand Jain
On 04/20/2018 11:15 PM, David Sterba wrote: On Fri, Apr 20, 2018 at 10:32:03PM +0800, Anand Jain wrote: On 04/19/2018 05:38 PM, Qu Wenruo wrote: Although we have already checked incompat flags manually before really mounting it, we could still enhance btrfs_check_super_valid() to check

Re: [PATCH 3/3] btrfs: Do super block verification before writing it to disk

2018-04-20 Thread Anand Jain
@@ -3563,6 +3565,12 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors) sb = fs_info->super_for_commit; dev_item = >dev_item; + if (btrfs_check_super_valid(fs_info, sb, -1)) { + btrfs_err(fs_info, + "superblock corruption

Re: [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid()

2018-04-20 Thread Anand Jain
On 04/19/2018 05:38 PM, Qu Wenruo wrote: Although we have already checked incompat flags manually before really mounting it, we could still enhance btrfs_check_super_valid() to check incompat flags for later write time super block validation check. This patch adds such incompat flags check

Re: [PATCH v2 12/16] btrfs: track running balance in a simpler way

2018-04-20 Thread Anand Jain
Ok not that simple, the running status is checked outside of balance_mutex and there's one more assertion that does not expect the balance_ctl to exist: @@ -4031,16 +4032,16 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info) return -ENOTCONN; } -

[PATCH] btrfs: fix BUG trying to resume balance without resume flag

2018-04-20 Thread Anand Jain
in btrfs_resume_balance_async() instead of btrfs_recover_balance(). 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/volumes.c index 66d2ed96aef1..9c29fdca9075

Re: [PATCH v2 15/16] btrfs: use mutex in btrfs_resume_balance_async

2018-04-20 Thread Anand Jain
or ro->rw remount. In the former case, no other user of the balance_ctl exists, in the latter, balance cannot run until the ro/rw transition is finished. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe

Re: [PATCH v2 14/16] btrfs: drop lock parameter from update_ioctl_balance_args and rename

2018-04-20 Thread Anand Jain
ste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 13/16] btrfs: move and comment read-only check in btrfs_cancel_balance

2018-04-20 Thread Anand Jain
On 04/20/2018 12:33 AM, David Sterba wrote: Balance cannot be started on a read-only filesystem and will have to finish/exit before eg. going to read-only via remount. It can be paused as well. btrfs balance pause /btrfs && mount -o remount,ro /dev/sdb /btrfs @@ -4053,15 +4053,20 @@

Re: [PATCH v2 09/16] btrfs: cleanup helpers that reset balance state

2018-04-20 Thread Anand Jain
-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 12/16] btrfs: track running balance in a simpler way

2018-04-20 Thread Anand Jain
On 04/20/2018 12:33 AM, David Sterba wrote: Currently fs_info::balance_running is 0 or 1 and does not use the semantics of atomics. The pause and cancel check for 0, that can happen only after __btrfs_balance exits for whatever reason. Parallel calls to balance ioctl may enter

Re: [PATCH v2 08/16] btrfs: add sanity check when resuming balance after mount

2018-04-20 Thread Anand Jain
document that the paused balance starts here and owns the exclusive op status. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body

Re: [PATCH v2 07/16] btrfs: add proper safety check before resuming dev-replace

2018-04-20 Thread Anand Jain
will be informed. Resolving that manually should be possible by waiting for the other operation to finish or cancel the paused state. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: s

Re: [PATCH v2 06/16] btrfs: move clearing of EXCL_OP out of __cancel_balance

2018-04-20 Thread Anand Jain
On 04/20/2018 12:33 AM, David Sterba wrote: Make the clearning visible in the callers so we can pair it with the test_and_set part. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand --- fs/btrfs/ioctl.c | 2 +

Re: [PATCH RESEND v4 0/4] device_list_add() peparation to add reappearing missing device

2018-04-20 Thread Anand Jain
On 04/20/2018 02:22 PM, Gu, Jinxiang wrote: Hi, I reproduced this using kernel v4.17-rc1. It is not always happens.( occurred times/test times: 1/20) Though it was reported here, its not related to this patch set. Instead its about the send receive. Pls post it as a separate thread so it

[PATCH] fstests: btrfs/011 cleanup the functions

2018-04-19 Thread Anand Jain
Use common helper functions where needed. By doing this it improves code readability and debugging of it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- tests/btrfs/011 | 197 ++-- 1 file changed, 63 insertions(+), 134 deletions(-)

[PATCH] btrfs: update uuid_mutex and device_list_mutex comments

2018-04-18 Thread Anand Jain
Make the uuid_mutex and device_list_mutex comments inline with the changes. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- Hi David, Can you kindly add this patch to the set: 'Review uuid_mutex usage' Thanks, Anand fs/btrfs/volumes.c | 21 + 1 file chan

[PATCH v3] btrfs-progs: dump-tree: add degraded option

2018-04-18 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> btrfs inspect dump-tree picks the disk with the largest generation to read the root tree by scanning for the required devices by default. But in 2 or more disks RAID1/5/6 you may need to know what's in the disks individually, so this option --

[PATCH v2] btrfs: add comment about BTRFS_FS_EXCL_OP

2018-04-18 Thread Anand Jain
Adds comments about BTRFS_FS_EXCL_OP to existing comments about the device locks. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: add more clarity to the comments added. fs/btrfs/volumes.c | 32 1 file changed, 32 insertions(+) diff -

[PATCH] fstests: btrfs/130 make it workable on small systems

2018-04-17 Thread Anand Jain
This test case takes a long time to complete at the default LOAD_FACTOR=1, so reduce the nr_extents to 256, so for larger systems it can still use higher LOAD_FACTOR. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- tests/btrfs/130 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH 1/1] fstests: btrfs/130 fix Invalid argument

2018-04-17 Thread Anand Jain
going into $seqres.full. [1] ba23855cdc8961bbaef1fcad4854d494cdb3afd3 btrfs-progs: send: use splice syscall instead of read/write to transfer buffer Signed-off-by: Anand Jain <anand.j...@oracle.com> --- tests/btrfs/130 | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/btrfs/130 b/

Re: [PATCH] btrfs: Do super block verification before writing it to disk

2018-04-17 Thread Anand Jain
On 04/17/2018 05:58 PM, Qu Wenruo wrote: On 2018年04月17日 17:05, Anand Jain wrote: v3:    Update commit message to show the corruption in details.    Modify the kernel error message to show corruption is detected before    transaction commitment.  Nice. Thanks. more below. @@ -3310,6

Re: [PATCH] btrfs: Do super block verification before writing it to disk

2018-04-17 Thread Anand Jain
v3: Update commit message to show the corruption in details. Modify the kernel error message to show corruption is detected before transaction commitment. Nice. Thanks. more below. @@ -3310,6 +3311,27 @@ static int write_dev_supers(struct btrfs_device *device,

Re: [PATCH] btrfs: Do super block verification before writing it to disk

2018-04-16 Thread Anand Jain
On 04/16/2018 10:02 AM, Qu Wenruo wrote: There are already 2 reports about strangely corrupted super blocks, where csum type and incompat flags get some obvious garbage, but csum still matches and all other vitals are correct. This normally means some kernel memory corruption happens,

[PATCH] btrfs: add comment about BTRFS_FS_EXCL_OP

2018-04-16 Thread Anand Jain
Adds comments about BTRFS_FS_EXCL_OP to existing comments about the device locks. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 16 1 file changed, 16 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3a3912

Re: [PATCH 13/16] btrfs: remove redundant read-only check from btrfs_cancel_balance

2018-04-16 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: Balance cannot be started on a read-only filesystem and will have to finish/exit before eg. going to read-only via remount. Cancelling does not need to check for that. In case the filesystem is forcibly set to read-only after an error, balance will

Re: [PATCH 08/16] btrfs: add sanity check when resuming balance after mount

2018-04-16 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: Replace a WARN_ON with a proper check and message in case something goes really wrong and resumed balance cannot set up its exclusive status. The check is a user friendly assertion, I don't expect to ever happen under normal circumstances. Also

Re: [PATCH v3] fstests: btrfs/159 superblock corruption test case

2018-04-13 Thread Anand Jain
+# Test if the superblock corruption is handled correctly: +# - Test fsid miss-match (csum ok) between primary and copy superblock +# Fixed by the ML patch: +# btrfs: check if the fsid in the primary sb and copy sb are same +# - Test if the mount fails if the primary

Re: [PATCH 11/16] btrfs: kill btrfs_fs_info::volume_mutex

2018-04-12 Thread Anand Jain
@@ -4569,8 +4560,10 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) /* this is either (2) or (3) */ if (!atomic_read(_info->balance_running)) { mutex_unlock(_info->balance_mutex); - if

Re: [PATCH v2] btrfs-progs: dump-tree: add degraded option

2018-04-12 Thread Anand Jain
diff --git a/cmds-inspect-dump-tree.c b/cmds-inspect-dump-tree.c index df44bb635c9c..d2676ce55af7 100644 --- a/cmds-inspect-dump-tree.c +++ b/cmds-inspect-dump-tree.c @@ -198,6 +198,7 @@ const char * const cmd_inspect_dump_tree_usage[] = { "-u|--uuid print only the uuid

[PATCH v2] btrfs-progs: wipe copies of the stale superblock beyond -b size

2018-04-12 Thread Anand Jain
if it's beyond the blockcount. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: zero only the magic of the alien superblock, instead of whole of superblock. And comments updated. Thanks. utils.c | 36 1 file changed, 36 insertions

Re: [PATCH v4 0/7] Superblock read and verify cleanups

2018-04-12 Thread Anand Jain
On 04/10/2018 10:48 PM, David Sterba wrote: On Fri, Mar 30, 2018 at 08:09:16AM +0800, Anand Jain wrote: v3->v4: Update changelog and signoff. Reintroduce explicit check for '-EUCLEAN' at Patch 2/8 and 5/8. v2->v3: Squash 4/8 btrfs: make btrfs_check_super_csum() non

[PATCH 12/15] btrfs: drop uuid_mutex in close_fs_devices()

2018-04-11 Thread Anand Jain
close_fs_devices() closes devices of a given fsid, and it is limited to all the devices of a fsid, so we don't have to hold the global uuid_mutex, instead we need the device_list_mutex as the device state is being changed. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/vol

[PATCH 08/15] btrfs: cleanup btrfs_rm_device() use cur_devices

2018-04-11 Thread Anand Jain
Instead of de-referencing the device->fs_devices use cur_devices which points to the same fs_devices. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/

[PATCH 01/15] btrfs: optimize move uuid_mutex closer to the critical section

2018-04-11 Thread Anand Jain
Move uuid_mutex closer to the exclusion section. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: David Sterba <dste...@suse.com> --- fs/btrfs/volumes.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/vol

[PATCH 06/15] btrfs: cleanup find_device() drop list_head pointer

2018-04-11 Thread Anand Jain
find_device() declares struct list_head *head pointer and used only once, instead just use it directly. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c

[PATCH 11/15] btrfs: drop uuid_mutex in btrfs_open_devices()

2018-04-11 Thread Anand Jain
-by: Anand Jain <anand.j...@oracle.com> --- 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 85948ef12ecf..dfebf8f29916 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1115,7 +1115,7

[PATCH 10/15] btrfs: drop uuid_mutex in btrfs_free_extra_devids()

2018-04-11 Thread Anand Jain
btrfs_free_extra_devids() frees the orphan fsid::devid but its search is limited to btrfs_fs_devices::devices, so we dont need uuid_mutex. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs

[PATCH 14/15] btrfs: drop uuid_mutex in btrfs_destroy_dev_replace_tgtdev()

2018-04-11 Thread Anand Jain
Delete the uuid_mutex lock here as this thread access the btrfs_fs_devices::devices only. And the device_list_mutex lock is already in place. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/volumes.

[PATCH 03/15] btrfs: cleanup __btrfs_open_devices() drop head pointer

2018-04-11 Thread Anand Jain
__btrfs_open_devices() declares struct list_head *head, however head is used only once, instead use btrfs_fs_devices::devices directly. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs

[PATCH 07/15] btrfs: cleanup btrfs_rm_device() promote fs_devices pointer

2018-04-11 Thread Anand Jain
This function uses fs_info::fs_devices number of time, however we declare and use it only at the end, instead do it in the beginning of the function and use it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 13 ++--- 1 file changed, 6 insertions

[PATCH 02/15] btrfs: rename struct btrfs_fs_devices::list

2018-04-11 Thread Anand Jain
btrfs_fs_devices::list is the list of BTRFS fsid in the kernel, a generic name 'list' makes it's search very difficult, rename it to fs_list. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/sysfs.c | 2 +- fs/btrfs/volumes.c | 16 fs/btrfs/volumes.h | 2

[PATCH 13/15] btrfs: drop uuid_mutex in btrfs_dev_replace_finishing()

2018-04-11 Thread Anand Jain
btrfs_dev_replace_finish() updates devices (soruce and target) which are within the btrfs_fs_devices::devices or withint the cloned seed devices (btrfs_fs_devices::seed::devices), so we don't need the global uuid_mutex. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/dev-rep

[PATCH 09/15] btrfs: uuid_mutex in read_chunk_tree, add a comment

2018-04-11 Thread Anand Jain
read_chunk_tree() calls read_one_dev(), but for seed device we have to search the fs_uuids list, so we need the uuid_mutex. Add a comment comment, so that we can improve this part. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 4 1 file changed, 4 inse

[PATCH 04/15] btrfs: rename __btrfs_close_devices to close_fs_devices

2018-04-11 Thread Anand Jain
__btrfs_close_devices() is un-exported, drop the __ prefix and rename it to close_fs_devices(). Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c

[PATCH 05/15] btrfs: rename __btrfs_open_devices to open_fs_devices

2018-04-11 Thread Anand Jain
__btrfs_open_devices() is un-exported drop __ prefix and rename it to open_fs_devices(). 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 ef8578

[PATCH 15/15] btrfs: cleanup btrfs_destroy_dev_replace_tgtdev() localize btrfs_fs_devices

2018-04-11 Thread Anand Jain
Declare a local btrfs_fs_devices pointer to access the same, as there are more than one access to the pointer. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs

[PATCH 0/15] Review uuid_mutex usage

2018-04-11 Thread Anand Jain
that they are inconsistent. Anand Jain (15): btrfs: optimize move uuid_mutex closer to the critical section btrfs: rename struct btrfs_fs_devices::list btrfs: cleanup __btrfs_open_devices() drop head pointer btrfs: rename __btrfs_close_devices to close_fs_devices btrfs: rename __btrfs_open_devices

Re: [PATCH 16/16] btrfs: open code set_balance_control

2018-04-09 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The helper is quite simple and I'd like to see the locking in the caller. Signed-off-by: David Sterba <dste...@suse.com> For the version at: git://github.com/kdave/btrfs-devel dev/remove-volume-mutex Reviewed-by: Anand Jain &l

Re: [PATCH 10/16] btrfs: remove wrong use of volume_mutex from btrfs_dev_replace_start

2018-04-09 Thread Anand Jain
is not held here to protect device lookup, but in this case device replace cannot run in parallel with device removal (due to exclusive op protection), so we don't need further locking here. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com

Re: [PATCH 11/16] btrfs: kill btrfs_fs_info::volume_mutex

2018-04-09 Thread Anand Jain
. > Signed-off-by: David Sterba <dste...@suse.com> Thanks for cleaning volume_mutex. Reviewed-by: Anand Jain <anand.j...@oracle.com> Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kern

Re: [PATCH 10/16] btrfs: remove wrong use of volume_mutex from btrfs_dev_replace_start

2018-04-09 Thread Anand Jain
On 04/09/2018 07:53 PM, David Sterba wrote: On Mon, Apr 09, 2018 at 04:39:03PM +0800, Anand Jain wrote: On 04/04/2018 02:34 AM, David Sterba wrote: The volume mutex does not protect against anything in this case, the comment about scrub is right but not related to locking and looks

Re: [PATCH 10/16] btrfs: remove wrong use of volume_mutex from btrfs_dev_replace_start

2018-04-09 Thread Anand Jain
On 04/09/2018 04:54 PM, Nikolay Borisov wrote: On 9.04.2018 11:39, Anand Jain wrote: On 04/04/2018 02:34 AM, David Sterba wrote: The volume mutex does not protect against anything in this case, the comment about scrub is right but not related to locking and looks confusing. The comment

Re: [PATCH 10/16] btrfs: remove wrong use of volume_mutex from btrfs_dev_replace_start

2018-04-09 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The volume mutex does not protect against anything in this case, the comment about scrub is right but not related to locking and looks confusing. The comment in btrfs_find_device_missing_or_by_path is wrong and confusing too. The device_list_mutex

Re: [PATCH 09/16] btrfs: cleanup helpers that reset balance state

2018-04-09 Thread Anand Jain
-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> A nitpick below. --- fs/btrfs/ioctl.c | 8 fs/btrfs/volumes.c | 27 --- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/b

Re: [PATCH 08/16] btrfs: add sanity check when resuming balance after mount

2018-04-09 Thread Anand Jain
umount). +*/ + if (test_and_set_bit(BTRFS_FS_EXCL_OP, _info->flags)) { + btrfs_err(fs_info, + "cannot set exclusive op status to resume balance"); + return -EINVAL; + } + Reviewed-by: Anand Jain <anand.j...@oracle.com> Than

[PATCH v3] fstests: btrfs/159 superblock corruption test case

2018-04-08 Thread Anand Jain
Verify if the superblock corruption is handled correctly. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v2->v3: Provide the disk to be corrupted as an arg, instead of swapping the devices, so drop mount_opt_minus_args(). 159.out slightly changed. v1->v2: $subject slig

Re: [PATCH v2] fstests: btrfs/159 superblock corruption test case

2018-04-08 Thread Anand Jain
+mount_opt_minus_args() +{ + local nr + local mnt_opt="" + + nr=`_scratch_mount_options | awk '{print NF}'` + if [ $nr -eq 4 ]; then Seems this only works with "scratch_mount_options" returns something like: "-o opt dev mnt" or "-o opt1,opt2 dev mnt" but not "-oopt

Re: [PATCH 07/16] btrfs: add proper safety check before resuming dev-replace

2018-04-07 Thread Anand Jain
On 04/07/2018 02:42 PM, Anand Jain wrote: On 04/04/2018 02:34 AM, David Sterba wrote: The device replace is paused by unmount or read only remount, and resumed on next mount or write remount. The exclusive status should be checked properly as it's a global invariant and we must not allow 2

Re: [PATCH 07/16] btrfs: add proper safety check before resuming dev-replace

2018-04-07 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The device replace is paused by unmount or read only remount, and resumed on next mount or write remount. The exclusive status should be checked properly as it's a global invariant and we must not allow 2 operations run. In this case, the balance

Re: Bad magic on superblock on /dev/sda at 65536

2018-04-06 Thread Anand Jain
First superblock is zero-ed and its not some random corruption, most probably someone else other than btrfs used the disk when it was unmounted? Or if the partition (if any) was changed? or if its a SAN storge hope the LUN wasn't recreated at the storage end. Thanks, Anand On 04/07/2018

Re: [PATCH 06/16] btrfs: move clearing of EXCL_OP out of __cancel_balance

2018-04-05 Thread Anand Jain
@@ -3926,11 +3925,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl, return ret; out: if (bctl->flags & BTRFS_BALANCE_RESUME) - __cancel_balance(fs_info); - else { + reset_balance_state(fs_info); reset_balance_state() is something

Re: [PATCH 05/16] btrfs: move volume_mutex to callers of btrfs_rm_device

2018-04-05 Thread Anand Jain
ex); clear_bit(BTRFS_FS_EXCL_OP, _info->flags); out_drop_write: mnt_drop_write_file(file); Why not memdup_user() be outside of volume_mutex? But not a big deal either. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: send th

Re: [PATCH 04/16] btrfs: move btrfs_init_dev_replace_tgtdev to dev-replace.c and make static

2018-04-05 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The function logically belongs there and there's only a single caller, no need to export it. No code changes. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsu

Re: [PATCH 03/16] btrfs: export and rename free_device

2018-04-05 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The function will be used outside of volumes.c, the allocation btrfs_alloc_device is also exported. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe fr

Re: [PATCH 02/16] btrfs: make success path out of btrfs_init_dev_replace_tgtdev more clear

2018-04-05 Thread Anand Jain
<dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 01/16] btrfs: squeeze btrfs_dev_replace_continue_on_mount to its caller

2018-04-05 Thread Anand Jain
On 04/04/2018 02:34 AM, David Sterba wrote: The function is called once and is fairly small, we can merge it with the caller. Signed-off-by: David Sterba <dste...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: s

Re: [PATCH] btrfs-progs: build: Do not use cp -a to install files

2018-04-05 Thread Anand Jain
maintain the UIDs/GIDs of the user that built the files rather than be owned by root. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org Mor

[PATCH v2] fstests: btrfs/159 superblock corruption test case

2018-04-05 Thread Anand Jain
Verify if the superblock corruption is handled correctly. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: $subject slightly changed Added more info about the test-case Keep the stuff from the ./new btrfs Add mount_opt_minus_args() to get the options (if) set at the co

Re: [PATCH typo-fixed] fstests: btrfs: 159 superblock corruption test case

2018-04-05 Thread Anand Jain
+seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" +status=1 # failure is the default! Please use './new btrfs' to generate new test template, which defines variables like 'tmp' and 'here', these variables may not be used in the test explicitly, but they

[PATCH 1/7] btrfs: cleanup btrfs_check_super_csum() for better code flow

2018-03-29 Thread Anand Jain
We check the %csum_type twice. Drop one. Check for the csum_type and then for the csum. Which also matches with the progs which have better logic. This is preparatory patch to get proper error code from btrfs_check_super_csum(). Signed-off-by: Anand Jain <anand.j...@oracle.com> Re

[PATCH v2 4/7] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Anand Jain
of= seek=274877906944 ibs=1 obs=1 count4K OR apply the btrfs-progs patch btrfs-progs: wipe copies of the stale superblock beyond -b size which shall find and wipe the non overwriting superblock during mkfs. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...

[PATCH v4 0/7] Superblock read and verify cleanups

2018-03-29 Thread Anand Jain
fs_scan_one_device(ioctl-arg-dev only) |_btrfs_read_disk_super() |_read_cache_page_gfp() Anand Jain (7): btrfs: cleanup btrfs_check_super_csum() for better code flow btrfs: return required error from btrfs_check_super_csum btrfs: cleanup btrfs_read_disk_super() to return std error btrfs: check if t

[PATCH v4 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
Return the required -EINVAL and -EUCLEAN from the function btrfs_check_super_csum(). And more the error log into the parent function. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...@suse.com> --- v2->v4: Check for -EUCLEAN in else if v1-&

[PATCH v2 3/7] btrfs: cleanup btrfs_read_disk_super() to return std error

2018-03-29 Thread Anand Jain
The only caller btrfs_scan_one_device() sets -EINVAL for error from btrfs_read_disk_super(), so this patch returns -EINVAL from the latter function. A preparatory patch to add csum check in btrfs_read_disk_super(). Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay B

Re: [PATCH v2 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
@@ -2570,9 +2568,14 @@ int open_ctree(struct super_block *sb, * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). */ - if (btrfs_check_super_csum(fs_info, bh->b_data)) { -

[PATCH v4 5/7] btrfs: verify superblock checksum during scan

2018-03-29 Thread Anand Jain
for the dmesg for errors. mkfs.btrfs -fq /dev/sdc dd if=/dev/urandom of=/dev/sdc ibs=1 obs=1 count=1 seek=67108864 btrfs dev scan /dev/sdc mount /dev/sdc /btrfs Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...@suse.com> --- v3->v4: Upda

[PATCH] btrfs-progs: wipe copies of the stale superblock beyond -b size

2018-03-29 Thread Anand Jain
if it's beyond the blockcount. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- utils.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/utils.c b/utils.c index e9cb3a82fda6..6a9408b06e73 100644 --- a/utils.c +++ b/utils.c @@ -365,6 +365,41

[PATCH 7/7] btrfs: drop the redundant invalidate_bdev()

2018-03-29 Thread Anand Jain
one_super(latest_bdev only) |___bread(latest_bdev) Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1eabcc4bf8d2..55b8a57435a9 100644 --- a/fs/btrfs/disk-io.c +++

[PATCH v3 5/7] btrfs: verify superblock checksum during scan

2018-03-29 Thread Anand Jain
for the dmesg for errors. mkfs.btrfs -fq /dev/sdc dd if=/dev/urandom of=/dev/sdc ibs=1 obs=1 count=1 seek=67108864 btrfs dev scan /dev/sdc mount /dev/sdc /btrfs Signed-off-by: Anand Jain <anand.j...@oracle.com> v3->v2: Also squash 4/8 in here. 4/8: btrfs: make btrfs_check_super_c

[PATCH v2 6/7] btrfs: verify checksum for all devices in mount context

2018-03-29 Thread Anand Jain
ock, by using the btrfs-progs cli. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Nikolay Borisov <nbori...@suse.com> v1->v2: git commit log update. With the call-chain (which I believe will go away in the long term, we need the uuid from the userland not the disk-p

[PATCH v2 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
Return the required -EINVAL and -EUCLEAN from the function btrfs_check_super_csum(). And more the error log into the parent function. Signed-off-by: Anand Jain <anand.j...@oracle.com> v1->v2: Fix commit indent reported by checkpatch.pl Fix pr_err split string --- fs/btrfs/disk-

[PATCH v2 4/7] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Anand Jain
of= seek=274877906944 ibs=1 obs=1 count4K OR apply the btrfs-progs patch btrfs-progs: wipe copies of the stale superblock beyond -b size which shall find and wipe the non overwriting superblock during mkfs. Signed-off-by: Anand Jain <anand.j...@oracle.com> v1->v2: Do an explicit read fo

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