* [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2
@ 2026-07-02 19:59 Darrick J. Wong
2026-07-02 20:00 ` [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int Darrick J. Wong
` (18 more replies)
0 siblings, 19 replies; 25+ messages in thread
From: Darrick J. Wong @ 2026-07-02 19:59 UTC (permalink / raw)
To: aalbersh, djwong
Cc: chuck.lever, roland.mainz, cmaiolino, cem, hch, brauner,
gaoyingjie, linux-xfs
Hi all,
This series ports kernel libxfs code to userspace from 7.2-rc1.
If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.
With a bit of luck, this should all go splendidly.
Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=libxfs-7.2-sync
---
Commits in this patchset:
* libxfs: convert diff_items helpers to cmp_int
* xfs: Report case sensitivity in fileattr_get
* xfs: fix exchmaps reservation limit check
* xfs: add a XFS_INODE_TO_AGNO helper
* xfs: add a XFS_INODE_TO_AGINO helper
* xfs: add a XFS_INO_TO_FSB helper
* xfs: add a xfs_rmap_inode_bmbt_owner
* xfs: add a xfs_rmap_inode_owner helper
* xfs: remove the i_ino field in struct xfs_inode
* xfs: cleanup xfs_imap
* xfs: remove im_len field in struct xfs_imap
* xfs: massage xfs_imap_to_bp into xfs_read_icluster
* xfs: store an agbno in struct xfs_imap
* xfs: mark struct xfs_imap as __packed
* xfs: fix pointer arithmetic error on 32-bit systems
* xfs: pass back updated nb from xfs_growfs_compute_deltas
* xfs: cleanup xfs_growfs_compute_deltas
* xfs: move XFS_LSN_CMP to xfs_log_format.h
---
include/linux.h | 17 +++++
include/xfs_inode.h | 7 ++
libxfs/libxfs_api_defs.h | 2 -
libxfs/xfs_ag.h | 5 +-
libxfs/xfs_bmap_btree.h | 2 -
libxfs/xfs_format.h | 6 ++
libxfs/xfs_inode_buf.h | 13 ++--
libxfs/xfs_log_format.h | 13 ++++
libxfs/xfs_parent.h | 2 -
libxfs/xfs_rmap.h | 4 +
db/attrset.c | 2 -
db/bmap_inflate.c | 4 +
db/dquot.c | 2 -
db/iunlink.c | 13 +++-
db/namei.c | 14 ++--
db/rdump.c | 2 -
libxfs/defer_item.c | 8 +--
libxfs/inode.c | 8 +--
libxfs/iunlink.c | 4 +
libxfs/listxattr.c | 4 +
libxfs/logitem.c | 17 ++++-
libxfs/util.c | 2 -
libxfs/xfs_ag.c | 42 ++++++-------
libxfs/xfs_attr.c | 2 -
libxfs/xfs_attr_leaf.c | 2 -
libxfs/xfs_bmap.c | 20 +++---
libxfs/xfs_bmap_btree.c | 8 +--
libxfs/xfs_btree.c | 18 +++---
libxfs/xfs_btree_staging.c | 2 -
libxfs/xfs_da_btree.c | 2 -
libxfs/xfs_dir2.c | 44 +++++++-------
libxfs/xfs_dir2_node.c | 2 -
libxfs/xfs_dir2_sf.c | 4 +
libxfs/xfs_exchmaps.c | 10 ++-
libxfs/xfs_ialloc.c | 90 ++++++++++++-----------------
libxfs/xfs_inode_buf.c | 24 ++++----
libxfs/xfs_inode_fork.c | 6 +-
libxfs/xfs_inode_util.c | 15 +++--
libxfs/xfs_metadir.c | 2 -
libxfs/xfs_parent.c | 8 +--
libxfs/xfs_rmap.c | 6 +-
libxfs/xfs_rtbitmap.c | 4 +
libxfs/xfs_rtrefcount_btree.c | 4 +
libxfs/xfs_rtrmap_btree.c | 4 +
libxfs/xfs_symlink_remote.c | 6 +-
mkfs/proto.c | 16 +++--
repair/bmap_repair.c | 12 +++-
repair/bulkload.c | 2 -
repair/phase6.c | 128 +++++++++++++++++++++--------------------
repair/pptr.c | 100 ++++++++++++++++----------------
repair/quotacheck.c | 8 +--
repair/rt.c | 6 +-
repair/rtrefcount_repair.c | 2 -
repair/rtrmap_repair.c | 2 -
repair/xfs_repair.c | 2 -
55 files changed, 394 insertions(+), 360 deletions(-)
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong @ 2026-07-02 20:00 ` Darrick J. Wong 2026-07-06 6:50 ` Christoph Hellwig 2026-07-02 20:00 ` [PATCH 02/18] xfs: Report case sensitivity in fileattr_get Darrick J. Wong ` (17 subsequent siblings) 18 siblings, 1 reply; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:00 UTC (permalink / raw) To: aalbersh, djwong; +Cc: linux-xfs From: Darrick J. Wong <djwong@kernel.org> Convert each log item type's ->diff_items implementation to use cmp_int like we did for the kernel a while ago. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> --- libxfs/defer_item.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 4fc2c74a548c91..5d72ee0706f0b7 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -50,7 +50,7 @@ xfs_extent_free_diff_items( struct xfs_extent_free_item *ra = xefi_entry(a); struct xfs_extent_free_item *rb = xefi_entry(b); - return ra->xefi_group->xg_gno - rb->xefi_group->xg_gno; + return cmp_int(ra->xefi_group->xg_gno, rb->xefi_group->xg_gno); } /* Get an EFI. */ @@ -252,7 +252,7 @@ xfs_rmap_update_diff_items( struct xfs_rmap_intent *ra = ri_entry(a); struct xfs_rmap_intent *rb = ri_entry(b); - return ra->ri_group->xg_gno - rb->ri_group->xg_gno; + return cmp_int(ra->ri_group->xg_gno, rb->ri_group->xg_gno); } /* Get an RUI. */ @@ -404,7 +404,7 @@ xfs_refcount_update_diff_items( struct xfs_refcount_intent *ra = ci_entry(a); struct xfs_refcount_intent *rb = ci_entry(b); - return ra->ri_group->xg_gno - rb->ri_group->xg_gno; + return cmp_int(ra->ri_group->xg_gno, rb->ri_group->xg_gno); } /* Get an CUI. */ @@ -563,7 +563,7 @@ xfs_bmap_update_diff_items( struct xfs_bmap_intent *ba = bi_entry(a); struct xfs_bmap_intent *bb = bi_entry(b); - return ba->bi_owner->i_ino - bb->bi_owner->i_ino; + return cmp_int(ba->bi_owner->i_ino, bb->bi_owner->i_ino); } /* Get an BUI. */ ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int 2026-07-02 20:00 ` [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int Darrick J. Wong @ 2026-07-06 6:50 ` Christoph Hellwig 0 siblings, 0 replies; 25+ messages in thread From: Christoph Hellwig @ 2026-07-06 6:50 UTC (permalink / raw) To: Darrick J. Wong; +Cc: aalbersh, linux-xfs Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 02/18] xfs: Report case sensitivity in fileattr_get 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong 2026-07-02 20:00 ` [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int Darrick J. Wong @ 2026-07-02 20:00 ` Darrick J. Wong 2026-07-02 20:01 ` [PATCH 03/18] xfs: fix exchmaps reservation limit check Darrick J. Wong ` (16 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:00 UTC (permalink / raw) To: aalbersh, djwong; +Cc: brauner, chuck.lever, roland.mainz, linux-xfs From: Chuck Lever <cel@kernel.org> Source kernel commit: c9da43e4e5c32c2cb318e616ffa48c7148a70d49 Upper layers such as NFSD need to query whether a filesystem is case-sensitive. Add FS_XFLAG_CASEFOLD to xfs_ip2xflags() when the filesystem is formatted with the ASCIICI feature flag. This serves both FS_IOC_FSGETXATTR (via xfs_fill_fsxattr() in xfs_fileattr_get()) and XFS_IOC_BULKSTAT (which populates bs_xflags directly from xfs_ip2xflags()), so bulkstat consumers and per-inode queries see a consistent view of the filesystem's case-folding behavior. FS_XFLAG_CASEFOLD is read-only: FS_XFLAG_RDONLY_MASK ensures FS_IOC_FSSETXATTR strips it, and xfs_flags2diflags() has no clause for CASEFOLD so the on-disk diflags are unaffected. The legacy FS_IOC_SETFLAGS path in xfs_fileattr_set() also allows FS_CASEFOLD_FL through its allowlist on ASCIICI filesystems so that a chattr read-modify-write cycle does not fail with EOPNOTSUPP. XFS always preserves case. XFS is case-sensitive by default, but supports ASCII case-insensitive lookups when formatted with the ASCIICI feature flag. Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Link: https://patch.msgid.link/20260507-case-sensitivity-v14-8-e62cc8200435@oracle.com Signed-off-by: Christian Brauner <brauner@kernel.org> [djwong: add some missing FS_XFLAG_ private definitions] Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> --- include/linux.h | 17 +++++++++++++++++ libxfs/xfs_inode_util.c | 2 ++ 2 files changed, 19 insertions(+) diff --git a/include/linux.h b/include/linux.h index 8972c9596c75f5..a10d531cffdb04 100644 --- a/include/linux.h +++ b/include/linux.h @@ -258,6 +258,23 @@ struct file_attr { #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ #endif +#ifndef FS_XFLAG_VERITY +#define FS_XFLAG_VERITY 0x00020000 /* fs-verity enabled */ +#endif + +/* + * Case handling flags (read-only, cannot be set via ioctl). + * Default (neither set) indicates POSIX semantics: case-sensitive + * lookups and case-preserving storage. + */ +#ifndef FS_XFLAG_CASEFOLD +#define FS_XFLAG_CASEFOLD 0x00040000 /* case-insensitive lookups */ +#endif + +#ifndef FS_XFLAG_CASENONPRESERVING +#define FS_XFLAG_CASENONPRESERVING 0x00080000 /* case not preserved */ +#endif + /* Atomic Write */ #ifndef RWF_ATOMIC #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040) diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index ccd38f18c3ed55..fd8441bf9b83dd 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -127,6 +127,8 @@ xfs_ip2xflags( if (xfs_inode_has_attr_fork(ip)) flags |= FS_XFLAG_HASATTR; + if (xfs_has_asciici(ip->i_mount)) + flags |= FS_XFLAG_CASEFOLD; return flags; } ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 03/18] xfs: fix exchmaps reservation limit check 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong 2026-07-02 20:00 ` [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int Darrick J. Wong 2026-07-02 20:00 ` [PATCH 02/18] xfs: Report case sensitivity in fileattr_get Darrick J. Wong @ 2026-07-02 20:01 ` Darrick J. Wong 2026-07-02 20:01 ` [PATCH 04/18] xfs: add a XFS_INODE_TO_AGNO helper Darrick J. Wong ` (15 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:01 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, gaoyingjie, linux-xfs From: Yingjie Gao <gaoyingjie@uniontech.com> Source kernel commit: 0a5213bbff62b51c7d4999ac8c7e11ea57d00d45 xfs_exchmaps_estimate_overhead() adds the bmbt and rmapbt overhead to a local resblks variable, but the final UINT_MAX check still tests req->resblks. That is the reservation value from before the overhead was added. The computed value is stored back in req->resblks and later passed to xfs_trans_alloc(), whose block reservation argument is unsigned int. Check the computed reservation so the existing limit applies to the value that will be used. Fixes: 966ceafc7a43 ("xfs: create deferred log items for file mapping exchanges") Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_exchmaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_exchmaps.c b/libxfs/xfs_exchmaps.c index 5566f9faf45612..651c3784caba73 100644 --- a/libxfs/xfs_exchmaps.c +++ b/libxfs/xfs_exchmaps.c @@ -708,7 +708,7 @@ xfs_exchmaps_estimate_overhead( return -ENOSPC; /* Can't actually reserve more than UINT_MAX blocks. */ - if (req->resblks > UINT_MAX) + if (resblks > UINT_MAX) return -ENOSPC; req->resblks = resblks; ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 04/18] xfs: add a XFS_INODE_TO_AGNO helper 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (2 preceding siblings ...) 2026-07-02 20:01 ` [PATCH 03/18] xfs: fix exchmaps reservation limit check Darrick J. Wong @ 2026-07-02 20:01 ` Darrick J. Wong 2026-07-02 20:01 ` [PATCH 05/18] xfs: add a XFS_INODE_TO_AGINO helper Darrick J. Wong ` (14 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:01 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: a22166add624818a6c43b807d37f99483ba268a6 Add a shortcut for the common XFS_INO_TO_AGNO(mp, ip->i_ino) pattern. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_format.h | 2 ++ db/iunlink.c | 4 ++-- libxfs/inode.c | 2 +- libxfs/xfs_dir2.c | 4 ++-- libxfs/xfs_ialloc.c | 2 +- libxfs/xfs_inode_util.c | 2 +- repair/pptr.c | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 779dac59b1f3ba..36a00c174f1ea1 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1276,6 +1276,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) #define XFS_INO_TO_AGNO(mp,i) \ ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) +#define XFS_INODE_TO_AGNO(ip) \ + XFS_INO_TO_AGNO((ip)->i_mount, (ip)->i_ino) #define XFS_INO_TO_AGINO(mp,i) \ ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) #define XFS_INO_TO_AGBNO(mp,i) \ diff --git a/db/iunlink.c b/db/iunlink.c index c73f818242b983..20946c967f548a 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -22,7 +22,7 @@ count_rtblocks( if (error) { dbprintf( _("could not read AG %u agino %u extents, err=%d\n"), - XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), + XFS_INODE_TO_AGNO(ip), XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), error); return 0; @@ -247,7 +247,7 @@ create_unlinked( dbprintf(_("Created unlinked inode %llu in agno %u\n"), (unsigned long long)ip->i_ino, - XFS_INO_TO_AGNO(mp, ip->i_ino)); + XFS_INODE_TO_AGNO(ip)); libxfs_irele(ip); return error; out_rele: diff --git a/libxfs/inode.c b/libxfs/inode.c index dc7e227e8ee92f..83741b97117106 100644 --- a/libxfs/inode.c +++ b/libxfs/inode.c @@ -159,7 +159,7 @@ libxfs_iget( ip->i_prev_unlinked = NULLAGINO; spin_lock_init(&VFS_I(ip)->i_lock); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, 0); xfs_perag_put(pag); diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c index 1a13fec25e15b3..562d617254b2e3 100644 --- a/libxfs/xfs_dir2.c +++ b/libxfs/xfs_dir2.c @@ -918,7 +918,7 @@ xfs_dir_add_child( if (VFS_I(ip)->i_nlink == 0) { struct xfs_perag *pag; - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); error = xfs_iunlink_remove(tp, pag, ip); xfs_perag_put(pag); if (error) @@ -1245,7 +1245,7 @@ xfs_dir_rename_children( ASSERT(VFS_I(du_wip->ip)->i_nlink == 0); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, du_wip->ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(du_wip->ip)); error = xfs_iunlink_remove(tp, pag, du_wip->ip); xfs_perag_put(pag); if (error) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 31c818f9870f8d..abfba2bfabafb7 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1865,7 +1865,7 @@ xfs_dialloc_pick_ag( if (S_ISDIR(mode)) return (atomic_inc_return(&mp->m_agirotor) - 1) % mp->m_maxagi; - start_agno = XFS_INO_TO_AGNO(mp, dp->i_ino); + start_agno = XFS_INODE_TO_AGNO(dp); if (start_agno >= mp->m_maxagi) start_agno = 0; diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index fd8441bf9b83dd..8e439dc2f4faff 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -528,7 +528,7 @@ xfs_iunlink( ASSERT(VFS_I(ip)->i_mode != 0); trace_xfs_iunlink(ip); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); /* Get the agi buffer first. It ensures lock ordering on the list. */ error = xfs_read_agi(pag, tp, 0, &agibp); diff --git a/repair/pptr.c b/repair/pptr.c index 6a9e072b360d7d..dc1ea2288eacc0 100644 --- a/repair/pptr.c +++ b/repair/pptr.c @@ -1050,7 +1050,7 @@ crosscheck_file_parent_ptrs( struct ag_pptr *ag_pptr, *prev_ag_pptr = NULL; struct file_pptr *file_pptr; struct xfs_mount *mp = ip->i_mount; - xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino); + xfs_agnumber_t agno = XFS_INODE_TO_AGNO(ip); xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); int error; ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 05/18] xfs: add a XFS_INODE_TO_AGINO helper 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (3 preceding siblings ...) 2026-07-02 20:01 ` [PATCH 04/18] xfs: add a XFS_INODE_TO_AGNO helper Darrick J. Wong @ 2026-07-02 20:01 ` Darrick J. Wong 2026-07-02 20:01 ` [PATCH 06/18] xfs: add a XFS_INO_TO_FSB helper Darrick J. Wong ` (13 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:01 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: f46edc9f1310d27710e2b39bf561ecef51f879d2 Add a shortcut for the common XFS_INO_TO_AGINO(mp, ip->i_ino) pattern. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_format.h | 2 ++ db/iunlink.c | 2 +- libxfs/iunlink.c | 2 +- libxfs/xfs_inode_util.c | 5 ++--- repair/pptr.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 36a00c174f1ea1..f812c6782492cb 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1280,6 +1280,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) XFS_INO_TO_AGNO((ip)->i_mount, (ip)->i_ino) #define XFS_INO_TO_AGINO(mp,i) \ ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) +#define XFS_INODE_TO_AGINO(ip) \ + XFS_INO_TO_AGINO((ip)->i_mount, (ip)->i_ino) #define XFS_INO_TO_AGBNO(mp,i) \ (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) diff --git a/db/iunlink.c b/db/iunlink.c index 20946c967f548a..7eeef5f0886e11 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -23,7 +23,7 @@ count_rtblocks( dbprintf( _("could not read AG %u agino %u extents, err=%d\n"), XFS_INODE_TO_AGNO(ip), - XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), + XFS_INODE_TO_AGINO(ip), error); return 0; } diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c index 2d4dd0aee0b87b..7a00915290db86 100644 --- a/libxfs/iunlink.c +++ b/libxfs/iunlink.c @@ -66,7 +66,7 @@ xfs_iunlink_log_dinode( } trace_xfs_iunlink_update_dinode(mp, pag_agno(iup->pag), - XFS_INO_TO_AGINO(mp, ip->i_ino), + XFS_INODE_TO_AGINO(ip), be32_to_cpu(dip->di_next_unlinked), iup->next_agino); diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index 8e439dc2f4faff..63b95238d8ce86 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -461,10 +461,9 @@ xfs_iunlink_insert_inode( struct xfs_buf *agibp, struct xfs_inode *ip) { - struct xfs_mount *mp = tp->t_mountp; struct xfs_agi *agi = agibp->b_addr; xfs_agino_t next_agino; - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); short bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; int error; @@ -550,7 +549,7 @@ xfs_iunlink_remove_inode( { struct xfs_mount *mp = tp->t_mountp; struct xfs_agi *agi = agibp->b_addr; - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); xfs_agino_t head_agino; short bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; int error; diff --git a/repair/pptr.c b/repair/pptr.c index dc1ea2288eacc0..39e7bb5030d02f 100644 --- a/repair/pptr.c +++ b/repair/pptr.c @@ -1051,7 +1051,7 @@ crosscheck_file_parent_ptrs( struct file_pptr *file_pptr; struct xfs_mount *mp = ip->i_mount; xfs_agnumber_t agno = XFS_INODE_TO_AGNO(ip); - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); int error; ag_pptr = peek_slab_cursor(fscan->ag_pptr_recs_cur); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 06/18] xfs: add a XFS_INO_TO_FSB helper 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (4 preceding siblings ...) 2026-07-02 20:01 ` [PATCH 05/18] xfs: add a XFS_INODE_TO_AGINO helper Darrick J. Wong @ 2026-07-02 20:01 ` Darrick J. Wong 2026-07-02 20:02 ` [PATCH 07/18] xfs: add a xfs_rmap_inode_bmbt_owner Darrick J. Wong ` (12 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:01 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: f8b7c9a8b0a9e43b054981d134b426d9464264f6 Add a shortcut for the common XFS_INO_TO_FSB(mp, ip->i_ino) pattern. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_format.h | 2 ++ libxfs/xfs_bmap.c | 8 +++----- libxfs/xfs_btree.c | 6 ++---- repair/bulkload.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index f812c6782492cb..9886af0507e3af 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1289,6 +1289,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) #define XFS_INO_TO_FSB(mp,i) \ XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) +#define XFS_INODE_TO_FSB(ip) \ + XFS_INO_TO_FSB((ip)->i_mount, (ip)->i_ino) #define XFS_AGINO_TO_INO(mp,a,i) \ (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 96975f88497add..d211d31697a2ee 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -675,8 +675,7 @@ xfs_bmap_extents_to_btree( args.minlen = args.maxlen = args.prod = 1; args.wasdel = wasdel; *logflagsp = 0; - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(mp, ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) goto out_root_realloc; @@ -822,8 +821,7 @@ xfs_bmap_local_to_extents( */ args.total = total; args.minlen = args.maxlen = args.prod = 1; - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(args.mp, ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) goto done; @@ -3584,7 +3582,7 @@ xfs_bmap_btalloc_best_length( xfs_extlen_t blen = 0; int error; - ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); + ap->blkno = XFS_INODE_TO_FSB(ap->ip); if (!xfs_bmap_adjacent(ap)) ap->eof = false; diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 4ab0d8d3789b18..0069fba162a8de 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -3240,8 +3240,7 @@ xfs_btree_new_iroot( if (level > 0) aptr = *xfs_btree_ptr_addr(cur, 1, block); else - aptr.l = cpu_to_be64(XFS_INO_TO_FSB(cur->bc_mp, - cur->bc_ino.ip->i_ino)); + aptr.l = cpu_to_be64(XFS_INODE_TO_FSB(cur->bc_ino.ip)); /* Allocate the new block. If we can't do it, we're toast. Give up. */ error = xfs_btree_alloc_block(cur, &aptr, &nptr, stat); @@ -5606,8 +5605,7 @@ xfs_btree_alloc_metafile_block( ASSERT(xfs_is_metadir_inode(ip)); xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, cur->bc_ino.whichfork); - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(cur->bc_mp, ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) return error; if (args.fsbno == NULLFSBLOCK) { diff --git a/repair/bulkload.c b/repair/bulkload.c index a9e51de0a24c17..6bc110071f022d 100644 --- a/repair/bulkload.c +++ b/repair/bulkload.c @@ -32,7 +32,7 @@ bulkload_init_inode( int whichfork, const struct xfs_owner_info *oinfo) { - bulkload_init_ag(bkl, sc, oinfo, XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino)); + bulkload_init_ag(bkl, sc, oinfo, XFS_INODE_TO_FSB(sc->ip)); bkl->ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); bkl->ifake.if_fork_size = xfs_inode_fork_size(sc->ip, whichfork); } ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 07/18] xfs: add a xfs_rmap_inode_bmbt_owner 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (5 preceding siblings ...) 2026-07-02 20:01 ` [PATCH 06/18] xfs: add a XFS_INO_TO_FSB helper Darrick J. Wong @ 2026-07-02 20:02 ` Darrick J. Wong 2026-07-02 20:02 ` [PATCH 08/18] xfs: add a xfs_rmap_inode_owner helper Darrick J. Wong ` (11 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:02 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: ee237a900ceef00c8d1ca17a5cfadbd50fba67e9 Add a small wrapper for initializing the bmbt owner to i_ino. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_rmap.h | 2 ++ libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_bmap_btree.c | 4 ++-- libxfs/xfs_btree.c | 4 ++-- repair/bmap_repair.c | 2 +- repair/rtrefcount_repair.c | 2 +- repair/rtrmap_repair.c | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 5f39f6e53cd19a..7188459f61cf3e 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -21,6 +21,8 @@ xfs_rmap_ino_bmbt_owner( if (whichfork == XFS_ATTR_FORK) oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } +#define xfs_rmap_inode_bmbt_owner(oi, ip, whichfork) \ + xfs_rmap_ino_bmbt_owner(oi, (ip)->i_ino, whichfork) static inline void xfs_rmap_ino_owner( diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index d211d31697a2ee..1bd65a0cba2629 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -596,7 +596,7 @@ xfs_bmap_btree_to_extents( if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) return error; - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, whichfork); error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo, XFS_AG_RESV_NONE, 0); if (error) @@ -670,7 +670,7 @@ xfs_bmap_extents_to_btree( memset(&args, 0, sizeof(args)); args.tp = tp; args.mp = mp; - xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork); + xfs_rmap_inode_bmbt_owner(&args.oinfo, ip, whichfork); args.minlen = args.maxlen = args.prod = 1; args.wasdel = wasdel; diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 6038c45674557b..077b862ca6d2ca 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -216,7 +216,7 @@ xfs_bmbt_alloc_block( memset(&args, 0, sizeof(args)); args.tp = cur->bc_tp; args.mp = cur->bc_mp; - xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_ino.ip->i_ino, + xfs_rmap_inode_bmbt_owner(&args.oinfo, cur->bc_ino.ip, cur->bc_ino.whichfork); args.minlen = args.maxlen = args.prod = 1; args.wasdel = cur->bc_flags & XFS_BTREE_BMBT_WASDEL; @@ -279,7 +279,7 @@ xfs_bmbt_free_block( struct xfs_owner_info oinfo; int error; - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, cur->bc_ino.whichfork); error = xfs_free_extent_later(cur->bc_tp, fsbno, 1, &oinfo, XFS_AG_RESV_NONE, 0); if (error) diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 0069fba162a8de..c7db42a4786005 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -5604,7 +5604,7 @@ xfs_btree_alloc_metafile_block( ASSERT(xfs_is_metadir_inode(ip)); - xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, cur->bc_ino.whichfork); + xfs_rmap_inode_bmbt_owner(&args.oinfo, ip, cur->bc_ino.whichfork); error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) return error; @@ -5636,7 +5636,7 @@ xfs_btree_free_metafile_block( ASSERT(xfs_is_metadir_inode(ip)); - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, cur->bc_ino.whichfork); error = xfs_free_extent_later(tp, fsbno, 1, &oinfo, XFS_AG_RESV_METAFILE, 0); if (error) diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index 192f189de05217..335a35af5379dc 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -576,7 +576,7 @@ xrep_bmap_build_new_fork( * Prepare to construct the new fork by initializing the new btree * structure and creating a fake ifork in the ifakeroot structure. */ - libxfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, rb->whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, rb->whichfork); bulkload_init_inode(&rb->new_fork_info, sc, rb->whichfork, &oinfo); bmap_cur = libxfs_bmbt_init_cursor(sc->mp, NULL, sc->ip, XFS_STAGING_FORK); diff --git a/repair/rtrefcount_repair.c b/repair/rtrefcount_repair.c index 228d080e5a5dcb..7906af17e8936b 100644 --- a/repair/rtrefcount_repair.c +++ b/repair/rtrefcount_repair.c @@ -173,7 +173,7 @@ xrep_rtrefc_build_new_tree( * Prepare to construct the new fork by initializing the new btree * structure and creating a fake ifork in the ifakeroot structure. */ - libxfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, XFS_DATA_FORK); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, XFS_DATA_FORK); bulkload_init_inode(&rr->new_fork_info, sc, XFS_DATA_FORK, &oinfo); cur = libxfs_rtrefcountbt_init_cursor(NULL, rr->rtg); libxfs_btree_stage_ifakeroot(cur, ifake); diff --git a/repair/rtrmap_repair.c b/repair/rtrmap_repair.c index 955db1738fe240..136fafc010243c 100644 --- a/repair/rtrmap_repair.c +++ b/repair/rtrmap_repair.c @@ -211,7 +211,7 @@ xrep_rtrmap_build_new_tree( * Prepare to construct the new fork by initializing the new btree * structure and creating a fake ifork in the ifakeroot structure. */ - libxfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, XFS_DATA_FORK); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, XFS_DATA_FORK); bulkload_init_inode(&rr->new_fork_info, sc, XFS_DATA_FORK, &oinfo); cur = libxfs_rtrmapbt_init_cursor(NULL, rr->rtg); libxfs_btree_stage_ifakeroot(cur, ifake); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 08/18] xfs: add a xfs_rmap_inode_owner helper 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (6 preceding siblings ...) 2026-07-02 20:02 ` [PATCH 07/18] xfs: add a xfs_rmap_inode_bmbt_owner Darrick J. Wong @ 2026-07-02 20:02 ` Darrick J. Wong 2026-07-02 20:02 ` [PATCH 09/18] xfs: remove the i_ino field in struct xfs_inode Darrick J. Wong ` (10 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:02 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: f882fc7dd9f04f73d94379deb9e68d8db613c976 Add a small wrapper for initializing the rmap owner to i_ino. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_rmap.h | 2 ++ libxfs/xfs_bmap.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 7188459f61cf3e..6016fd5fcad98f 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -37,6 +37,8 @@ xfs_rmap_ino_owner( if (whichfork == XFS_ATTR_FORK) oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } +#define xfs_rmap_inode_owner(oi, ip, whichfork, offset) \ + xfs_rmap_ino_owner(oi, (ip)->i_ino, whichfork, offset) static inline bool xfs_rmap_should_skip_owner_update( diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 1bd65a0cba2629..23cc5bb4627288 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -813,7 +813,7 @@ xfs_bmap_local_to_extents( args.mp = ip->i_mount; args.total = total; args.minlen = args.maxlen = args.prod = 1; - xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0); + xfs_rmap_inode_owner(&args.oinfo, ip, whichfork, 0); /* * Allocate a block. We know we need only one, since the ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 09/18] xfs: remove the i_ino field in struct xfs_inode 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (7 preceding siblings ...) 2026-07-02 20:02 ` [PATCH 08/18] xfs: add a xfs_rmap_inode_owner helper Darrick J. Wong @ 2026-07-02 20:02 ` Darrick J. Wong 2026-07-02 20:02 ` [PATCH 10/18] xfs: cleanup xfs_imap Darrick J. Wong ` (9 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:02 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 1113a6d6d5d1336f4415fa1367aac0f853f0892d Now that the VFS inode has a u64 i_ino field, there is no need to store a copy of the inode number in the xfs_inode structure. Introduce an I_INO() wrapper as a shortcut to the inode number so that we don't have to propagate the VFS inode everywhere. The only non-obvious part is the clearing of i_ino to 0 for RCU freeing the inode. None of this calls into VFS paths, which makes clearing the VFS inode field here just as safe as clearing the old field in the xfs_inode. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- include/xfs_inode.h | 7 ++ libxfs/xfs_format.h | 6 +- libxfs/xfs_parent.h | 2 - libxfs/xfs_rmap.h | 4 + db/attrset.c | 2 - db/bmap_inflate.c | 4 + db/dquot.c | 2 - db/iunlink.c | 2 - db/namei.c | 14 ++-- db/rdump.c | 2 - libxfs/defer_item.c | 2 - libxfs/inode.c | 4 + libxfs/listxattr.c | 4 + libxfs/logitem.c | 4 + libxfs/util.c | 2 - libxfs/xfs_attr.c | 2 - libxfs/xfs_attr_leaf.c | 2 - libxfs/xfs_bmap.c | 6 +- libxfs/xfs_bmap_btree.c | 4 + libxfs/xfs_btree.c | 8 +-- libxfs/xfs_btree_staging.c | 2 - libxfs/xfs_da_btree.c | 2 - libxfs/xfs_dir2.c | 40 ++++++------- libxfs/xfs_dir2_node.c | 2 - libxfs/xfs_dir2_sf.c | 4 + libxfs/xfs_exchmaps.c | 8 +-- libxfs/xfs_ialloc.c | 2 - libxfs/xfs_inode_buf.c | 4 + libxfs/xfs_inode_fork.c | 6 +- libxfs/xfs_inode_util.c | 6 +- libxfs/xfs_metadir.c | 2 - libxfs/xfs_parent.c | 8 +-- libxfs/xfs_rmap.c | 6 +- libxfs/xfs_rtbitmap.c | 4 + libxfs/xfs_rtrefcount_btree.c | 4 + libxfs/xfs_rtrmap_btree.c | 4 + libxfs/xfs_symlink_remote.c | 6 +- mkfs/proto.c | 16 +++-- repair/bmap_repair.c | 4 + repair/phase6.c | 128 +++++++++++++++++++++-------------------- repair/pptr.c | 96 +++++++++++++++---------------- repair/quotacheck.c | 8 +-- repair/rt.c | 6 +- repair/xfs_repair.c | 2 - 44 files changed, 229 insertions(+), 224 deletions(-) diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 61d4d285a10613..f07a34ec5d4643 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -72,6 +72,7 @@ struct inode { unsigned long i_state; /* Not actually used in userspace */ uint32_t i_generation; uint64_t i_version; + uint64_t i_ino; /* inode number (agno/agino) */ struct timespec64 __i_atime; struct timespec64 __i_mtime; struct timespec64 __i_ctime; /* use inode_*_ctime accessors! */ @@ -218,7 +219,6 @@ static inline bool inode_wrong_type(const struct inode *inode, umode_t mode) typedef struct xfs_inode { struct cache_node i_node; struct xfs_mount *i_mount; /* fs mount struct ptr */ - xfs_ino_t i_ino; /* inode number (agno/agino) */ struct xfs_imap i_imap; /* location for xfs_imap() */ struct xfs_ifork *i_cowfp; /* copy on write extents */ struct xfs_ifork i_df; /* data fork */ @@ -366,6 +366,11 @@ static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip) } #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_diflags & XFS_DIFLAG_REALTIME) +static inline uint64_t I_INO(const struct xfs_inode *ip) +{ + return VFS_IC(ip)->i_ino; +} + static inline bool xfs_is_zoned_inode(struct xfs_inode *ip) { return xfs_has_zoned(ip->i_mount) && XFS_IS_REALTIME_INODE(ip); diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index 9886af0507e3af..dd0ed046fbe9c9 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -1277,11 +1277,11 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) #define XFS_INO_TO_AGNO(mp,i) \ ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) #define XFS_INODE_TO_AGNO(ip) \ - XFS_INO_TO_AGNO((ip)->i_mount, (ip)->i_ino) + XFS_INO_TO_AGNO((ip)->i_mount, I_INO(ip)) #define XFS_INO_TO_AGINO(mp,i) \ ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) #define XFS_INODE_TO_AGINO(ip) \ - XFS_INO_TO_AGINO((ip)->i_mount, (ip)->i_ino) + XFS_INO_TO_AGINO((ip)->i_mount, I_INO(ip)) #define XFS_INO_TO_AGBNO(mp,i) \ (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) @@ -1290,7 +1290,7 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) #define XFS_INO_TO_FSB(mp,i) \ XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) #define XFS_INODE_TO_FSB(ip) \ - XFS_INO_TO_FSB((ip)->i_mount, (ip)->i_ino) + XFS_INO_TO_FSB((ip)->i_mount, I_INO(ip)) #define XFS_AGINO_TO_INO(mp,a,i) \ (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) diff --git a/libxfs/xfs_parent.h b/libxfs/xfs_parent.h index b8036527cdc73c..8eb4de9c5f1a9c 100644 --- a/libxfs/xfs_parent.h +++ b/libxfs/xfs_parent.h @@ -34,7 +34,7 @@ xfs_inode_to_parent_rec( struct xfs_parent_rec *rec, const struct xfs_inode *dp) { - xfs_parent_rec_init(rec, dp->i_ino, VFS_IC(dp)->i_generation); + xfs_parent_rec_init(rec, I_INO(dp), VFS_IC(dp)->i_generation); } extern struct kmem_cache *xfs_parent_args_cache; diff --git a/libxfs/xfs_rmap.h b/libxfs/xfs_rmap.h index 6016fd5fcad98f..4afa33575ce204 100644 --- a/libxfs/xfs_rmap.h +++ b/libxfs/xfs_rmap.h @@ -22,7 +22,7 @@ xfs_rmap_ino_bmbt_owner( oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } #define xfs_rmap_inode_bmbt_owner(oi, ip, whichfork) \ - xfs_rmap_ino_bmbt_owner(oi, (ip)->i_ino, whichfork) + xfs_rmap_ino_bmbt_owner(oi, I_INO(ip), whichfork) static inline void xfs_rmap_ino_owner( @@ -38,7 +38,7 @@ xfs_rmap_ino_owner( oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } #define xfs_rmap_inode_owner(oi, ip, whichfork, offset) \ - xfs_rmap_ino_owner(oi, (ip)->i_ino, whichfork, offset) + xfs_rmap_ino_owner(oi, I_INO(ip), whichfork, offset) static inline bool xfs_rmap_should_skip_owner_update( diff --git a/db/attrset.c b/db/attrset.c index 273c2029560047..ec51ce2e07756d 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -701,7 +701,7 @@ attrlist_print( .whichfork = XFS_ATTR_FORK, .op_flags = XFS_DA_OP_OKNOENT, .dp = ip, - .owner = ip->i_ino, + .owner = I_INO(ip), .trans = tp, .attr_filter = attr_flags & XFS_ATTR_NSP_ONDISK_MASK, .name = name, diff --git a/db/bmap_inflate.c b/db/bmap_inflate.c index cc7c197e788d7f..13891896fc8b60 100644 --- a/db/bmap_inflate.c +++ b/db/bmap_inflate.c @@ -176,7 +176,7 @@ alloc_bmbt_blocks( target = XFS_AGB_TO_FSB(mp, tgt_agno, 0); } - libxfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, + libxfs_rmap_ino_bmbt_owner(&args.oinfo, I_INO(ip), XFS_DATA_FORK); error = -libxfs_alloc_vextent_start_ag(&args, target); @@ -421,7 +421,7 @@ estimate_size( report: dbprintf(_("ino 0x%llx nextents %llu btblocks %llu btheight %u dirty %u\n"), - ip->i_ino, nextents, bmap_bload.nr_blocks, + I_INO(ip), nextents, bmap_bload.nr_blocks, bmap_bload.btree_height, dirty_blocks); return 0; diff --git a/db/dquot.c b/db/dquot.c index c028d50e4ca4e6..0c1ebf4e7907f6 100644 --- a/db/dquot.c +++ b/db/dquot.c @@ -104,7 +104,7 @@ dqtype_to_inode( if (error) goto out_dp; - ret = ip->i_ino; + ret = I_INO(ip); libxfs_irele(ip); out_dp: if (dp) diff --git a/db/iunlink.c b/db/iunlink.c index 7eeef5f0886e11..b4705a187b28b1 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -246,7 +246,7 @@ create_unlinked( dbprintf(_("commit inode: %s\n"), strerror(error)); dbprintf(_("Created unlinked inode %llu in agno %u\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), XFS_INODE_TO_AGNO(ip)); libxfs_irele(ip); return error; diff --git a/db/namei.c b/db/namei.c index 0a50ec87df9f54..6e5d0ac46360d9 100644 --- a/db/namei.c +++ b/db/namei.c @@ -331,7 +331,7 @@ list_sfdir( /* . and .. entries */ off = xfs_dir2_db_off_to_dataptr(geo, geo->datablk, geo->data_entry_offset); - error = dir_emit(args->trans, args->dp, off, ".", -1, dp->i_ino, + error = dir_emit(args->trans, args->dp, off, ".", -1, I_INO(dp), XFS_DIR3_FT_DIR, private); if (error) return error; @@ -503,7 +503,7 @@ listdir( .trans = tp, .dp = dp, .geo = dp->i_mount->m_dir_geo, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; @@ -748,7 +748,7 @@ list_leaf_pptrs( struct xfs_buf *leaf_bp; int error; - error = -libxfs_attr3_leaf_read(NULL, ip, ip->i_ino, 0, &leaf_bp); + error = -libxfs_attr3_leaf_read(NULL, ip, I_INO(ip), 0, &leaf_bp); if (error) return error; @@ -846,7 +846,7 @@ list_node_pptrs( libxfs_trans_brelse(NULL, leaf_bp); - error = -libxfs_attr3_leaf_read(NULL, ip, ip->i_ino, + error = -libxfs_attr3_leaf_read(NULL, ip, I_INO(ip), leafhdr.forw, &leaf_bp); if (error) return error; @@ -1062,7 +1062,7 @@ create_child( libxfs_trans_ijoin(tp, dp, 0); libxfs_trans_ijoin(tp, ip, 0); - error = -libxfs_dir_createname(tp, dp, &xname, ip->i_ino, resblks); + error = -libxfs_dir_createname(tp, dp, &xname, I_INO(ip), resblks); if (error) goto out_trans; @@ -1076,7 +1076,7 @@ create_child( /* Replace the dotdot entry in the child directory. */ if (isdir) { error = -libxfs_dir_replace(tp, ip, &xfs_name_dotdot, - dp->i_ino, resblks); + I_INO(dp), resblks); if (error) goto out_trans; } @@ -1287,7 +1287,7 @@ remove_child( if (error) goto out_trans; - error = -libxfs_dir_removename(tp, dp, &xname, ip->i_ino, resblks); + error = -libxfs_dir_removename(tp, dp, &xname, I_INO(ip), resblks); if (error) goto out_trans; diff --git a/db/rdump.c b/db/rdump.c index 599d0727e78892..7fd171a9d53f25 100644 --- a/db/rdump.c +++ b/db/rdump.c @@ -376,7 +376,7 @@ rdump_xattr( .trans = tp, .dp = ip, .geo = mp->m_attr_geo, - .owner = ip->i_ino, + .owner = I_INO(ip), .attr_filter = attr_flags & XFS_ATTR_NSP_ONDISK_MASK, .namelen = namelen, .name = name, diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 5d72ee0706f0b7..14ee4152551783 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -563,7 +563,7 @@ xfs_bmap_update_diff_items( struct xfs_bmap_intent *ba = bi_entry(a); struct xfs_bmap_intent *bb = bi_entry(b); - return cmp_int(ba->bi_owner->i_ino, bb->bi_owner->i_ino); + return cmp_int(I_INO(ba->bi_owner), I_INO(bb->bi_owner)); } /* Get an BUI. */ diff --git a/libxfs/inode.c b/libxfs/inode.c index 83741b97117106..b4bf3b5859a7e6 100644 --- a/libxfs/inode.c +++ b/libxfs/inode.c @@ -151,7 +151,7 @@ libxfs_iget( return -ENOMEM; VFS_I(ip)->i_count = 1; - ip->i_ino = ino; + VFS_I(ip)->i_ino = ino; ip->i_mount = mp; ip->i_diflags2 = mp->m_ino_geo.new_diflags2; ip->i_af.if_format = XFS_DINODE_FMT_EXTENTS; @@ -160,7 +160,7 @@ libxfs_iget( spin_lock_init(&VFS_I(ip)->i_lock); pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); - error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, 0); + error = xfs_imap(pag, tp, I_INO(ip), &ip->i_imap, 0); xfs_perag_put(pag); if (error) diff --git a/libxfs/listxattr.c b/libxfs/listxattr.c index 34205682f022d5..fb6f1d53b9d8f5 100644 --- a/libxfs/listxattr.c +++ b/libxfs/listxattr.c @@ -101,7 +101,7 @@ xattr_walk_leaf( struct xfs_buf *leaf_bp; int error; - error = -libxfs_attr3_leaf_read(tp, ip, ip->i_ino, 0, &leaf_bp); + error = -libxfs_attr3_leaf_read(tp, ip, I_INO(ip), 0, &leaf_bp); if (error) return error; @@ -231,7 +231,7 @@ xattr_walk_node( if (bitmap_test(seen_blocks, leafhdr.forw, 1)) goto out_bitmap; - error = -libxfs_attr3_leaf_read(tp, ip, ip->i_ino, + error = -libxfs_attr3_leaf_read(tp, ip, I_INO(ip), leafhdr.forw, &leaf_bp); if (error) goto out_bitmap; diff --git a/libxfs/logitem.c b/libxfs/logitem.c index d8d86d919cf4d7..67b982788061f8 100644 --- a/libxfs/logitem.c +++ b/libxfs/logitem.c @@ -140,7 +140,7 @@ static uint64_t xfs_inode_item_sort( struct xfs_log_item *lip) { - return INODE_ITEM(lip)->ili_inode->i_ino; + return I_INO(INODE_ITEM(lip)->ili_inode); } /* @@ -316,7 +316,7 @@ xfs_inode_item_init( iip = ip->i_itemp = kmem_cache_zalloc(xfs_ili_cache, 0); #ifdef LI_DEBUG fprintf(stderr, "inode_item_init for inode %llu, iip=%p\n", - ip->i_ino, iip); + I_INO(ip), iip); #endif spin_lock_init(&iip->ili_lock); diff --git a/libxfs/util.c b/libxfs/util.c index 143d011ac60ddd..6cbbe9056ebad8 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -343,7 +343,7 @@ xfs_inode_verifier_error( xfs_alert(NULL, "Metadata %s detected at %p, inode 0x%llx %s", error == -EFSBADCRC ? "CRC error" : "corruption", failaddr ? failaddr : __return_address, - ip->i_ino, name); + I_INO(ip), name); } /* diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index a2611aace8190f..bff8096767014e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -275,7 +275,7 @@ xfs_attr_get( return -EIO; if (!args->owner) - args->owner = args->dp->i_ino; + args->owner = I_INO(args->dp); args->geo = args->dp->i_mount->m_attr_geo; args->whichfork = XFS_ATTR_FORK; xfs_attr_sethash(args); diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 6aaa7ff10959d5..c621ccedaa489b 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -1426,7 +1426,7 @@ xfs_attr3_leaf_init( struct xfs_da_args args = { .trans = tp, .dp = dp, - .owner = dp->i_ino, + .owner = I_INO(dp), .geo = dp->i_mount->m_attr_geo, }; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 23cc5bb4627288..330325004106d9 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -968,7 +968,7 @@ xfs_bmap_add_attrfork_local( dargs.total = dargs.geo->fsbcount; dargs.whichfork = XFS_DATA_FORK; dargs.trans = tp; - dargs.owner = ip->i_ino; + dargs.owner = I_INO(ip); return xfs_dir2_sf_to_block(&dargs); } @@ -1102,7 +1102,7 @@ xfs_bmap_complain_bad_rec( xfs_warn(mp, "Bmap BTree record corruption in inode 0x%llx %s fork detected at %pS!", - ip->i_ino, forkname, fa); + I_INO(ip), forkname, fa); xfs_warn(mp, "Offset 0x%llx, start block 0x%llx, block count 0x%llx state 0x%x", irec->br_startoff, irec->br_startblock, irec->br_blockcount, @@ -1135,7 +1135,7 @@ xfs_iread_bmbt_block( num_recs = xfs_btree_get_numrecs(block); if (unlikely(ir->loaded + num_recs > ifp->if_nextents)) { xfs_warn(ip->i_mount, "corrupt dinode %llu, (btree extents).", - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, block, sizeof(*block), __this_address); xfs_bmap_mark_sick(ip, whichfork); diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 077b862ca6d2ca..a12ba6918c7b73 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -35,10 +35,10 @@ xfs_bmbt_init_block( { if (bp) xfs_btree_init_buf(ip->i_mount, bp, &xfs_bmbt_ops, level, - numrecs, ip->i_ino); + numrecs, I_INO(ip)); else xfs_btree_init_block(ip->i_mount, buf, &xfs_bmbt_ops, level, - numrecs, ip->i_ino); + numrecs, I_INO(ip)); } /* diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index c7db42a4786005..ec77f325aab692 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -368,7 +368,7 @@ xfs_btree_check_ptr( case XFS_BTREE_TYPE_INODE: xfs_err(cur->bc_mp, "Inode %llu fork %d: Corrupt %sbt pointer at level %d index %d.", - cur->bc_ino.ip->i_ino, + I_INO(cur->bc_ino.ip), cur->bc_ino.whichfork, cur->bc_ops->name, level, index); break; @@ -1302,7 +1302,7 @@ xfs_btree_owner( case XFS_BTREE_TYPE_MEM: return cur->bc_mem.xfbtree->owner; case XFS_BTREE_TYPE_INODE: - return cur->bc_ino.ip->i_ino; + return I_INO(cur->bc_ino.ip); case XFS_BTREE_TYPE_AG: return cur->bc_group->xg_gno; default: @@ -3126,7 +3126,7 @@ xfs_btree_promote_leaf_iroot( */ broot = cur->bc_ops->broot_realloc(cur, 1); xfs_btree_init_block(cur->bc_mp, broot, cur->bc_ops, - cur->bc_nlevels - 1, 1, cur->bc_ino.ip->i_ino); + cur->bc_nlevels - 1, 1, I_INO(cur->bc_ino.ip)); pp = xfs_btree_ptr_addr(cur, 1, broot); kp = xfs_btree_key_addr(cur, 1, broot); @@ -3823,7 +3823,7 @@ xfs_btree_demote_leaf_child( */ broot = cur->bc_ops->broot_realloc(cur, numrecs); xfs_btree_init_block(cur->bc_mp, broot, cur->bc_ops, 0, numrecs, - cur->bc_ino.ip->i_ino); + I_INO(cur->bc_ino.ip)); rp = xfs_btree_rec_addr(cur, 1, broot); crp = xfs_btree_rec_addr(cur, 1, cblock); diff --git a/libxfs/xfs_btree_staging.c b/libxfs/xfs_btree_staging.c index 4300c058807ba5..c3c7ea54895a60 100644 --- a/libxfs/xfs_btree_staging.c +++ b/libxfs/xfs_btree_staging.c @@ -309,7 +309,7 @@ xfs_btree_bload_prep_block( /* Initialize it and send it out. */ xfs_btree_init_block(cur->bc_mp, ifp->if_broot, cur->bc_ops, - level, nr_this_block, cur->bc_ino.ip->i_ino); + level, nr_this_block, I_INO(cur->bc_ino.ip)); *bpp = NULL; *blockp = ifp->if_broot; diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index 508fd1475c006a..b51b10f916ab29 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -2776,7 +2776,7 @@ xfs_dabuf_map( error = -EFSCORRUPTED; if (xfs_error_level >= XFS_ERRLEVEL_LOW) { xfs_alert(mp, "%s: bno %u inode %llu", - __func__, bno, dp->i_ino); + __func__, bno, I_INO(dp)); for (i = 0; i < nirecs; i++) { xfs_alert(mp, diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c index 562d617254b2e3..fce2d847c76091 100644 --- a/libxfs/xfs_dir2.c +++ b/libxfs/xfs_dir2.c @@ -243,7 +243,7 @@ xfs_dir_init( int error; ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); - error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino); + error = xfs_dir_ino_validate(tp->t_mountp, I_INO(pdp)); if (error) return error; @@ -254,8 +254,8 @@ xfs_dir_init( args->geo = dp->i_mount->m_dir_geo; args->dp = dp; args->trans = tp; - args->owner = dp->i_ino; - error = xfs_dir2_sf_create(args, pdp->i_ino); + args->owner = I_INO(dp); + error = xfs_dir2_sf_create(args, I_INO(pdp)); kfree(args); return error; } @@ -355,7 +355,7 @@ xfs_dir_createname( args->whichfork = XFS_DATA_FORK; args->trans = tp; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_createname_args(args); kfree(args); @@ -446,7 +446,7 @@ xfs_dir_lookup( args->whichfork = XFS_DATA_FORK; args->trans = tp; args->op_flags = XFS_DA_OP_OKNOENT; - args->owner = dp->i_ino; + args->owner = I_INO(dp); if (ci_name) args->op_flags |= XFS_DA_OP_CILOOKUP; @@ -515,7 +515,7 @@ xfs_dir_removename( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_removename_args(args); kfree(args); return rval; @@ -575,7 +575,7 @@ xfs_dir_replace( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_replace_args(args); kfree(args); return rval; @@ -854,7 +854,7 @@ xfs_dir_create_child( xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); xfs_assert_ilocked(dp, XFS_ILOCK_EXCL); - error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, name, I_INO(ip), resblks); if (error) { ASSERT(error != -ENOSPC); return error; @@ -925,7 +925,7 @@ xfs_dir_add_child( return error; } - error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, name, I_INO(ip), resblks); if (error) return error; @@ -994,7 +994,7 @@ xfs_dir_remove_child( * get freed before the child directory is closed. If the fs * gets shrunk, this can lead to dirent inode validation errors. */ - if (dp->i_ino != tp->t_mountp->m_sb.sb_rootino) { + if (I_INO(dp) != tp->t_mountp->m_sb.sb_rootino) { error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, tp->t_mountp->m_sb.sb_rootino, 0); if (error) @@ -1015,7 +1015,7 @@ xfs_dir_remove_child( if (error) return error; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_removename(tp, dp, name, I_INO(ip), resblks); if (error) { ASSERT(error != -ENOENT); return error; @@ -1058,12 +1058,12 @@ xfs_dir_exchange_children( int error; /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); + error = xfs_dir_replace(tp, dp1, name1, I_INO(ip2), spaceres); if (error) return error; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); + error = xfs_dir_replace(tp, dp2, name2, I_INO(ip1), spaceres); if (error) return error; @@ -1077,7 +1077,7 @@ xfs_dir_exchange_children( if (S_ISDIR(VFS_I(ip2)->i_mode)) { error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, - dp1->i_ino, spaceres); + I_INO(dp1), spaceres); if (error) return error; @@ -1101,7 +1101,7 @@ xfs_dir_exchange_children( if (S_ISDIR(VFS_I(ip1)->i_mode)) { error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, - dp2->i_ino, spaceres); + I_INO(dp2), spaceres); if (error) return error; @@ -1264,7 +1264,7 @@ xfs_dir_rename_children( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + I_INO(src_ip), spaceres); if (error) return error; @@ -1285,7 +1285,7 @@ xfs_dir_rename_children( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + I_INO(src_ip), spaceres); if (error) return error; @@ -1319,7 +1319,7 @@ xfs_dir_rename_children( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, spaceres); + I_INO(target_dp), spaceres); ASSERT(error != -EEXIST); if (error) return error; @@ -1357,10 +1357,10 @@ xfs_dir_rename_children( * altogether. */ if (du_wip->ip) - error = xfs_dir_replace(tp, src_dp, src_name, du_wip->ip->i_ino, + error = xfs_dir_replace(tp, src_dp, src_name, I_INO(du_wip->ip), spaceres); else - error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, + error = xfs_dir_removename(tp, src_dp, src_name, I_INO(src_ip), spaceres); if (error) return error; diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 9d8bb27f716fe4..97b8860be942b9 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -1736,7 +1736,7 @@ xfs_dir2_node_add_datablk( fbno)) { xfs_alert(mp, "%s: dir ino %llu needed freesp block %lld for data block %lld, got %lld", - __func__, (unsigned long long)dp->i_ino, + __func__, (unsigned long long)I_INO(dp), (long long)xfs_dir2_db_to_fdb(args->geo, *dbno), (long long)*dbno, (long long)fbno); if (fblk) { diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index 1a67cdd6a70706..0567cf8b9c1bb2 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -301,7 +301,7 @@ xfs_dir2_block_to_sf( * Skip . */ if (dep->namelen == 1 && dep->name[0] == '.') - ASSERT(be64_to_cpu(dep->inumber) == dp->i_ino); + ASSERT(be64_to_cpu(dep->inumber) == I_INO(dp)); /* * Skip .., but make sure the inode number is right. */ @@ -863,7 +863,7 @@ xfs_dir2_sf_lookup( * Special case for . */ if (args->namelen == 1 && args->name[0] == '.') { - args->inumber = dp->i_ino; + args->inumber = I_INO(dp); args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; return -EEXIST; diff --git a/libxfs/xfs_exchmaps.c b/libxfs/xfs_exchmaps.c index 651c3784caba73..3347dee2c1a852 100644 --- a/libxfs/xfs_exchmaps.c +++ b/libxfs/xfs_exchmaps.c @@ -426,7 +426,7 @@ xfs_exchmaps_attr_to_sf( .geo = tp->t_mountp->m_attr_geo, .whichfork = XFS_ATTR_FORK, .trans = tp, - .owner = xmi->xmi_ip2->i_ino, + .owner = I_INO(xmi->xmi_ip2), }; struct xfs_buf *bp; int forkoff; @@ -435,7 +435,7 @@ xfs_exchmaps_attr_to_sf( if (!xfs_attr_is_leaf(xmi->xmi_ip2)) return 0; - error = xfs_attr3_leaf_read(tp, xmi->xmi_ip2, xmi->xmi_ip2->i_ino, 0, + error = xfs_attr3_leaf_read(tp, xmi->xmi_ip2, I_INO(xmi->xmi_ip2), 0, &bp); if (error) return error; @@ -458,7 +458,7 @@ xfs_exchmaps_dir_to_sf( .geo = tp->t_mountp->m_dir_geo, .whichfork = XFS_DATA_FORK, .trans = tp, - .owner = xmi->xmi_ip2->i_ino, + .owner = I_INO(xmi->xmi_ip2), }; struct xfs_dir2_sf_hdr sfh; struct xfs_buf *bp; @@ -468,7 +468,7 @@ xfs_exchmaps_dir_to_sf( if (xfs_dir2_format(&args, &error) != XFS_DIR2_FMT_BLOCK) return error; - error = xfs_dir3_block_read(tp, xmi->xmi_ip2, xmi->xmi_ip2->i_ino, &bp); + error = xfs_dir3_block_read(tp, xmi->xmi_ip2, I_INO(xmi->xmi_ip2), &bp); if (error) return error; diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index abfba2bfabafb7..64f0376a10508f 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1890,7 +1890,7 @@ xfs_dialloc( struct xfs_perag *pag; struct xfs_ino_geometry *igeo = M_IGEO(mp); xfs_ino_t ino = NULLFSINO; - xfs_ino_t parent = args->pip ? args->pip->i_ino : 0; + xfs_ino_t parent = args->pip ? I_INO(args->pip) : 0; xfs_agnumber_t agno; xfs_agnumber_t start_agno; umode_t mode = args->mode & S_IFMT; diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index f56aef0dbb3db9..2fc9462e95d67e 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -182,7 +182,7 @@ xfs_inode_from_disk( ASSERT(ip->i_cowfp == NULL); - fa = xfs_dinode_verify(ip->i_mount, ip->i_ino, from); + fa = xfs_dinode_verify(ip->i_mount, I_INO(ip), from); if (fa) { xfs_inode_verifier_error(ip, -EFSCORRUPTED, "dinode", from, sizeof(*from), fa); @@ -355,7 +355,7 @@ xfs_inode_to_disk( to->di_flags2 = cpu_to_be64(ip->i_diflags2); /* also covers the di_used_blocks union arm: */ to->di_cowextsize = cpu_to_be32(ip->i_cowextsize); - to->di_ino = cpu_to_be64(ip->i_ino); + to->di_ino = cpu_to_be64(I_INO(ip)); to->di_lsn = cpu_to_be64(lsn); memset(to->di_pad2, 0, sizeof(to->di_pad2)); uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index 87afe671886ede..46699896da2404 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -85,7 +85,7 @@ xfs_iformat_local( if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { xfs_warn(ip->i_mount, "corrupt inode %llu (bad size %d for local fork, size = %zd).", - (unsigned long long) ip->i_ino, size, + (unsigned long long)I_INO(ip), size, XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_local", dip, sizeof(*dip), @@ -124,7 +124,7 @@ xfs_iformat_extents( */ if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, mp, whichfork))) { xfs_warn(ip->i_mount, "corrupt inode %llu ((a)extents = %llu).", - ip->i_ino, nex); + I_INO(ip), nex); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_extents(1)", dip, sizeof(*dip), __this_address); @@ -203,7 +203,7 @@ xfs_iformat_btree( ifp->if_nextents > ip->i_nblocks) || level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) { xfs_warn(mp, "corrupt inode %llu (btree).", - (unsigned long long) ip->i_ino); + (unsigned long long)I_INO(ip)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_btree", dfp, size, __this_address); diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c index 63b95238d8ce86..cef34004dbe7a2 100644 --- a/libxfs/xfs_inode_util.c +++ b/libxfs/xfs_inode_util.c @@ -651,7 +651,7 @@ xfs_droplink( if (inode->i_nlink == 0) { xfs_info_ratelimited(tp->t_mountp, "Inode 0x%llx link count dropped below zero. Pinning link count.", - ip->i_ino); + I_INO(ip)); set_nlink(inode, XFS_NLINK_PINNED); } if (inode->i_nlink != XFS_NLINK_PINNED) @@ -680,7 +680,7 @@ xfs_bumplink( if (inode->i_nlink == XFS_NLINK_PINNED - 1) xfs_info_ratelimited(tp->t_mountp, "Inode 0x%llx link count exceeded maximum. Pinning link count.", - ip->i_ino); + I_INO(ip)); if (inode->i_nlink != XFS_NLINK_PINNED) inc_nlink(inode); @@ -704,7 +704,7 @@ xfs_inode_uninit( * makes the AGI lock -> unlinked list modification order the same as * used in O_TMPFILE creation. */ - error = xfs_difree(tp, pag, ip->i_ino, xic); + error = xfs_difree(tp, pag, I_INO(ip), xic); if (error) return error; diff --git a/libxfs/xfs_metadir.c b/libxfs/xfs_metadir.c index bffe9ba9129002..bfb261e3f72da2 100644 --- a/libxfs/xfs_metadir.c +++ b/libxfs/xfs_metadir.c @@ -93,7 +93,7 @@ xfs_metadir_lookup( .hashval = xfs_dir2_hashname(mp, xname), .whichfork = XFS_DATA_FORK, .op_flags = XFS_DA_OP_OKNOENT, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; diff --git a/libxfs/xfs_parent.c b/libxfs/xfs_parent.c index d82c38197f4696..ef406103517164 100644 --- a/libxfs/xfs_parent.c +++ b/libxfs/xfs_parent.c @@ -199,7 +199,7 @@ xfs_parent_addname( xfs_inode_to_parent_rec(&ppargs->rec, dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, parent_name); + I_INO(child), parent_name); return xfs_attr_setname(&ppargs->args, 0); } @@ -221,7 +221,7 @@ xfs_parent_removename( xfs_inode_to_parent_rec(&ppargs->rec, dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, parent_name); + I_INO(child), parent_name); return xfs_attr_removename(&ppargs->args); } @@ -245,7 +245,7 @@ xfs_parent_replacename( xfs_inode_to_parent_rec(&ppargs->rec, old_dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, old_name); + I_INO(child), old_name); xfs_inode_to_parent_rec(&ppargs->new_rec, new_dp); @@ -309,7 +309,7 @@ xfs_parent_lookup( struct xfs_da_args *scratch) { memset(scratch, 0, sizeof(struct xfs_da_args)); - xfs_parent_da_args_init(scratch, tp, pptr, ip, ip->i_ino, parent_name); + xfs_parent_da_args_init(scratch, tp, pptr, ip, I_INO(ip), parent_name); return xfs_attr_get_ilocked(scratch); } diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 9da10afe3578b5..e65f4d7808be38 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -2779,7 +2779,7 @@ xfs_rmap_map_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_MAP_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* Unmap an extent out of a file. */ @@ -2799,7 +2799,7 @@ xfs_rmap_unmap_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_UNMAP_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* @@ -2825,7 +2825,7 @@ xfs_rmap_convert_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_CONVERT_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* Schedule the creation of an rmap for non-file data. */ diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 7a06305b4e11dd..1681e4a91d7a80 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -209,7 +209,7 @@ xfs_rtbuf_get( if (xfs_has_rtgroups(mp)) { struct xfs_rtbuf_blkinfo *hdr = bp->b_addr; - if (hdr->rt_owner != cpu_to_be64(ip->i_ino)) { + if (hdr->rt_owner != cpu_to_be64(I_INO(ip))) { xfs_buf_mark_corrupt(bp); xfs_trans_brelse(args->tp, bp); xfs_rtginode_mark_sick(args->rtg, type); @@ -1404,7 +1404,7 @@ xfs_rtfile_initialize_block( hdr->rt_magic = cpu_to_be32(XFS_RTBITMAP_MAGIC); else hdr->rt_magic = cpu_to_be32(XFS_RTSUMMARY_MAGIC); - hdr->rt_owner = cpu_to_be64(ip->i_ino); + hdr->rt_owner = cpu_to_be64(I_INO(ip)); hdr->rt_blkno = cpu_to_be64(XFS_FSB_TO_DADDR(mp, fsbno)); hdr->rt_lsn = 0; uuid_copy(&hdr->rt_uuid, &mp->m_sb.sb_meta_uuid); diff --git a/libxfs/xfs_rtrefcount_btree.c b/libxfs/xfs_rtrefcount_btree.c index f893677e0fcd32..2c51b618e1ce1d 100644 --- a/libxfs/xfs_rtrefcount_btree.c +++ b/libxfs/xfs_rtrefcount_btree.c @@ -600,7 +600,7 @@ xfs_rtrefcountbt_from_disk( rblocklen = xfs_rtrefcount_broot_space(mp, dblock); xfs_btree_init_block(mp, rblock, &xfs_rtrefcountbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); rblock->bb_level = dblock->bb_level; rblock->bb_numrecs = dblock->bb_numrecs; @@ -749,7 +749,7 @@ xfs_rtrefcountbt_create( xfs_rtrefcount_broot_space_calc(mp, 0, 0)); if (broot) xfs_btree_init_block(mp, broot, &xfs_rtrefcountbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE | XFS_ILOG_DBROOT); return 0; } diff --git a/libxfs/xfs_rtrmap_btree.c b/libxfs/xfs_rtrmap_btree.c index 7191bf445c399b..7fbe6c19c454d7 100644 --- a/libxfs/xfs_rtrmap_btree.c +++ b/libxfs/xfs_rtrmap_btree.c @@ -838,7 +838,7 @@ xfs_rtrmapbt_from_disk( unsigned int numrecs; unsigned int maxrecs; - xfs_btree_init_block(mp, rblock, &xfs_rtrmapbt_ops, 0, 0, ip->i_ino); + xfs_btree_init_block(mp, rblock, &xfs_rtrmapbt_ops, 0, 0, I_INO(ip)); rblock->bb_level = dblock->bb_level; rblock->bb_numrecs = dblock->bb_numrecs; @@ -980,7 +980,7 @@ xfs_rtrmapbt_create( broot = xfs_broot_realloc(ifp, xfs_rtrmap_broot_space_calc(mp, 0, 0)); if (broot) xfs_btree_init_block(mp, broot, &xfs_rtrmapbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE | XFS_ILOG_DBROOT); return 0; diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c index d29eae498c493e..7b62dba485a5fa 100644 --- a/libxfs/xfs_symlink_remote.c +++ b/libxfs/xfs_symlink_remote.c @@ -193,7 +193,7 @@ xfs_symlink_local_to_remote( bp->b_ops = &xfs_symlink_buf_ops; buf = bp->b_addr; - buf += xfs_symlink_hdr_set(mp, ip->i_ino, 0, ifp->if_bytes, bp); + buf += xfs_symlink_hdr_set(mp, I_INO(ip), 0, ifp->if_bytes, bp); memcpy(buf, ifp->if_data, ifp->if_bytes); xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsymlink_hdr) + ifp->if_bytes - 1); @@ -274,13 +274,13 @@ xfs_symlink_remote_read( cur_chunk = bp->b_addr; if (xfs_has_crc(mp)) { - if (!xfs_symlink_hdr_ok(ip->i_ino, offset, + if (!xfs_symlink_hdr_ok(I_INO(ip), offset, byte_cnt, bp)) { xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); error = -EFSCORRUPTED; xfs_alert(mp, "symlink header does not match required off/len/owner (0x%x/0x%x,0x%llx)", - offset, byte_cnt, ip->i_ino); + offset, byte_cnt, I_INO(ip)); xfs_buf_relse(bp); goto out; diff --git a/mkfs/proto.c b/mkfs/proto.c index dd47e41d833e5a..bdd0fadda5175c 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -289,7 +289,7 @@ writesymlink( xfs_extlen_t nb = XFS_B_TO_FSB(mp, len); int error; - error = -libxfs_symlink_write_target(tp, ip, ip->i_ino, buf, len, nb, + error = -libxfs_symlink_write_target(tp, ip, I_INO(ip), buf, len, nb, nb); if (error) { fprintf(stderr, @@ -417,7 +417,7 @@ writeattr( struct xfs_da_args args = { .dp = ip, .geo = ip->i_mount->m_attr_geo, - .owner = ip->i_ino, + .owner = I_INO(ip), .whichfork = XFS_ATTR_FORK, .op_flags = XFS_DA_OP_OKNOENT, .value = valuebuf, @@ -548,7 +548,7 @@ newdirent( rsv = XFS_DIRENTER_SPACE_RES(mp, name->len); - error = -libxfs_dir_createname(tp, pip, name, ip->i_ino, rsv); + error = -libxfs_dir_createname(tp, pip, name, I_INO(ip), rsv); if (error) fail(_("directory createname error"), error); @@ -927,7 +927,7 @@ parseproto( fail(_("Inode allocation failed"), error); if (!pip) { pip = ip; - mp->m_sb.sb_rootino = ip->i_ino; + mp->m_sb.sb_rootino = I_INO(ip); libxfs_log_sb(tp); isroot = 1; } else { @@ -1057,10 +1057,10 @@ create_sb_metadata_file( switch (type) { case XFS_RTGI_BITMAP: - mp->m_sb.sb_rbmino = ip->i_ino; + mp->m_sb.sb_rbmino = I_INO(ip); break; case XFS_RTGI_SUMMARY: - mp->m_sb.sb_rsumino = ip->i_ino; + mp->m_sb.sb_rsumino = I_INO(ip); break; default: error = EFSCORRUPTED; @@ -1634,7 +1634,7 @@ create_nondir_inode( * hardlink, so we need to store it. */ if (file_stat->st_nlink > 1) - track_hardlink_inode(file_stat, ip->i_ino); + track_hardlink_inode(file_stat, I_INO(ip)); libxfs_irele(ip); } @@ -1880,7 +1880,7 @@ populate_from_dir( if (error) fail(_("Inode allocation failed"), error); - mp->m_sb.sb_rootino = ip->i_ino; + mp->m_sb.sb_rootino = I_INO(ip); libxfs_log_sb(tp); newdirectory(mp, tp, ip, ip); libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index 335a35af5379dc..2e1995b3933428 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -134,7 +134,7 @@ xrep_bmap_walk_rmap( int error; /* Skip extents which are not owned by this inode and fork. */ - if (rec->rm_owner != rb->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rb->sc->ip)) return 0; error = xrep_bmap_check_fork_rmap(rb, cur, rec); @@ -252,7 +252,7 @@ xrep_bmap_walk_rtrmap( int error = 0; /* Skip extents which are not owned by this inode and fork. */ - if (rec->rm_owner != rb->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rb->sc->ip)) return 0; error = xrep_bmap_check_rtfork_rmap(rb->sc, cur, rec); diff --git a/repair/phase6.c b/repair/phase6.c index 75429d4ca111d4..326fdfa3afb46a 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -277,7 +277,7 @@ dir_hash_check( if (seeval == DIR_HASH_CK_OK) return 0; do_warn(_("bad hash table for directory inode %" PRIu64 " (%s): "), - ip->i_ino, seevalstr[seeval]); + I_INO(ip), seevalstr[seeval]); if (!no_modify) do_warn(_("rebuilding\n")); else @@ -654,8 +654,8 @@ _("Couldn't create rtgroup %u %s inode, error %d\n"), ip = rtg->rtg_inodes[type]; /* Mark the inode in use. */ - mark_ino_inuse(mp, ip->i_ino, S_IFREG, mp->m_rtdirip->i_ino); - mark_ino_metadata(mp, ip->i_ino); + mark_ino_inuse(mp, I_INO(ip), S_IFREG, I_INO(mp->m_rtdirip)); + mark_ino_metadata(mp, I_INO(ip)); return true; } @@ -786,7 +786,7 @@ mk_metadir( libxfs_trans_ijoin(tp, mp->m_metadirip, 0); libxfs_metafile_set_iflag(tp, mp->m_metadirip, XFS_METAFILE_DIR); - mark_ino_metadata(mp, mp->m_metadirip->i_ino); + mark_ino_metadata(mp, I_INO(mp->m_metadirip)); error = -libxfs_trans_commit(tp); if (error) @@ -905,7 +905,7 @@ mk_orphanage( do_error( _("can't make %s, createname error %d\n"), ORPHANAGE, error); - add_parent_ptr(du.ip->i_ino, (unsigned char *)ORPHANAGE, du.dp, false); + add_parent_ptr(I_INO(du.ip), (unsigned char *)ORPHANAGE, du.dp, false); /* * We bumped up the link count in the root directory to account @@ -974,7 +974,7 @@ trunc_metadata_inode( if (err) do_error( _("truncation of metadata inode 0x%llx failed, err=%d\n"), - (unsigned long long)ip->i_ino, err); + (unsigned long long)I_INO(ip), err); } /* @@ -1008,7 +1008,7 @@ add_orphan_pptr( sizeof(struct xfs_attr_sf_hdr), true); if (error) do_error(_("can't add attr fork to inode 0x%llx\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); } error = -libxfs_parent_addname(tp, ppargs, orphanage_ip, xname, ip); @@ -1202,7 +1202,7 @@ mv_orphanage( } if (xfs_has_parent(mp)) - add_parent_ptr(ino_p->i_ino, xname.name, orphanage_ip, false); + add_parent_ptr(I_INO(ino_p), xname.name, orphanage_ip, false); libxfs_irele(ino_p); libxfs_irele(orphanage_ip); @@ -1303,10 +1303,10 @@ longform_dir2_rebuild( * orphanage later (the inode number here needs to be valid * for the libxfs_dir_init() call). */ - pip.i_ino = get_inode_parent(irec, ino_offset); - if (pip.i_ino == NULLFSINO || - libxfs_dir_ino_validate(mp, pip.i_ino)) - pip.i_ino = mp->m_sb.sb_rootino; + VFS_I(&pip)->i_ino = get_inode_parent(irec, ino_offset); + if (VFS_I(&pip)->i_ino == NULLFSINO || + libxfs_dir_ino_validate(mp, I_INO(&pip))) + VFS_I(&pip)->i_ino = mp->m_sb.sb_rootino; nres = libxfs_remove_space_res(mp, 0); error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, nres, 0, 0, &tp); @@ -1317,7 +1317,7 @@ longform_dir2_rebuild( error = dir_binval(tp, ip, XFS_DATA_FORK); if (error) do_error(_("error %d invalidating directory %llu blocks\n"), - error, (unsigned long long)ip->i_ino); + error, (unsigned long long)I_INO(ip)); if ((error = -libxfs_bmap_last_offset(ip, &lastblock, XFS_DATA_FORK))) do_error(_("xfs_bmap_last_offset failed -- error - %d\n"), @@ -1435,7 +1435,7 @@ dir2_kill_block( args.trans = tp; args.whichfork = XFS_DATA_FORK; args.geo = mp->m_dir_geo; - args.owner = ip->i_ino; + args.owner = I_INO(ip); if (da_bno >= mp->m_dir_geo->leafblk && da_bno < mp->m_dir_geo->freeblk) error = -libxfs_da_shrink_inode(&args, da_bno, bp); else @@ -1443,7 +1443,7 @@ dir2_kill_block( xfs_dir2_da_to_db(mp->m_dir_geo, da_bno), bp); if (error) do_error(_("shrink_inode failed inode %" PRIu64 " block %u\n"), - ip->i_ino, da_bno); + I_INO(ip), da_bno); error = -libxfs_trans_commit(tp); if (error) do_error( @@ -1479,14 +1479,14 @@ check_longform_ftype( do_warn( _("would fix ftype mismatch (%d/%d) in directory/child inode %" PRIu64 "/%" PRIu64 "\n"), dir_ftype, ino_ftype, - ip->i_ino, inum); + I_INO(ip), inum); return; } do_warn( _("fixing ftype mismatch (%d/%d) in directory/child inode %" PRIu64 "/%" PRIu64 "\n"), dir_ftype, ino_ftype, - ip->i_ino, inum); + I_INO(ip), inum); libxfs_dir2_data_put_ftype(mp, dep, ino_ftype); libxfs_dir2_data_log_entry(da, bp, dep); dir_hash_update_ftype(hashtab, addr, ino_ftype); @@ -1540,7 +1540,7 @@ longform_dir2_entry_check_data( struct xfs_da_args da = { .dp = ip, .geo = mp->m_dir_geo, - .owner = ip->i_ino, + .owner = I_INO(ip), }; @@ -1633,11 +1633,11 @@ longform_dir2_entry_check_data( if (junkit) { do_warn( _("empty data block %u in directory inode %" PRIu64 ": "), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); } else { do_warn(_ ("corrupt block %u in directory inode %" PRIu64 ": "), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); } if (!no_modify) { do_warn(_("junking block\n")); @@ -1663,7 +1663,7 @@ longform_dir2_entry_check_data( if (be32_to_cpu(d->magic) != wantmagic) { do_warn( _("bad directory block magic # %#x for directory inode %" PRIu64 " block %d: "), - be32_to_cpu(d->magic), ip->i_ino, da_bno); + be32_to_cpu(d->magic), I_INO(ip), da_bno); if (!no_modify) { do_warn(_("fixing magic # to %#x\n"), wantmagic); d->magic = cpu_to_be32(wantmagic); @@ -1691,7 +1691,7 @@ longform_dir2_entry_check_data( if (lastfree) { do_warn( _("directory inode %" PRIu64 " block %u has consecutive free entries: "), - ip->i_ino, da_bno); + I_INO(ip), da_bno); if (!no_modify) { do_warn(_("joining together\n")); @@ -1737,7 +1737,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" in directory inode %" PRIu64 " points to non-existent inode %" PRIu64 ", "), - fname, ip->i_ino, inum, NULLFSINO)) { + fname, I_INO(ip), inum, NULLFSINO)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1754,7 +1754,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" in directory inode %" PRIu64 " points to free inode %" PRIu64 ", "), - fname, ip->i_ino, inum, NULLFSINO)) { + fname, I_INO(ip), inum, NULLFSINO)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1770,7 +1770,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" in regular dir %" PRIu64" points to a metadata inode %" PRIu64 ", "), - fname, ip->i_ino, inum, NULLFSINO)) { + fname, I_INO(ip), inum, NULLFSINO)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1786,7 +1786,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" in metadata dir %" PRIu64" points to a regular inode %" PRIu64 ", "), - fname, ip->i_ino, inum, NULLFSINO)) { + fname, I_INO(ip), inum, NULLFSINO)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1804,7 +1804,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("%s (ino %" PRIu64 ") in root (%" PRIu64 ") is not a directory, "), - ORPHANAGE, inum, ip->i_ino, NULLFSINO)) { + ORPHANAGE, inum, I_INO(ip), NULLFSINO)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1827,7 +1827,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " already points to ino %" PRIu64 ", "), - fname, inum, ip->i_ino, dup_inum)) { + fname, inum, I_INO(ip), dup_inum)) { dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); } @@ -1858,7 +1858,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is not in the the first block, "), fname, - inum, ip->i_ino, NULLFSINO)) { + inum, I_INO(ip), NULLFSINO)) { dir_hash_junkit(hashtab, addr); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); @@ -1881,7 +1881,7 @@ longform_dir2_entry_check_data( * '..' is already accounted for or will be taken care * of when directory is moved to orphanage. */ - if (ip->i_ino == inum) { + if (I_INO(ip) == inum) { ASSERT(no_modify || (dep->name[0] == '.' && dep->namelen == 1)); add_inode_ref(current_irec, current_ino_offset); @@ -1891,7 +1891,7 @@ longform_dir2_entry_check_data( nbad++; if (entry_junked( _("entry \"%s\" in dir %" PRIu64 " is not the first entry, "), - fname, inum, ip->i_ino, NULLFSINO)) { + fname, inum, I_INO(ip), NULLFSINO)) { dir_hash_junkit(hashtab, addr); dep->name[0] = '/'; libxfs_dir2_data_log_entry(&da, bp, dep); @@ -1944,8 +1944,8 @@ longform_dir2_entry_check_data( junkit = 1; do_warn( _("entry \"%s\" in dir %" PRIu64" points to an already connected directory inode %" PRIu64 "\n"), - fname, ip->i_ino, inum); - } else if (parent == ip->i_ino) { + fname, I_INO(ip), inum); + } else if (parent == I_INO(ip)) { add_inode_reached(irec, ino_offset); add_inode_ref(current_irec, current_ino_offset); } else if (parent == NULLFSINO) { @@ -1953,8 +1953,8 @@ _("entry \"%s\" in dir %" PRIu64" points to an already connected directory inode so, set it as the parent and mark for rebuild */ do_warn( _("entry \"%s\" in dir ino %" PRIu64 " doesn't have a .. entry, will set it in ino %" PRIu64 ".\n"), - fname, ip->i_ino, inum); - set_inode_parent(irec, ino_offset, ip->i_ino); + fname, I_INO(ip), inum); + set_inode_parent(irec, ino_offset, I_INO(ip)); add_inode_reached(irec, ino_offset); add_inode_ref(current_irec, current_ino_offset); add_dotdot_update(XFS_INO_TO_AGNO(mp, inum), irec, @@ -1963,7 +1963,7 @@ _("entry \"%s\" in dir %" PRIu64" points to an already connected directory inode junkit = 1; do_warn( _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 ") in ino %" PRIu64 "\n"), - fname, ip->i_ino, parent, inum); + fname, I_INO(ip), parent, inum); } if (junkit) { if (inum == orphanage_ino) @@ -2086,12 +2086,12 @@ longform_dir2_check_leaf( if (error == EFSBADCRC || error == EFSCORRUPTED || fixit) { do_warn( _("leaf block %u for directory inode %" PRIu64 " bad CRC\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); return 1; } else if (error) { do_error( _("can't read block %u for directory inode %" PRIu64 ", error %d\n"), - da_bno, ip->i_ino, error); + da_bno, I_INO(ip), error); /* NOTREACHED */ } @@ -2108,13 +2108,13 @@ longform_dir2_check_leaf( (char *)&ents[leafhdr.count] > (char *)bestsp) { do_warn( _("leaf block %u for directory inode %" PRIu64 " bad header\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } if (leafhdr.magic == XFS_DIR3_LEAF1_MAGIC) { - error = check_da3_header(mp, bp, ip->i_ino); + error = check_da3_header(mp, bp, I_INO(ip)); if (error) { libxfs_buf_relse(bp); return error; @@ -2134,7 +2134,7 @@ longform_dir2_check_leaf( if (badtail) { do_warn( _("leaf block %u for directory inode %" PRIu64 " bad tail\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } @@ -2195,7 +2195,7 @@ longform_dir2_check_node( if (error) { do_warn( _("can't read leaf block %u for directory inode %" PRIu64 ", error %d\n"), - da_bno, ip->i_ino, error); + da_bno, I_INO(ip), error); return 1; } leaf = bp->b_addr; @@ -2207,7 +2207,7 @@ longform_dir2_check_node( leafhdr.magic == XFS_DA3_NODE_MAGIC)) { do_warn( _("unknown magic number %#x for block %u in directory inode %" PRIu64 "\n"), - leafhdr.magic, da_bno, ip->i_ino); + leafhdr.magic, da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } @@ -2215,7 +2215,7 @@ longform_dir2_check_node( /* check v5 metadata */ if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC || leafhdr.magic == XFS_DA3_NODE_MAGIC) { - error = check_da3_header(mp, bp, ip->i_ino); + error = check_da3_header(mp, bp, I_INO(ip)); if (error) { libxfs_buf_relse(bp); return error; @@ -2238,7 +2238,7 @@ longform_dir2_check_node( leafhdr.count < leafhdr.stale) { do_warn( _("leaf block %u for directory inode %" PRIu64 " bad header\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } @@ -2270,7 +2270,7 @@ longform_dir2_check_node( if (error) { do_warn( _("can't read freespace block %u for directory inode %" PRIu64 ", error %d\n"), - da_bno, ip->i_ino, error); + da_bno, I_INO(ip), error); return 1; } free = bp->b_addr; @@ -2285,13 +2285,13 @@ longform_dir2_check_node( freehdr.nvalid < freehdr.nused) { do_warn( _("free block %u for directory inode %" PRIu64 " bad header\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } if (freehdr.magic == XFS_DIR3_FREE_MAGIC) { - error = check_dir3_header(mp, bp, ip->i_ino); + error = check_dir3_header(mp, bp, I_INO(ip)); if (error) { libxfs_buf_relse(bp); return error; @@ -2303,7 +2303,7 @@ longform_dir2_check_node( be16_to_cpu(bests[i])) { do_warn( _("free block %u entry %i for directory ino %" PRIu64 " bad\n"), - da_bno, i, ip->i_ino); + da_bno, i, I_INO(ip)); libxfs_buf_relse(bp); return 1; } @@ -2313,7 +2313,7 @@ longform_dir2_check_node( if (used != freehdr.nused) { do_warn( _("free block %u for directory inode %" PRIu64 " bad nused\n"), - da_bno, ip->i_ino); + da_bno, I_INO(ip)); libxfs_buf_relse(bp); return 1; } @@ -2324,7 +2324,7 @@ longform_dir2_check_node( (freetab->ents[i].v != NULLDATAOFF)) { do_warn( _("missing freetab entry %u for directory inode %" PRIu64 "\n"), - i, ip->i_ino); + i, I_INO(ip)); return 1; } } @@ -2376,7 +2376,7 @@ longform_dir2_entry_check( /* is this a block, leaf, or node directory? */ args.dp = ip; args.geo = mp->m_dir_geo; - args.owner = ip->i_ino; + args.owner = I_INO(ip); fmt = libxfs_dir2_format(&args, &error); /* check directory "data" blocks (ie. name/inode pairs) */ @@ -2734,7 +2734,7 @@ shortform_dir2_entry_check( inode_is_meta(irec, ino_offset)) { do_warn( _("entry \"%s\" in regular dir %" PRIu64" points to a metadata inode %" PRIu64 ", "), - fname, ip->i_ino, lino); + fname, I_INO(ip), lino); next_sfep = shortform_dir2_junk(mp, sfp, sfep, lino, &max_size, &i, &bytes_deleted, ino_dirty); @@ -2749,7 +2749,7 @@ shortform_dir2_entry_check( !inode_is_meta(irec, ino_offset)) { do_warn( _("entry \"%s\" in metadata dir %" PRIu64" points to a regular inode %" PRIu64 ", "), - fname, ip->i_ino, lino); + fname, I_INO(ip), lino); next_sfep = shortform_dir2_junk(mp, sfp, sfep, lino, &max_size, &i, &bytes_deleted, ino_dirty); @@ -3000,7 +3000,7 @@ fix_dotdot( libxfs_trans_ijoin(tp, ip, 0); - error = -libxfs_dir_createname(tp, ip, &xfs_name_dotdot, ip->i_ino, + error = -libxfs_dir_createname(tp, ip, &xfs_name_dotdot, I_INO(ip), nres); if (error) do_error( @@ -3133,7 +3133,7 @@ process_dir_inode( do_error( _("error %d fixing shortform directory %llu\n"), error, - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); } else { libxfs_trans_cancel(tp); } @@ -3189,7 +3189,7 @@ _("error %d fixing shortform directory %llu\n"), libxfs_trans_ijoin(tp, ip, 0); error = -libxfs_dir_createname(tp, ip, &xfs_name_dot, - ip->i_ino, nres); + I_INO(ip), nres); if (error) do_error( _("can't make \".\" entry in dir ino %" PRIu64 ", createname error %d\n"), @@ -3436,9 +3436,9 @@ reset_rt_metadir_inodes( } if (mp->m_rtdirip) { - mark_ino_inuse(mp, mp->m_rtdirip->i_ino, S_IFDIR, - mp->m_metadirip->i_ino); - mark_ino_metadata(mp, mp->m_rtdirip->i_ino); + mark_ino_inuse(mp, I_INO(mp->m_rtdirip), S_IFDIR, + I_INO(mp->m_metadirip)); + mark_ino_metadata(mp, I_INO(mp->m_rtdirip)); } } @@ -3557,8 +3557,8 @@ _("Couldn't reset link count on %s quota inode, error %d\n"), } /* Mark the inode in use. */ - mark_ino_inuse(mp, ip->i_ino, S_IFREG, dp->i_ino); - mark_ino_metadata(mp, ip->i_ino); + mark_ino_inuse(mp, I_INO(ip), S_IFREG, I_INO(dp)); + mark_ino_metadata(mp, I_INO(ip)); libxfs_irele(ip); return true; bad: @@ -3584,8 +3584,8 @@ reset_quota_metadir_inodes( do_error(_("failed to create quota metadir (%d)\n"), error); - mark_ino_inuse(mp, dp->i_ino, S_IFDIR, mp->m_metadirip->i_ino); - mark_ino_metadata(mp, dp->i_ino); + mark_ino_inuse(mp, I_INO(dp), S_IFDIR, I_INO(mp->m_metadirip)); + mark_ino_metadata(mp, I_INO(dp)); ensure_quota_file(dp, XFS_DQTYPE_USER); ensure_quota_file(dp, XFS_DQTYPE_GROUP); diff --git a/repair/pptr.c b/repair/pptr.c index 39e7bb5030d02f..84cd27d62b7c0b 100644 --- a/repair/pptr.c +++ b/repair/pptr.c @@ -372,7 +372,7 @@ add_parent_ptr( }; struct ag_pptr ag_pptr = { .child_agino = XFS_INO_TO_AGINO(mp, ino), - .parent_ino = dp->i_ino, + .parent_ino = I_INO(dp), .parent_gen = VFS_I(dp)->i_generation, .namelen = dname.len, }; @@ -407,7 +407,7 @@ add_parent_ptr( dbg_printf( _("%s: dp %llu gen 0x%x fname '%s' namehash 0x%x ino %llu namecookie 0x%llx\n"), __func__, - (unsigned long long)dp->i_ino, + (unsigned long long)I_INO(dp), VFS_I(dp)->i_generation, fname, ag_pptr.namehash, @@ -438,7 +438,7 @@ remove_garbage_xattrs( .attr_filter = ga->attr_filter, .namelen = ga->attrnamelen, .valuelen = ga->attrvaluelen, - .owner = ip->i_ino, + .owner = I_INO(ip), .geo = ip->i_mount->m_attr_geo, .whichfork = XFS_ATTR_FORK, .op_flags = XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED, @@ -452,7 +452,7 @@ remove_garbage_xattrs( do_error( _("allocating %zu bytes to remove ino %llu garbage xattr failed: %s\n"), desired, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(errno)); bufsize = desired; } @@ -480,7 +480,7 @@ remove_garbage_xattrs( if (error) do_error( _("removing ino %llu garbage xattr failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); } @@ -515,7 +515,7 @@ record_garbage_xattr( if (!fscan->have_garbage) do_warn( _("would delete garbage parent pointer extended attributes in ino %llu\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); fscan->have_garbage = true; return; } @@ -526,7 +526,7 @@ record_garbage_xattr( do_warn( _("deleting garbage parent pointer extended attributes in ino %llu\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); error = -init_slab(&fscan->garbage_xattr_recs, sizeof(struct garbage_xattr)); @@ -547,20 +547,20 @@ record_garbage_xattr( &garbage_xattr.attrname_cookie, name, namelen); if (error) do_error(_("storing ino %llu garbage xattr failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); error = -xfblob_store(fscan->garbage_xattr_names, &garbage_xattr.attrvalue_cookie, value, valuelen); if (error) do_error(_("storing ino %llu garbage xattr failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); error = -slab_add(fscan->garbage_xattr_recs, &garbage_xattr); if (error) do_error(_("storing ino %llu garbage xattr rec failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); } @@ -627,7 +627,7 @@ examine_xattr( if (error) do_error( _("storing ino %llu parent pointer '%.*s' failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), namelen, (const char *)name, strerror(error)); @@ -635,7 +635,7 @@ examine_xattr( error = -slab_add(fscan->file_pptr_recs, &file_pptr); if (error) do_error(_("storing ino %llu parent pointer rec failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); dbg_printf( @@ -647,7 +647,7 @@ examine_xattr( (const char *)name, namelen, file_pptr.namehash, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr.name_cookie, file_pptr.name_in_nameblobs); @@ -690,7 +690,7 @@ add_file_pptr( xfs_parent_rec_init(&pptr_rec, ag_pptr->parent_ino, ag_pptr->parent_gen); - return -libxfs_parent_set(ip, ip->i_ino, &xname, &pptr_rec, &scratch); + return -libxfs_parent_set(ip, I_INO(ip), &xname, &pptr_rec, &scratch); } /* Remove an on disk parent pointer from a file. */ @@ -709,7 +709,7 @@ remove_file_pptr( xfs_parent_rec_init(&pptr_rec, file_pptr->parent_ino, file_pptr->parent_gen); - return -libxfs_parent_unset(ip, ip->i_ino, &xname, &pptr_rec, &scratch); + return -libxfs_parent_unset(ip, I_INO(ip), &xname, &pptr_rec, &scratch); } /* Remove all pptrs from @ip. */ @@ -724,17 +724,17 @@ clear_all_pptrs( if (no_modify) { do_warn(_("would delete unlinked ino %llu parent pointers\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); return; } do_warn(_("deleting unlinked ino %llu parent pointers\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); error = -init_slab_cursor(fscan->file_pptr_recs, NULL, &cur); if (error) do_error(_("init ino %llu pptr cursor failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); while ((file_pptr = pop_slab_cursor(cur)) != NULL) { @@ -744,7 +744,7 @@ clear_all_pptrs( if (error) do_error( _("loading incorrect name for ino %llu parent pointer (ino %llu gen 0x%x namecookie 0x%llx) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, (unsigned long long)file_pptr->name_cookie, @@ -754,7 +754,7 @@ clear_all_pptrs( if (error) do_error( _("wiping ino %llu pptr (ino %llu gen 0x%x) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, strerror(error)); @@ -778,7 +778,7 @@ add_missing_parent_ptr( if (error) do_error( _("loading missing name for ino %llu parent pointer (ino %llu gen 0x%x namecookie 0x%llx) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, (unsigned long long)ag_pptr->name_cookie, @@ -787,7 +787,7 @@ add_missing_parent_ptr( if (no_modify) { do_warn( _("would add missing ino %llu parent pointer (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, @@ -796,7 +796,7 @@ add_missing_parent_ptr( } else { do_warn( _("adding missing ino %llu parent pointer (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, @@ -807,7 +807,7 @@ add_missing_parent_ptr( if (error) do_error( _("adding ino %llu pptr (ino %llu gen 0x%x name '%.*s') failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, @@ -829,7 +829,7 @@ remove_incorrect_parent_ptr( if (error) do_error( _("loading incorrect name for ino %llu parent pointer (ino %llu gen 0x%x namecookie 0x%llx) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, (unsigned long long)file_pptr->name_cookie, @@ -838,7 +838,7 @@ remove_incorrect_parent_ptr( if (no_modify) { do_warn( _("would remove bad ino %llu parent pointer (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -848,7 +848,7 @@ remove_incorrect_parent_ptr( do_warn( _("removing bad ino %llu parent pointer (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -858,7 +858,7 @@ remove_incorrect_parent_ptr( if (error) do_error( _("removing ino %llu pptr (ino %llu gen 0x%x name '%.*s') failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -886,7 +886,7 @@ compare_parent_ptrs( if (error) do_error( _("loading master-list name for ino %llu parent pointer (ino %llu gen 0x%x namecookie 0x%llx namelen %u) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, (unsigned long long)ag_pptr->name_cookie, @@ -897,7 +897,7 @@ compare_parent_ptrs( if (error) do_error( _("loading file-list name for ino %llu parent pointer (ino %llu gen 0x%x namecookie 0x%llx namelen %u) failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, (unsigned long long)file_pptr->name_cookie, @@ -919,7 +919,7 @@ compare_parent_ptrs( if (no_modify) { do_warn( _("would update ino %llu parent pointer (ino %llu gen 0x%x name '%.*s') -> (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -933,7 +933,7 @@ compare_parent_ptrs( do_warn( _("updating ino %llu parent pointer (ino %llu gen 0x%x name '%.*s') -> (ino %llu gen 0x%x name '%.*s')\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -948,7 +948,7 @@ compare_parent_ptrs( if (error) do_error( _("erasing ino %llu pptr (ino %llu gen 0x%x name '%.*s') failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, @@ -964,7 +964,7 @@ _("erasing ino %llu pptr (ino %llu gen 0x%x name '%.*s') failed: %s\n"), if (error && error != EEXIST) do_error( _("updating ino %llu pptr (ino %llu gen 0x%x name '%.*s') failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, @@ -1081,7 +1081,7 @@ crosscheck_file_parent_ptrs( _("found dirent referring to ino %llu even though inobt scan moved on to ino %llu?!\n"), (unsigned long long)XFS_AGINO_TO_INO(mp, agno, ag_pptr->child_agino), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); /* does not return */ } @@ -1096,7 +1096,7 @@ crosscheck_file_parent_ptrs( &fscan->file_pptr_recs_cur); if (error) do_error(_("init ino %llu parent pointer cursor failed: %s\n"), - (unsigned long long)ip->i_ino, strerror(error)); + (unsigned long long)I_INO(ip), strerror(error)); do { int cmp_result; @@ -1114,7 +1114,7 @@ crosscheck_file_parent_ptrs( (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->name_cookie); prev_ag_pptr = ag_pptr; advance_slab_cursor(fscan->ag_pptr_recs_cur); @@ -1131,7 +1131,7 @@ crosscheck_file_parent_ptrs( (unsigned long long)ag_pptr->parent_ino, ag_pptr->parent_gen, ag_pptr->namelen, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)ag_pptr->name_cookie); if (file_pptr) { @@ -1141,13 +1141,13 @@ crosscheck_file_parent_ptrs( (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->name_cookie); } else { dbg_printf( _("%s: ran out of parent pointers for ino %llu (file)\n"), __func__, - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); } cmp_result = cmp_file_to_ag_pptr(file_pptr, ag_pptr); @@ -1188,7 +1188,7 @@ crosscheck_file_parent_ptrs( (unsigned long long)file_pptr->parent_ino, file_pptr->parent_gen, file_pptr->namelen, - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)file_pptr->name_cookie); /* @@ -1223,11 +1223,11 @@ check_file_parent_ptrs( libxfs_trans_cancel(tp); if (error && !no_modify) do_error(_("ino %llu parent pointer scan failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); if (error) { do_warn(_("ino %llu parent pointer scan failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); goto out_free; } @@ -1361,20 +1361,20 @@ erase_pptrs( &garbage_xattr.attrname_cookie, name, namelen); if (error) do_error(_("storing ino %llu garbage pptr failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); error = -xfblob_store(fscan->garbage_xattr_names, &garbage_xattr.attrvalue_cookie, value, valuelen); if (error) do_error(_("storing ino %llu garbage pptr failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); error = -slab_add(fscan->garbage_xattr_recs, &garbage_xattr); if (error) do_error(_("storing ino %llu garbage pptr rec failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); return 0; @@ -1399,7 +1399,7 @@ try_erase_parent_ptrs( if (no_modify) { do_warn( _("would delete garbage parent pointers in metadata ino %llu\n"), - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); return; } @@ -1423,7 +1423,7 @@ try_erase_parent_ptrs( libxfs_trans_cancel(tp); if (error) do_warn(_("ino %llu garbage pptr collection failed: %s\n"), - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), strerror(error)); remove_garbage_xattrs(ip, &fscan); diff --git a/repair/quotacheck.c b/repair/quotacheck.c index f4c0314177b013..fc7e3864654cd4 100644 --- a/repair/quotacheck.c +++ b/repair/quotacheck.c @@ -169,7 +169,7 @@ qc_count_rtblocks( if (error) { do_warn( _("could not read ino %"PRIu64" extents, err=%d\n"), - ip->i_ino, error); + I_INO(ip), error); chkd_flags = 0; return 0; } @@ -375,7 +375,7 @@ qc_walk_dquot_extent( if (error) { do_warn( _("cannot read %s inode %"PRIu64", block %"PRIu64", disk block %"PRIu64", err=%d\n"), - qflags_typestr(dquots->type), ip->i_ino, + qflags_typestr(dquots->type), I_INO(ip), map->br_startoff + bno, map->br_startblock + bno, error); chkd_flags = 0; @@ -454,7 +454,7 @@ quotacheck_verify( if (error) { do_warn( _("could not read %s inode %"PRIu64" extents, err=%d\n"), - qflags_typestr(type), ip->i_ino, error); + qflags_typestr(type), I_INO(ip), error); chkd_flags = 0; goto err; } @@ -659,7 +659,7 @@ mark_quota_inode( if (error) goto out_corrupt; - set_quota_inode(type, ip->i_ino); + set_quota_inode(type, I_INO(ip)); libxfs_irele(ip); return 0; diff --git a/repair/rt.c b/repair/rt.c index 781d8968446c27..3e51c9b5eb4beb 100644 --- a/repair/rt.c +++ b/repair/rt.c @@ -268,7 +268,7 @@ check_rtfile_contents( if (xfs_has_rtgroups(mp)) { struct xfs_rtbuf_blkinfo *hdr = bp->b_addr; - if (hdr->rt_owner != cpu_to_be64(ip->i_ino)) { + if (hdr->rt_owner != cpu_to_be64(I_INO(ip))) { do_warn( _("corrupt owner in %s at dblock 0x%llx\n"), filename, (unsigned long long)bno); @@ -461,12 +461,12 @@ mark_rtginode( goto out_corrupt; if (xfs_has_rtgroups(rtg_mount(rtg))) { - if (bitmap_test(rtg_inodes[type], ip->i_ino, 1)) { + if (bitmap_test(rtg_inodes[type], I_INO(ip), 1)) { error = EFSCORRUPTED; goto out_corrupt; } - error = bitmap_set(rtg_inodes[type], ip->i_ino, 1); + error = bitmap_set(rtg_inodes[type], I_INO(ip), 1); if (error) goto out_corrupt; } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 6b97a806384096..bc79bfc05a29b3 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -668,7 +668,7 @@ check_metadir_inode( /* If we changed the metadir inode, try reloading it. */ if (!mp->m_metadirip || - mp->m_metadirip->i_ino != mp->m_sb.sb_metadirino) { + I_INO(mp->m_metadirip) != mp->m_sb.sb_metadirino) { if (mp->m_metadirip) libxfs_irele(mp->m_metadirip); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 10/18] xfs: cleanup xfs_imap 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (8 preceding siblings ...) 2026-07-02 20:02 ` [PATCH 09/18] xfs: remove the i_ino field in struct xfs_inode Darrick J. Wong @ 2026-07-02 20:02 ` Darrick J. Wong 2026-07-02 20:03 ` [PATCH 11/18] xfs: remove im_len field in struct xfs_imap Darrick J. Wong ` (8 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:02 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 41397e7ca8a06507ae6f52f68cd27b0812e9a561 Reshuffle the code a bit so that the imap_lookup and filling out of the xfs_imap structure aren't duplicated. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_ialloc.c | 62 +++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 64f0376a10508f..8c42c045924db8 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -2506,43 +2506,37 @@ xfs_imap( * inodes in stale state on disk. Hence we have to do a btree lookup * in all cases where an untrusted inode number is passed. */ - if (flags & XFS_IGET_UNTRUSTED) { - error = xfs_imap_lookup(pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); - if (error) - return error; - goto out_map; - } + if (!(flags & XFS_IGET_UNTRUSTED)) { + /* + * If the inode cluster size is the same or smaller than the + * blocksize, get to the buffer by simple arithmetics. + */ + if (M_IGEO(mp)->blocks_per_cluster == 1) { + cluster_agbno = agbno; + offset = XFS_INO_TO_OFFSET(mp, ino); + ASSERT(offset < mp->m_sb.sb_inopblock); + goto out; + } - /* - * If the inode cluster size is the same as the blocksize or - * smaller we get to the buffer by simple arithmetics. - */ - if (M_IGEO(mp)->blocks_per_cluster == 1) { - offset = XFS_INO_TO_OFFSET(mp, ino); - ASSERT(offset < mp->m_sb.sb_inopblock); + /* + * If the inode chunks are aligned, use simple maths to find the + * location. + */ + if (M_IGEO(mp)->inoalign_mask) { + offset_agbno = agbno & M_IGEO(mp)->inoalign_mask; + chunk_agbno = agbno - offset_agbno; + goto out_map; + } - imap->im_blkno = xfs_agbno_to_daddr(pag, agbno); - imap->im_len = XFS_FSB_TO_BB(mp, 1); - imap->im_boffset = (unsigned short)(offset << - mp->m_sb.sb_inodelog); - return 0; + /* + * Otherwise we have to do a btree lookup to find the location. + */ } - /* - * If the inode chunks are aligned then use simple maths to - * find the location. Otherwise we have to do a btree - * lookup to find the location. - */ - if (M_IGEO(mp)->inoalign_mask) { - offset_agbno = agbno & M_IGEO(mp)->inoalign_mask; - chunk_agbno = agbno - offset_agbno; - } else { - error = xfs_imap_lookup(pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); - if (error) - return error; - } + error = xfs_imap_lookup(pag, tp, agino, agbno, &chunk_agbno, + &offset_agbno, flags); + if (error) + return error; out_map: ASSERT(agbno >= chunk_agbno); @@ -2551,7 +2545,7 @@ xfs_imap( M_IGEO(mp)->blocks_per_cluster); offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + XFS_INO_TO_OFFSET(mp, ino); - +out: imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno); imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 11/18] xfs: remove im_len field in struct xfs_imap 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (9 preceding siblings ...) 2026-07-02 20:02 ` [PATCH 10/18] xfs: cleanup xfs_imap Darrick J. Wong @ 2026-07-02 20:03 ` Darrick J. Wong 2026-07-02 20:03 ` [PATCH 12/18] xfs: massage xfs_imap_to_bp into xfs_read_icluster Darrick J. Wong ` (7 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:03 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 33451947c4f0f91df74af2db4384143446a1157a im_len is always set to the same value for a given file system, which makes it redundant. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_inode_buf.h | 1 - libxfs/xfs_ialloc.c | 10 +++++----- libxfs/xfs_inode_buf.c | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 8d43d2641c7328..54870796da419a 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -15,7 +15,6 @@ struct xfs_dinode; */ struct xfs_imap { xfs_daddr_t im_blkno; /* starting BB of inode chunk */ - unsigned short im_len; /* length in BBs of inode chunk */ unsigned short im_boffset; /* inode offset in block in bytes */ }; diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 8c42c045924db8..f313acbe559ad7 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -2547,7 +2547,6 @@ xfs_imap( XFS_INO_TO_OFFSET(mp, ino); out: imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno); - imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); /* @@ -2556,12 +2555,13 @@ xfs_imap( * read_buf and panicing when we get an error from the * driver. */ - if ((imap->im_blkno + imap->im_len) > + if (imap->im_blkno + + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster) > XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { xfs_alert(mp, - "%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)", - __func__, (unsigned long long) imap->im_blkno, - (unsigned long long) imap->im_len, + "%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)", + __func__, imap->im_blkno, + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); return -EINVAL; } diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 2fc9462e95d67e..84800fb3b37b7a 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -134,7 +134,8 @@ xfs_imap_to_bp( int error; error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, - imap->im_len, 0, bpp, &xfs_inode_buf_ops); + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), + 0, bpp, &xfs_inode_buf_ops); if (xfs_metadata_is_sick(error)) xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno), XFS_SICK_AG_INODES); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 12/18] xfs: massage xfs_imap_to_bp into xfs_read_icluster 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (10 preceding siblings ...) 2026-07-02 20:03 ` [PATCH 11/18] xfs: remove im_len field in struct xfs_imap Darrick J. Wong @ 2026-07-02 20:03 ` Darrick J. Wong 2026-07-02 20:03 ` [PATCH 13/18] xfs: store an agbno in struct xfs_imap Darrick J. Wong ` (6 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:03 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: caffb4252cf15c5c3bbe7ff1f48f24f4015edb9c xfs_imap_to_bp only uses the im_blkno field from struct xfs_imap, so pass that directly. Rename the function to xfs_read_icluster, which describes the functionality much better and matches other helpers like xfs_read_agf and xfs_read_agi. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/libxfs_api_defs.h | 2 +- libxfs/xfs_inode_buf.h | 6 +++--- db/iunlink.c | 2 +- libxfs/inode.c | 2 +- libxfs/iunlink.c | 2 +- libxfs/logitem.c | 3 ++- libxfs/xfs_ialloc.c | 2 +- libxfs/xfs_inode_buf.c | 12 +++++------- repair/bmap_repair.c | 2 +- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index d7c912e778799c..4f542ae7267e8c 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -200,7 +200,7 @@ #define xfs_iext_lookup_extent libxfs_iext_lookup_extent #define xfs_iext_next libxfs_iext_next #define xfs_ifork_zap_attr libxfs_ifork_zap_attr -#define xfs_imap_to_bp libxfs_imap_to_bp +#define xfs_read_icluster libxfs_read_icluster #define xfs_initialize_perag libxfs_initialize_perag #define xfs_initialize_perag_data libxfs_initialize_perag_data diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 54870796da419a..bcad22871b5c40 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -11,15 +11,15 @@ struct xfs_dinode; /* * Inode location information. Stored in the inode and passed to - * xfs_imap_to_bp() to get a buffer and dinode for a given inode. + * xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { xfs_daddr_t im_blkno; /* starting BB of inode chunk */ unsigned short im_boffset; /* inode offset in block in bytes */ }; -int xfs_imap_to_bp(struct xfs_mount *mp, struct xfs_trans *tp, - struct xfs_imap *imap, struct xfs_buf **bpp); +int xfs_read_icluster(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_daddr_t bno, struct xfs_buf **bpp); void xfs_dinode_calc_crc(struct xfs_mount *mp, struct xfs_dinode *dip); void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, xfs_lsn_t lsn); diff --git a/db/iunlink.c b/db/iunlink.c index b4705a187b28b1..ba5637553d6de5 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -65,7 +65,7 @@ get_next_unlinked( dbprintf("\n"); } - error = -libxfs_imap_to_bp(mp, NULL, &ip->i_imap, &ino_bp); + error = -libxfs_read_icluster(mp, NULL, ip->i_imap.im_blkno, &ino_bp); if (error) { libxfs_irele(ip); goto bad; diff --git a/libxfs/inode.c b/libxfs/inode.c index b4bf3b5859a7e6..fe127160ed0a11 100644 --- a/libxfs/inode.c +++ b/libxfs/inode.c @@ -182,7 +182,7 @@ libxfs_iget( } else { struct xfs_buf *bp; - error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp); + error = xfs_read_icluster(mp, tp, ip->i_imap.im_blkno, &bp); if (error) goto out_destroy; diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c index 7a00915290db86..15654d262ba0d1 100644 --- a/libxfs/iunlink.c +++ b/libxfs/iunlink.c @@ -44,7 +44,7 @@ xfs_iunlink_log_dinode( int offset; int error; - error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &ibp); + error = xfs_read_icluster(mp, tp, ip->i_imap.im_blkno, &ibp); if (error) return error; /* diff --git a/libxfs/logitem.c b/libxfs/logitem.c index 67b982788061f8..ac50b680d38623 100644 --- a/libxfs/logitem.c +++ b/libxfs/logitem.c @@ -261,7 +261,8 @@ xfs_inode_item_precommit( * here. */ spin_unlock(&iip->ili_lock); - error = xfs_imap_to_bp(ip->i_mount, tp, &ip->i_imap, &bp); + error = xfs_read_icluster(ip->i_mount, tp, ip->i_imap.im_blkno, + &bp); if (error) return error; diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index f313acbe559ad7..7ecb7d54577a0d 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1070,7 +1070,7 @@ xfs_dialloc_check_ino( if (error) return -EAGAIN; - error = xfs_imap_to_bp(pag_mount(pag), tp, &imap, &bp); + error = xfs_read_icluster(pag_mount(pag), tp, imap.im_blkno, &bp); if (error) return -EAGAIN; diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 84800fb3b37b7a..6882f7099ab030 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -120,24 +120,22 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = { /* - * This routine is called to map an inode to the buffer containing the on-disk - * version of the inode. It returns a pointer to the buffer containing the - * on-disk inode in the bpp parameter. + * Read the inode cluster at @bno and return it in @bpp. */ int -xfs_imap_to_bp( +xfs_read_icluster( struct xfs_mount *mp, struct xfs_trans *tp, - struct xfs_imap *imap, + xfs_daddr_t bno, struct xfs_buf **bpp) { int error; - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, bno, XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), 0, bpp, &xfs_inode_buf_ops); if (xfs_metadata_is_sick(error)) - xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno), + xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, bno), XFS_SICK_AG_INODES); return error; } diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index 2e1995b3933428..dadd6e2ce39f8b 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -821,7 +821,7 @@ rebuild_bmap( * Rebuilding the inode fork rolled the transaction, so we need to * re-grab the inode cluster buffer and dinode pointer for the caller. */ - err2 = -libxfs_imap_to_bp(mp, NULL, &sc.ip->i_imap, ino_bpp); + err2 = -libxfs_read_icluster(mp, NULL, sc.ip->i_imap.im_blkno, ino_bpp); if (err2) do_error( _("Unable to re-grab inode cluster buffer after failed repair of inode %llu, error %d.\n"), ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 13/18] xfs: store an agbno in struct xfs_imap 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (11 preceding siblings ...) 2026-07-02 20:03 ` [PATCH 12/18] xfs: massage xfs_imap_to_bp into xfs_read_icluster Darrick J. Wong @ 2026-07-02 20:03 ` Darrick J. Wong 2026-07-02 20:03 ` [PATCH 14/18] xfs: mark struct xfs_imap as __packed Darrick J. Wong ` (5 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:03 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 9b64ca202f364a6bf8e19bdd20953bc2d776c67f The xfs_imap structure is embedded into the xfs_inode, which means the size of it directly affects the inode size. Replacing the xfs_daddr_t with an xfs_agbno_t and taking the AG information from other easily available sources allows us to shrink the structure including the typical padding from 16 bytes to 8 bytes. As a side-effect the debugging check in xfs_imap() naturally now converges to a stricter variant that checks that the cluster is located inside a single AG, and not just inside the entire device. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_inode_buf.h | 8 ++++---- db/iunlink.c | 5 ++++- libxfs/inode.c | 2 +- libxfs/iunlink.c | 2 +- libxfs/logitem.c | 14 +++++++++----- libxfs/xfs_ialloc.c | 24 +++++++----------------- libxfs/xfs_inode_buf.c | 11 ++++++----- repair/bmap_repair.c | 6 +++++- 8 files changed, 37 insertions(+), 35 deletions(-) diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index bcad22871b5c40..57192adc774491 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -14,12 +14,12 @@ struct xfs_dinode; * xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { - xfs_daddr_t im_blkno; /* starting BB of inode chunk */ - unsigned short im_boffset; /* inode offset in block in bytes */ + xfs_agblock_t im_agbno; /* starting agbno of inode cluster */ + unsigned short im_boffset; /* offset in inode cluster in bytes */ }; -int xfs_read_icluster(struct xfs_mount *mp, struct xfs_trans *tp, - xfs_daddr_t bno, struct xfs_buf **bpp); +int xfs_read_icluster(struct xfs_perag *pag, struct xfs_trans *tp, + xfs_agblock_t agbno, struct xfs_buf **bpp); void xfs_dinode_calc_crc(struct xfs_mount *mp, struct xfs_dinode *dip); void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, xfs_lsn_t lsn); diff --git a/db/iunlink.c b/db/iunlink.c index ba5637553d6de5..447d2859b104c7 100644 --- a/db/iunlink.c +++ b/db/iunlink.c @@ -43,6 +43,7 @@ get_next_unlinked( struct xfs_buf *ino_bp; struct xfs_dinode *dip; struct xfs_inode *ip; + struct xfs_perag *pag; xfs_ino_t ino; xfs_agino_t ret; int error; @@ -65,7 +66,9 @@ get_next_unlinked( dbprintf("\n"); } - error = -libxfs_read_icluster(mp, NULL, ip->i_imap.im_blkno, &ino_bp); + pag = libxfs_perag_get(mp, agno); + error = -libxfs_read_icluster(pag, NULL, ip->i_imap.im_agbno, &ino_bp); + libxfs_perag_put(pag); if (error) { libxfs_irele(ip); goto bad; diff --git a/libxfs/inode.c b/libxfs/inode.c index fe127160ed0a11..b6838d3d4bd30d 100644 --- a/libxfs/inode.c +++ b/libxfs/inode.c @@ -182,7 +182,7 @@ libxfs_iget( } else { struct xfs_buf *bp; - error = xfs_read_icluster(mp, tp, ip->i_imap.im_blkno, &bp); + error = xfs_read_icluster(pag, tp, ip->i_imap.im_agbno, &bp); if (error) goto out_destroy; diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c index 15654d262ba0d1..875e0caae98818 100644 --- a/libxfs/iunlink.c +++ b/libxfs/iunlink.c @@ -44,7 +44,7 @@ xfs_iunlink_log_dinode( int offset; int error; - error = xfs_read_icluster(mp, tp, ip->i_imap.im_blkno, &ibp); + error = xfs_read_icluster(iup->pag, tp, ip->i_imap.im_agbno, &ibp); if (error) return error; /* diff --git a/libxfs/logitem.c b/libxfs/logitem.c index ac50b680d38623..6e56e476d1ea08 100644 --- a/libxfs/logitem.c +++ b/libxfs/logitem.c @@ -16,6 +16,7 @@ #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_rtbitmap.h" +#include "xfs_ag.h" struct kmem_cache *xfs_buf_item_cache; struct kmem_cache *xfs_ili_cache; /* inode log item cache */ @@ -180,6 +181,7 @@ xfs_inode_item_precommit( { struct xfs_inode_log_item *iip = INODE_ITEM(lip); struct xfs_inode *ip = iip->ili_inode; + struct xfs_mount *mp = ip->i_mount; struct inode *inode = VFS_I(ip); unsigned int flags = iip->ili_dirty_flags; @@ -200,7 +202,7 @@ xfs_inode_item_precommit( * to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE | XFS_ILOG_TIMESTAMP)) && - xfs_has_bigtime(ip->i_mount) && + xfs_has_bigtime(mp) && !xfs_inode_has_bigtime(ip)) { ip->i_diflags2 |= XFS_DIFLAG2_BIGTIME; flags |= XFS_ILOG_CORE; @@ -214,7 +216,7 @@ xfs_inode_item_precommit( */ if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) && (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) && - xfs_extlen_to_rtxmod(ip->i_mount, ip->i_extsize) > 0) { + xfs_extlen_to_rtxmod(mp, ip->i_extsize) > 0) { ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT); ip->i_extsize = 0; @@ -241,13 +243,14 @@ xfs_inode_item_precommit( */ if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) && (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) && - xfs_extlen_to_rtxmod(ip->i_mount, ip->i_cowextsize) > 0) { + xfs_extlen_to_rtxmod(mp, ip->i_cowextsize) > 0) { ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; ip->i_cowextsize = 0; flags |= XFS_ILOG_CORE; } if (!iip->ili_item.li_buf) { + struct xfs_perag *pag; struct xfs_buf *bp; int error; @@ -261,8 +264,9 @@ xfs_inode_item_precommit( * here. */ spin_unlock(&iip->ili_lock); - error = xfs_read_icluster(ip->i_mount, tp, ip->i_imap.im_blkno, - &bp); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); + error = xfs_read_icluster(pag, tp, ip->i_imap.im_agbno, &bp); + xfs_perag_put(pag); if (error) return error; diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 7ecb7d54577a0d..f2669dc4907ecf 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1070,7 +1070,7 @@ xfs_dialloc_check_ino( if (error) return -EAGAIN; - error = xfs_read_icluster(pag_mount(pag), tp, imap.im_blkno, &bp); + error = xfs_read_icluster(pag, tp, imap.im_agbno, &bp); if (error) return -EAGAIN; @@ -2546,23 +2546,13 @@ xfs_imap( offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + XFS_INO_TO_OFFSET(mp, ino); out: - imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno); + imap->im_agbno = cluster_agbno; imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); - - /* - * If the inode number maps to a block outside the bounds - * of the file system then return NULL rather than calling - * read_buf and panicing when we get an error from the - * driver. - */ - if (imap->im_blkno + - XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster) > - XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { - xfs_alert(mp, - "%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)", - __func__, imap->im_blkno, - XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), - XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); + if (imap->im_agbno + M_IGEO(mp)->blocks_per_cluster > + pag_group(pag)->xg_block_count) { + xfs_alert(mp, "inode cluster out of range: %u/%u > %u", + imap->im_agbno, M_IGEO(mp)->blocks_per_cluster, + pag_group(pag)->xg_block_count); return -EINVAL; } return 0; diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 6882f7099ab030..9990aaeef5fd76 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -124,19 +124,20 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = { */ int xfs_read_icluster( - struct xfs_mount *mp, + struct xfs_perag *pag, struct xfs_trans *tp, - xfs_daddr_t bno, + xfs_agblock_t agbno, struct xfs_buf **bpp) { + struct xfs_mount *mp = pag_mount(pag); int error; - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, bno, + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, + xfs_agbno_to_daddr(pag, agbno), XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), 0, bpp, &xfs_inode_buf_ops); if (xfs_metadata_is_sick(error)) - xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, bno), - XFS_SICK_AG_INODES); + xfs_agno_mark_sick(mp, pag_agno(pag), XFS_SICK_AG_INODES); return error; } diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c index dadd6e2ce39f8b..dfdce1a0e01f4a 100644 --- a/repair/bmap_repair.c +++ b/repair/bmap_repair.c @@ -740,6 +740,7 @@ rebuild_bmap( .mp = mp, }; const struct xfs_buf_ops *bp_ops; + struct xfs_perag *pag; unsigned long boffset; unsigned long long resblks; xfs_daddr_t bp_bn; @@ -821,7 +822,10 @@ rebuild_bmap( * Rebuilding the inode fork rolled the transaction, so we need to * re-grab the inode cluster buffer and dinode pointer for the caller. */ - err2 = -libxfs_read_icluster(mp, NULL, sc.ip->i_imap.im_blkno, ino_bpp); + pag = libxfs_perag_get(mp, XFS_INODE_TO_AGNO(sc.ip)); + err2 = -libxfs_read_icluster(pag, NULL, sc.ip->i_imap.im_agbno, + ino_bpp); + libxfs_perag_put(pag); if (err2) do_error( _("Unable to re-grab inode cluster buffer after failed repair of inode %llu, error %d.\n"), ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 14/18] xfs: mark struct xfs_imap as __packed 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (12 preceding siblings ...) 2026-07-02 20:03 ` [PATCH 13/18] xfs: store an agbno in struct xfs_imap Darrick J. Wong @ 2026-07-02 20:03 ` Darrick J. Wong 2026-07-02 20:04 ` [PATCH 15/18] xfs: fix pointer arithmetic error on 32-bit systems Darrick J. Wong ` (4 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:03 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 4f16139d8e296ec5403c3ebbe874dcd5c57648ca This returns 2 bytes of padding at the to struct xfs_inode into which this structure is embedded. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_inode_buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 57192adc774491..f3624532b0238a 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -16,7 +16,7 @@ struct xfs_dinode; struct xfs_imap { xfs_agblock_t im_agbno; /* starting agbno of inode cluster */ unsigned short im_boffset; /* offset in inode cluster in bytes */ -}; +} __packed; int xfs_read_icluster(struct xfs_perag *pag, struct xfs_trans *tp, xfs_agblock_t agbno, struct xfs_buf **bpp); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 15/18] xfs: fix pointer arithmetic error on 32-bit systems 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (13 preceding siblings ...) 2026-07-02 20:03 ` [PATCH 14/18] xfs: mark struct xfs_imap as __packed Darrick J. Wong @ 2026-07-02 20:04 ` Darrick J. Wong 2026-07-02 20:04 ` [PATCH 16/18] xfs: pass back updated nb from xfs_growfs_compute_deltas Darrick J. Wong ` (3 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:04 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, hch, linux-xfs From: Darrick J. Wong <djwong@kernel.org> Source kernel commit: 84eec3f7fc73144d1a230c9e8ad92721e37dcaab The translation of the old XFS_BMBT_KEY_ADDR macro into a static function is not correct on 32-bit systems because the sizeof() argument went from being a xfs_bmbt_key_t (i.e. a struct) to a (struct xfs_bmbt_key *) (i.e. a pointer to the same struct). On 64-bit systems this turns out ok because they are the same size, but on 32-bit systems this is catastrophic because they are not the same size. So far there have been no complaints, most likely because the xfs developers urge against running it on 32-bit systems. But this needs fixing asap. Fixes: 79124b37400635 ("xfs: replace shouty XFS_BM{BT,DR} macros") Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_bmap_btree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h index b238d559ab0369..e0c870beaf670c 100644 --- a/libxfs/xfs_bmap_btree.h +++ b/libxfs/xfs_bmap_btree.h @@ -89,7 +89,7 @@ xfs_bmbt_key_addr( { return (struct xfs_bmbt_key *) ((char *)block + xfs_bmbt_block_len(mp) + - (index - 1) * sizeof(struct xfs_bmbt_key *)); + (index - 1) * sizeof(struct xfs_bmbt_key)); } static inline xfs_bmbt_ptr_t * ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 16/18] xfs: pass back updated nb from xfs_growfs_compute_deltas 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (14 preceding siblings ...) 2026-07-02 20:04 ` [PATCH 15/18] xfs: fix pointer arithmetic error on 32-bit systems Darrick J. Wong @ 2026-07-02 20:04 ` Darrick J. Wong 2026-07-02 20:04 ` [PATCH 17/18] xfs: cleanup xfs_growfs_compute_deltas Darrick J. Wong ` (2 subsequent siblings) 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:04 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 4cb6e89a3d901d4da515977e55f9a9a779238660 xfs_growfs_compute_deltas can update nb for corner cases like a number of blocks that would create a less the minimal sized AG, or running past the max AG limit. Pass back the calculated value to the caller, as it relies on to calculate the new number of perag structures. Note that the grown file system size is not affected by this miscalculation as it uses the passed back delta value. Fixes: a49b7ff63f98 ("xfs: Refactoring the nagcount and delta calculation") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_ag.h | 2 +- libxfs/xfs_ag.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 16a9b43a3c270c..8aa4266c55714d 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -330,7 +330,7 @@ int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp, xfs_extlen_t delta); void -xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t nb, +xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t *nb, int64_t *deltap, xfs_agnumber_t *nagcountp); int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp, xfs_extlen_t len); diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 1c75ef51056789..fb8c9bb3df82ed 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -864,7 +864,7 @@ xfs_ag_shrink_space( void xfs_growfs_compute_deltas( struct xfs_mount *mp, - xfs_rfsblock_t nb, + xfs_rfsblock_t *nb, int64_t *deltap, xfs_agnumber_t *nagcountp) { @@ -872,19 +872,19 @@ xfs_growfs_compute_deltas( int64_t delta; xfs_agnumber_t nagcount; - nb_div = nb; + nb_div = *nb; nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS) nb_div++; else if (nb_mod) - nb = nb_div * mp->m_sb.sb_agblocks; + *nb = nb_div * mp->m_sb.sb_agblocks; if (nb_div > XFS_MAX_AGNUMBER + 1) { nb_div = XFS_MAX_AGNUMBER + 1; - nb = nb_div * mp->m_sb.sb_agblocks; + *nb = nb_div * mp->m_sb.sb_agblocks; } nagcount = nb_div; - delta = nb - mp->m_sb.sb_dblocks; + delta = *nb - mp->m_sb.sb_dblocks; *deltap = delta; *nagcountp = nagcount; } ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 17/18] xfs: cleanup xfs_growfs_compute_deltas 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (15 preceding siblings ...) 2026-07-02 20:04 ` [PATCH 16/18] xfs: pass back updated nb from xfs_growfs_compute_deltas Darrick J. Wong @ 2026-07-02 20:04 ` Darrick J. Wong 2026-07-02 20:05 ` [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h Darrick J. Wong 2026-07-06 6:53 ` [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Christoph Hellwig 18 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:04 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: dfac6ba84819bd12535943c4090766bbc6c5ea7e xfs_growfs_compute_deltas has an odd calling conventions, and looks very convoluted due to the use of do_div and strangely named and typed variables. Rename it, make it return the agcount and let the caller calculate the delta. The internally use the better div_u64_rem helper and descriptive variable names and types. Also add a comment describing what the function is used for. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_ag.h | 5 ++--- libxfs/xfs_ag.c | 42 ++++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h index 8aa4266c55714d..fd22fe59893176 100644 --- a/libxfs/xfs_ag.h +++ b/libxfs/xfs_ag.h @@ -329,12 +329,11 @@ struct aghdr_init_data { int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp, xfs_extlen_t delta); -void -xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t *nb, - int64_t *deltap, xfs_agnumber_t *nagcountp); int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp, xfs_extlen_t len); int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo); +xfs_agnumber_t xfs_growfs_compute_agcount(struct xfs_mount *mp, + xfs_rfsblock_t *nb); static inline xfs_fsblock_t xfs_agbno_to_fsb( diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index fb8c9bb3df82ed..2f47a02cc6fdb9 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -861,32 +861,30 @@ xfs_ag_shrink_space( return err2; } -void -xfs_growfs_compute_deltas( +/* + * Return the agcount for the new file system size passed in *nb and adjust *nb + * when it has to be reduced because of maximum AG count or because it would + * create a below minimum size AG. + */ +xfs_agnumber_t +xfs_growfs_compute_agcount( struct xfs_mount *mp, - xfs_rfsblock_t *nb, - int64_t *deltap, - xfs_agnumber_t *nagcountp) + xfs_rfsblock_t *nb) { - xfs_rfsblock_t nb_div, nb_mod; - int64_t delta; - xfs_agnumber_t nagcount; + uint64_t agcount; /* 64-bits wide to catch overflows */ + xfs_extlen_t remainder; - nb_div = *nb; - nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); - if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS) - nb_div++; - else if (nb_mod) - *nb = nb_div * mp->m_sb.sb_agblocks; - - if (nb_div > XFS_MAX_AGNUMBER + 1) { - nb_div = XFS_MAX_AGNUMBER + 1; - *nb = nb_div * mp->m_sb.sb_agblocks; + agcount = div_u64_rem(*nb, mp->m_sb.sb_agblocks, &remainder); + if (agcount >= XFS_MAX_AGNUMBER + 1) { + agcount = XFS_MAX_AGNUMBER + 1; + remainder = 0; + } + *nb = (xfs_rfsblock_t)agcount * mp->m_sb.sb_agblocks; + if (remainder >= XFS_MIN_AG_BLOCKS) { + *nb += remainder; + agcount++; } - nagcount = nb_div; - delta = *nb - mp->m_sb.sb_dblocks; - *deltap = delta; - *nagcountp = nagcount; + return agcount; } /* ^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (16 preceding siblings ...) 2026-07-02 20:04 ` [PATCH 17/18] xfs: cleanup xfs_growfs_compute_deltas Darrick J. Wong @ 2026-07-02 20:05 ` Darrick J. Wong 2026-07-06 6:53 ` Christoph Hellwig 2026-07-08 17:45 ` [PATCH v1.1 " Darrick J. Wong 2026-07-06 6:53 ` [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Christoph Hellwig 18 siblings, 2 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-02 20:05 UTC (permalink / raw) To: aalbersh, djwong; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 202ff980a464198616e53e85e5276e68c00a1031 Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit. This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- libxfs/xfs_log_format.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 3f5a24dda90701..a4e1b3eb425cda 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t; #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) #define BLOCK_LSN(lsn) ((uint)(lsn)) +/* + * By comparing each component, we don't have to worry about extra endian issues + * in treating two 32 bit numbers as one 64 bit number + */ +static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2) +{ + if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) + return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999; + if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) + return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999; + return 0; +} + /* this is used in a spot where we might otherwise double-endian-flip */ #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h 2026-07-02 20:05 ` [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h Darrick J. Wong @ 2026-07-06 6:53 ` Christoph Hellwig 2026-07-07 17:16 ` Darrick J. Wong 2026-07-08 17:45 ` [PATCH v1.1 " Darrick J. Wong 1 sibling, 1 reply; 25+ messages in thread From: Christoph Hellwig @ 2026-07-06 6:53 UTC (permalink / raw) To: Darrick J. Wong; +Cc: aalbersh, cem, cmaiolino, hch, linux-xfs With this, the old user space version in xfs_trans.h can go away. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h 2026-07-06 6:53 ` Christoph Hellwig @ 2026-07-07 17:16 ` Darrick J. Wong 0 siblings, 0 replies; 25+ messages in thread From: Darrick J. Wong @ 2026-07-07 17:16 UTC (permalink / raw) To: Christoph Hellwig; +Cc: aalbersh, cem, cmaiolino, hch, linux-xfs On Sun, Jul 05, 2026 at 11:53:29PM -0700, Christoph Hellwig wrote: > With this, the old user space version in xfs_trans.h can go away. Will fix, thanks. --D ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v1.1 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h 2026-07-02 20:05 ` [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h Darrick J. Wong 2026-07-06 6:53 ` Christoph Hellwig @ 2026-07-08 17:45 ` Darrick J. Wong 2026-07-09 4:47 ` Christoph Hellwig 1 sibling, 1 reply; 25+ messages in thread From: Darrick J. Wong @ 2026-07-08 17:45 UTC (permalink / raw) To: aalbersh; +Cc: cem, cmaiolino, hch, linux-xfs From: Christoph Hellwig <hch@lst.de> Source kernel commit: 202ff980a464198616e53e85e5276e68c00a1031 Because CYCLE_LSN/BLOCK_LSN are defined in xfs_log_format.h, XFS_LSN_CMP forces a xfs_log_format.h dependency in xfs_log.h. Move XFS_LSN_CMP to xfs_log_format.h and drop the macro/inline indirection to clean up our header mess a little bit. This also helps xfsprogs, which doesn't have xfs_log.h, but needs XFS_LSN_CMP. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org> --- v1.1: remove old code from xfs_trans.h per review comment --- include/xfs_trans.h | 18 ------------------ libxfs/xfs_log_format.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/include/xfs_trans.h b/include/xfs_trans.h index d4b546a0e3d026..9102bc6f5b27f3 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -164,22 +164,4 @@ libxfs_trans_read_buf( #define xfs_ail_get_push_target(ail) \ ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN) -/* from xfs_log.h */ -/* - * By comparing each component, we don't have to worry about extra - * endian issues in treating two 32 bit numbers as one 64 bit number - */ -static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) -{ - if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) - return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999; - - if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) - return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999; - - return 0; -} - -#define XFS_LSN_CMP(a, b) _lsn_cmp(a, b) - #endif /* __XFS_TRANS_H__ */ diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index 3f5a24dda90701..a4e1b3eb425cda 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t; #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) #define BLOCK_LSN(lsn) ((uint)(lsn)) +/* + * By comparing each component, we don't have to worry about extra endian issues + * in treating two 32 bit numbers as one 64 bit number + */ +static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2) +{ + if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) + return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999; + if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) + return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999; + return 0; +} + /* this is used in a spot where we might otherwise double-endian-flip */ #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v1.1 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h 2026-07-08 17:45 ` [PATCH v1.1 " Darrick J. Wong @ 2026-07-09 4:47 ` Christoph Hellwig 0 siblings, 0 replies; 25+ messages in thread From: Christoph Hellwig @ 2026-07-09 4:47 UTC (permalink / raw) To: Darrick J. Wong; +Cc: aalbersh, cem, cmaiolino, hch, linux-xfs Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong ` (17 preceding siblings ...) 2026-07-02 20:05 ` [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h Darrick J. Wong @ 2026-07-06 6:53 ` Christoph Hellwig 18 siblings, 0 replies; 25+ messages in thread From: Christoph Hellwig @ 2026-07-06 6:53 UTC (permalink / raw) To: Darrick J. Wong Cc: aalbersh, chuck.lever, roland.mainz, cmaiolino, cem, hch, brauner, gaoyingjie, linux-xfs The resync looks good, module the minor nitpick on the last patch: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2026-07-09 4:47 UTC | newest] Thread overview: 25+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-02 19:59 [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Darrick J. Wong 2026-07-02 20:00 ` [PATCH 01/18] libxfs: convert diff_items helpers to cmp_int Darrick J. Wong 2026-07-06 6:50 ` Christoph Hellwig 2026-07-02 20:00 ` [PATCH 02/18] xfs: Report case sensitivity in fileattr_get Darrick J. Wong 2026-07-02 20:01 ` [PATCH 03/18] xfs: fix exchmaps reservation limit check Darrick J. Wong 2026-07-02 20:01 ` [PATCH 04/18] xfs: add a XFS_INODE_TO_AGNO helper Darrick J. Wong 2026-07-02 20:01 ` [PATCH 05/18] xfs: add a XFS_INODE_TO_AGINO helper Darrick J. Wong 2026-07-02 20:01 ` [PATCH 06/18] xfs: add a XFS_INO_TO_FSB helper Darrick J. Wong 2026-07-02 20:02 ` [PATCH 07/18] xfs: add a xfs_rmap_inode_bmbt_owner Darrick J. Wong 2026-07-02 20:02 ` [PATCH 08/18] xfs: add a xfs_rmap_inode_owner helper Darrick J. Wong 2026-07-02 20:02 ` [PATCH 09/18] xfs: remove the i_ino field in struct xfs_inode Darrick J. Wong 2026-07-02 20:02 ` [PATCH 10/18] xfs: cleanup xfs_imap Darrick J. Wong 2026-07-02 20:03 ` [PATCH 11/18] xfs: remove im_len field in struct xfs_imap Darrick J. Wong 2026-07-02 20:03 ` [PATCH 12/18] xfs: massage xfs_imap_to_bp into xfs_read_icluster Darrick J. Wong 2026-07-02 20:03 ` [PATCH 13/18] xfs: store an agbno in struct xfs_imap Darrick J. Wong 2026-07-02 20:03 ` [PATCH 14/18] xfs: mark struct xfs_imap as __packed Darrick J. Wong 2026-07-02 20:04 ` [PATCH 15/18] xfs: fix pointer arithmetic error on 32-bit systems Darrick J. Wong 2026-07-02 20:04 ` [PATCH 16/18] xfs: pass back updated nb from xfs_growfs_compute_deltas Darrick J. Wong 2026-07-02 20:04 ` [PATCH 17/18] xfs: cleanup xfs_growfs_compute_deltas Darrick J. Wong 2026-07-02 20:05 ` [PATCH 18/18] xfs: move XFS_LSN_CMP to xfs_log_format.h Darrick J. Wong 2026-07-06 6:53 ` Christoph Hellwig 2026-07-07 17:16 ` Darrick J. Wong 2026-07-08 17:45 ` [PATCH v1.1 " Darrick J. Wong 2026-07-09 4:47 ` Christoph Hellwig 2026-07-06 6:53 ` [PATCHSET 2/2] xfsprogs: new libxfs code from kernel 7.2 Christoph Hellwig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox