All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandan Babu R <chandan.babu@oracle.com>
To: gregkh@linuxfoundation.org
Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org,
	stable@vger.kernel.org, djwong@kernel.org,
	chandan.babu@oracle.com, amir73il@gmail.com,
	leah.rumancik@gmail.com
Subject: [PATCH 5.4 14/26] xfs: factor out quotaoff intent AIL removal and memory free
Date: Wed, 26 Oct 2022 11:58:31 +0530	[thread overview]
Message-ID: <20221026062843.927600-15-chandan.babu@oracle.com> (raw)
In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com>

From: Brian Foster <bfoster@redhat.com>

commit 854f82b1f6039a418b7d1407513f8640e05fd73f upstream.

AIL removal of the quotaoff start intent and free of both intents is
hardcoded to the ->iop_committed() handler of the end intent. Factor
out the start intent handling code so it can be used in a future
patch to properly handle quotaoff errors. Use xfs_trans_ail_remove()
instead of the _delete() variant to acquire the AIL lock and also
handle cases where an intent might not reside in the AIL at the
time of a failure.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 fs/xfs/xfs_dquot_item.c | 29 ++++++++++++++++++++---------
 fs/xfs/xfs_dquot_item.h |  1 +
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index d60647d7197b..2b816e9b4465 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -307,18 +307,10 @@ xfs_qm_qoffend_logitem_committed(
 {
 	struct xfs_qoff_logitem	*qfe = QOFF_ITEM(lip);
 	struct xfs_qoff_logitem	*qfs = qfe->qql_start_lip;
-	struct xfs_ail		*ailp = qfs->qql_item.li_ailp;
 
-	/*
-	 * Delete the qoff-start logitem from the AIL.
-	 * xfs_trans_ail_delete() drops the AIL lock.
-	 */
-	spin_lock(&ailp->ail_lock);
-	xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR);
+	xfs_qm_qoff_logitem_relse(qfs);
 
-	kmem_free(qfs->qql_item.li_lv_shadow);
 	kmem_free(lip->li_lv_shadow);
-	kmem_free(qfs);
 	kmem_free(qfe);
 	return (xfs_lsn_t)-1;
 }
@@ -336,6 +328,25 @@ static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
 	.iop_push	= xfs_qm_qoff_logitem_push,
 };
 
+/*
+ * Delete the quotaoff intent from the AIL and free it. On success,
+ * this should only be called for the start item. It can be used for
+ * either on shutdown or abort.
+ */
+void
+xfs_qm_qoff_logitem_relse(
+	struct xfs_qoff_logitem	*qoff)
+{
+	struct xfs_log_item	*lip = &qoff->qql_item;
+
+	ASSERT(test_bit(XFS_LI_IN_AIL, &lip->li_flags) ||
+	       test_bit(XFS_LI_ABORTED, &lip->li_flags) ||
+	       XFS_FORCED_SHUTDOWN(lip->li_mountp));
+	xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR);
+	kmem_free(lip->li_lv_shadow);
+	kmem_free(qoff);
+}
+
 /*
  * Allocate and initialize an quotaoff item of the correct quota type(s).
  */
diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h
index 3bb19e556ade..2b86a43d7ce2 100644
--- a/fs/xfs/xfs_dquot_item.h
+++ b/fs/xfs/xfs_dquot_item.h
@@ -28,6 +28,7 @@ void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp);
 struct xfs_qoff_logitem	*xfs_qm_qoff_logitem_init(struct xfs_mount *mp,
 		struct xfs_qoff_logitem *start,
 		uint flags);
+void xfs_qm_qoff_logitem_relse(struct xfs_qoff_logitem *);
 struct xfs_qoff_logitem	*xfs_trans_get_qoff_item(struct xfs_trans *tp,
 		struct xfs_qoff_logitem *startqoff,
 		uint flags);
-- 
2.35.1


  parent reply	other threads:[~2022-10-26  6:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  6:28 [PATCH 5.4 00/26] xfs stable candidate patches for 5.4.y (from v5.7) Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 01/26] xfs: open code insert range extent split helper Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 02/26] xfs: rework insert range into an atomic operation Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 03/26] xfs: rework collapse " Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 04/26] xfs: add a function to deal with corrupt buffers post-verifiers Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 05/26] xfs: xfs_buf_corruption_error should take __this_address Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 06/26] xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 07/26] xfs: check owner of dir3 data blocks Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 08/26] xfs: check owner of dir3 blocks Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 09/26] xfs: Use scnprintf() for avoiding potential buffer overflow Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 10/26] xfs: remove the xfs_disk_dquot_t and xfs_dquot_t Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 11/26] xfs: remove the xfs_dq_logitem_t typedef Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 12/26] xfs: remove the xfs_qoff_logitem_t typedef Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 13/26] xfs: Replace function declaration by actual definition Chandan Babu R
2022-10-26  6:28 ` Chandan Babu R [this message]
2022-10-26  6:28 ` [PATCH 5.4 15/26] xfs: fix unmount hang and memory leak on shutdown during quotaoff Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 16/26] xfs: preserve default grace interval during quotacheck Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 17/26] xfs: Lower CIL flush limit for large logs Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 18/26] xfs: Throttle commits on delayed background CIL push Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 19/26] xfs: factor common AIL item deletion code Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 20/26] xfs: tail updates only need to occur when LSN changes Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 21/26] xfs: don't write a corrupt unmount record to force summary counter recalc Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 22/26] xfs: trylock underlying buffer on dquot flush Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 23/26] xfs: factor out a new xfs_log_force_inode helper Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 24/26] xfs: reflink should force the log out if mounted with wsync Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 25/26] xfs: move inode flush to the sync workqueue Chandan Babu R
2022-10-26  6:28 ` [PATCH 5.4 26/26] xfs: fix use-after-free on CIL context on shutdown Chandan Babu R
2022-10-26 14:52 ` [PATCH 5.4 00/26] xfs stable candidate patches for 5.4.y (from v5.7) Greg KH
2022-10-27 14:58   ` Greg KH
2022-10-27 15:28     ` Chandan Babu R

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=20221026062843.927600-15-chandan.babu@oracle.com \
    --to=chandan.babu@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=djwong@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=leah.rumancik@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.