]> git.baikalelectronics.ru Git - kernel.git/commit
iomap: iomap that extends beyond EOF should be marked dirty
authorChandan Babu R <chandan.babu@oracle.com>
Wed, 21 Sep 2022 03:23:37 +0000 (08:53 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:03:58 +0000 (11:03 +0200)
commit15304349343be4f4ae13cd4ccca859a87a225502
tree6cf44710146c8b54e755b766aae6d7ffbc3c7fdd
parent990e19f86f0031011b9bcfd2f930156a9a7c60c3
iomap: iomap that extends beyond EOF should be marked dirty

From: Dave Chinner <dchinner@redhat.com>

commit 1473cbfce336d4b80204faaf197e2fb7b6d86750 upstream.

When doing a direct IO that spans the current EOF, and there are
written blocks beyond EOF that extend beyond the current write, the
only metadata update that needs to be done is a file size extension.

However, we don't mark such iomaps as IOMAP_F_DIRTY to indicate that
there is IO completion metadata updates required, and hence we may
fail to correctly sync file size extensions made in IO completion
when O_DSYNC writes are being used and the hardware supports FUA.

Hence when setting IOMAP_F_DIRTY, we need to also take into account
whether the iomap spans the current EOF. If it does, then we need to
mark it dirty so that IO completion will call generic_write_sync()
to flush the inode size update to stable storage correctly.

Fixes: 811c6a541c98 ("iomap: Use FUA for pure data O_DSYNC DIO writes")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: removed the ext4 part; they'll handle it separately]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_iomap.c
include/linux/iomap.h