public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chandan Babu R <chandan.babu@oracle.com>
To: djwong@kernel.org
Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org,
	amir73il@gmail.com, leah.rumancik@gmail.com
Subject: [PATCH 5.4 CANDIDATE 15/17] xfs: consider shutdown in bmapbt cursor delete assert
Date: Tue, 11 Apr 2023 09:05:12 +0530	[thread overview]
Message-ID: <20230411033514.58024-16-chandan.babu@oracle.com> (raw)
In-Reply-To: <20230411033514.58024-1-chandan.babu@oracle.com>

From: Brian Foster <bfoster@redhat.com>

commit 1cd738b13ae9b29e03d6149f0246c61f76e81fcf upstream.

[ Slightly modify fs/xfs/libxfs/xfs_btree.c to resolve merge conflicts ]

The assert in xfs_btree_del_cursor() checks that the bmapbt block
allocation field has been handled correctly before the cursor is
freed. This field is used for accurate calculation of indirect block
reservation requirements (for delayed allocations), for example.
generic/019 reproduces a scenario where this assert fails because
the filesystem has shutdown while in the middle of a bmbt record
insertion. This occurs after a bmbt block has been allocated via the
cursor but before the higher level bmap function (i.e.
xfs_bmap_add_extent_hole_real()) completes and resets the field.

Update the assert to accommodate the transient state if the
filesystem has shutdown. While here, clean up the indentation and
comments in the function.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 fs/xfs/libxfs/xfs_btree.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 8c43cac15832..121251651fea 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -354,20 +354,17 @@ xfs_btree_free_block(
  */
 void
 xfs_btree_del_cursor(
-	xfs_btree_cur_t	*cur,		/* btree cursor */
-	int		error)		/* del because of error */
+	struct xfs_btree_cur	*cur,		/* btree cursor */
+	int			error)		/* del because of error */
 {
-	int		i;		/* btree level */
+	int			i;		/* btree level */
 
 	/*
-	 * Clear the buffer pointers, and release the buffers.
-	 * If we're doing this in the face of an error, we
-	 * need to make sure to inspect all of the entries
-	 * in the bc_bufs array for buffers to be unlocked.
-	 * This is because some of the btree code works from
-	 * level n down to 0, and if we get an error along
-	 * the way we won't have initialized all the entries
-	 * down to 0.
+	 * Clear the buffer pointers and release the buffers. If we're doing
+	 * this because of an error, inspect all of the entries in the bc_bufs
+	 * array for buffers to be unlocked. This is because some of the btree
+	 * code works from level n down to 0, and if we get an error along the
+	 * way we won't have initialized all the entries down to 0.
 	 */
 	for (i = 0; i < cur->bc_nlevels; i++) {
 		if (cur->bc_bufs[i])
@@ -375,15 +372,10 @@ xfs_btree_del_cursor(
 		else if (!error)
 			break;
 	}
-	/*
-	 * Can't free a bmap cursor without having dealt with the
-	 * allocated indirect blocks' accounting.
-	 */
+
 	ASSERT(cur->bc_btnum != XFS_BTNUM_BMAP ||
-	       cur->bc_private.b.allocated == 0);
-	/*
-	 * Free the cursor.
-	 */
+	       cur->bc_private.b.allocated == 0 ||
+	       XFS_FORCED_SHUTDOWN(cur->bc_mp));
 	kmem_zone_free(xfs_btree_cur_zone, cur);
 }
 
-- 
2.39.1


  parent reply	other threads:[~2023-04-11  3:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  3:34 [PATCH 5.4 CANDIDATE 00/17] xfs stable candidate patches for 5.4.y (from v5.11 & v5.12) Chandan Babu R
2023-04-11  3:34 ` [PATCH 5.4 CANDIDATE 01/17] xfs: show the proper user quota options Chandan Babu R
2023-04-11  3:34 ` [PATCH 5.4 CANDIDATE 02/17] xfs: merge the projid fields in struct xfs_icdinode Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 03/17] xfs: ensure that the inode uid/gid match values match the icdinode ones Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 04/17] xfs: remove the icdinode di_uid/di_gid members Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 05/17] xfs: remove the kuid/kgid conversion wrappers Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 06/17] xfs: add a new xfs_sb_version_has_v3inode helper Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 07/17] xfs: only check the superblock version for dinode size calculation Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 08/17] xfs: simplify di_flags2 inheritance in xfs_ialloc Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 09/17] xfs: simplify a check in xfs_ioctl_setattr_check_cowextsize Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 10/17] xfs: remove the di_version field from struct icdinode Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 11/17] xfs: fix up non-directory creation in SGID directories Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 12/17] xfs: set inode size after creating symlink Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 13/17] xfs: report corruption only as a regular error Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 14/17] xfs: shut down the filesystem if we screw up quota reservation Chandan Babu R
2023-04-11  3:35 ` Chandan Babu R [this message]
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 16/17] xfs: don't reuse busy extents on extent trim Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 17/17] xfs: force log and push AIL to clear pinned inodes when aborting mount Chandan Babu R
2023-04-11 18:15 ` [PATCH 5.4 CANDIDATE 00/17] xfs stable candidate patches for 5.4.y (from v5.11 & v5.12) Darrick J. Wong

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=20230411033514.58024-16-chandan.babu@oracle.com \
    --to=chandan.babu@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=djwong@kernel.org \
    --cc=leah.rumancik@gmail.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