]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split
authorChristoph Hellwig <hch@lst.de>
Mon, 21 Oct 2024 00:10:46 +0000 (17:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:03 +0000 (15:45 -0700)
Source kernel commit: a5f73342abe1f796140f6585e43e2aa7bc1b7975

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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c

index 3028ef0cd3cb2c4dd51042e0aa05abe6c88f85f4..01a87b45a6a5c0696d6c57438f5a9eaf16a6466b 100644 (file)
@@ -1328,6 +1328,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(
@@ -1384,7 +1387,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;
 }
 
index 820e8575246b50f8e6d8ad89f774c9357ea87b71..38f345a923c757c3ba10df565b97e6efbf07560e 100644 (file)
@@ -589,9 +589,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;
@@ -613,6 +612,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;