Re: fatal database corruption with btrfs "out of space" with ~50 GB left

2018-02-18 Thread Anand Jain
On 02/14/2018 10:19 PM, Tomasz Chmielewski wrote: Just FYI, how dangerous running btrfs can be - we had a fatal, unrecoverable MySQL corruption when btrfs decided to do one of these "I have ~50 GB left, so let's do out of space (and corrupt some files at the same time, ha ha!)". Thanks

[PATCH v2] btrfs: use ASSERT to report logical error in cow_file_range()

2018-02-15 Thread Anand Jain
Use ASSERT to report logical error in cow_file_range(), also move it a bit closer to when the num_bytes is derived. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: ASSERT logic changed. Thanks Nikolay. fs/btrfs/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3

[PATCH RESEND] btrfs: delete function btrfs_close_extra_devices()

2018-02-14 Thread Anand Jain
, delete it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 13 --- fs/btrfs/volumes.c | 63 -- fs/btrfs/volumes.h | 1 - 3 files changed, 77 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/dis

[PATCH] btrfs: use ASSERT to report logical error in cow_file_range()

2018-02-14 Thread Anand Jain
Use ASSERT to report logical error in cow_file_range(), also move it a bit closer to when the num_bytes is derived. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/i

[PATCH v2] btrfs: cow_file_range() num_bytes and disk_num_bytes are same

2018-02-14 Thread Anand Jain
This patch deletes local variable disk_num_bytes as its value is same as num_bytes in the function cow_file_range(). Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Fix conflict. Removed Reviewed-by: David Sterba <dste...@suse.com> as there is a conflict

[PATCH] btrfs: remove unused function btrfs_async_submit_limit()

2018-02-14 Thread Anand Jain
Commit [1] removed the need to use btrfs_async_submit_limit(), so delete it. [1] commit 736cd52e0c720103f52ab9da47b6cc3af6b083f6 Btrfs: remove nr_async_submits and async_submit_draining Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 8 fs/btrfs/dis

Re: [PATCH v2 2/2] btrfs: verify max_inline mount parameter

2018-02-14 Thread Anand Jain
On 02/14/2018 12:28 AM, David Sterba wrote: On Tue, Feb 13, 2018 at 05:49:50PM +0800, Anand Jain wrote: We aren't verifying the parameter passed to the max_inline mount option, so we won't report and fail the mount if a junk value is specified for example, -o max_inline=abc. This patch

Re: [PATCH] btrfs: manage subvolid mount option as %u

2018-02-14 Thread Anand Jain
On 02/14/2018 12:10 AM, David Sterba wrote: On Tue, Feb 13, 2018 at 05:50:43PM +0800, Anand Jain wrote: As -o subvolid mount option is an u64 manage it as %u for token verifications, instead of %s. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.

[PATCH v2] btrfs: fix bare unsigned declarations

2018-02-14 Thread Anand Jain
We have btrfs_fs_info::data_chunk_allocations and btrfs_fs_info::metadata_ratio declared as unsigned which would be unsinged int and kernel style prefers unsigned int over bare unsigned. So this patch changes them to u32. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Upda

[PATCH v2] btrfs: verify subvolid mount parameter

2018-02-14 Thread Anand Jain
We aren't verifying the parameter passed to the subvolid mount option, so we won't report and fail the mount if a junk value is specified for example, -o subvolid=abc. This patch verifies the subvolid option with match_u64. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v

Re: [PATCH v2] btrfs: fix endianness compatibility during the SB RW

2018-02-14 Thread Anand Jain
On 02/14/2018 01:55 AM, David Sterba wrote: On Tue, Feb 13, 2018 at 06:27:13PM +0800, Anand Jain wrote: On 02/13/2018 05:01 PM, Qu Wenruo wrote: On 2018年02月13日 11:00, Anand Jain wrote: Fixes the endianness bug in the fs_info::super_copy by using its btrfs_set_super...() function to set

Re: [PATCH] btrfs: manage thread_pool mount option as %u

2018-02-13 Thread Anand Jain
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 02c7766e6849..8112619cac95 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -346,7 +346,7 @@ static const match_table_t tokens = { {Opt_barrier, "barrier"}, {Opt_max_inline, "max_inline=%u"},

Re: [PATCH v2] btrfs: fix endianness compatibility during the SB RW

2018-02-13 Thread Anand Jain
On 02/13/2018 05:01 PM, Qu Wenruo wrote: On 2018年02月13日 11:00, Anand Jain wrote: Fixes the endianness bug in the fs_info::super_copy by using its btrfs_set_super...() function to set values in the SB, as these functions manage the endianness compatibility nicely. Signed-off-by: Anand Jain

[PATCH] btrfs: manage subvolid mount option as %u

2018-02-13 Thread Anand Jain
As -o subvolid mount option is an u64 manage it as %u for token verifications, instead of %s. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/s

[PATCH] btrfs: manage commit mount option as %u

2018-02-13 Thread Anand Jain
As -o commit mount option is unsinged so manage it as %u for token verifications, instead of %d. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ctree.h | 2 +- fs/btrfs/super.c | 26 ++ 2 files changed, 11 insertions(+), 17 deletions(-) diff --gi

[PATCH] btrfs: manage thread_pool mount option as %u

2018-02-13 Thread Anand Jain
-o thread_pool is alway unsigned. Manage it that way all around. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ctree.h | 2 +- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/super.c | 13 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/c

[PATCH] btrfs: manage check_int_print_mask mount option as %u

2018-02-13 Thread Anand Jain
As -o check_int_print_mask mount option is unsinged so manage it as %u for token verifications, instead of %d. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 16 +--- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/super.c b/fs

[PATCH] btrfs: manage metadata_ratio mount option as %u

2018-02-13 Thread Anand Jain
As -o metadata_ratio mount option is unsinged so manage it as %u for token verifications, instead of %s. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/super.c b/fs

[PATCH] btrfs: fix bare unsigned declarations

2018-02-13 Thread Anand Jain
Kernel style prefers "unsigned int " over "unsigned " and "signed int " over "signed ". Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ctree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs

[PATCH] btrfs: add a comment to mark the deprecated mount option

2018-02-13 Thread Anand Jain
-o alloc_start and -o subvolrootid are deprecated mount options, comment them in the tokens list. And leave them as it is. No functional changes. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --gi

[PATCH v2 1/2] btrfs: declare max_inline as u32

2018-02-13 Thread Anand Jain
As of now btrfs_fs_info::max_line is u64, which can't be larger than btrfs_fs_info::sectorsize which is defined as u32, so make btrfs_fs_info::max_line u32, Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Born in v2. fs/btrfs/ctree.h | 2 +- fs/btrfs/super.c | 8

[PATCH v2 2/2] btrfs: verify max_inline mount parameter

2018-02-13 Thread Anand Jain
We aren't verifying the parameter passed to the max_inline mount option, so we won't report and fail the mount if a junk value is specified for example, -o max_inline=abc. This patch converts the max_inline option to %d and checks if it's a number >= 0. Signed-off-by: Anand Jain <a

Re: [PATCH] btrfs: verify max_inline mount parameter

2018-02-13 Thread Anand Jain
On 02/13/2018 01:13 AM, David Sterba wrote: On Mon, Feb 12, 2018 at 11:35:46PM +0800, Anand Jain wrote: We aren't verifying the parameter passed to the max_inline mount option, so we won't report and fail the mount if a junk value is specified for example, -o max_inline=abc. This patch

[PATCH] btrfs: extent_buffer_uptodate() make it static and inline

2018-02-12 Thread Anand Jain
bss dec hex filename 1131090 82898 18992 1232980 12d054 fs/btrfs/btrfs.ko Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/extent_io.c | 5 - fs/btrfs/extent_io.h | 5 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs

Re: [PATCH] btrfs: fix extent_buffer_uptodate() return

2018-02-12 Thread Anand Jain
On 02/13/2018 12:55 AM, David Sterba wrote: On Mon, Feb 12, 2018 at 11:34:56PM +0800, Anand Jain wrote: extent_buffer_uptodate() returns from test_bit() which is of type bool, so update extent_buffer_uptodate() to it. The return value of test_bit differes by architecture, there are several

[PATCH] btrfs: no need to check if tgt_device is null

2018-02-12 Thread Anand Jain
We don't have to check if tgt_device is null and then delete it, because there wouldn't be a case where tgt_device will be null in a mounted context. If the replacement is already canceled then we won't be here, since there is a switch above to deviate. Signed-off-by: Anand Jain <anan

[PATCH v2] btrfs: log, when replace, is canceled by the user

2018-02-12 Thread Anand Jain
For forensic investigations of issues, we would want to know if and when the user cancels the replace. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: use btrfs_dev_name() instead of rcu_str_deref() as btrfs_dev_name() also provides "missing" string,

Re: [PATCH 1/1] btrfs: log, when replace, is canceled by the user

2018-02-12 Thread Anand Jain
+ + btrfs_info(fs_info, "dev_replace from %s (devid %llu) to %s canceled", + btrfs_dev_name(src_device), src_device->devid, + rcu_str_deref(tgt_device->name)); The behavior is quite good. Although I'm wondering why for @src_device we use

[PATCH v2] btrfs: fix endianness compatibility during the SB RW

2018-02-12 Thread Anand Jain
Fixes the endianness bug in the fs_info::super_copy by using its btrfs_set_super...() function to set values in the SB, as these functions manage the endianness compatibility nicely. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Update change log. Update $Subject.

Re: [PATCH] btrfs: use set functions to update latest refs to the SB

2018-02-12 Thread Anand Jain
On 02/13/2018 12:34 AM, David Sterba wrote: On Mon, Feb 12, 2018 at 11:37:49PM +0800, Anand Jain wrote: We have btrfs_set_super...() to set the various values, so just use it. Sorry but this is not "just use it", as it fixes an endianness bug and should be documented in the

[PATCH] btrfs: use set functions to update latest refs to the SB

2018-02-12 Thread Anand Jain
We have btrfs_set_super...() to set the various values, so just use it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/transaction.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c

[PATCH] btrfs: fix extent_buffer_uptodate() return

2018-02-12 Thread Anand Jain
extent_buffer_uptodate() returns from test_bit() which is of type bool, so update extent_buffer_uptodate() to it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/extent_io.c | 2 +- fs/btrfs/extent_io.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --gi

[PATCH 2/3] btrfs: rename __btrfs_dev_replace_cancel()

2018-02-12 Thread Anand Jain
Remove __ which is for the special functions. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/dev-replace.h | 2 +- fs/btrfs/ioctl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btr

[PATCH 3/3] btrfs: btrfs_dev_replace_cancel() can return int

2018-02-12 Thread Anand Jain
Current u64 return from btrfs_dev_replace_cancel() was probably done to match the btrfs_ioctl_dev_replace_args::result. However as our actual return value fits in int, and it further gets typecast to u64, so just return int. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btr

[PATCH 1/3] btrfs: open code btrfs_dev_replace_cancel()

2018-02-12 Thread Anand Jain
btrfs_dev_replace_cancel() calls __btrfs_dev_replace_cancel() for the actual cancel so just code it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/dev-replace.c | 10 +- fs/btrfs/dev-replace.h | 3 +-- fs/btrfs/ioctl.c | 3 ++- 3 files changed, 4 inse

[PATCH 1/1] btrfs: open code btrfs_init_dev_replace_tgtdev_for_resume()

2018-02-12 Thread Anand Jain
btrfs_init_dev_replace_tgtdev_for_resume() initializes replace target device in few simple steps, so do it at the parent function. Moreover, there isn't any other caller so just open code it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/dev-replace.c | 10 -- fs

[PATCH 0/3] cleanup btrfs_dev_replace_cancel()

2018-02-12 Thread Anand Jain
Anand Jain (3): btrfs: open code btrfs_dev_replace_cancel() btrfs: rename __btrfs_dev_replace_cancel() btrfs: change the return arg type for btrfs_dev_replace_cancel() fs/btrfs/dev-replace.c | 12 ++-- fs/btrfs/dev-replace.h | 3 +-- fs/btrfs/ioctl.c | 3 ++- 3 files

[PATCH 1/1] btrfs: log, when replace, is canceled by the user

2018-02-12 Thread Anand Jain
For forensic investigations of issues, we would want to know if and when the user cancels the replace. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/dev-replace.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c

[PATCH] btrfs: verify max_inline mount parameter

2018-02-12 Thread Anand Jain
We aren't verifying the parameter passed to the max_inline mount option, so we won't report and fail the mount if a junk value is specified for example, -o max_inline=abc. This patch converts the max_inline option to %d and checks if it's a number >= 0. Signed-off-by: Anand Jain <a

[PATCH] btrfs-progs: print-tree: fix INODE_ITEM sequence and flags

2018-02-12 Thread Anand Jain
dump-tree prints wrong sequence number and the flags numbers, as we misplaced the printf args. This patch fixes it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- print-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print-tree.c b/print-tree.c

Re: [PATCH RFC] Btrfs: expose bad chunks in sysfs

2018-02-08 Thread Anand Jain
On 02/06/2018 07:15 AM, Liu Bo wrote: Btrfs tries its best to tolerate write errors, but kind of silently (except some messages in kernel log). For raid1 and raid10, this is usually not a problem because there is a copy as backup, while for parity based raid setup, i.e. raid5 and raid6, the

Re: [PATCH] btrfs: delete function btrfs_close_extra_devices()

2018-02-07 Thread Anand Jain
ping ? 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 2/2] btrfs: add read_mirror_policy parameter devid

2018-02-04 Thread Anand Jain
So usually this should be functionality handled by the raid/san controller I guess, > but given that btrfs is playing the role of a controller here at what point are we drawing the line of not implementing block-level functionality into the filesystem ?     Don't worry this is not invading

Re: [PATCH v3] btrfs: print error if primary super block write fails

2018-02-04 Thread Anand Jain
On 02/05/2018 02:38 PM, Anand Jain wrote: On 02/03/2018 03:09 AM, Howard McLauchlan wrote: Presently, failing a primary super block write but succeeding in at least one super block write in general will appear to users as if nothing important went wrong. However, upon unmounting and re

Re: [PATCH v3] btrfs: print error if primary super block write fails

2018-02-04 Thread Anand Jain
On 02/03/2018 03:09 AM, Howard McLauchlan wrote: Presently, failing a primary super block write but succeeding in at least one super block write in general will appear to users as if nothing important went wrong. However, upon unmounting and re-mounting, the file system will be in a rolled

Re: [PATCH 2/2] btrfs: add read_mirror_policy parameter devid

2018-02-01 Thread Anand Jain
On 02/01/2018 01:26 PM, Edmund Nadolski wrote: On 1/31/18 7:36 AM, Anand Jain wrote: On 01/31/2018 09:42 PM, Nikolay Borisov wrote: So usually this should be functionality handled by the raid/san controller I guess, > but given that btrfs is playing the role of a controller here at w

Re: [PATCH 2/2] btrfs: add read_mirror_policy parameter devid

2018-01-31 Thread Anand Jain
On 01/31/2018 09:42 PM, Nikolay Borisov wrote: So usually this should be functionality handled by the raid/san controller I guess, > but given that btrfs is playing the role of a controller here at what point are we drawing the line of not implementing block-level functionality into the

Re: [PATCH 0/2] Policy to balance read across mirrored devices

2018-01-31 Thread Anand Jain
On 01/31/2018 06:47 PM, Peter Becker wrote: 2018-01-31 10:01 GMT+01:00 Anand Jain <anand.j...@oracle.com>: When a stripe is not present on the read optimized disk it will just use the lower devid disk containing the stripe (instead of failing back to the pid based rando

Re: [PATCH 2/2] btrfs: add read_mirror_policy parameter devid

2018-01-31 Thread Anand Jain
On 01/31/2018 05:54 PM, Nikolay Borisov wrote: On 31.01.2018 11:28, Anand Jain wrote: On 01/31/2018 04:38 PM, Nikolay Borisov wrote: On 30.01.2018 08:30, Anand Jain wrote: Adds the mount option:    mount -o read_mirror_policy= To set the devid of the device which should be used

Re: [PATCH 2/2] btrfs: add read_mirror_policy parameter devid

2018-01-31 Thread Anand Jain
On 01/31/2018 04:38 PM, Nikolay Borisov wrote: On 30.01.2018 08:30, Anand Jain wrote: Adds the mount option: mount -o read_mirror_policy= To set the devid of the device which should be used for read. That means all the normal reads will go to that particular device only. This also

Re: [PATCH 1/2] btrfs: add mount option read_mirror_policy

2018-01-31 Thread Anand Jain
On 01/31/2018 04:06 PM, Nikolay Borisov wrote: diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 1a462ab85c49..4759e988b0df 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1100,6 +1100,8 @@ struct btrfs_fs_info { spinlock_t ref_verify_lock; struct rb_root

Re: [PATCH 0/2] Policy to balance read across mirrored devices

2018-01-31 Thread Anand Jain
On 01/31/2018 03:51 PM, Peter Becker wrote: A little question about mount -o read_mirror_policy=. How would this work with RAID1 over 3 or 4 HDD's? In particular, if the desired block is not available on device . When a stripe is not present on the read optimized disk it will just use the

[PATCH v3 2/2] btrfs: fix alloc device order consistency

2018-01-30 Thread Anand Jain
Add opened device to the tail of dev_alloc_list instead of head, so that it maintains the same order as dev_list. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/vol

Re: [PATCH] Btrfs: fix null pointer dereference when replacing missing device

2018-01-30 Thread Anand Jain
o, I missed the context of degraded when writing this patch. Thanks for the fix. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand --- fs/btrfs/extent-tree.c | 4 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9

[PATCH v3 0/2] fix device orders consistency

2018-01-30 Thread Anand Jain
ducing the missing chunk related problems more consistent. (More fixes of this sort is coming up). Anand Jain (2): btrfs: fix device order consistency btrfs: fix alloc device order consistency fs/btrfs/volumes.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) --

[PATCH v3 1/2] btrfs: fix device order consistency

2018-01-30 Thread Anand Jain
the devices are having and same SB generation. 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 b5036bd69e6a..0109f370ad5b 100644 --- a/fs/btrfs/volumes.c

Re: [PATCH v2 1/2] btrfs: fix device order consistency

2018-01-30 Thread Anand Jain
+static int device_sort(void *priv, struct list_head *a, struct list_head *b) I'll rename that to devid_cmp as it's the comparator and not really a sorting function. Ok. I will make that change in v3. Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe

Re: [PATCH 2/2] btrfs: drop optimal argument from find_live_mirror()

2018-01-30 Thread Anand Jain
On 01/30/2018 05:12 PM, Nikolay Borisov wrote: On 30.01.2018 08:28, Anand Jain wrote: Drop optimal argument from the function find_live_mirror() as we can deduce it in the function itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8

Re: [PATCH 3/3] btrfs: Refactor parameter of BTRFS_MAX_DEVS() from root to fs_info

2018-01-30 Thread Anand Jain
On 01/30/2018 03:40 PM, Qu Wenruo wrote: Signed-off-by: Qu Wenruo <w...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand --- fs/btrfs/volumes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/vol

Re: [PATCH 1/3] btrfs: Refactor __get_raid_index() to btrfs_bg_flags_to_raid_index()

2018-01-30 Thread Anand Jain
to define it as a normal function. This also makes later code re-use between kernel and btrfs-progs easier. Signed-off-by: Qu Wenruo <w...@suse.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand --- fs/btrfs/extent-tree.c | 26 ---

Re: [PATCH 2/3] btrfs: Unexport get_block_group_index()

2018-01-30 Thread Anand Jain
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e9c31b567a9c..6e1128aa29d6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7346,7 +7346,8 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache) return ret; } -int

[PATCH 2/2] btrfs: add read_mirror_policy parameter devid

2018-01-29 Thread Anand Jain
. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/super.c | 21 + fs/btrfs/volumes.c | 10 ++ fs/btrfs/volumes.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index dfe6b3c67df3..d3aad87e 100644 --- a/fs

[PATCH 1/2] btrfs: add mount option read_mirror_policy

2018-01-29 Thread Anand Jain
$pid policy configurable from the mount option. For example.. mount -o read_mirror_policy=pid (which is also default) Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/super.c | 10 ++ fs/btrfs/volumes.c | 8 +++- fs/btrfs/volumes.

[PATCH 2/2] btrfs: drop optimal argument from find_live_mirror()

2018-01-29 Thread Anand Jain
Drop optimal argument from the function find_live_mirror() as we can deduce it in the function itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/vol

[PATCH 0/2] Policy to balance read across mirrored devices

2018-01-29 Thread Anand Jain
: [PATCH 0/2] Preparatory to add read_mirror mount option Anand Jain (2): btrfs: add mount option read_mirror_policy btrfs: add read_mirror_policy parameter devid fs/btrfs/ctree.h | 2 ++ fs/btrfs/super.c | 31 +++ fs/btrfs/volumes.c | 18 +- fs

[PATCH 0/2] Preparatory to add read_mirror mount option

2018-01-29 Thread Anand Jain
Adds cleanups to find_live_mirror(), so that we can add more policy on how the read mirror device should be found. Anand Jain (2): btrfs: drop num argument from find_live_mirror() btrfs: drop optimal argument from find_live_mirror() fs/btrfs/volumes.c | 20 ++-- 1 file

[PATCH 1/2] btrfs: drop num argument from find_live_mirror()

2018-01-29 Thread Anand Jain
Obtain the stripes info from the map directly and so no need to pass it as an argument. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c

Re: [PATCH] btrfs: fix err_cast.cocci warnings

2018-01-29 Thread Anand Jain
TR_ERR(...)) Generated by: scripts/coccinelle/api/err_cast.cocci Fixes: bf155c98d312 ("btrfs: get device pointer from device_list_add()") CC: Anand Jain <anand.j...@oracle.com> Signed-off-by: Fengguang Wu <fengguang...@intel.com> Thanks for the fix, I'll fold it to

Re: [PATCH] btrfs: Fix UAF

2018-01-29 Thread Anand Jain
On 01/29/2018 03:01 PM, Nikolay Borisov wrote: On 29.01.2018 04:38, Anand Jain wrote: On 01/26/2018 09:20 PM, Nikolay Borisov wrote: Commit 4fde46f0cc71 ("Btrfs: free the stale device") introduced btrfs_free_stale_device which iterates the device lists for all regist

Re: [PATCH] btrfs: Fix UAF

2018-01-28 Thread Anand Jain
. The fix is to use 'break' when we know we are freeing the current fs_devs. No break is needed as we need to iterate all stale devices and delete the found stale entry, so commit [1] used list_for_each_entry_safe() and removed the break, [1] commit 38cf665d338fca33af4b16f9ec7cad6637fc0fec Aut

[PATCH] btrfs: delete function btrfs_close_extra_devices()

2018-01-25 Thread Anand Jain
by the __btrfs_open_devices() and is based on the generation number again. So this patch deletes btrfs_close_extra_devices() function and its calls as there is no use of it. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/disk-io.c | 13 --- fs/btrfs/volumes.

Re: [PATCH] bytrfs-progs: Print error on invalid extent item format during check

2018-01-24 Thread Anand Jain
nitpick: typo in $subject. 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

[PATCH v2 1/2] btrfs: fix device order consistency

2018-01-22 Thread Anand Jain
the devices are having and same SB generation. 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 03f2685a5018..98e41d286283 100644 --- a/fs/btrfs/volumes.c

[PATCH v2 0/2] fix device orders consistency

2018-01-22 Thread Anand Jain
ing the missing chunk related problems more consistent. (More fixes of this sort is coming up). Anand Jain (2): btrfs: fix device order consistency btrfs: fix alloc device order consistency fs/btrfs/volumes.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.

[PATCH v5 0/4] device_list_add() peparation to add reappearing missing device

2018-01-22 Thread Anand Jain
rn. Cleanup of device_list_add(), mainly in preparation to handle reappearing missing device which its next reroll will be sent separately. *** BLURB HERE *** Anand Jain (4): btrfs: move pr_info into device_list_add btrfs: set the total_devices in device_list_add() btrfs: get device

[PATCH 4/4] btrfs: drop devid as device_list_add() arg

2018-01-22 Thread Anand Jain
As struct btrfs_disk_super is being passed, so it can get devid the same way its parent does. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef Bacik <jba...@fb.com> --- fs/btrfs/volumes.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --gi

[PATCH 3/4] btrfs: get device pointer from device_list_add()

2018-01-22 Thread Anand Jain
Instead of pointer to btrfs_fs_devices as an arg in device_list_add() better to get pointer to btrfs_device as return value, then we have both, pointer to btrfs_device and btrfs_fs_devices. btrfs_device is needed to handle reappearing missing device. Signed-off-by: Anand Jain <anan

[PATCH 2/4] btrfs: set the total_devices in device_list_add()

2018-01-22 Thread Anand Jain
There is no other parent for device_list_add() except for btrfs_scan_one_device(), which would set btrfs_fs_devices::total_devices if device_list_add is successful and this can be done with in device_list_add() itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef

[PATCH 1/4] btrfs: move pr_info into device_list_add

2018-01-22 Thread Anand Jain
Commit 60999ca4b403 ("btrfs: make device scan less noisy") adds return value 1 to device_list_add(), so that parent function can call pr_info only when new device is added. Move the pr_info() part into device_list_add() so that this function can be kept simple. Signed-off-by: Anand Jai

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

2018-01-22 Thread Anand Jain
On 01/20/2018 07:27 AM, David Sterba wrote: On Thu, Jan 18, 2018 at 06:47:17PM +0100, David Sterba wrote: On Thu, Jan 18, 2018 at 10:02:32PM +0800, Anand Jain wrote: (Apply on top of my patchset [PATCH v4 0/6] preparatory work to add device forget for conflict free apply. They don't

[PATCH v2 1/2] btrfs: make code easy to read in btrfs_open_one_device()

2018-01-21 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> First set the usual case that is writeable, then check for any special case like a seed device or a rdonly device and set the state appropriately. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Add comments, and update c

[PATCH v2.1 2/2] btrfs: optimize move uuid_mutex closer to the critical section

2018-01-21 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> --- v2->v2.1: updated the v2 reroll log below. v1->v2: Add received reviewed-by. Thxs. Fix conflict on top of kdave misc-next.

[PATCH v2 1/2] btrfs: make code easy to read in btrfs_open_one_device()

2018-01-21 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> First set the usual case that is writeable, then check for any special case like a seed device or a rdonly device and set the state appropriately. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- v1->v2: Add comment and commit log

[PATCH v2 2/2] btrfs: optimize move uuid_mutex closer to the critical section

2018-01-21 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> --- v1->v1: No change. Add received reviewed-by. Thxs. fs/btrfs/volumes.c | 17 - 1 file changed, 8 insertions(

Re: [PATCH 1/3] btrfs: make code easy to read in btrfs_open_one_device()

2018-01-21 Thread Anand Jain
On 01/05/2018 10:09 PM, David Sterba wrote: On Fri, Dec 15, 2017 at 03:40:14PM +0800, Anand Jain wrote: No functional change. First set the usual case, writeable then check for any special config. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- fs/btrfs/volumes.c | 8 +++---

Re: [PATCH] Fstests: btrfs/011 fix device mounted when tests aborts

2018-01-18 Thread Anand Jain
to cleanup() to umount SCRATCH_MNT by 011 itself. Signed-off-by: Liu Bo <bo.li@oracle.com> Reviewed-by: Anand Jain <anand.j...@oracle.com> Tested-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand --- tests/btrfs/011 | 1 + 1 file changed, 1 insertion(+) diff --git a

[PATCH 2/4] btrfs: set the total_devices in device_list_add()

2018-01-18 Thread Anand Jain
There is no other parent for device_list_add() except for btrfs_scan_one_device(), which would set btrfs_fs_devices::total_devices if device_list_add is successful and this can be done with in device_list_add() itself. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef

[PATCH 3/4] btrfs: get device pointer from device_list_add()

2018-01-18 Thread Anand Jain
Instead of pointer to btrfs_fs_devices as an arg in device_list_add() better to get pointer to btrfs_device as return value, then we have both, pointer to btrfs_device and btrfs_fs_devices. btrfs_device is needed to handle reappearing missing device. Signed-off-by: Anand Jain <anan

[PATCH 4/4] btrfs: drop devid as device_list_add() arg

2018-01-18 Thread Anand Jain
As struct btrfs_disk_super is being passed, so it can get devid the same way its parent does. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef Bacik <jba...@fb.com> --- fs/btrfs/volumes.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --gi

[PATCH 1/4] btrfs: move pr_info into device_list_add

2018-01-18 Thread Anand Jain
Commit 60999ca4b403 ("btrfs: make device scan less noisy") adds return value 1 to device_list_add(), so that parent function can call pr_info only when new device is added. Move the pr_info() part into device_list_add() so that this function can be kept simple. Signed-off-by: Anand Jai

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

2018-01-18 Thread Anand Jain
l be sent separately. Anand Jain (4): btrfs: move pr_info into device_list_add btrfs: set the total_devices in device_list_add() btrfs: get device pointer from device_list_add() btrfs: drop devid as device_list_add() arg fs/btrfs/volumes.c | 63 +++--

[PATCH v5 0/6] preparatory work to add device forget

2018-01-18 Thread Anand Jain
btrfs_device::name is null when we have missing device and unmounted. So we still need to check for dev->name. We can reuse the function btrfs_free_stale_device() to add feature to forget a scanned device or all stale devices. So this patch set proposes following changes to it. Anand Jain (6):

[PATCH 2/6] btrfs: no need to check for btrfs_fs_devices::seeding

2018-01-18 Thread Anand Jain
There is no need to check for btrfs_fs_devices::seeding when we have checked for btrfs_fs_devices::opened, because we can't sprout without its seed FS being opened. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef Bacik <jba...@fb.com> --- fs/btrfs/volumes.c |

[PATCH 6/6] btrfs: make btrfs_free_stale_devices() to match the path

2018-01-18 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> The btrfs_free_stale_devices() is updated to match for the given device path and delete it. (It searches for only unmounted list of devices.) Also drop the comment about different path being used for the same device, since now we will have cli to cle

[PATCH 4/6] btrfs: make btrfs_free_stale_devices() argument optional

2018-01-18 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> This updates btrfs_free_stale_devices() helper function to delete all unmouted devices, when arg is NULL. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef Bacik <jba...@fb.com> --- fs/btrfs/volumes.c | 14

[PATCH 3/6] btrfs: make btrfs_free_stale_device() to iterate all stales

2018-01-18 Thread Anand Jain
From: Anand Jain <anand.j...@oracle.com> Let the list iterator iterate further and find other stale devices and delete it. This is in preparation to add support for user land request-able stale devices cleanup. Also rename btrfs_free_stale_device() to btrfs_free_stale_devices(). Sign

[PATCH 1/6] btrfs: cleanup btrfs_free_stale_device() usage

2018-01-18 Thread Anand Jain
We call btrfs_free_stale_device() only when we alloc a new struct btrfs_device (ret=1), so move it closer to where we alloc the new device. Also drop the comments. Signed-off-by: Anand Jain <anand.j...@oracle.com> Reviewed-by: Josef Bacik <jba...@fb.com> --- fs/btrfs/volumes.c | 8

Re: [PATCH 1/2] btrfs: fix device order consistency

2018-01-18 Thread Anand Jain
On 01/18/2018 04:32 PM, Nikolay Borisov wrote: On 18.01.2018 04:32, Anand Jain wrote: By maintaining the device order consistency it makes reproducing the problem more consistent. So fix this by having the devices Which problem is that ? I noticed when trying to reproduce raid1 missed

Re: [PATCH 1/2] btrfs: fix the bug of device scan/ready for mounted, filesystem

2018-01-17 Thread Anand Jain
r btrfs_scan_one_device() in the path of device ready/scan ioctl. Reviewed-by: Anand Jain <anand.j...@oracle.com> Thanks, Anand Signed-off-by: Tomohiro Misono <misono.tomoh...@jp.fujitsu.com> --- fs/btrfs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

Re: [PATCH v4 2/4] btrfs: cleanup btrfs_mount() using btrfs_mount_root()

2018-01-17 Thread Anand Jain
On 01/17/2018 04:30 PM, Misono, Tomohiro wrote: On 2018/01/16 20:45, Anand Jain wrote: On 01/16/2018 03:26 AM, David Sterba wrote: On Fri, Jan 12, 2018 at 06:14:40PM +0800, Anand Jain wrote: Misono, This change is causing subsequent (subvol) mount to fail when device option

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