xfsprogs: libxfs-v7.0-sync
cover xfsprogs: libxfs-v7.0-sync
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(-)
Signature · 23 lines
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 <[email protected]>
Signed-off-by: Andrey Albershteyn <[email protected]>
+ ## 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_initPATCH 1/3 xfs: annotate struct xfs_attr_list_context with __counted_by_ptr
From: Bill Wendling <[email protected]>
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.
--- include/platform_defs.h | 3 +++ libxfs/xfs_attr.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
include/platform_defs.h +3 -0
@@ -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__ */
libxfs/xfs_attr.h +2 -1
@@ -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
Signature · 1 line
2.51.2
PATCH 2/3 xfs: factor out xfs_attr3_node_entry_remove
In reply to Andrey AlbershteynFrom: Long Li <[email protected]>
Source kernel commit: ce4e789cf3561c9fac73cc24445bfed9ea0c514b
Factor out wrapper xfs_attr3_node_entry_remove function, which exported for external use.
--- libxfs/xfs_da_btree.c | 53 ++++++++++++++++++++++++++++++++++--------- libxfs/xfs_da_btree.h | 2 ++ 2 files changed, 44 insertions(+), 11 deletions(-)
libxfs/xfs_da_btree.c +42 -11
@@ -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.
libxfs/xfs_da_btree.h +2 -0
@@ -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.
Signature · 1 line
2.51.2
PATCH 3/3 xfs: factor out xfs_attr3_leaf_init
In reply to Andrey AlbershteynFrom: Long Li <[email protected]>
Source kernel commit: e65bb55d7f8c2041c8fdb73cd29b0b4cad4ed847
Factor out wrapper xfs_attr3_leaf_init function, which exported for external use.
--- libxfs/xfs_attr_leaf.c | 22 ++++++++++++++++++++++ libxfs/xfs_attr_leaf.h | 3 +++ 2 files changed, 25 insertions(+)
libxfs/xfs_attr_leaf.c +22 -0
@@ -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. *
libxfs/xfs_attr_leaf.h +3 -0
@@ -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,
Signature · 1 line
2.51.2