[PATCH 3/3] fsdax: Output address in dax_iomap_pfn() and rename it

2021-04-06 Thread Shiyang Ruan
Add address output in dax_iomap_pfn() in order to perform a memcpy() in CoW case. Since this function both output address and pfn, rename it to dax_iomap_direct_access(). Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig Reviewed-by: Ritesh Harjani --- fs/dax.c | 16

[PATCH 2/3] fsdax: Factor helper: dax_fault_actor()

2021-04-06 Thread Shiyang Ruan
The core logic in the two dax page fault functions is similar. So, move the logic into a common helper function. Also, to facilitate the addition of new features, such as CoW, switch-case is no longer used to handle different iomap types. Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig

[PATCH 1/3] fsdax: Factor helpers to simplify dax fault code

2021-04-06 Thread Shiyang Ruan
The dax page fault code is too long and a bit difficult to read. And it is hard to understand when we trying to add new features. Some of the PTE/PMD codes have similar logic. So, factor them as helper functions to simplify the code. Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig Rev

[PATCH 0/3] fsdax: Factor helper functions to simplify the code

2021-04-06 Thread Shiyang Ruan
The page fault part of fsdax code is little complex. In order to add CoW feature and make it easy to understand, I was suggested to factor some helper functions to simplify the current dax code. (Rebased on v5.12-rc5) == Shiyang Ruan (3): fsdax: Factor helpers to simplify dax fault code fsdax

Re: [PATCH 2/2] btrfs: Use reada_control pointer instead of void pointer

2021-04-06 Thread Anand Jain
On 07/04/2021 00:24, Goldwyn Rodrigues wrote: From: Goldwyn Rodrigues Since struct reada_control is defined in ctree.h, Use struct reada_control pointer as a function argument for btrfs_reada_wait() instead of a void pointer in order > to avoid type-casting within the function. yep. Signed

Re: [PATCH 1/2] btrfs: Remove unused function btrfs_reada_detach()

2021-04-06 Thread Anand Jain
On 07/04/2021 00:24, Goldwyn Rodrigues wrote: From: Goldwyn Rodrigues btrfs_reada_detach() is not called by any function. Remove. btrfs_reada_detach() was never used. commit 48a3b6366f69 (btrfs: make static code static & remove dead code) spared it. IMO ok to remove btrfs_reada_detach(

Re: [PATCH v3 00/13] btrfs: support read-write for subpage metadata

2021-04-06 Thread Qu Wenruo
On 2021/4/6 上午10:31, Anand Jain wrote: On 05/04/2021 14:14, Qu Wenruo wrote: On 2021/4/3 下午7:08, David Sterba wrote: On Thu, Mar 25, 2021 at 03:14:32PM +0800, Qu Wenruo wrote: This patchset can be fetched from the following github repo, along with the full subpage RW support: https://gith

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

2021-04-06 Thread Anand Jain
On 07/04/2021 00:48, David Sterba wrote: On Mon, Apr 05, 2021 at 05:18:32PM +0800, Su Yue wrote: On Mon 05 Apr 2021 at 16:38, Anand Jain wrote: Ping again. It's already queued in misc-next. commit 441737bb30f83914bb8517f52088c0130138d74b (misc-next) Author: Anand Jain Date: Fri Jul 1

[PATCH v2] generic: test fiemap offsets and < 512 byte ranges

2021-04-06 Thread Boris Burkov
btrfs trims fiemap extents to the inputted offset, which leads to inconsistent results for most inputs, and downright bizarre outputs like [7..6] when the trimmed extent is at the end of an extent and shorter than 512 bytes. This test covers a bunch of cases like that and ensures that file systems

[PATCH] generic: test fiemap offsets and < 512 byte ranges

2021-04-06 Thread Boris Burkov
btrfs trims fiemap extents to the inputted offset, which leads to inconsistent results for most inputs, and downright bizarre outputs like [7..6] when the trimmed extent is at the end of an extent and shorter than 512 bytes. This test covers a bunch of cases like that and ensures that file systems

[PATCH] btrfs: return whole extents in fiemap

2021-04-06 Thread Boris Burkov
`xfs_io -c 'fiemap ' ` can give surprising results on btrfs that differ from xfs. btrfs spits out extents trimmed to fit the user input. If the user's fiemap request has an offset, then rather than returning each whole extent which intersects that range, we also trim the start extent to not have

Re: [PATCH] btrfs: Use readahead_batch_length

2021-04-06 Thread David Sterba
On Sun, Mar 21, 2021 at 09:03:11PM +, Matthew Wilcox (Oracle) wrote: > Implement readahead_batch_length() to determine the number of bytes in > the current batch of readahead pages and use it in btrfs. > > Signed-off-by: Matthew Wilcox (Oracle) Thanks, I'll take it through my tree as btrfs i

Re: [PATCH] fs: btrfs: Remove repeated struct declaration

2021-04-06 Thread David Sterba
On Thu, Apr 01, 2021 at 04:03:39PM +0800, Wan Jiabing wrote: > struct btrfs_inode is declared twice. One is declared at 67th line. > The blew declaration is not needed. Remove the duplicate. > struct btrfs_fs_info should be declared in the forward declarations. > Move it to the forward declarations

Re: [PATCH v3 00/13] btrfs: support read-write for subpage metadata

2021-04-06 Thread David Sterba
On Tue, Apr 06, 2021 at 10:31:58AM +0800, Anand Jain wrote: > On 05/04/2021 14:14, Qu Wenruo wrote: > > > > > > On 2021/4/3 下午7:08, David Sterba wrote: > >> On Thu, Mar 25, 2021 at 03:14:32PM +0800, Qu Wenruo wrote: > >>> This patchset can be fetched from the following github repo, along with > >

Re: [PATCH v3 00/13] btrfs: support read-write for subpage metadata

2021-04-06 Thread David Sterba
On Mon, Apr 05, 2021 at 02:14:34PM +0800, Qu Wenruo wrote: > > > On 2021/4/3 下午7:08, David Sterba wrote: > > On Thu, Mar 25, 2021 at 03:14:32PM +0800, Qu Wenruo wrote: > >> This patchset can be fetched from the following github repo, along with > >> the full subpage RW support: > >> https://githu

Re: [PATCH v8 28/39] btrfs: handle btrfs_search_slot failure in replace_path

2021-04-06 Thread David Sterba
On Fri, Mar 12, 2021 at 03:25:23PM -0500, Josef Bacik wrote: > This can fail for any number of reasons, why bring the whole box down > with it? I've written something more relevant for the code change. > Reviewed-by: Qu Wenruo > Signed-off-by: Josef Bacik > --- > fs/btrfs/relocation.c | 3 ++-

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

2021-04-06 Thread David Sterba
On Mon, Apr 05, 2021 at 05:18:32PM +0800, Su Yue wrote: > > On Mon 05 Apr 2021 at 16:38, Anand Jain > wrote: > > > Ping again. > > > It's already queued in misc-next. > commit 441737bb30f83914bb8517f52088c0130138d74b (misc-next) > Author: Anand Jain > Date: Fri Jul 17 18:05:25 2020 +0800 N

[PATCH 2/2] btrfs: Use reada_control pointer instead of void pointer

2021-04-06 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Since struct reada_control is defined in ctree.h, Use struct reada_control pointer as a function argument for btrfs_reada_wait() instead of a void pointer in order to avoid type-casting within the function. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/ctree.h | 2 +- f

[PATCH 1/2] btrfs: Remove unused function btrfs_reada_detach()

2021-04-06 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues btrfs_reada_detach() is not called by any function. Remove. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/ctree.h | 1 - fs/btrfs/reada.c | 9 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f2fd73e58ee6.

Re: [PATCH 00/12] btrfs-progs: refactor and generalize chunk/dev_extent allocation

2021-04-06 Thread Su Yue
On Tue 06 Apr 2021 at 21:24, Naohiro Aota wrote: On Tue, Apr 06, 2021 at 06:54:37PM +0800, Su Yue wrote: On Tue 06 Apr 2021 at 16:05, Naohiro Aota wrote: > This is the userland counterpart of the following series. > > https://lore.kernel.org/linux-btrfs/20200225035626.1049501-1-naohi

[PATCH] btrfs-progs: Fix null pointer deref in balance_level

2021-04-06 Thread Nikolay Borisov
In case the right buffer is emptied it's first set to null and subsequently it's dereferenced to get its size to pass to root_sub_used. This naturally leads to a null pointer dereference. The correct thing to do is to pass the stashed right->len in "blocksize". Fixes #296 Signed-off-by: Nikolay B

Re: [PATCH 00/12] btrfs-progs: refactor and generalize chunk/dev_extent allocation

2021-04-06 Thread Naohiro Aota
On Tue, Apr 06, 2021 at 06:54:37PM +0800, Su Yue wrote: > > On Tue 06 Apr 2021 at 16:05, Naohiro Aota wrote: > > > This is the userland counterpart of the following series. > > > > https://lore.kernel.org/linux-btrfs/20200225035626.1049501-1-naohiro.a...@wdc.com/ > > > > This series refactors

Re: [PATCH -next] btrfs: integrity-checker: use DEFINE_MUTEX() for mutex lock

2021-04-06 Thread David Sterba
On Mon, Apr 05, 2021 at 06:14:46PM +0800, Zheng Yongjun wrote: > mutex lock can be initialized automatically with DEFINE_MUTEX() > rather than explicitly calling mutex_init(). > > Reported-by: Hulk Robot > Signed-off-by: Zheng Yongjun You've sent this patch already and haven't provided the answ

Re: [PATCH 00/12] btrfs-progs: refactor and generalize chunk/dev_extent allocation

2021-04-06 Thread Su Yue
On Tue 06 Apr 2021 at 16:05, Naohiro Aota wrote: This is the userland counterpart of the following series. https://lore.kernel.org/linux-btrfs/20200225035626.1049501-1-naohiro.a...@wdc.com/ This series refactors chunk allocation and device_extent allocation functions and make them genera

Re: [PATCH 00/12] btrfs-progs: refactor and generalize chunk/dev_extent allocation

2021-04-06 Thread Johannes Thumshirn
On 06/04/2021 10:07, Naohiro Aota wrote: > This is the userland counterpart of the following series. > > https://lore.kernel.org/linux-btrfs/20200225035626.1049501-1-naohiro.a...@wdc.com/ > > This series refactors chunk allocation and device_extent allocation > functions and make them generalized

[PATCH 12/12] btrfs-progs: rename calc_size to stripe_size

2021-04-06 Thread Naohiro Aota
alloc_chunk_ctl::calc_size is actually the stripe_size in the kernel side code. Let's rename it to clarify what the "calc" is. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 56 - 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/

[PATCH 11/12] btrfs-progs: simplify arguments of chunk_bytes_by_type()

2021-04-06 Thread Naohiro Aota
Chunk_bytes_by_type() takes type, calc_size, and ctl as arguments. But the first two can be obtained from the ctl. Let's drop these arguments for simplicity. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/k

[PATCH 10/12] btrfs-progs: drop alloc_chunk_ctl::stripe_len

2021-04-06 Thread Naohiro Aota
Since commit b9444efb6658 ("btrfs-progs: don't pretend RAID56 has a different stripe length"), alloc_chunk_ctl::stripe_len is always fixed to BTRFS_STRIPE_LEN. Let's replace alloc_chunk_ctl::stripe_len with BTRFS_STRIPE_LEN, like in the kernel code. Signed-off-by: Naohiro Aota --- kernel-shared/

[PATCH 09/12] btrfs-progs: use round_down for allocation calcs

2021-04-06 Thread Naohiro Aota
Several calculations in the chunk allocation process use this pattern. x /= y; x *= y; Replace this pattern with round_down(). Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel-shared/volumes.

[PATCH 08/12] btrfs-progs: fix to use half the available space for DUP profile

2021-04-06 Thread Naohiro Aota
In the DUP profile, we can use only half of the space available in a device extent. Fix the calculation of calc_size for it. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/vol

[PATCH 06/12] btrfs-progs: factor out create_chunk()

2021-04-06 Thread Naohiro Aota
Factor out create_chunk() from btrfs_alloc_chunk(). This new function creates a chunk. There is no functional changes. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 217 ++-- 1 file changed, 120 insertions(+), 97 deletions(-) diff --git a/kernel-

[PATCH 07/12] btrfs-progs: rewrite btrfs_alloc_data_chunk() using create_chunk()

2021-04-06 Thread Naohiro Aota
btrfs_alloc_data_chunk() and create_chunk() have the most part in common. Let's rewrite btrfs_alloc_data_chunk() using create_chunk(). There are two differences between btrfs_alloc_data_chunk() and create_chunk(). create_chunk() uses find_next_chunk() to decide the logical address of the chunk, an

[PATCH 05/12] btrfs-progs: factor out decide_stripe_size()

2021-04-06 Thread Naohiro Aota
Factor out decide_stripe_size() from btrfs_alloc_chunk(). This new function calculates the actual stripe size to allocate and decides the size of a stripe (ctl->calc_size). This commit has no functional changes. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 44 ++

[PATCH 03/12] btrfs-progs: convert type of alloc_chunk_ctl::type

2021-04-06 Thread Naohiro Aota
Convert alloc_chunk_ctl::type to take the original type in btrfs_alloc_chunk(). This will help refactoring in the following commits. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel-shared/volumes.c b/kernel-

[PATCH 04/12] btrfs-progs: consolidate parameter initialization of regular allocator

2021-04-06 Thread Naohiro Aota
Move parameter initialization code for regular allocator to init_alloc_chunk_ctl_policy_regular(). This will help adding another allocator in the future. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 112 +++- 1 file changed, 64 insertions(+), 48 d

[PATCH 02/12] btrfs-progs: refactor find_free_dev_extent_start()

2021-04-06 Thread Naohiro Aota
Factor out the function dev_extent_search_start() from find_free_dev_extent_start() to decide the starting position of a device extent search. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ker

[PATCH 00/12] btrfs-progs: refactor and generalize chunk/dev_extent allocation

2021-04-06 Thread Naohiro Aota
This is the userland counterpart of the following series. https://lore.kernel.org/linux-btrfs/20200225035626.1049501-1-naohiro.a...@wdc.com/ This series refactors chunk allocation and device_extent allocation functions and make them generalized to be able to implement other allocation policy easi

[PATCH 01/12] btrfs-progs: introduce chunk allocation policy

2021-04-06 Thread Naohiro Aota
Introduce chunk allocation policy for btrfs. This policy controls how chunks and device extents are allocated from devices. Signed-off-by: Naohiro Aota --- kernel-shared/volumes.c | 1 + kernel-shared/volumes.h | 6 ++ 2 files changed, 7 insertions(+) diff --git a/kernel-shared/volumes.c b/