From: Christoph Hellwig <hch@lst.de>
To: Chandan Babu R <chandan.babu@oracle.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>, linux-xfs@vger.kernel.org
Subject: [PATCH 3/6] xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split
Date: Tue, 20 Aug 2024 19:04:54 +0200 [thread overview]
Message-ID: <20240820170517.528181-4-hch@lst.de> (raw)
In-Reply-To: <20240820170517.528181-1-hch@lst.de>
xfs_attr3_leaf_split propagates the need for an extra btree split as
-ENOSPC to it's only caller, but the same return value can also be
returned from xfs_da_grow_inode when it fails to find free space.
Distinguish the two cases by returning 1 for the extra split case instead
of overloading -ENOSPC.
This can be triggered relatively easily with the pending realtime group
support and a file system with a lot of small zones that use metadata
space on the main device. In this case every about 5-10th run of
xfs/538 runs into the following assert:
ASSERT(oldblk->magic == XFS_ATTR_LEAF_MAGIC);
in xfs_attr3_leaf_split caused by an allocation failure. Note that
the allocation failure is caused by another bug that will be fixed
subsequently, but this commit at least sorts out the error handling.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_attr_leaf.c | 5 ++++-
fs/xfs/libxfs/xfs_da_btree.c | 5 +++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index bcaf28732bfcae..92acef51876e4b 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1334,6 +1334,9 @@ xfs_attr3_leaf_create(
/*
* Split the leaf node, rebalance, then add the new entry.
+ *
+ * Returns 0 if the entry was added, 1 if a further split is needed or a
+ * negative error number otherwise.
*/
int
xfs_attr3_leaf_split(
@@ -1390,7 +1393,7 @@ xfs_attr3_leaf_split(
oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
if (!added)
- return -ENOSPC;
+ return 1;
return 0;
}
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 16a529a8878083..17d9e6154f1978 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -593,9 +593,8 @@ xfs_da3_split(
switch (oldblk->magic) {
case XFS_ATTR_LEAF_MAGIC:
error = xfs_attr3_leaf_split(state, oldblk, newblk);
- if ((error != 0) && (error != -ENOSPC)) {
+ if (error < 0)
return error; /* GROT: attr is inconsistent */
- }
if (!error) {
addblk = newblk;
break;
@@ -617,6 +616,8 @@ xfs_da3_split(
error = xfs_attr3_leaf_split(state, newblk,
&state->extrablk);
}
+ if (error == 1)
+ return -ENOSPC;
if (error)
return error; /* GROT: attr inconsistent */
addblk = newblk;
--
2.43.0
next prev parent reply other threads:[~2024-08-20 17:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 17:04 fix a DEBUG-only assert failure in xfs/538 Christoph Hellwig
2024-08-20 17:04 ` [PATCH 1/6] xfs: merge xfs_attr_leaf_try_add into xfs_attr_leaf_addname Christoph Hellwig
2024-08-21 15:52 ` Darrick J. Wong
2024-08-20 17:04 ` [PATCH 2/6] xfs: return bool from xfs_attr3_leaf_add Christoph Hellwig
2024-08-21 15:56 ` Darrick J. Wong
2024-08-20 17:04 ` Christoph Hellwig [this message]
2024-08-21 15:57 ` [PATCH 3/6] xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split Darrick J. Wong
2024-08-22 3:40 ` Christoph Hellwig
2024-08-20 17:04 ` [PATCH 4/6] xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate Christoph Hellwig
2024-08-21 15:59 ` Darrick J. Wong
2024-08-20 17:04 ` [PATCH 5/6] xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc Christoph Hellwig
2024-08-21 8:24 ` Christoph Hellwig
2024-08-21 16:04 ` Darrick J. Wong
2024-08-20 17:04 ` [PATCH 6/6] xfs: support lowmode allocations in xfs_bmap_exact_minlen_extent_alloc Christoph Hellwig
2024-08-21 16:07 ` Darrick J. Wong
2024-08-22 3:41 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2024-08-24 3:40 fix a DEBUG-only assert failure in xfs/538 v2 Christoph Hellwig
2024-08-24 3:40 ` [PATCH 3/6] xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split Christoph Hellwig
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=20240820170517.528181-4-hch@lst.de \
--to=hch@lst.de \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--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