diff mbox series

[08/21] xfs: delegate post-allocation iget

Message ID 157784120578.1365473.11920528262279415127.stgit@magnolia (mailing list archive)
State Deferred, archived
Headers show
Series xfs: hoist inode operations to libxfs | expand

Commit Message

Darrick J. Wong Jan. 1, 2020, 1:13 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Create a post-allocation iget helper so that the upcoming libxfs hoist
doesn't have to determine the xfs_iget interface.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_inode.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 75a0a22c605d..7832ee9550e5 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -617,6 +617,21 @@  xfs_lookup(
 	return error;
 }
 
+/*
+ * Create in-core inode for a newly allocated on-disk inode.  Get the in-core
+ * inode with the lock held exclusively because we're setting fields here and
+ * need to prevent others from looking at the inode until we're done.
+ */
+static int
+xfs_ialloc_iget(
+	struct xfs_trans	*tp,
+	xfs_ino_t		ino,
+	struct xfs_inode	**ipp)
+{
+	return xfs_iget(tp->t_mountp, tp, ino, XFS_IGET_CREATE, XFS_ILOCK_EXCL,
+			ipp);
+}
+
 /*
  * Initialize a newly allocated inode with the given arguments.  Heritable
  * inode properties will be copied from the parent if one is supplied and the
@@ -851,8 +866,7 @@  xfs_ialloc(
 	 * This is because we're setting fields here we need
 	 * to prevent others from looking at until we're done.
 	 */
-	error = xfs_iget(mp, tp, ino, XFS_IGET_CREATE,
-			 XFS_ILOCK_EXCL, &ip);
+	error = xfs_ialloc_iget(tp, ino, &ip);
 	if (error)
 		return error;
 	ASSERT(ip != NULL);