All of lore.kernel.org
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: catherine.hoang@oracle.com,cem@kernel.org,djwong@kernel.org,gregkh@linuxfoundation.org,hch@lst.de,xfs-stable@lists.linux.dev
Cc: <stable-commits@vger.kernel.org>
Subject: Patch "xfs: return bool from xfs_attr3_leaf_add" has been added to the 6.6-stable tree
Date: Fri, 21 Feb 2025 16:23:28 +0100	[thread overview]
Message-ID: <2025022128-unrivaled-distract-ec1d@gregkh> (raw)
In-Reply-To: <20250205214025.72516-9-catherine.hoang@oracle.com>


This is a note to let you know that I've just added the patch titled

    xfs: return bool from xfs_attr3_leaf_add

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xfs-return-bool-from-xfs_attr3_leaf_add.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From stable+bounces-113974-greg=kroah.com@vger.kernel.org Wed Feb  5 22:40:56 2025
From: Catherine Hoang <catherine.hoang@oracle.com>
Date: Wed,  5 Feb 2025 13:40:09 -0800
Subject: xfs: return bool from xfs_attr3_leaf_add
To: stable@vger.kernel.org
Cc: xfs-stable@lists.linux.dev
Message-ID: <20250205214025.72516-9-catherine.hoang@oracle.com>

From: Christoph Hellwig <hch@lst.de>

commit 346c1d46d4c631c0c88592d371f585214d714da4 upstream.

[backport: dependency of a5f7334 and b3f4e84]

xfs_attr3_leaf_add only has two potential return values, indicating if the
entry could be added or not.  Replace the errno return with a bool so that
ENOSPC from it can't easily be confused with a real ENOSPC.

Remove the return value from the xfs_attr3_leaf_add_work helper entirely,
as it always return 0.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_attr.c      |   13 +++++--------
 fs/xfs/libxfs/xfs_attr_leaf.c |   37 +++++++++++++++++++------------------
 fs/xfs/libxfs/xfs_attr_leaf.h |    2 +-
 3 files changed, 25 insertions(+), 27 deletions(-)

--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -503,10 +503,7 @@ xfs_attr_leaf_addname(
 	 * or perform more xattr manipulations. Otherwise there is nothing more
 	 * to do and we can return success.
 	 */
-	error = xfs_attr3_leaf_add(bp, args);
-	if (error) {
-		if (error != -ENOSPC)
-			return error;
+	if (!xfs_attr3_leaf_add(bp, args)) {
 		error = xfs_attr3_leaf_to_node(args);
 		if (error)
 			return error;
@@ -520,7 +517,7 @@ xfs_attr_leaf_addname(
 	}
 
 	trace_xfs_attr_leaf_addname_return(attr->xattri_dela_state, args->dp);
-	return error;
+	return 0;
 
 out_brelse:
 	xfs_trans_brelse(args->trans, bp);
@@ -1393,21 +1390,21 @@ xfs_attr_node_try_addname(
 {
 	struct xfs_da_state		*state = attr->xattri_da_state;
 	struct xfs_da_state_blk		*blk;
-	int				error;
+	int				error = 0;
 
 	trace_xfs_attr_node_addname(state->args);
 
 	blk = &state->path.blk[state->path.active-1];
 	ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
 
-	error = xfs_attr3_leaf_add(blk->bp, state->args);
-	if (error == -ENOSPC) {
+	if (!xfs_attr3_leaf_add(blk->bp, state->args)) {
 		if (state->path.active == 1) {
 			/*
 			 * Its really a single leaf node, but it had
 			 * out-of-line values so it looked like it *might*
 			 * have been a b-tree. Let the caller deal with this.
 			 */
+			error = -ENOSPC;
 			goto out;
 		}
 
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -46,7 +46,7 @@
  */
 STATIC int xfs_attr3_leaf_create(struct xfs_da_args *args,
 				 xfs_dablk_t which_block, struct xfs_buf **bpp);
-STATIC int xfs_attr3_leaf_add_work(struct xfs_buf *leaf_buffer,
+STATIC void xfs_attr3_leaf_add_work(struct xfs_buf *leaf_buffer,
 				   struct xfs_attr3_icleaf_hdr *ichdr,
 				   struct xfs_da_args *args, int freemap_index);
 STATIC void xfs_attr3_leaf_compact(struct xfs_da_args *args,
@@ -990,10 +990,8 @@ xfs_attr_shortform_to_leaf(
 		}
 		error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */
 		ASSERT(error == -ENOATTR);
-		error = xfs_attr3_leaf_add(bp, &nargs);
-		ASSERT(error != -ENOSPC);
-		if (error)
-			goto out;
+		if (!xfs_attr3_leaf_add(bp, &nargs))
+			ASSERT(0);
 		sfe = xfs_attr_sf_nextentry(sfe);
 	}
 	error = 0;
@@ -1349,8 +1347,9 @@ xfs_attr3_leaf_split(
 	struct xfs_da_state_blk	*oldblk,
 	struct xfs_da_state_blk	*newblk)
 {
-	xfs_dablk_t blkno;
-	int error;
+	bool			added;
+	xfs_dablk_t		blkno;
+	int			error;
 
 	trace_xfs_attr_leaf_split(state->args);
 
@@ -1385,10 +1384,10 @@ xfs_attr3_leaf_split(
 	 */
 	if (state->inleaf) {
 		trace_xfs_attr_leaf_add_old(state->args);
-		error = xfs_attr3_leaf_add(oldblk->bp, state->args);
+		added = xfs_attr3_leaf_add(oldblk->bp, state->args);
 	} else {
 		trace_xfs_attr_leaf_add_new(state->args);
-		error = xfs_attr3_leaf_add(newblk->bp, state->args);
+		added = xfs_attr3_leaf_add(newblk->bp, state->args);
 	}
 
 	/*
@@ -1396,13 +1395,15 @@ xfs_attr3_leaf_split(
 	 */
 	oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
 	newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
-	return error;
+	if (!added)
+		return -ENOSPC;
+	return 0;
 }
 
 /*
  * Add a name to the leaf attribute list structure.
  */
-int
+bool
 xfs_attr3_leaf_add(
 	struct xfs_buf		*bp,
 	struct xfs_da_args	*args)
@@ -1411,6 +1412,7 @@ xfs_attr3_leaf_add(
 	struct xfs_attr3_icleaf_hdr ichdr;
 	int			tablesize;
 	int			entsize;
+	bool			added = true;
 	int			sum;
 	int			tmp;
 	int			i;
@@ -1439,7 +1441,7 @@ xfs_attr3_leaf_add(
 		if (ichdr.freemap[i].base < ichdr.firstused)
 			tmp += sizeof(xfs_attr_leaf_entry_t);
 		if (ichdr.freemap[i].size >= tmp) {
-			tmp = xfs_attr3_leaf_add_work(bp, &ichdr, args, i);
+			xfs_attr3_leaf_add_work(bp, &ichdr, args, i);
 			goto out_log_hdr;
 		}
 		sum += ichdr.freemap[i].size;
@@ -1451,7 +1453,7 @@ xfs_attr3_leaf_add(
 	 * no good and we should just give up.
 	 */
 	if (!ichdr.holes && sum < entsize)
-		return -ENOSPC;
+		return false;
 
 	/*
 	 * Compact the entries to coalesce free space.
@@ -1464,24 +1466,24 @@ xfs_attr3_leaf_add(
 	 * free region, in freemap[0].  If it is not big enough, give up.
 	 */
 	if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) {
-		tmp = -ENOSPC;
+		added = false;
 		goto out_log_hdr;
 	}
 
-	tmp = xfs_attr3_leaf_add_work(bp, &ichdr, args, 0);
+	xfs_attr3_leaf_add_work(bp, &ichdr, args, 0);
 
 out_log_hdr:
 	xfs_attr3_leaf_hdr_to_disk(args->geo, leaf, &ichdr);
 	xfs_trans_log_buf(args->trans, bp,
 		XFS_DA_LOGRANGE(leaf, &leaf->hdr,
 				xfs_attr3_leaf_hdr_size(leaf)));
-	return tmp;
+	return added;
 }
 
 /*
  * Add a name to a leaf attribute list structure.
  */
-STATIC int
+STATIC void
 xfs_attr3_leaf_add_work(
 	struct xfs_buf		*bp,
 	struct xfs_attr3_icleaf_hdr *ichdr,
@@ -1599,7 +1601,6 @@ xfs_attr3_leaf_add_work(
 		}
 	}
 	ichdr->usedbytes += xfs_attr_leaf_entsize(leaf, args->index);
-	return 0;
 }
 
 /*
--- a/fs/xfs/libxfs/xfs_attr_leaf.h
+++ b/fs/xfs/libxfs/xfs_attr_leaf.h
@@ -78,7 +78,7 @@ int	xfs_attr3_leaf_split(struct xfs_da_s
 int	xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
 					struct xfs_da_args *args);
 int	xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
-int	xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
+bool	xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
 				 struct xfs_da_args *args);
 int	xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
 				    struct xfs_da_args *args);


Patches currently in stable-queue which might be from catherine.hoang@oracle.com are

queue-6.6/xfs-return-bool-from-xfs_attr3_leaf_add.patch
queue-6.6/xfs-fix-a-sloppy-memory-handling-bug-in-xfs_iroot_realloc.patch
queue-6.6/xfs-streamline-xfs_filestream_pick_ag.patch
queue-6.6/xfs-merge-xfs_attr_leaf_try_add-into-xfs_attr_leaf_addname.patch
queue-6.6/xfs-don-t-free-cowblocks-from-under-dirty-pagecache-on-unshare.patch
queue-6.6/xfs-pass-the-exact-range-to-initialize-to-xfs_initialize_perag.patch
queue-6.6/xfs-assert-a-valid-limit-in-xfs_rtfind_forw.patch
queue-6.6/xfs-don-t-use-__gfp_retry_mayfail-in-xfs_initialize_perag.patch
queue-6.6/xfs-use-try_cmpxchg-in-xlog_cil_insert_pcp_aggregate.patch
queue-6.6/xfs-don-t-ifdef-around-the-exact-minlen-allocations.patch
queue-6.6/xfs-reduce-unnecessary-searches-when-searching-for-the-best-extents.patch
queue-6.6/xfs-validate-inumber-in-xfs_iget.patch
queue-6.6/xfs-support-lowmode-allocations-in-xfs_bmap_exact_minlen_extent_alloc.patch
queue-6.6/xfs-skip-background-cowblock-trims-on-inodes-open-for-write.patch
queue-6.6/xfs-remove-empty-declartion-in-header-file.patch
queue-6.6/xfs-fold-xfs_bmap_alloc_userdata-into-xfs_bmapi_allocate.patch
queue-6.6/xfs-update-the-file-system-geometry-after-recoverying-superblock-buffers.patch
queue-6.6/xfs-call-xfs_bmap_exact_minlen_extent_alloc-from-xfs_bmap_btalloc.patch
queue-6.6/xfs-distinguish-extra-split-from-real-enospc-from-xfs_attr_node_try_addname.patch
queue-6.6/xfs-error-out-when-a-superblock-buffer-update-reduces-the-agcount.patch
queue-6.6/xfs-update-the-pag-for-the-last-ag-at-recovery-time.patch
queue-6.6/xfs-check-for-delayed-allocations-before-setting-extsize.patch
queue-6.6/xfs-fix-a-typo.patch
queue-6.6/xfs-distinguish-extra-split-from-real-enospc-from-xfs_attr3_leaf_split.patch

  reply	other threads:[~2025-02-21 15:24 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 21:40 [PATCH 6.6 00/24] xfs backports for 6.6.y (from 6.12) Catherine Hoang
2025-02-05 21:40 ` [PATCH 6.6 01/24] xfs: assert a valid limit in xfs_rtfind_forw Catherine Hoang
2025-02-07 22:51   ` Sasha Levin
2025-02-21 15:23   ` Patch "xfs: assert a valid limit in xfs_rtfind_forw" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 02/24] xfs: validate inumber in xfs_iget Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: validate inumber in xfs_iget" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 03/24] xfs: fix a sloppy memory handling bug in xfs_iroot_realloc Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: fix a sloppy memory handling bug in xfs_iroot_realloc" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 04/24] xfs: fix a typo Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: fix a typo" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 05/24] xfs: skip background cowblock trims on inodes open for write Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: skip background cowblock trims on inodes open for write" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 06/24] xfs: don't free cowblocks from under dirty pagecache on unshare Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: don't free cowblocks from under dirty pagecache on unshare" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 07/24] xfs: merge xfs_attr_leaf_try_add into xfs_attr_leaf_addname Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: merge xfs_attr_leaf_try_add into xfs_attr_leaf_addname" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 08/24] xfs: return bool from xfs_attr3_leaf_add Catherine Hoang
2025-02-21 15:23   ` gregkh [this message]
2025-02-05 21:40 ` [PATCH 6.6 09/24] xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 10/24] xfs: distinguish extra split from real ENOSPC from xfs_attr_node_try_addname Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: distinguish extra split from real ENOSPC from xfs_attr_node_try_addname" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 11/24] xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 12/24] xfs: don't ifdef around the exact minlen allocations Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: don't ifdef around the exact minlen allocations" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 13/24] xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 14/24] xfs: support lowmode allocations in xfs_bmap_exact_minlen_extent_alloc Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: support lowmode allocations in xfs_bmap_exact_minlen_extent_alloc" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 15/24] xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate() Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate()" has been added to the 6.6-stable tree gregkh
2025-02-21 15:33     ` Uros Bizjak
2025-02-21 15:57       ` Greg KH
2025-02-05 21:40 ` [PATCH 6.6 16/24] xfs: Remove empty declartion in header file Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: Remove empty declartion in header file" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 17/24] xfs: pass the exact range to initialize to xfs_initialize_perag Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: pass the exact range to initialize to xfs_initialize_perag" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 18/24] xfs: update the file system geometry after recoverying superblock buffers Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: update the file system geometry after recoverying superblock buffers" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 19/24] xfs: error out when a superblock buffer update reduces the agcount Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: error out when a superblock buffer update reduces the agcount" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 20/24] xfs: don't use __GFP_RETRY_MAYFAIL in xfs_initialize_perag Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: don't use __GFP_RETRY_MAYFAIL in xfs_initialize_perag" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 21/24] xfs: update the pag for the last AG at recovery time Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: update the pag for the last AG at recovery time" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 22/24] xfs: Reduce unnecessary searches when searching for the best extents Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: Reduce unnecessary searches when searching for the best extents" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 23/24] xfs: streamline xfs_filestream_pick_ag Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: streamline xfs_filestream_pick_ag" has been added to the 6.6-stable tree gregkh
2025-02-05 21:40 ` [PATCH 6.6 24/24] xfs: Check for delayed allocations before setting extsize Catherine Hoang
2025-02-21 15:23   ` Patch "xfs: Check for delayed allocations before setting extsize" has been added to the 6.6-stable tree gregkh

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=2025022128-unrivaled-distract-ec1d@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=catherine.hoang@oracle.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=stable-commits@vger.kernel.org \
    --cc=xfs-stable@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.