Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a719370b authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: factor DIO write mapping from get_blocks



Clarify and separate the buffer mapping logic so that the direct IO mapping is
not tangled up in propagating the extent status to teh mapping buffer. This
makes it easier to extend the direct IO mapping to use an ioend in future.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent c517d838
Loading
Loading
Loading
Loading
+27 −13
Original line number Original line Diff line number Diff line
@@ -1233,6 +1233,22 @@ xfs_vm_releasepage(
	return try_to_free_buffers(page);
	return try_to_free_buffers(page);
}
}


/*
 * do all the direct IO specific mapping buffer manipulation here.
 */
static void
xfs_map_direct(
	struct inode		*inode,
	struct buffer_head	*bh_result,
	struct xfs_bmbt_irec	*imap,
	xfs_off_t		offset)
{
	if (ISUNWRITTEN(imap)) {
		bh_result->b_private = inode;
		set_buffer_defer_completion(bh_result);
	}
}

STATIC int
STATIC int
__xfs_get_blocks(
__xfs_get_blocks(
	struct inode		*inode,
	struct inode		*inode,
@@ -1331,21 +1347,19 @@ __xfs_get_blocks(
		goto out_unlock;
		goto out_unlock;
	}
	}


	if (imap.br_startblock != HOLESTARTBLOCK &&
	    imap.br_startblock != DELAYSTARTBLOCK) {
	/*
	/*
		 * For unwritten extents do not report a disk address on
	 * For unwritten extents do not report a disk address in the buffered
		 * the read case (treat as if we're reading into a hole).
	 * read case (treat as if we're reading into a hole).
	 */
	 */
		if (create || !ISUNWRITTEN(&imap))
	if (imap.br_startblock != HOLESTARTBLOCK &&
	    imap.br_startblock != DELAYSTARTBLOCK &&
	    (create || !ISUNWRITTEN(&imap))) {
		xfs_map_buffer(inode, bh_result, &imap, offset);
		xfs_map_buffer(inode, bh_result, &imap, offset);
		if (create && ISUNWRITTEN(&imap)) {
		if (ISUNWRITTEN(&imap))
			if (direct) {
				bh_result->b_private = inode;
				set_buffer_defer_completion(bh_result);
			}
			set_buffer_unwritten(bh_result);
			set_buffer_unwritten(bh_result);
		}
		/* direct IO needs special help */
		if (create && direct)
			xfs_map_direct(inode, bh_result, &imap, offset);
	}
	}


	/*
	/*