public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: linux-xfs@vger.kernel.org, david@fromorbit.com
Subject: [PATCH 3/2] xfs: free the intent item when allocating recovery transaction fails
Date: Thu, 17 Sep 2020 00:01:35 -0700	[thread overview]
Message-ID: <20200917070135.GV7955@magnolia> (raw)
In-Reply-To: <160031332353.3624373.16349101558356065522.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

The recovery functions of all four log intent items fail to free the
intent item if the transaction allocation fails.  Fix this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_bmap_item.c     |    5 ++++-
 fs/xfs/xfs_extfree_item.c  |    5 ++++-
 fs/xfs/xfs_refcount_item.c |    5 ++++-
 fs/xfs/xfs_rmap_item.c     |    5 ++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 2b1cf3ed8172..85d18cd708ba 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -484,8 +484,11 @@ xfs_bui_item_recover(
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
 			XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);
-	if (error)
+	if (error) {
+		xfs_bui_release(buip);
 		return error;
+	}
+
 	/*
 	 * Recovery stashes all deferred ops during intent processing and
 	 * finishes them on completion. Transfer current dfops state to this
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6cb8cd11072a..9ceac1a0a39f 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -619,8 +619,11 @@ xfs_efi_item_recover(
 	}
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
-	if (error)
+	if (error) {
+		xfs_efi_release(efip);
 		return error;
+	}
+
 	efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
 
 	for (i = 0; i < efip->efi_format.efi_nextents; i++) {
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 492d80a0b406..aae2a6ec00d3 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -491,8 +491,11 @@ xfs_cui_item_recover(
 	 */
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
 			mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);
-	if (error)
+	if (error) {
+		xfs_cui_release(cuip);
 		return error;
+	}
+
 	/*
 	 * Recovery stashes all deferred ops during intent processing and
 	 * finishes them on completion. Transfer current dfops state to this
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index dc5b0753cd51..9e7fabb54ff1 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -523,8 +523,11 @@ xfs_rui_item_recover(
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
 			mp->m_rmap_maxlevels, 0, XFS_TRANS_RESERVE, &tp);
-	if (error)
+	if (error) {
+		xfs_rui_release(ruip);
 		return error;
+	}
+
 	rudp = xfs_trans_get_rud(tp, ruip);
 
 	for (i = 0; i < ruip->rui_format.rui_nextents; i++) {

  parent reply	other threads:[~2020-09-17  7:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17  3:28 [PATCH 0/2] xfs: fix simple problems with log intent recovery Darrick J. Wong
2020-09-17  3:28 ` [PATCH 1/2] xfs: log new intent items created as part of finishing recovered intent items Darrick J. Wong
2020-09-17  4:58   ` Dave Chinner
2020-09-17  9:07   ` Christoph Hellwig
2020-09-17 17:45     ` Darrick J. Wong
2020-09-17  3:28 ` [PATCH 2/2] xfs: attach inode to dquot in xfs_bui_item_recover Darrick J. Wong
2020-09-17  4:54   ` Dave Chinner
2020-09-17  6:36     ` Darrick J. Wong
2020-09-17  7:01   ` [PATCH v2 " Darrick J. Wong
2020-09-17  8:03     ` Dave Chinner
2020-09-17  9:04     ` Christoph Hellwig
2020-09-17  7:01 ` Darrick J. Wong [this message]
2020-09-17  8:05   ` [PATCH 3/2] xfs: free the intent item when allocating recovery transaction fails Dave Chinner
2020-09-17  9:06   ` Christoph Hellwig
2020-09-18  1:48     ` Darrick J. Wong
2020-09-18  2:17 ` [PATCH v2 3/2] xfs: fix simple problems with log intent recovery Darrick J. Wong
2020-09-18  2:19   ` [PATCH v3 3/2] xfs: don't release log intent items when recovery fails Darrick J. Wong
2020-09-19  5:49     ` Christoph Hellwig
2020-09-21  6:49     ` Dave Chinner

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=20200917070135.GV7955@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.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