Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/3] xfsprogs: libxfs-v7.0-sync
@ 2026-04-27 12:09 Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 1/3] xfs: annotate struct xfs_attr_list_context with __counted_by_ptr Andrey Albershteyn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrey Albershteyn @ 2026-04-27 12:09 UTC (permalink / raw)
  To: linux-xfs; +Cc: cem, djwong, hch, leo.lilong, morbo, Andrey Albershteyn

Hi all,

This is libxfs sync to v7.0 with a few missing patches. The most of the sync was
done by Darrick as part of his xfs_healer/health monitoring series.

The __counted_by_ptr is NOPed. This attribute existed before but without
pointer support, so this can not be easily wrapped by has_attribute. This will
require build checks to check compiler version which doesn't seem to be a
practice in xfsprogs.

Range-diff attached below.

Git Tag:
https://git.kernel.org/pub/scm/linux/kernel/git/aalbersh/xfsprogs-dev.git tags/libxfs-v7.0-sync_2026-04-27

Bill Wendling (1):
  xfs: annotate struct xfs_attr_list_context with __counted_by_ptr

Long Li (2):
  xfs: factor out xfs_attr3_node_entry_remove
  xfs: factor out xfs_attr3_leaf_init

 include/platform_defs.h |  3 +++
 libxfs/xfs_attr.h       |  3 ++-
 libxfs/xfs_attr_leaf.c  | 22 +++++++++++++++++
 libxfs/xfs_attr_leaf.h  |  3 +++
 libxfs/xfs_da_btree.c   | 53 ++++++++++++++++++++++++++++++++---------
 libxfs/xfs_da_btree.h   |  2 ++
 6 files changed, 74 insertions(+), 12 deletions(-)

-- 
2.51.2

-- 
1:  d67701f62d9a ! 1:  df91bc3bdc9b xfs: annotate struct xfs_attr_list_context with __counted_by_ptr
    @@ Commit message
         Signed-off-by: Carlos Maiolino <cem@kernel.org>
         Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
     
    + ## include/platform_defs.h ##
    +@@ include/platform_defs.h: struct kvec {
    + #define BLK_ZONE_COND_ACTIVE      0xff
    + #endif
    + 
    ++/* xfs_attr.h */
    ++#define __counted_by_ptr(member)
    ++
    + #endif    /* __XFS_PLATFORM_DEFS_H__ */
    +
      ## libxfs/xfs_attr.h ##
     @@ libxfs/xfs_attr.h: struct xfs_attr_list_context {
        struct xfs_trans        *tp;
2:  d3b48de1f7db = 2:  e7aab724c89a xfs: factor out xfs_attr3_node_entry_remove
3:  a0a6a995a5b5 = 3:  922f14a9b776 xfs: factor out xfs_attr3_leaf_init

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] xfs: annotate struct xfs_attr_list_context with __counted_by_ptr
  2026-04-27 12:09 [PATCH 0/3] xfsprogs: libxfs-v7.0-sync Andrey Albershteyn
@ 2026-04-27 12:09 ` Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 2/3] xfs: factor out xfs_attr3_node_entry_remove Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 3/3] xfs: factor out xfs_attr3_leaf_init Andrey Albershteyn
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Albershteyn @ 2026-04-27 12:09 UTC (permalink / raw)
  To: linux-xfs; +Cc: cem, djwong, hch, leo.lilong, morbo, Andrey Albershteyn

From: Bill Wendling <morbo@google.com>

Source kernel commit: e5966096d0856d071269cb5928d6bc33342d2dfd

Add the `__counted_by_ptr` attribute to the `buffer` field of `struct
xfs_attr_list_context`. This field is used to point to a buffer of
size `bufsize`.

The `buffer` field is assigned in:
1. `xfs_ioc_attr_list` in `fs/xfs/xfs_handle.c`
2. `xfs_xattr_list` in `fs/xfs/xfs_xattr.c`
3. `xfs_getparents` in `fs/xfs/xfs_handle.c` (implicitly initialized to NULL)

In `xfs_ioc_attr_list`, `buffer` was assigned before `bufsize`. Reorder
them to ensure `bufsize` is set before `buffer` is assigned, although
no access happens between them.

In `xfs_xattr_list`, `buffer` was assigned before `bufsize`. Reorder
them to ensure `bufsize` is set before `buffer` is assigned.

In `xfs_getparents`, `buffer` is NULL (from zero initialization) and
remains NULL. `bufsize` is set to a non-zero value, but since `buffer`
is NULL, no access occurs.

In all cases, the pointer `buffer` is not accessed before `bufsize` is set.

This patch was generated by CodeMender and reviewed by Bill Wendling.
Tested by running xfstests.

Signed-off-by: Bill Wendling <morbo@google.com>
Reviewed-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: Andrey Albershteyn <aalbersh@kernel.org>
---
 include/platform_defs.h | 3 +++
 libxfs/xfs_attr.h       | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/platform_defs.h b/include/platform_defs.h
index b2d80597a83a..5a829db66e08 100644
--- a/include/platform_defs.h
+++ b/include/platform_defs.h
@@ -330,4 +330,7 @@ struct kvec {
 #define BLK_ZONE_COND_ACTIVE	0xff
 #endif
 
+/* xfs_attr.h */
+#define __counted_by_ptr(member)
+
 #endif	/* __XFS_PLATFORM_DEFS_H__ */
diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h
index 8244305949de..67fd9c75ac3f 100644
--- a/libxfs/xfs_attr.h
+++ b/libxfs/xfs_attr.h
@@ -55,7 +55,8 @@ struct xfs_attr_list_context {
 	struct xfs_trans	*tp;
 	struct xfs_inode	*dp;		/* inode */
 	struct xfs_attrlist_cursor_kern cursor;	/* position in list */
-	void			*buffer;	/* output buffer */
+	/* output buffer */
+	void			*buffer __counted_by_ptr(bufsize);
 
 	/*
 	 * Abort attribute list iteration if non-zero.  Can be used to pass
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] xfs: factor out xfs_attr3_node_entry_remove
  2026-04-27 12:09 [PATCH 0/3] xfsprogs: libxfs-v7.0-sync Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 1/3] xfs: annotate struct xfs_attr_list_context with __counted_by_ptr Andrey Albershteyn
@ 2026-04-27 12:09 ` Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 3/3] xfs: factor out xfs_attr3_leaf_init Andrey Albershteyn
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Albershteyn @ 2026-04-27 12:09 UTC (permalink / raw)
  To: linux-xfs; +Cc: cem, djwong, hch, leo.lilong, morbo, Andrey Albershteyn

From: Long Li <leo.lilong@huawei.com>

Source kernel commit: ce4e789cf3561c9fac73cc24445bfed9ea0c514b

Factor out wrapper xfs_attr3_node_entry_remove function, which
exported for external use.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Long Li <leo.lilong@huawei.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
 libxfs/xfs_da_btree.c | 53 ++++++++++++++++++++++++++++++++++---------
 libxfs/xfs_da_btree.h |  2 ++
 2 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
index 2fce657af5d0..508fd1475c00 100644
--- a/libxfs/xfs_da_btree.c
+++ b/libxfs/xfs_da_btree.c
@@ -1502,21 +1502,20 @@ xfs_da3_fixhashpath(
 }
 
 /*
- * Remove an entry from an intermediate node.
+ * Internal implementation to remove an entry from an intermediate node.
  */
 STATIC void
-xfs_da3_node_remove(
-	struct xfs_da_state	*state,
-	struct xfs_da_state_blk	*drop_blk)
+__xfs_da3_node_remove(
+	struct xfs_trans	*tp,
+	struct xfs_inode	*dp,
+	struct xfs_da_geometry  *geo,
+	struct xfs_da_state_blk *drop_blk)
 {
 	struct xfs_da_intnode	*node;
 	struct xfs_da3_icnode_hdr nodehdr;
 	struct xfs_da_node_entry *btree;
 	int			index;
 	int			tmp;
-	struct xfs_inode	*dp = state->args->dp;
-
-	trace_xfs_da_node_remove(state->args);
 
 	node = drop_blk->bp->b_addr;
 	xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, node);
@@ -1532,17 +1531,17 @@ xfs_da3_node_remove(
 		tmp  = nodehdr.count - index - 1;
 		tmp *= (uint)sizeof(xfs_da_node_entry_t);
 		memmove(&btree[index], &btree[index + 1], tmp);
-		xfs_trans_log_buf(state->args->trans, drop_blk->bp,
+		xfs_trans_log_buf(tp, drop_blk->bp,
 		    XFS_DA_LOGRANGE(node, &btree[index], tmp));
 		index = nodehdr.count - 1;
 	}
 	memset(&btree[index], 0, sizeof(xfs_da_node_entry_t));
-	xfs_trans_log_buf(state->args->trans, drop_blk->bp,
+	xfs_trans_log_buf(tp, drop_blk->bp,
 	    XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
 	nodehdr.count -= 1;
 	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
-	xfs_trans_log_buf(state->args->trans, drop_blk->bp,
-	    XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));
+	xfs_trans_log_buf(tp, drop_blk->bp,
+	    XFS_DA_LOGRANGE(node, &node->hdr, geo->node_hdr_size));
 
 	/*
 	 * Copy the last hash value from the block to propagate upwards.
@@ -1550,6 +1549,38 @@ xfs_da3_node_remove(
 	drop_blk->hashval = be32_to_cpu(btree[index - 1].hashval);
 }
 
+/*
+ * Remove an entry from an intermediate node.
+ */
+STATIC void
+xfs_da3_node_remove(
+	struct xfs_da_state	*state,
+	struct xfs_da_state_blk	*drop_blk)
+{
+	trace_xfs_da_node_remove(state->args);
+
+	__xfs_da3_node_remove(state->args->trans, state->args->dp,
+			state->args->geo, drop_blk);
+}
+
+/*
+ * Remove an entry from an intermediate attr node at the specified index.
+ */
+void
+xfs_attr3_node_entry_remove(
+	struct xfs_trans	*tp,
+	struct xfs_inode	*dp,
+	struct xfs_buf		*bp,
+	int			index)
+{
+	struct xfs_da_state_blk blk = {
+		.index		= index,
+		.bp		= bp,
+	};
+
+	__xfs_da3_node_remove(tp, dp, dp->i_mount->m_attr_geo, &blk);
+}
+
 /*
  * Unbalance the elements between two intermediate nodes,
  * move all Btree elements from one node into another.
diff --git a/libxfs/xfs_da_btree.h b/libxfs/xfs_da_btree.h
index 354d5d65043e..afcf2d3c7a21 100644
--- a/libxfs/xfs_da_btree.h
+++ b/libxfs/xfs_da_btree.h
@@ -184,6 +184,8 @@ int	xfs_da3_split(xfs_da_state_t *state);
 int	xfs_da3_join(xfs_da_state_t *state);
 void	xfs_da3_fixhashpath(struct xfs_da_state *state,
 			    struct xfs_da_state_path *path_to_to_fix);
+void	xfs_attr3_node_entry_remove(struct xfs_trans *tp, struct xfs_inode *dp,
+			    struct xfs_buf *bp, int index);
 
 /*
  * Routines used for finding things in the Btree.
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] xfs: factor out xfs_attr3_leaf_init
  2026-04-27 12:09 [PATCH 0/3] xfsprogs: libxfs-v7.0-sync Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 1/3] xfs: annotate struct xfs_attr_list_context with __counted_by_ptr Andrey Albershteyn
  2026-04-27 12:09 ` [PATCH 2/3] xfs: factor out xfs_attr3_node_entry_remove Andrey Albershteyn
@ 2026-04-27 12:09 ` Andrey Albershteyn
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Albershteyn @ 2026-04-27 12:09 UTC (permalink / raw)
  To: linux-xfs; +Cc: cem, djwong, hch, leo.lilong, morbo, Andrey Albershteyn

From: Long Li <leo.lilong@huawei.com>

Source kernel commit: e65bb55d7f8c2041c8fdb73cd29b0b4cad4ed847

Factor out wrapper xfs_attr3_leaf_init function, which exported for
external use.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Long Li <leo.lilong@huawei.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
 libxfs/xfs_attr_leaf.c | 22 ++++++++++++++++++++++
 libxfs/xfs_attr_leaf.h |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
index 90be21a38876..6aaa7ff10959 100644
--- a/libxfs/xfs_attr_leaf.c
+++ b/libxfs/xfs_attr_leaf.c
@@ -1412,6 +1412,28 @@ xfs_attr3_leaf_create(
 	return 0;
 }
 
+/*
+ * Reinitialize an existing attr fork block as an empty leaf, and attach
+ * the buffer to tp.
+ */
+int
+xfs_attr3_leaf_init(
+	struct xfs_trans	*tp,
+	struct xfs_inode	*dp,
+	xfs_dablk_t		blkno)
+{
+	struct xfs_buf		*bp = NULL;
+	struct xfs_da_args	args = {
+		.trans		= tp,
+		.dp		= dp,
+		.owner		= dp->i_ino,
+		.geo		= dp->i_mount->m_attr_geo,
+	};
+
+	ASSERT(tp != NULL);
+
+	return xfs_attr3_leaf_create(&args, blkno, &bp);
+}
 /*
  * Split the leaf node, rebalance, then add the new entry.
  *
diff --git a/libxfs/xfs_attr_leaf.h b/libxfs/xfs_attr_leaf.h
index aca46da2bc50..72639efe6ac3 100644
--- a/libxfs/xfs_attr_leaf.h
+++ b/libxfs/xfs_attr_leaf.h
@@ -87,6 +87,9 @@ int	xfs_attr3_leaf_list_int(struct xfs_buf *bp,
 /*
  * Routines used for shrinking the Btree.
  */
+
+int	xfs_attr3_leaf_init(struct xfs_trans *tp, struct xfs_inode *dp,
+				xfs_dablk_t blkno);
 int	xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
 void	xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
 				       struct xfs_da_state_blk *drop_blk,
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-27 12:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 12:09 [PATCH 0/3] xfsprogs: libxfs-v7.0-sync Andrey Albershteyn
2026-04-27 12:09 ` [PATCH 1/3] xfs: annotate struct xfs_attr_list_context with __counted_by_ptr Andrey Albershteyn
2026-04-27 12:09 ` [PATCH 2/3] xfs: factor out xfs_attr3_node_entry_remove Andrey Albershteyn
2026-04-27 12:09 ` [PATCH 3/3] xfs: factor out xfs_attr3_leaf_init Andrey Albershteyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox