[PATCH v8 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-30 Thread Misono Tomohiro
Add unprivileged version of ino_lookup ioctl BTRFS_IOC_INO_LOOKUP_USER to allow normal users to call "btrfs subvolume list/show" etc. in combination with BTRFS_IOC_GET_SUBVOL_INFO/BTRFS_IOC_GET_SUBVOL_ROOTREF. This can be used like BTRFS_IOC_INO_LOOKUP but the argument is different. This is

Re: [bug report] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-30 Thread Misono Tomohiro
Thanks for the reporting. I will update the patch. Regards, Tomohiro Misono On 2018/05/30 19:19, Dan Carpenter wrote: > Hello Tomohiro Misono, > > The patch 56bfce6502b7: "btrfs: Add unprivileged version of > ino_lookup ioctl" from May 16, 2018, leads to the following static > checker warning:

Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()

2018-05-30 Thread Su Yue
On 05/30/2018 11:33 PM, David Sterba wrote: > On Wed, May 30, 2018 at 02:49:10PM +0800, Su Yue wrote: >> btrfs_alloc_path() may fail due to no enough memory, >> so let the function return -ENOMEM instead of -ENOENT is better. >> >> Signed-off-by: Su Yue > > Reviewed-by: David Sterba > >

Re: [PATCH 2/2] btrfs: Refactor running of delayed inode items during transaction commit

2018-05-30 Thread Nikolay Borisov
On 28.05.2018 19:12, David Sterba wrote: > On Mon, May 28, 2018 at 03:26:58PM +0300, Nikolay Borisov wrote: >> dmesg looks like: >> [6.649213] WARNING: CPU: 0 PID: 2838 at fs/btrfs/transaction.c:303 >> record_root_in_trans+0x38/0xd0 > > Found in the logs. I reported it to the

Re: [PATCH] Btrfs: clean up error handling in btrfs_truncate()

2018-05-30 Thread David Sterba
On Tue, May 29, 2018 at 12:24:31PM -0700, Omar Sandoval wrote: > On Tue, May 22, 2018 at 09:59:50AM -0700, Omar Sandoval wrote: > > From: Omar Sandoval > > > > btrfs_truncate() uses two variables for error handling, ret and err (if > > this sounds familiar, it's because

[josef-btrfs:blk-iolatency 12/13] blk-iolatency.c:undefined reference to `__udivdi3'

2018-05-30 Thread kbuild test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git blk-iolatency head: 6fd950dfd5f71e7eba6d0763c6861669cec7963f commit: f624090ed7dadc44d46a8a0b4381ab286c9f45fb [12/13] block: introduce blk-iolatency io controller config: i386-allyesconfig (attached as .config)

Re: [PATCH v3 1/2] btrfs: Factor out read portion of btrfs_get_blocks_direct

2018-05-30 Thread David Sterba
On Wed, May 02, 2018 at 03:19:32PM +0300, Nikolay Borisov wrote: > Currently this function handles both the READ and WRITE dio cases. This > is facilitated by a bunch of 'if' statements, a goto short-circuit > statement and a very perverse aliasing of "!created"(READ) case > by setting lockstart =

Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()

2018-05-30 Thread David Sterba
On Wed, May 30, 2018 at 02:49:10PM +0800, Su Yue wrote: > btrfs_alloc_path() may fail due to no enough memory, > so let the function return -ENOMEM instead of -ENOENT is better. > > Signed-off-by: Su Yue Reviewed-by: David Sterba Thanks. I've audited all return codes after failed path

Re: [PATCH] btrfs: return error value if create_io_em() failed in cow_file_range()

2018-05-30 Thread David Sterba
On Wed, May 30, 2018 at 04:48:56PM +0800, Su Yue wrote: > In cow_file_range(), create_io_em() may fail, but its return value is > not recorded. > Then return value may be 0 even it failed which is a wrong behavior. > > Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. > >

Re: [PATCH v4 3/4] btrfs: lzo: Add header length check to avoid slab out of bounds access

2018-05-30 Thread David Sterba
On Wed, May 30, 2018 at 12:58:24PM +0800, Qu Wenruo wrote: > > Reported-by: James Harvey > Signed-off-by: Qu Wenruo > --- > changelog: > v3->v4: Patch replaced, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to

Re: [PATCH 1/2] btrfs: drop unused parameter qgroup_reserved

2018-05-30 Thread David Sterba
On Wed, May 30, 2018 at 11:00:38AM +0800, Gu Jinxiang wrote: > From: Gu JinXiang > > Since commit 7775c8184ec0 > ("btrfs: remove unused parameter from btrfs_subvolume_release_metadata") > parameter qgroup_reserved is not used by caller > of function btrfs_subvolume_reserve_metadata. > So remove

[bug report] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-30 Thread Dan Carpenter
Hello Tomohiro Misono, The patch 56bfce6502b7: "btrfs: Add unprivileged version of ino_lookup ioctl" from May 16, 2018, leads to the following static checker warning: fs/btrfs/ioctl.c:2478 btrfs_search_path_in_tree_user() error: 'temp_inode' dereferencing possible ERR_PTR()

Re: [PATCH] btrfs: return error value if create_io_em() failed in cow_file_range()

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 11:48, Su Yue wrote: > In cow_file_range(), create_io_em() may fail, but its return value is > not recorded. > Then return value may be 0 even it failed which is a wrong behavior. > > Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. > > Signed-off-by: Su Yue

[PATCH] btrfs: return error value if create_io_em() failed in cow_file_range()

2018-05-30 Thread Su Yue
In cow_file_range(), create_io_em() may fail, but its return value is not recorded. Then return value may be 0 even it failed which is a wrong behavior. Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. Signed-off-by: Su Yue --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3

Re: [PATCH v2 2/2] btrfs-progs: ins: dump-tree: Print tree name for extent data/tree block backref

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 10:25, Misono Tomohiro wrote: > Print tree name instead of number to make output more readable. > > Example: > [before] >extent data backref root 5 objectid 257 offset 16384 count 1 > >tree block backref root 18446744073709551607 > > [after] >extent data backref

[PATCH v2 2/2] btrfs-progs: ins: dump-tree: Print tree name for extent data/tree block backref

2018-05-30 Thread Misono Tomohiro
Print tree name instead of number to make output more readable. Example: [before] extent data backref root 5 objectid 257 offset 16384 count 1 tree block backref root 18446744073709551607 [after] extent data backref root FS_TREE objectid 257 offset 16384 count 1 tree block

Re: [PATCH REBASED 2/2] btrfs: Delayed empty block group auto removal to next transaction

2018-05-30 Thread Qu Wenruo
On 2018年05月30日 15:01, Nikolay Borisov wrote: > > > On 30.05.2018 07:40, Qu Wenruo wrote: >> Under certain KVM load and LTP tests, we are possible to hit the >> following calltrace if quota is enabled: >> -- >> BTRFS critical (device vda2): unable to find logical 8820195328 length 4096 >>

Re: [PATCH 6/6] btrfs: rename btrfs_free_stale_devices drop btrfs prefix

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 09:58, Anand Jain wrote: > btrfs_free_stale_devices() is a static function drop the btrfs prefix. > > Signed-off-by: Anand Jain Nit: I think this patch could be dropped, it's not a set-in-stone rule that static function shouldn't have btrfs_ prefix. Personally, I'd prefer all

Re: [PATCH REBASED 2/2] btrfs: Delayed empty block group auto removal to next transaction

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 07:40, Qu Wenruo wrote: > Under certain KVM load and LTP tests, we are possible to hit the > following calltrace if quota is enabled: > -- > BTRFS critical (device vda2): unable to find logical 8820195328 length 4096 > BTRFS critical (device vda2): unable to find logical

Re: [PATCH 2/2] btrfs-progs: ins: dump-tree: Print tree name for tree block backref

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 09:55, Misono Tomohiro wrote: > On 2018/05/30 15:28, Nikolay Borisov wrote: >> >> >> On 30.05.2018 07:55, Misono Tomohiro wrote: >>> Print tree name instead of number to make output more readable. >>> >>> Signed-off-by: Misono Tomohiro >>> --- >>> print-tree.c | 5 +++-- >>> 1

Re: [PATCH 2/2] btrfs-progs: ins: dump-tree: Print tree name for tree block backref

2018-05-30 Thread Misono Tomohiro
On 2018/05/30 15:28, Nikolay Borisov wrote: > > > On 30.05.2018 07:55, Misono Tomohiro wrote: >> Print tree name instead of number to make output more readable. >> >> Signed-off-by: Misono Tomohiro >> --- >> print-tree.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff

[PATCH 5/6] btrfs: fix btrfs_free_stale_devices() with needed locks

2018-05-30 Thread Anand Jain
btrfs_free_stale_devices() finds the stale (not opened) matching device path in the fs_uuid list. We are already under uuid_mutex so when we check for each fs_devices, hold the respective device_list_mutex. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 25 +++-- 1 file

[PATCH 6/6] btrfs: rename btrfs_free_stale_devices drop btrfs prefix

2018-05-30 Thread Anand Jain
btrfs_free_stale_devices() is a static function drop the btrfs prefix. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a6a23b0185e5..afb3504f4097 100644 ---

[PATCH 4/6] btrfs: btrfs_free_stale_devices() rename local variables

2018-05-30 Thread Anand Jain
Over the years we named %fs_devices and %devices to represent, the struct btrfs_fs_devices and the struct btrfs_device. So follow the same norm here too. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 35 ++- 1 file changed, 18

[PATCH 3/6] btrfs: update device_list_mutex protected items

2018-05-30 Thread Anand Jain
Include items of fs_uuids::fs_devices to be protected by device_list_mutex, like (but not limited to) fs_devices::opened, fs_devices::total_devices and fs_devices::num_devices. This is been done in the code already. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2

[PATCH 2/6] btrfs: fix device_list_add() missing device_list_mutex()

2018-05-30 Thread Anand Jain
When the device is added or if the device pointer is retrieved for writing, make sure that device_list_mutex is held. Also make sure it is held when we check fs_devices::opened and fs_devices::total_devices is updated. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 16 1

[PATCH 1/6] btrfs: do btrfs_free_stale_devices() outside of device_list_add()

2018-05-30 Thread Anand Jain
btrfs_free_stale_devices() looks for device path reused for another fsid, and deletes the older fs_devices::device entry. In preparation to handle proper locks in the device_list_add(), move the btrfs_free_stale_devices() outside of the device_list_add() as these two functions has two distinct

[PATCH 0/6] fix device_list_mutex usage and cleanups in device_list_add()

2018-05-30 Thread Anand Jain
Patch 1/6 is a preparatory patch to add the required device_list_mutex in device_list_add() in the patch 2/6. Patch 3/6 updates the comments on device_list_mutex. Patch 4/6 is just a cleanup patch no functional changes. Patch 5/6 adds the required device_list_mutex in btrfs_free_stale_device().

Re: [PATCH REBASED 1/2] btrfs: Use btrfs_mark_bg_unused() to replace open code

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 07:40, Qu Wenruo wrote: > Introduce a small helper, btrfs_mark_bg_unused(), to accquire needed > locks and add a block group to unused_bgs list. > > No functional modification, and only 3 callers are involved. > > Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov > --- >

Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 09:49, Su Yue wrote: > btrfs_alloc_path() may fail due to no enough memory, > so let the function return -ENOMEM instead of -ENOENT is better. > > Signed-off-by: Su Yue Reviewed-by: Nikolay Borisov > --- > Changelog: > v2: > Add commit message to describe the patch. Thanks

[PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()

2018-05-30 Thread Su Yue
btrfs_alloc_path() may fail due to no enough memory, so let the function return -ENOMEM instead of -ENOENT is better. Signed-off-by: Su Yue --- Changelog: v2: Add commit message to describe the patch. Thanks Nikolay. fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1

Re: [PATCH 2/2] btrfs-progs: ins: dump-tree: Print tree name for tree block backref

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 07:55, Misono Tomohiro wrote: > Print tree name instead of number to make output more readable. > > Signed-off-by: Misono Tomohiro > --- > print-tree.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/print-tree.c b/print-tree.c > index

Re: [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()

2018-05-30 Thread Nikolay Borisov
On 30.05.2018 05:07, Su Yue wrote: > Signed-off-by: Su Yue Generally we discourage commit log messages. I understand this patch is very obvious but put a sentence saying that btrfs_alloc_path can fail due to enomem hence returning enomem is the right ting to do here. > --- >

Re: [PATCH] btrfs: set device state reappearing missing device

2018-05-30 Thread Anand Jain
On 05/29/2018 02:50 PM, Gu Jinxiang wrote: From: Gu JinXiang patch for commit 921518924084 ("btrfs: handle dynamically reappearing missing device"). --- v4: :: . No need to set in_fs_metadata flag as its already set on missing device --- > Since BTRFS_DEV_STATE_IN_FS_METADATA will be clear