Skip to content

Commit a5f7334

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split
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 <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 346c1d4 commit a5f7334

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,9 @@ xfs_attr3_leaf_create(
13311331

13321332
/*
13331333
* Split the leaf node, rebalance, then add the new entry.
1334+
*
1335+
* Returns 0 if the entry was added, 1 if a further split is needed or a
1336+
* negative error number otherwise.
13341337
*/
13351338
int
13361339
xfs_attr3_leaf_split(
@@ -1387,7 +1390,7 @@ xfs_attr3_leaf_split(
13871390
oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
13881391
newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
13891392
if (!added)
1390-
return -ENOSPC;
1393+
return 1;
13911394
return 0;
13921395
}
13931396

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,8 @@ xfs_da3_split(
593593
switch (oldblk->magic) {
594594
case XFS_ATTR_LEAF_MAGIC:
595595
error = xfs_attr3_leaf_split(state, oldblk, newblk);
596-
if ((error != 0) && (error != -ENOSPC)) {
596+
if (error < 0)
597597
return error; /* GROT: attr is inconsistent */
598-
}
599598
if (!error) {
600599
addblk = newblk;
601600
break;
@@ -617,6 +616,8 @@ xfs_da3_split(
617616
error = xfs_attr3_leaf_split(state, newblk,
618617
&state->extrablk);
619618
}
619+
if (error == 1)
620+
return -ENOSPC;
620621
if (error)
621622
return error; /* GROT: attr inconsistent */
622623
addblk = newblk;

0 commit comments

Comments
 (0)