Commit 1aa91d9c authored by Stefan Roesch's avatar Stefan Roesch Committed by Jens Axboe
Browse files

xfs: Add async buffered write support



This adds the async buffered write support to XFS. For async buffered
write requests, the request will return -EAGAIN if the ilock cannot be
obtained immediately.

Signed-off-by: default avatarStefan Roesch <shr@fb.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20220623175157.1715274-15-shr@fb.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9641506b
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -410,7 +410,7 @@ xfs_file_write_checks(
		spin_unlock(&ip->i_flags_lock);

out:
	return file_modified(file);
	return kiocb_modified(iocb);
}

static int
@@ -700,12 +700,11 @@ xfs_file_buffered_write(
	bool			cleared_space = false;
	unsigned int		iolock;

	if (iocb->ki_flags & IOCB_NOWAIT)
		return -EOPNOTSUPP;

write_retry:
	iolock = XFS_IOLOCK_EXCL;
	xfs_ilock(ip, iolock);
	ret = xfs_ilock_iocb(iocb, iolock);
	if (ret)
		return ret;

	ret = xfs_file_write_checks(iocb, from, &iolock);
	if (ret)
@@ -1165,7 +1164,7 @@ xfs_file_open(
{
	if (xfs_is_shutdown(XFS_M(inode->i_sb)))
		return -EIO;
	file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
	file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC;
	return generic_file_open(inode, file);
}

+4 −1
Original line number Diff line number Diff line
@@ -886,6 +886,7 @@ xfs_buffered_write_iomap_begin(
	bool			eof = false, cow_eof = false, shared = false;
	int			allocfork = XFS_DATA_FORK;
	int			error = 0;
	unsigned int		lockmode = XFS_ILOCK_EXCL;

	if (xfs_is_shutdown(mp))
		return -EIO;
@@ -897,7 +898,9 @@ xfs_buffered_write_iomap_begin(

	ASSERT(!XFS_IS_REALTIME_INODE(ip));

	xfs_ilock(ip, XFS_ILOCK_EXCL);
	error = xfs_ilock_for_iomap(ip, flags, &lockmode);
	if (error)
		return error;

	if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
	    XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {