Bio read race with different ranges inside the same page?

2021-02-25 Thread Qu Wenruo
Hi, Is it possible that multiple ranges of the same page are submitted to one or more bios, and such ranges race with each other and cause data corruption. Recently I'm trying to add subpage read/write support for btrfs, and notice one strange false data corruption. E.g, there is a 64K page to

Re: [report] lockdep warning when mounting seed device

2021-02-25 Thread Su Yue
On Fri 26 Feb 2021 at 13:01, Anand Jain wrote: On 25/02/2021 12:39, Su Yue wrote: While playing with seed device(misc/next and v5.11), lockdep complains the following: To reproduce: dev1=/dev/sdb1 dev2=/dev/sdb2 umount /mnt mkfs.btrfs -f $dev1 btrfstune -S 1 $dev1 mount $dev1 /mnt btrfs d

Re: [report] lockdep warning when mounting seed device

2021-02-25 Thread Anand Jain
On 25/02/2021 12:39, Su Yue wrote: While playing with seed device(misc/next and v5.11), lockdep complains the following: To reproduce: dev1=/dev/sdb1 dev2=/dev/sdb2 umount /mnt mkfs.btrfs -f $dev1 btrfstune -S 1 $dev1 mount $dev1 /mnt btrfs device add $dev2 /mnt/ -f umount /mnt m

Re: [PATCH v2 07/10] iomap: Introduce iomap_apply2() for operations on two files

2021-02-25 Thread Darrick J. Wong
On Fri, Feb 26, 2021 at 08:20:27AM +0800, Shiyang Ruan wrote: > Some operations, such as comparing a range of data in two files under > fsdax mode, requires nested iomap_open()/iomap_end() on two file. Thus, > we introduce iomap_apply2() to accept arguments from two files and > iomap_actor2_t for

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Gao Xiang
On Thu, Feb 25, 2021 at 10:50:56AM -0800, Eric Biggers wrote: > On Thu, Feb 25, 2021 at 02:26:47PM +0100, David Sterba wrote: > > > > LZ4 support has been asked for so many times that it has it's own FAQ > > entry: > > https://btrfs.wiki.kernel.org/index.php/FAQ#Will_btrfs_support_LZ4.3F > > > >

Re: xfstests seems broken on btrfs with multi-dev TEST_DEV

2021-02-25 Thread Anand Jain
On 25/02/2021 11:18, Qu Wenruo wrote: On 2021/2/25 上午11:15, Eric Sandeen wrote: On 2/24/21 9:13 PM, Qu Wenruo wrote: Now this makes way more sense, Sorry for the earlier mistake. as your previous comment on _btrfs_forget_or_module_reload is completely correct. _btrfs_forget_or_module

[PATCH v2 09/10] fs/xfs: Handle CoW for fsdax write() path

2021-02-25 Thread Shiyang Ruan
In fsdax mode, WRITE and ZERO on a shared extent need CoW performed. After CoW, new allocated extents needs to be remapped to the file. So, add an iomap_end for dax write ops to do the remapping work. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_bmap_util.c | 3 ++- fs/xfs/xfs_file.c | 9 +

[PATCH v2 10/10] fs/xfs: Add dedupe support for fsdax

2021-02-25 Thread Shiyang Ruan
Add xfs_break_two_dax_layouts() to break layout for tow dax files. Then call compare range function only when files are both DAX or not. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_file.c| 20 fs/xfs/xfs_inode.c | 8 +++- fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_re

[PATCH v2 08/10] fsdax: Dedup file range to use a compare function

2021-02-25 Thread Shiyang Ruan
With dax we cannot deal with readpage() etc. So, we create a dax comparison funciton which is similar with vfs_dedupe_file_range_compare(). And introduce dax_remap_file_range_prep() for filesystem use. Signed-off-by: Goldwyn Rodrigues Signed-off-by: Shiyang Ruan --- fs/dax.c | 51 ++

[PATCH v2 07/10] iomap: Introduce iomap_apply2() for operations on two files

2021-02-25 Thread Shiyang Ruan
Some operations, such as comparing a range of data in two files under fsdax mode, requires nested iomap_open()/iomap_end() on two file. Thus, we introduce iomap_apply2() to accept arguments from two files and iomap_actor2_t for actions on two files. Signed-off-by: Shiyang Ruan --- fs/iomap/appl

[PATCH v2 06/10] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero

2021-02-25 Thread Shiyang Ruan
Punch hole on a reflinked file needs dax_copy_edge() too. Otherwise, data in not aligned area will be not correct. So, add the srcmap to dax_iomap_zero() and replace memset() as dax_copy_edge(). Signed-off-by: Shiyang Ruan --- fs/dax.c | 6 -- fs/iomap/buffered-io.c | 2 +- i

[PATCH v2 04/10] fsdax: Introduce dax_iomap_cow_copy()

2021-02-25 Thread Shiyang Ruan
In the case where the iomap is a write operation and iomap is not equal to srcmap after iomap_begin, we consider it is a CoW operation. The destance extent which iomap indicated is new allocated extent. So, it is needed to copy the data from srcmap to new allocated extent. In theory, it is better

[PATCH v2 05/10] fsdax: Replace mmap entry in case of CoW

2021-02-25 Thread Shiyang Ruan
We replace the existing entry to the newly allocated one in case of CoW. Also, we mark the entry as PAGECACHE_TAG_TOWRITE so writeback marks this entry as writeprotected. This helps us snapshots so new write pagefaults after snapshots trigger a CoW. Signed-off-by: Goldwyn Rodrigues Signed-off-by

[PATCH v2 01/10] fsdax: Factor helpers to simplify dax fault code

2021-02-25 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 --- fs/dax.c | 152 +++

[PATCH v2 03/10] fsdax: Output address in dax_iomap_pfn() and rename it

2021-02-25 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 --- fs/dax.c | 16 1 file changed, 12 insertion

[PATCH v2 00/10] fsdax,xfs: Add reflink&dedupe support for fsdax

2021-02-25 Thread Shiyang Ruan
This patchset is attempt to add CoW support for fsdax, and take XFS, which has both reflink and fsdax feature, as an example. Changes from V1: - Factor some helper functions to simplify dax fault code - Introduce iomap_apply2() for dax_dedupe_file_range_compare() - Fix mistakes and other proble

[PATCH v2 02/10] fsdax: Factor helper: dax_fault_actor()

2021-02-25 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 --- fs/dax.c | 211 ++

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Neal Gompa
On Thu, Feb 25, 2021 at 6:18 PM Amy Parker wrote: > > Thanks for your comments, Jim. I was originally going to abandon my > thoughts about LZ4 on btrfs - but I didn't realize that FAQ was from > 2014. > > > lz4 has had ongoing development and now exists in other linux kernel fs's. > What other fil

Re: [PATCH] btrfs: do more graceful error/warning for 32bit kernel

2021-02-25 Thread Qu Wenruo
On 2021/2/25 下午11:34, David Sterba wrote: On Thu, Feb 25, 2021 at 07:44:19AM +0800, Qu Wenruo wrote: On 2021/2/25 上午3:18, David Sterba wrote: On Sat, Feb 20, 2021 at 10:06:33AM +0800, Qu Wenruo wrote: Due to the pagecache limit of 32bit systems, btrfs can't access metadata at or beyond 16

Re: [PATCH v2] btrfs: Remove force argument from run_delalloc_nocow()

2021-02-25 Thread Amy Parker
On Thu, Feb 25, 2021 at 1:04 PM Goldwyn Rodrigues wrote: > > force_nocow can be calculated by btrfs_inode and does not need to be > passed as an argument. > > This simplifies run_delalloc_nocow() call from btrfs_run_delalloc_range() > since the decision whether the extent is cow'd or not can be de

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Amy Parker
Thanks for your comments, Jim. I was originally going to abandon my thoughts about LZ4 on btrfs - but I didn't realize that FAQ was from 2014. > lz4 has had ongoing development and now exists in other linux kernel fs's. What other filesystems currently employ LZ4? Not as familiar with it being use

[PATCH v2] btrfs: Remove force argument from run_delalloc_nocow()

2021-02-25 Thread Goldwyn Rodrigues
force_nocow can be calculated by btrfs_inode and does not need to be passed as an argument. This simplifies run_delalloc_nocow() call from btrfs_run_delalloc_range() since the decision whether the extent is cow'd or not can be derived from need_force_cow(). Since BTRFS_INODE_NODATACOW and BTRFS_IN

Re: WARNING: CPU: 3 PID: 2548 at fs/btrfs/transaction.c:537 start_transaction+0x489/0x4f0

2021-02-25 Thread Casey Schaufler
On 2/25/2021 12:39 PM, Filipe Manana wrote: > On Thu, Feb 25, 2021 at 7:52 PM Casey Schaufler > wrote: >> I recently upgraded a Smack based system to Fedora33. I now get >> this stack trace on a regular basis. The system appears to be >> functioning correctly, but I find the warning worrisome. >

Re: WARNING: CPU: 3 PID: 2548 at fs/btrfs/transaction.c:537 start_transaction+0x489/0x4f0

2021-02-25 Thread Filipe Manana
On Thu, Feb 25, 2021 at 7:52 PM Casey Schaufler wrote: > > I recently upgraded a Smack based system to Fedora33. I now get > this stack trace on a regular basis. The system appears to be > functioning correctly, but I find the warning worrisome. You have SELinux enabled I suppose. Try the follow

WARNING: CPU: 3 PID: 2548 at fs/btrfs/transaction.c:537 start_transaction+0x489/0x4f0

2021-02-25 Thread Casey Schaufler
I recently upgraded a Smack based system to Fedora33. I now get this stack trace on a regular basis. The system appears to be functioning correctly, but I find the warning worrisome. [ 220.732359] [ cut here ] [ 220.732398] WARNING: CPU: 3 PID: 2548 at fs/btrfs/transacti

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Eric Biggers
On Thu, Feb 25, 2021 at 02:26:47PM +0100, David Sterba wrote: > > LZ4 support has been asked for so many times that it has it's own FAQ > entry: > https://btrfs.wiki.kernel.org/index.php/FAQ#Will_btrfs_support_LZ4.3F > > The decompression speed is not the only thing that should be evaluated, > th

Re: [PATCH 2/6] btrfs: Export qgroup_reserve_meta

2021-02-25 Thread David Sterba
On Tue, Feb 23, 2021 at 07:42:48AM +0800, Qu Wenruo wrote: > > > On 2021/2/23 上午12:40, Nikolay Borisov wrote: > > Signed-off-by: Nikolay Borisov > > Considering how small the export is, I prefer this to be merged with > next patch, as it's much easier to understand why we want to export the > f

Re: [PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration

2021-02-25 Thread David Sterba
On Thu, Feb 25, 2021 at 09:21:31AM +0800, Anand Jain wrote: > On 12/02/2021 22:36, David Sterba wrote: > > On Wed, Feb 10, 2021 at 09:25:18PM -0800, Anand Jain wrote: > >> Move the static function scrub_checksum_tree_block() before its use in > >> the scrub.c, and drop its declaration. > >> > >> No

Re: [PATCH] btrfs: Use transid for DIR_ITEM/DIR_INDEX's location

2021-02-25 Thread David Sterba
On Fri, Aug 28, 2020 at 04:20:10PM +0300, Nikolay Borisov wrote: > When a snapshot is created its root item is inserted in the root tree > with the 'offset' field set to the transaction id when the snapshot > was created. Immediately afterwards the offset is set to -1 so when > the same key is used

Re: [PATCH] btrfs: fix spurious free_space_tree remount warning

2021-02-25 Thread David Sterba
On Thu, Feb 25, 2021 at 03:59:20PM +0100, David Sterba wrote: > On Tue, Feb 23, 2021 at 08:28:10PM +0200, Nikolay Borisov wrote: > > > > > > On 23.02.21 г. 20:22 ч., Boris Burkov wrote: > > > The intended logic of the check is to catch cases where the desired > > > free_space_tree setting doesn't

Re: [PATCH] btrfs: do more graceful error/warning for 32bit kernel

2021-02-25 Thread David Sterba
On Thu, Feb 25, 2021 at 07:44:19AM +0800, Qu Wenruo wrote: > > > On 2021/2/25 上午3:18, David Sterba wrote: > > On Sat, Feb 20, 2021 at 10:06:33AM +0800, Qu Wenruo wrote: > >> Due to the pagecache limit of 32bit systems, btrfs can't access metadata > >> at or beyond 16T boundary correctly. > >> > >

Re: [PATCH] btrfs: fix spurious free_space_tree remount warning

2021-02-25 Thread David Sterba
On Tue, Feb 23, 2021 at 08:28:10PM +0200, Nikolay Borisov wrote: > > > On 23.02.21 г. 20:22 ч., Boris Burkov wrote: > > The intended logic of the check is to catch cases where the desired > > free_space_tree setting doesn't match the mounted setting, and the > > remount is anything but ro->rw. Ho

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Filipe Manana
On Thu, Feb 25, 2021 at 1:23 PM Neal Gompa wrote: > > On Wed, Feb 24, 2021 at 11:10 PM Amy Parker wrote: > > > > The compression options in Btrfs are great, and help save a ton of > > space on disk. Zstandard works extremely well for this, and is fairly > > fast. However, it can heavily reduce th

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread David Sterba
On Thu, Feb 25, 2021 at 08:18:53AM -0500, Neal Gompa wrote: > On Wed, Feb 24, 2021 at 11:10 PM Amy Parker wrote: > > > > The compression options in Btrfs are great, and help save a ton of > > space on disk. Zstandard works extremely well for this, and is fairly > > fast. However, it can heavily re

Re: [PATCH u-boot 2/2] fs: btrfs: change directory list output to be aligned as before

2021-02-25 Thread Tom Rini
On Tue, Feb 09, 2021 at 07:05:08PM +0100, Marek Behún wrote: > Since commit 325dd1f642dd ("fs: btrfs: Use btrfs_iter_dir() to ...") > when btrfs is listing a directory, the output is not aligned: > >15 Wed Sep 09 13:20:03 2020 boot.scr -> @/boot/boot.scr > 0 Tue Feb 02

Re: [PATCH u-boot 1/2] fs: btrfs: skip xattrs in directory listing

2021-02-25 Thread Tom Rini
On Tue, Feb 09, 2021 at 07:05:07PM +0100, Marek Behún wrote: > Skip xattrs in directory listing. U-Boot filesystem drivers do not list > xattrs. > > Signed-off-by: Marek Behún > Cc: David Sterba > Cc: Qu Wenruo > Cc: Tom Rini > Reviewed-by: Qu Wenruo Applied to u-boot/master, thanks! -- T

Re: Adding LZ4 compression support to Btrfs

2021-02-25 Thread Neal Gompa
On Wed, Feb 24, 2021 at 11:10 PM Amy Parker wrote: > > The compression options in Btrfs are great, and help save a ton of > space on disk. Zstandard works extremely well for this, and is fairly > fast. However, it can heavily reduce the speed of quick disks, does > not work well on lower-end syste

[PATCH] btrfs: Refactor error handling in btrfs_zero_range

2021-02-25 Thread Nikolay Borisov
The major complexity when it comes to error handling in btrfs_zero_range stems from the code executed under the 'reserve_space' label. Rather than it having an effect on the whole of btrfs_zero_range refactor it so that error handling specific to the functions called in this branch is contained onl

Re: xfstest btrfs/154 failed at kernel 5.4.100

2021-02-25 Thread Wang Yugui
Hi, btrfs/154 passed with with the backport of this patch. btrfs: correctly calculate item size used when item key collision happens Thanks a lot. Best Regards Wang Yugui (wangyu...@e16-tech.com) 2021/02/25 > > > On 25.02.21 г. 9:53 ч., Wang Yugui wrote: > > Hi, > > > > xfstest btrfs/154 fai

Re: xfstest btrfs/154 failed at kernel 5.4.100

2021-02-25 Thread Nikolay Borisov
On 25.02.21 г. 9:53 ч., Wang Yugui wrote: > Hi, > > xfstest btrfs/154 failed at kernel 5.4.100 > > frequency: always > kernel version: 5.4.100, other kernel version yet not tested. > xfstest: https://github.com/kdave/xfstests.git > btrfs-progs: 5.10.1 > but mkfs.btrfs default enable no-h