diff mbox series

[4/8] xfs: distinguish extra split from real ENOSPC from xfs_attr_node_try_addname

Message ID 20240904053820.2836285-5-hch@lst.de (mailing list archive)
State Superseded, archived
Headers show
Series [1/8] xfs: merge xfs_attr_leaf_try_add into xfs_attr_leaf_addname | expand

Commit Message

Christoph Hellwig Sept. 4, 2024, 5:37 a.m. UTC
Just like xfs_attr3_leaf_split, xfs_attr_node_try_addname can return
-ENOSPC both for an actual failure to allocate a disk block, but also
to signal the caller to convert the format of the attr fork.  Use magic
1 to ask for the conversion here as well.

Note that unlike the similar issue in xfs_attr3_leaf_split, this one was
only found by code review.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_attr.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Darrick J. Wong Sept. 17, 2024, 6:19 p.m. UTC | #1
On Wed, Sep 04, 2024 at 08:37:55AM +0300, Christoph Hellwig wrote:
> Just like xfs_attr3_leaf_split, xfs_attr_node_try_addname can return
> -ENOSPC both for an actual failure to allocate a disk block, but also
> to signal the caller to convert the format of the attr fork.  Use magic
> 1 to ask for the conversion here as well.
> 
> Note that unlike the similar issue in xfs_attr3_leaf_split, this one was
> only found by code review.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 0bf4f718be462f..c63da14eee0432 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -597,7 +597,7 @@ xfs_attr_node_addname(
>  		return error;
>  
>  	error = xfs_attr_node_try_addname(attr);
> -	if (error == -ENOSPC) {
> +	if (error == 1) {
>  		error = xfs_attr3_leaf_to_node(args);
>  		if (error)
>  			return error;
> @@ -1386,9 +1386,12 @@ xfs_attr_node_addname_find_attr(
>  /*
>   * Add a name to a Btree-format attribute list.
>   *
> - * This will involve walking down the Btree, and may involve splitting
> - * leaf nodes and even splitting intermediate nodes up to and including
> - * the root node (a special case of an intermediate node).
> + * This will involve walking down the Btree, and may involve splitting leaf
> + * nodes and even splitting intermediate nodes up to and including the root
> + * node (a special case of an intermediate node).
> + *
> + * If the tree was still in single leaf format and needs to converted to
> + * real node format return 1 and let the caller handle that.
>   */
>  static int
>  xfs_attr_node_try_addname(
> @@ -1410,7 +1413,7 @@ xfs_attr_node_try_addname(
>  			 * out-of-line values so it looked like it *might*
>  			 * have been a b-tree. Let the caller deal with this.
>  			 */
> -			error = -ENOSPC;
> +			error = 1;
>  			goto out;
>  		}
>  
> -- 
> 2.45.2
> 
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 0bf4f718be462f..c63da14eee0432 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -597,7 +597,7 @@  xfs_attr_node_addname(
 		return error;
 
 	error = xfs_attr_node_try_addname(attr);
-	if (error == -ENOSPC) {
+	if (error == 1) {
 		error = xfs_attr3_leaf_to_node(args);
 		if (error)
 			return error;
@@ -1386,9 +1386,12 @@  xfs_attr_node_addname_find_attr(
 /*
  * Add a name to a Btree-format attribute list.
  *
- * This will involve walking down the Btree, and may involve splitting
- * leaf nodes and even splitting intermediate nodes up to and including
- * the root node (a special case of an intermediate node).
+ * This will involve walking down the Btree, and may involve splitting leaf
+ * nodes and even splitting intermediate nodes up to and including the root
+ * node (a special case of an intermediate node).
+ *
+ * If the tree was still in single leaf format and needs to converted to
+ * real node format return 1 and let the caller handle that.
  */
 static int
 xfs_attr_node_try_addname(
@@ -1410,7 +1413,7 @@  xfs_attr_node_try_addname(
 			 * out-of-line values so it looked like it *might*
 			 * have been a b-tree. Let the caller deal with this.
 			 */
-			error = -ENOSPC;
+			error = 1;
 			goto out;
 		}