public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v2 03/18] xfs: Hold inode locks in xfs_ialloc
Date: Mon, 18 Jul 2022 13:20:07 -0700	[thread overview]
Message-ID: <20220718202022.6598-4-allison.henderson@oracle.com> (raw)
In-Reply-To: <20220718202022.6598-1-allison.henderson@oracle.com>

Modify xfs_ialloc to hold locks after return.  Caller will be
responsible for manual unlock.  We will need this later to hold locks
across parent pointer operations

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_inode.c   | 6 +++++-
 fs/xfs/xfs_qm.c      | 4 +++-
 fs/xfs/xfs_symlink.c | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index cfdcca95594f..cce5fe7c048e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -774,6 +774,8 @@ xfs_inode_inherit_flags2(
 /*
  * Initialise a newly allocated inode and return the in-core inode to the
  * caller locked exclusively.
+ *
+ * Caller is responsible for unlocking the inode manually upon return
  */
 int
 xfs_init_new_inode(
@@ -900,7 +902,7 @@ xfs_init_new_inode(
 	/*
 	 * Log the new values stuffed into the inode.
 	 */
-	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
+	xfs_trans_ijoin(tp, ip, 0);
 	xfs_trans_log_inode(tp, ip, flags);
 
 	/* now that we have an i_mode we can setup the inode structure */
@@ -1077,6 +1079,7 @@ xfs_create(
 	xfs_qm_dqrele(pdqp);
 
 	*ipp = ip;
+	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return 0;
 
  out_trans_cancel:
@@ -1173,6 +1176,7 @@ xfs_create_tmpfile(
 	xfs_qm_dqrele(pdqp);
 
 	*ipp = ip;
+	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return 0;
 
  out_trans_cancel:
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 57dd3b722265..5582c44f12ab 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -817,8 +817,10 @@ xfs_qm_qino_alloc(
 		ASSERT(xfs_is_shutdown(mp));
 		xfs_alert(mp, "%s failed (error %d)!", __func__, error);
 	}
-	if (need_alloc)
+	if (need_alloc) {
 		xfs_finish_inode_setup(*ipp);
+		xfs_iunlock(*ipp, XFS_ILOCK_EXCL);
+	}
 	return error;
 }
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 8389f3ef88ef..d8e120913036 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -337,6 +337,7 @@ xfs_symlink(
 	xfs_qm_dqrele(pdqp);
 
 	*ipp = ip;
+	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return 0;
 
 out_trans_cancel:
@@ -358,6 +359,8 @@ xfs_symlink(
 
 	if (unlock_dp_on_error)
 		xfs_iunlock(dp, XFS_ILOCK_EXCL);
+	if (ip)
+		xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return error;
 }
 
-- 
2.25.1


  parent reply	other threads:[~2022-07-18 20:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 20:20 [PATCH v2 00/18] Parent Pointers Allison Henderson
2022-07-18 20:20 ` [PATCH v2 01/18] xfs: Fix multi-transaction larp replay Allison Henderson
2022-07-18 20:20 ` [PATCH v2 02/18] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Allison Henderson
2022-07-18 20:20 ` Allison Henderson [this message]
2022-07-18 20:20 ` [PATCH v2 04/18] xfs: Hold inode locks in xfs_trans_alloc_dir Allison Henderson
2022-07-18 20:20 ` [PATCH v2 05/18] xfs: get directory offset when adding directory name Allison Henderson
2022-07-18 20:20 ` [PATCH v2 06/18] xfs: get directory offset when removing " Allison Henderson
2022-07-18 20:20 ` [PATCH v2 07/18] xfs: get directory offset when replacing a " Allison Henderson
2022-07-18 20:20 ` [PATCH v2 08/18] xfs: add parent pointer support to attribute code Allison Henderson
2022-07-18 20:20 ` [PATCH v2 09/18] xfs: define parent pointer xattr format Allison Henderson
2022-07-18 20:20 ` [PATCH v2 10/18] xfs: Add xfs_verify_pptr Allison Henderson
2022-07-18 20:20 ` [PATCH v2 11/18] xfs: extend transaction reservations for parent attributes Allison Henderson
2022-07-18 20:20 ` [PATCH v2 12/18] xfs: parent pointer attribute creation Allison Henderson
2022-07-18 20:20 ` [PATCH v2 13/18] xfs: add parent attributes to link Allison Henderson
2022-07-18 20:20 ` [PATCH v2 14/18] xfs: remove parent pointers in unlink Allison Henderson
2022-07-18 20:20 ` [PATCH v2 15/18] xfs: Add parent pointers to rename Allison Henderson
2022-07-18 20:20 ` [PATCH v2 16/18] xfs: Add the parent pointer support to the superblock version 5 Allison Henderson
2022-07-18 20:20 ` [PATCH v2 17/18] xfs: Add helper function xfs_attr_list_context_init Allison Henderson
2022-07-18 20:20 ` [PATCH v2 18/18] xfs: Add parent pointer ioctl Allison Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220718202022.6598-4-allison.henderson@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox