Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
* RWF_NOWAIT writes not failing when writing to a range with holes
@ 2020-06-15 17:53 Filipe Manana
  2020-07-08 14:17 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2020-06-15 17:53 UTC (permalink / raw)
  To: linux-ext4

Hi,

I found out a bug in btrfs where a RWF_NOWRITE does not fail if we
write to a range that starts with an extent followed by holes (since
it requires allocating extent(s)).

When writing a test case for fstests I noticed xfs fails with -EAGAIN
as expected, but ext4 succeeds just like btrfs currently does:

mkfs.ext4 -F /dev/sdb
mount /dev/sdb /mnt

xfs_io -f -d -c "pwrite -S 0xab -b 256K 0 256K" /mnt/bar
xfs_io -c "fpunch 64K 64K" /mnt/bar
sync
xfs_io -d -c "pwrite -N -V 1 -b 128K -S 0xfe 0 128K" /mnt/bar

Is this a known bug? Or is there a technical reason that makes it too
expensive to check no extents will need to be allocated?

Thanks.

-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RWF_NOWAIT writes not failing when writing to a range with holes
  2020-06-15 17:53 RWF_NOWAIT writes not failing when writing to a range with holes Filipe Manana
@ 2020-07-08 14:17 ` Jan Kara
  2020-10-15 15:37   ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2020-07-08 14:17 UTC (permalink / raw)
  To: Filipe Manana; +Cc: linux-ext4

Hi!

On Mon 15-06-20 18:53:11, Filipe Manana wrote:
> I found out a bug in btrfs where a RWF_NOWRITE does not fail if we
> write to a range that starts with an extent followed by holes (since
> it requires allocating extent(s)).
> 
> When writing a test case for fstests I noticed xfs fails with -EAGAIN
> as expected, but ext4 succeeds just like btrfs currently does:
> 
> mkfs.ext4 -F /dev/sdb
> mount /dev/sdb /mnt
> 
> xfs_io -f -d -c "pwrite -S 0xab -b 256K 0 256K" /mnt/bar
> xfs_io -c "fpunch 64K 64K" /mnt/bar
> sync
> xfs_io -d -c "pwrite -N -V 1 -b 128K -S 0xfe 0 128K" /mnt/bar
> 
> Is this a known bug? Or is there a technical reason that makes it too
> expensive to check no extents will need to be allocated?

Thanks for report! This is actually a fallout of the conversion of ext4
direct IO code to iomap (commit 378f32bab37 "ext4: introduce direct I/O
write using iomap infrastructure"). I'll send a fix.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RWF_NOWAIT writes not failing when writing to a range with holes
  2020-07-08 14:17 ` Jan Kara
@ 2020-10-15 15:37   ` Filipe Manana
  0 siblings, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2020-10-15 15:37 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Wed, Jul 8, 2020 at 3:17 PM Jan Kara <jack@suse.cz> wrote:
>
> Hi!
>
> On Mon 15-06-20 18:53:11, Filipe Manana wrote:
> > I found out a bug in btrfs where a RWF_NOWRITE does not fail if we
> > write to a range that starts with an extent followed by holes (since
> > it requires allocating extent(s)).
> >
> > When writing a test case for fstests I noticed xfs fails with -EAGAIN
> > as expected, but ext4 succeeds just like btrfs currently does:
> >
> > mkfs.ext4 -F /dev/sdb
> > mount /dev/sdb /mnt
> >
> > xfs_io -f -d -c "pwrite -S 0xab -b 256K 0 256K" /mnt/bar
> > xfs_io -c "fpunch 64K 64K" /mnt/bar
> > sync
> > xfs_io -d -c "pwrite -N -V 1 -b 128K -S 0xfe 0 128K" /mnt/bar
> >
> > Is this a known bug? Or is there a technical reason that makes it too
> > expensive to check no extents will need to be allocated?
>
> Thanks for report! This is actually a fallout of the conversion of ext4
> direct IO code to iomap (commit 378f32bab37 "ext4: introduce direct I/O
> write using iomap infrastructure"). I'll send a fix.

Thanks for looking into it Jan.

I just wrote a test case for fstests that exercises that case and
others where btrfs used to fail.
And I think I found some regression happened in ext4 in the meanwhile.
Basically a write into a fallocated extent that starts at eof now
fails with -EAGAIN in ext4 on a 5.9-rc6 kernel at least, but it used
to work when I found the bug in btrfs [1] (with a 5.7 kernel iirc).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4b1946284dd6641afdb9457101056d9e6ee6204c

That new test case:
https://patchwork.kernel.org/project/fstests/patch/aa8318c5beb380a9e99142d1b5e776b739d04bdb.1602774113.git.fdmanana@suse.com/

Thanks.

>
>                                                                 Honza
>
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR



-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 17:53 RWF_NOWAIT writes not failing when writing to a range with holes Filipe Manana
2020-07-08 14:17 ` Jan Kara
2020-10-15 15:37   ` Filipe Manana

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ext4


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git