Commit a5f73342 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent 346c1d46
...@@ -1331,6 +1331,9 @@ xfs_attr3_leaf_create( ...@@ -1331,6 +1331,9 @@ xfs_attr3_leaf_create(
/* /*
* Split the leaf node, rebalance, then add the new entry. * 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 int
xfs_attr3_leaf_split( xfs_attr3_leaf_split(
...@@ -1387,7 +1390,7 @@ xfs_attr3_leaf_split( ...@@ -1387,7 +1390,7 @@ xfs_attr3_leaf_split(
oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL); oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL); newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
if (!added) if (!added)
return -ENOSPC; return 1;
return 0; return 0;
} }
......
...@@ -593,9 +593,8 @@ xfs_da3_split( ...@@ -593,9 +593,8 @@ xfs_da3_split(
switch (oldblk->magic) { switch (oldblk->magic) {
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
error = xfs_attr3_leaf_split(state, oldblk, newblk); error = xfs_attr3_leaf_split(state, oldblk, newblk);
if ((error != 0) && (error != -ENOSPC)) { if (error < 0)
return error; /* GROT: attr is inconsistent */ return error; /* GROT: attr is inconsistent */
}
if (!error) { if (!error) {
addblk = newblk; addblk = newblk;
break; break;
...@@ -617,6 +616,8 @@ xfs_da3_split( ...@@ -617,6 +616,8 @@ xfs_da3_split(
error = xfs_attr3_leaf_split(state, newblk, error = xfs_attr3_leaf_split(state, newblk,
&state->extrablk); &state->extrablk);
} }
if (error == 1)
return -ENOSPC;
if (error) if (error)
return error; /* GROT: attr inconsistent */ return error; /* GROT: attr inconsistent */
addblk = newblk; addblk = newblk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment