* [PATCH 01/13] libxfs: use libxfs.h in xfs_platform.h
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:44 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 02/13] libxfs: provide memalloc_nofs_{save,restore} stubs Christoph Hellwig
` (11 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
xfs_platform.h duplicates a lot of the include chains and some of the
definitions in include/libxfs.h. Use that header from xfs_plaform.h and
remove the duplication.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/xfs_platform.h | 37 +------------------------------------
1 file changed, 1 insertion(+), 36 deletions(-)
diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
index d09fb0aae00f..9aa898200da8 100644
--- a/libxfs/xfs_platform.h
+++ b/libxfs/xfs_platform.h
@@ -37,33 +37,9 @@
#ifndef _XFS_PLATFORM_H
#define _XFS_PLATFORM_H
-/* CONFIG_XFS_* must be defined to 1 to work with IS_ENABLED() */
-#define CONFIG_XFS_RT 1
-#define CONFIG_XFS_BTREE_IN_MEM 1
-
-#include "libxfs_api_defs.h"
-#include "platform_defs.h"
-#include "xfs.h"
-
-#include "list.h"
-#include "hlist.h"
-#include "cache.h"
-#include "bitops.h"
-#include "kmem.h"
-#include "libfrog/radix-tree.h"
-#include "libfrog/bitmask.h"
-#include "libfrog/div64.h"
-#include "libfrog/util.h"
-#include "atomic.h"
-#include "spinlock.h"
+#include "libxfs.h"
#include "linux-err.h"
-#include "xfs_types.h"
-#include "xfs_arch.h"
-
-#include "xfs_fs.h"
-#include "libfrog/crc32c.h"
-
#include <sys/xattr.h>
/* Zones used in libxfs allocations that aren't in shared header files */
@@ -77,9 +53,6 @@ extern struct kmem_cache *xfs_trans_cache;
#define IOMAP_F_SHARED 0x04
#define xfs_bmbt_to_iomap(a, b, c, d, e, f) ((void) 0)
-/* CRC stuff, buffer API dependent on it */
-#define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l))
-
/* fake up kernel's iomap, (not) used in xfs_bmap.[ch] */
struct iomap {
unsigned long long offset; /* do not use */
@@ -88,14 +61,6 @@ struct iomap {
#define cancel_delayed_work_sync(work) do { } while(0)
-#include "xfs_cksum.h"
-
-/*
- * This mirrors the kernel include for xfs_buf.h - it's implicitly included in
- * every files via a similar include in the kernel xfs_linux.h.
- */
-#include "libxfs_io.h"
-
/* for all the support code that uses progname in error messages */
extern char *progname;
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 01/13] libxfs: use libxfs.h in xfs_platform.h
2026-10-05 12:56 ` [PATCH 01/13] libxfs: use libxfs.h in xfs_platform.h Christoph Hellwig
@ 2026-10-05 21:44 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:44 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:11PM +0200, Christoph Hellwig wrote:
> xfs_platform.h duplicates a lot of the include chains and some of the
> definitions in include/libxfs.h. Use that header from xfs_plaform.h and
> remove the duplication.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Seems fine to me to combine these, not sure why we didn't earlier...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/xfs_platform.h | 37 +------------------------------------
> 1 file changed, 1 insertion(+), 36 deletions(-)
>
> diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
> index d09fb0aae00f..9aa898200da8 100644
> --- a/libxfs/xfs_platform.h
> +++ b/libxfs/xfs_platform.h
> @@ -37,33 +37,9 @@
> #ifndef _XFS_PLATFORM_H
> #define _XFS_PLATFORM_H
>
> -/* CONFIG_XFS_* must be defined to 1 to work with IS_ENABLED() */
> -#define CONFIG_XFS_RT 1
> -#define CONFIG_XFS_BTREE_IN_MEM 1
> -
> -#include "libxfs_api_defs.h"
> -#include "platform_defs.h"
> -#include "xfs.h"
> -
> -#include "list.h"
> -#include "hlist.h"
> -#include "cache.h"
> -#include "bitops.h"
> -#include "kmem.h"
> -#include "libfrog/radix-tree.h"
> -#include "libfrog/bitmask.h"
> -#include "libfrog/div64.h"
> -#include "libfrog/util.h"
> -#include "atomic.h"
> -#include "spinlock.h"
> +#include "libxfs.h"
> #include "linux-err.h"
>
> -#include "xfs_types.h"
> -#include "xfs_arch.h"
> -
> -#include "xfs_fs.h"
> -#include "libfrog/crc32c.h"
> -
> #include <sys/xattr.h>
>
> /* Zones used in libxfs allocations that aren't in shared header files */
> @@ -77,9 +53,6 @@ extern struct kmem_cache *xfs_trans_cache;
> #define IOMAP_F_SHARED 0x04
> #define xfs_bmbt_to_iomap(a, b, c, d, e, f) ((void) 0)
>
> -/* CRC stuff, buffer API dependent on it */
> -#define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l))
> -
> /* fake up kernel's iomap, (not) used in xfs_bmap.[ch] */
> struct iomap {
> unsigned long long offset; /* do not use */
> @@ -88,14 +61,6 @@ struct iomap {
>
> #define cancel_delayed_work_sync(work) do { } while(0)
>
> -#include "xfs_cksum.h"
> -
> -/*
> - * This mirrors the kernel include for xfs_buf.h - it's implicitly included in
> - * every files via a similar include in the kernel xfs_linux.h.
> - */
> -#include "libxfs_io.h"
> -
> /* for all the support code that uses progname in error messages */
> extern char *progname;
>
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 02/13] libxfs: provide memalloc_nofs_{save,restore} stubs
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
2026-10-05 12:56 ` [PATCH 01/13] libxfs: use libxfs.h in xfs_platform.h Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:45 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 03/13] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c Christoph Hellwig
` (10 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/libxfs.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/libxfs.h b/include/libxfs.h
index 7f0c22ef4991..549176cf0b2c 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -54,6 +54,9 @@ struct iomap;
#define unlikely(x) (x)
#define likely(x) (x)
+#define memalloc_nofs_save() (0)
+#define memalloc_nofs_restore(flags) do { } while (0)
+
/*
* This mirrors the kernel include for xfs_buf.h - it's implicitly included in
* every files via a similar include in the kernel xfs_linux.h.
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 02/13] libxfs: provide memalloc_nofs_{save,restore} stubs
2026-10-05 12:56 ` [PATCH 02/13] libxfs: provide memalloc_nofs_{save,restore} stubs Christoph Hellwig
@ 2026-10-05 21:45 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:45 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:12PM +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> include/libxfs.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/libxfs.h b/include/libxfs.h
> index 7f0c22ef4991..549176cf0b2c 100644
> --- a/include/libxfs.h
> +++ b/include/libxfs.h
> @@ -54,6 +54,9 @@ struct iomap;
> #define unlikely(x) (x)
> #define likely(x) (x)
>
> +#define memalloc_nofs_save() (0)
> +#define memalloc_nofs_restore(flags) do { } while (0)
> +
> /*
> * This mirrors the kernel include for xfs_buf.h - it's implicitly included in
> * every files via a similar include in the kernel xfs_linux.h.
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 03/13] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
2026-10-05 12:56 ` [PATCH 01/13] libxfs: use libxfs.h in xfs_platform.h Christoph Hellwig
2026-10-05 12:56 ` [PATCH 02/13] libxfs: provide memalloc_nofs_{save,restore} stubs Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:45 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 04/13] libxfs: move the xfs_rtbitmap.h include in xfs_bmap.c Christoph Hellwig
` (9 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
This fully resyncs with the kernel version.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/xfs_sb.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index ea99f8b5eee5..cccbcd153316 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -27,7 +27,6 @@
#include "xfs_rtgroup.h"
#include "xfs_rtrmap_btree.h"
#include "xfs_rtrefcount_btree.h"
-#include "xfs_rtbitmap.h"
/*
* Physical superblock buffer manipulations. Shared with libxfs in userspace.
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 03/13] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c
2026-10-05 12:56 ` [PATCH 03/13] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c Christoph Hellwig
@ 2026-10-05 21:45 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:45 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:13PM +0200, Christoph Hellwig wrote:
> This fully resyncs with the kernel version.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/xfs_sb.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
> index ea99f8b5eee5..cccbcd153316 100644
> --- a/libxfs/xfs_sb.c
> +++ b/libxfs/xfs_sb.c
> @@ -27,7 +27,6 @@
> #include "xfs_rtgroup.h"
> #include "xfs_rtrmap_btree.h"
> #include "xfs_rtrefcount_btree.h"
> -#include "xfs_rtbitmap.h"
>
> /*
> * Physical superblock buffer manipulations. Shared with libxfs in userspace.
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 04/13] libxfs: move the xfs_rtbitmap.h include in xfs_bmap.c
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (2 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 03/13] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-06 11:27 ` Andrey Albershteyn
2026-10-05 12:56 ` [PATCH 05/13] libxfs: remove the unused xfs_log_item.li_mountp field Christoph Hellwig
` (8 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
To better align with the kernel version.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/xfs_bmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index cec59446711b..cfce4358e2bf 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -20,6 +20,7 @@
#include "xfs_alloc.h"
#include "xfs_bmap.h"
#include "xfs_bmap_btree.h"
+#include "xfs_rtbitmap.h"
#include "xfs_errortag.h"
#include "xfs_error.h"
#include "xfs_quota.h"
@@ -30,7 +31,6 @@
#include "xfs_ag.h"
#include "xfs_ag_resv.h"
#include "xfs_refcount.h"
-#include "xfs_rtbitmap.h"
#include "xfs_health.h"
#include "defer_item.h"
#include "xfs_symlink_remote.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 04/13] libxfs: move the xfs_rtbitmap.h include in xfs_bmap.c
2026-10-05 12:56 ` [PATCH 04/13] libxfs: move the xfs_rtbitmap.h include in xfs_bmap.c Christoph Hellwig
@ 2026-10-06 11:27 ` Andrey Albershteyn
0 siblings, 0 replies; 31+ messages in thread
From: Andrey Albershteyn @ 2026-10-06 11:27 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
On 2026-10-05 14:56:14, Christoph Hellwig wrote:
> To better align with the kernel version.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> libxfs/xfs_bmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> index cec59446711b..cfce4358e2bf 100644
> --- a/libxfs/xfs_bmap.c
> +++ b/libxfs/xfs_bmap.c
> @@ -20,6 +20,7 @@
> #include "xfs_alloc.h"
> #include "xfs_bmap.h"
> #include "xfs_bmap_btree.h"
> +#include "xfs_rtbitmap.h"
> #include "xfs_errortag.h"
> #include "xfs_error.h"
> #include "xfs_quota.h"
> @@ -30,7 +31,6 @@
> #include "xfs_ag.h"
> #include "xfs_ag_resv.h"
> #include "xfs_refcount.h"
> -#include "xfs_rtbitmap.h"
> #include "xfs_health.h"
> #include "defer_item.h"
> #include "xfs_symlink_remote.h"
> --
> 2.53.0
>
>
Looks good to me
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
--
- Andrey
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 05/13] libxfs: remove the unused xfs_log_item.li_mountp field
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (3 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 04/13] libxfs: move the xfs_rtbitmap.h include in xfs_bmap.c Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:46 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 06/13] libxfs: remove the unused xfs_inode_log_item.ili_fsync_fields field Christoph Hellwig
` (7 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
To prepare for reusing the kernel version of the struct.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/stubs/xfs_trans.h | 1 -
libxfs/trans.c | 1 -
libxfs/util.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index 9102bc6f5b27..9b6a47988147 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -24,7 +24,6 @@ struct xfs_item_ops {
typedef struct xfs_log_item {
struct list_head li_trans; /* transaction list */
xfs_lsn_t li_lsn; /* last on-disk lsn */
- struct xfs_mount *li_mountp; /* ptr to fs mount */
uint li_type; /* item type */
unsigned long li_flags; /* misc flags */
struct xfs_buf *li_buf; /* real buffer pointer */
diff --git a/libxfs/trans.c b/libxfs/trans.c
index c89b035ffeaf..9dd2e244a812 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -52,7 +52,6 @@ libxfs_trans_add_item(
struct xfs_trans *tp,
struct xfs_log_item *lip)
{
- ASSERT(lip->li_mountp == tp->t_mountp);
ASSERT(lip->li_ailp == tp->t_mountp->m_ail);
ASSERT(list_empty(&lip->li_trans));
ASSERT(!test_bit(XFS_LI_DIRTY, &lip->li_flags));
diff --git a/libxfs/util.c b/libxfs/util.c
index 6cbbe9056eba..2d8f57abd585 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -408,7 +408,6 @@ xfs_log_item_init(
int type,
const struct xfs_item_ops *ops)
{
- item->li_mountp = mp;
item->li_type = type;
item->li_ops = ops;
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 05/13] libxfs: remove the unused xfs_log_item.li_mountp field
2026-10-05 12:56 ` [PATCH 05/13] libxfs: remove the unused xfs_log_item.li_mountp field Christoph Hellwig
@ 2026-10-05 21:46 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:46 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:15PM +0200, Christoph Hellwig wrote:
> To prepare for reusing the kernel version of the struct.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks ok,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/stubs/xfs_trans.h | 1 -
> libxfs/trans.c | 1 -
> libxfs/util.c | 1 -
> 3 files changed, 3 deletions(-)
>
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index 9102bc6f5b27..9b6a47988147 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -24,7 +24,6 @@ struct xfs_item_ops {
> typedef struct xfs_log_item {
> struct list_head li_trans; /* transaction list */
> xfs_lsn_t li_lsn; /* last on-disk lsn */
> - struct xfs_mount *li_mountp; /* ptr to fs mount */
> uint li_type; /* item type */
> unsigned long li_flags; /* misc flags */
> struct xfs_buf *li_buf; /* real buffer pointer */
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index c89b035ffeaf..9dd2e244a812 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -52,7 +52,6 @@ libxfs_trans_add_item(
> struct xfs_trans *tp,
> struct xfs_log_item *lip)
> {
> - ASSERT(lip->li_mountp == tp->t_mountp);
> ASSERT(lip->li_ailp == tp->t_mountp->m_ail);
> ASSERT(list_empty(&lip->li_trans));
> ASSERT(!test_bit(XFS_LI_DIRTY, &lip->li_flags));
> diff --git a/libxfs/util.c b/libxfs/util.c
> index 6cbbe9056eba..2d8f57abd585 100644
> --- a/libxfs/util.c
> +++ b/libxfs/util.c
> @@ -408,7 +408,6 @@ xfs_log_item_init(
> int type,
> const struct xfs_item_ops *ops)
> {
> - item->li_mountp = mp;
> item->li_type = type;
> item->li_ops = ops;
>
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 06/13] libxfs: remove the unused xfs_inode_log_item.ili_fsync_fields field
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (4 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 05/13] libxfs: remove the unused xfs_log_item.li_mountp field Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:46 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 07/13] libxfs: remove the xfs_log_item_t and xfs_buf_log_item_t typedefs Christoph Hellwig
` (6 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
To prepare for reusing the kernel version of the struct.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/logitem.c | 1 -
libxfs/stubs/xfs_trans.h | 1 -
2 files changed, 2 deletions(-)
diff --git a/libxfs/logitem.c b/libxfs/logitem.c
index 6e56e476d1ea..d09ff75e9ce2 100644
--- a/libxfs/logitem.c
+++ b/libxfs/logitem.c
@@ -231,7 +231,6 @@ xfs_inode_item_precommit(
* (ili_fields) correctly tracks that the version has changed.
*/
spin_lock(&iip->ili_lock);
- iip->ili_fsync_fields |= (flags & ~XFS_ILOG_IVERSION);
if (flags & XFS_ILOG_IVERSION)
flags = ((flags & ~XFS_ILOG_IVERSION) | XFS_ILOG_CORE);
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index 9b6a47988147..fcd58930cc85 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -40,7 +40,6 @@ struct xfs_inode_log_item {
unsigned int ili_dirty_flags; /* dirty in current tx */
unsigned int ili_last_fields; /* fields when flushed*/
unsigned int ili_fields; /* fields to be logged */
- unsigned int ili_fsync_fields; /* ignored by userspace */
spinlock_t ili_lock;
};
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 06/13] libxfs: remove the unused xfs_inode_log_item.ili_fsync_fields field
2026-10-05 12:56 ` [PATCH 06/13] libxfs: remove the unused xfs_inode_log_item.ili_fsync_fields field Christoph Hellwig
@ 2026-10-05 21:46 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:46 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:16PM +0200, Christoph Hellwig wrote:
> To prepare for reusing the kernel version of the struct.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Yeah, that's been gone for a while...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/logitem.c | 1 -
> libxfs/stubs/xfs_trans.h | 1 -
> 2 files changed, 2 deletions(-)
>
> diff --git a/libxfs/logitem.c b/libxfs/logitem.c
> index 6e56e476d1ea..d09ff75e9ce2 100644
> --- a/libxfs/logitem.c
> +++ b/libxfs/logitem.c
> @@ -231,7 +231,6 @@ xfs_inode_item_precommit(
> * (ili_fields) correctly tracks that the version has changed.
> */
> spin_lock(&iip->ili_lock);
> - iip->ili_fsync_fields |= (flags & ~XFS_ILOG_IVERSION);
> if (flags & XFS_ILOG_IVERSION)
> flags = ((flags & ~XFS_ILOG_IVERSION) | XFS_ILOG_CORE);
>
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index 9b6a47988147..fcd58930cc85 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -40,7 +40,6 @@ struct xfs_inode_log_item {
> unsigned int ili_dirty_flags; /* dirty in current tx */
> unsigned int ili_last_fields; /* fields when flushed*/
> unsigned int ili_fields; /* fields to be logged */
> - unsigned int ili_fsync_fields; /* ignored by userspace */
> spinlock_t ili_lock;
> };
>
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 07/13] libxfs: remove the xfs_log_item_t and xfs_buf_log_item_t typedefs
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (5 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 06/13] libxfs: remove the unused xfs_inode_log_item.ili_fsync_fields field Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:46 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 08/13] libxfs: remove libxfs_trans_alloc_rollable Christoph Hellwig
` (5 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
These are long gone from the kernel, so catch up.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/logitem.c | 8 ++++----
libxfs/stubs/xfs_trans.h | 12 ++++++------
libxfs/trans.c | 8 ++++----
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/libxfs/logitem.c b/libxfs/logitem.c
index d09ff75e9ce2..0bb9088db351 100644
--- a/libxfs/logitem.c
+++ b/libxfs/logitem.c
@@ -74,10 +74,10 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
void
xfs_buf_item_init(
struct xfs_buf *bp,
- xfs_mount_t *mp)
+ struct xfs_mount *mp)
{
- xfs_log_item_t *lip;
- xfs_buf_log_item_t *bip;
+ struct xfs_log_item *lip;
+ struct xfs_buf_log_item *bip;
#ifdef LI_DEBUG
fprintf(stderr, "buf_item_init for buffer %p\n", bp);
@@ -121,7 +121,7 @@ xfs_buf_item_init(
*/
void
xfs_buf_item_log(
- xfs_buf_log_item_t *bip,
+ struct xfs_buf_log_item *bip,
uint first,
uint last)
{
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index fcd58930cc85..1117aad80c2f 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -21,7 +21,7 @@ struct xfs_item_ops {
int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
};
-typedef struct xfs_log_item {
+struct xfs_log_item {
struct list_head li_trans; /* transaction list */
xfs_lsn_t li_lsn; /* last on-disk lsn */
uint li_type; /* item type */
@@ -29,12 +29,12 @@ typedef struct xfs_log_item {
struct xfs_buf *li_buf; /* real buffer pointer */
struct list_head li_bio_list; /* buffer item list */
const struct xfs_item_ops *li_ops; /* function list */
-} xfs_log_item_t;
+};
#define XFS_LI_DIRTY 3 /* log item dirty in transaction */
struct xfs_inode_log_item {
- xfs_log_item_t ili_item; /* common portion */
+ struct xfs_log_item ili_item; /* common portion */
struct xfs_inode *ili_inode; /* inode pointer */
unsigned short ili_lock_flags; /* lock flags */
unsigned int ili_dirty_flags; /* dirty in current tx */
@@ -43,13 +43,13 @@ struct xfs_inode_log_item {
spinlock_t ili_lock;
};
-typedef struct xfs_buf_log_item {
- xfs_log_item_t bli_item; /* common item structure */
+ struct xfs_buf_log_item {
+ struct xfs_log_item bli_item; /* common item structure */
struct xfs_buf *bli_buf; /* real buffer pointer */
unsigned int bli_flags; /* misc flags */
unsigned int bli_recur; /* recursion count */
struct xfs_buf_log_format __bli_format; /* in-log header */
-} xfs_buf_log_item_t;
+};
#define XFS_BLI_DIRTY (1<<0)
#define XFS_BLI_HOLD (1<<1)
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 9dd2e244a812..aa303288a81c 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -941,7 +941,7 @@ free_item:
static void
buf_item_done(
- xfs_buf_log_item_t *bip)
+ struct xfs_buf_log_item *bip)
{
struct xfs_buf *bp;
int hold;
@@ -972,7 +972,7 @@ trans_committed(
xfs_trans_del_item(lip);
if (lip->li_type == XFS_LI_BUF)
- buf_item_done((xfs_buf_log_item_t *)lip);
+ buf_item_done((struct xfs_buf_log_item *)lip);
else if (lip->li_type == XFS_LI_INODE)
inode_item_done((struct xfs_inode_log_item *)lip);
else {
@@ -985,7 +985,7 @@ trans_committed(
static void
buf_item_unlock(
- xfs_buf_log_item_t *bip)
+ struct xfs_buf_log_item *bip)
{
struct xfs_buf *bp = bip->bli_buf;
uint hold;
@@ -1017,7 +1017,7 @@ xfs_trans_free_items(
list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
xfs_trans_del_item(lip);
if (lip->li_type == XFS_LI_BUF)
- buf_item_unlock((xfs_buf_log_item_t *)lip);
+ buf_item_unlock((struct xfs_buf_log_item *)lip);
else if (lip->li_type == XFS_LI_INODE)
inode_item_unlock((struct xfs_inode_log_item *)lip);
else {
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 07/13] libxfs: remove the xfs_log_item_t and xfs_buf_log_item_t typedefs
2026-10-05 12:56 ` [PATCH 07/13] libxfs: remove the xfs_log_item_t and xfs_buf_log_item_t typedefs Christoph Hellwig
@ 2026-10-05 21:46 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:46 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:17PM +0200, Christoph Hellwig wrote:
> These are long gone from the kernel, so catch up.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Hooray!!!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/logitem.c | 8 ++++----
> libxfs/stubs/xfs_trans.h | 12 ++++++------
> libxfs/trans.c | 8 ++++----
> 3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/libxfs/logitem.c b/libxfs/logitem.c
> index d09ff75e9ce2..0bb9088db351 100644
> --- a/libxfs/logitem.c
> +++ b/libxfs/logitem.c
> @@ -74,10 +74,10 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
> void
> xfs_buf_item_init(
> struct xfs_buf *bp,
> - xfs_mount_t *mp)
> + struct xfs_mount *mp)
> {
> - xfs_log_item_t *lip;
> - xfs_buf_log_item_t *bip;
> + struct xfs_log_item *lip;
> + struct xfs_buf_log_item *bip;
>
> #ifdef LI_DEBUG
> fprintf(stderr, "buf_item_init for buffer %p\n", bp);
> @@ -121,7 +121,7 @@ xfs_buf_item_init(
> */
> void
> xfs_buf_item_log(
> - xfs_buf_log_item_t *bip,
> + struct xfs_buf_log_item *bip,
> uint first,
> uint last)
> {
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index fcd58930cc85..1117aad80c2f 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -21,7 +21,7 @@ struct xfs_item_ops {
> int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
> };
>
> -typedef struct xfs_log_item {
> +struct xfs_log_item {
> struct list_head li_trans; /* transaction list */
> xfs_lsn_t li_lsn; /* last on-disk lsn */
> uint li_type; /* item type */
> @@ -29,12 +29,12 @@ typedef struct xfs_log_item {
> struct xfs_buf *li_buf; /* real buffer pointer */
> struct list_head li_bio_list; /* buffer item list */
> const struct xfs_item_ops *li_ops; /* function list */
> -} xfs_log_item_t;
> +};
>
> #define XFS_LI_DIRTY 3 /* log item dirty in transaction */
>
> struct xfs_inode_log_item {
> - xfs_log_item_t ili_item; /* common portion */
> + struct xfs_log_item ili_item; /* common portion */
> struct xfs_inode *ili_inode; /* inode pointer */
> unsigned short ili_lock_flags; /* lock flags */
> unsigned int ili_dirty_flags; /* dirty in current tx */
> @@ -43,13 +43,13 @@ struct xfs_inode_log_item {
> spinlock_t ili_lock;
> };
>
> -typedef struct xfs_buf_log_item {
> - xfs_log_item_t bli_item; /* common item structure */
> + struct xfs_buf_log_item {
> + struct xfs_log_item bli_item; /* common item structure */
> struct xfs_buf *bli_buf; /* real buffer pointer */
> unsigned int bli_flags; /* misc flags */
> unsigned int bli_recur; /* recursion count */
> struct xfs_buf_log_format __bli_format; /* in-log header */
> -} xfs_buf_log_item_t;
> +};
>
> #define XFS_BLI_DIRTY (1<<0)
> #define XFS_BLI_HOLD (1<<1)
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index 9dd2e244a812..aa303288a81c 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -941,7 +941,7 @@ free_item:
>
> static void
> buf_item_done(
> - xfs_buf_log_item_t *bip)
> + struct xfs_buf_log_item *bip)
> {
> struct xfs_buf *bp;
> int hold;
> @@ -972,7 +972,7 @@ trans_committed(
> xfs_trans_del_item(lip);
>
> if (lip->li_type == XFS_LI_BUF)
> - buf_item_done((xfs_buf_log_item_t *)lip);
> + buf_item_done((struct xfs_buf_log_item *)lip);
> else if (lip->li_type == XFS_LI_INODE)
> inode_item_done((struct xfs_inode_log_item *)lip);
> else {
> @@ -985,7 +985,7 @@ trans_committed(
>
> static void
> buf_item_unlock(
> - xfs_buf_log_item_t *bip)
> + struct xfs_buf_log_item *bip)
> {
> struct xfs_buf *bp = bip->bli_buf;
> uint hold;
> @@ -1017,7 +1017,7 @@ xfs_trans_free_items(
> list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
> xfs_trans_del_item(lip);
> if (lip->li_type == XFS_LI_BUF)
> - buf_item_unlock((xfs_buf_log_item_t *)lip);
> + buf_item_unlock((struct xfs_buf_log_item *)lip);
> else if (lip->li_type == XFS_LI_INODE)
> inode_item_unlock((struct xfs_inode_log_item *)lip);
> else {
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 08/13] libxfs: remove libxfs_trans_alloc_rollable
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (6 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 07/13] libxfs: remove the xfs_log_item_t and xfs_buf_log_item_t typedefs Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:47 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 09/13] libxfs: return int from xfs_buf_item_init Christoph Hellwig
` (4 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
There is no real value in this userland-only wrapper. Remove it and
open code the calls, and switch to clearly better fitting transaction
reservations where applicable.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/stubs/xfs_trans.h | 2 --
libxfs/trans.c | 15 ---------------
mkfs/proto.c | 8 +++++---
mkfs/xfs_mkfs.c | 3 ++-
repair/phase5.c | 3 ++-
repair/phase6.c | 3 ++-
repair/rmap.c | 5 +++--
7 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index 1117aad80c2f..9e8737f09d8e 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -88,8 +88,6 @@ int libxfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
int libxfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
struct xfs_inode *ip, unsigned int *dblocks,
struct xfs_trans **tpp, int *nospace_error);
-int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks,
- struct xfs_trans **tpp);
struct xfs_trans *libxfs_trans_alloc_empty(struct xfs_mount *mp);
int libxfs_trans_commit(struct xfs_trans *);
void libxfs_trans_cancel(struct xfs_trans *);
diff --git a/libxfs/trans.c b/libxfs/trans.c
index aa303288a81c..f36c54b9c806 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -306,21 +306,6 @@ libxfs_trans_alloc_empty(
return __libxfs_trans_alloc(mp, XFS_TRANS_NO_WRITECOUNT);
}
-/*
- * Allocate a transaction that can be rolled. Since userspace doesn't have
- * a need for log reservations, we really only tr_itruncate to get the
- * permanent log reservation flag to avoid blowing asserts.
- */
-int
-libxfs_trans_alloc_rollable(
- struct xfs_mount *mp,
- unsigned int blocks,
- struct xfs_trans **tpp)
-{
- return libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, blocks,
- 0, 0, tpp);
-}
-
void
libxfs_trans_cancel(
struct xfs_trans *tp)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index bdd0fadda517..f17ed3b88112 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -161,7 +161,8 @@ getres(
uint r;
for (i = 0, r = MKFS_BLOCKRES(blocks); r >= blocks; r--) {
- i = -libxfs_trans_alloc_rollable(mp, r, &tp);
+ i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, r, 0, 0,
+ &tp);
if (i == 0)
return tp;
}
@@ -251,7 +252,7 @@ rsvfile(
/*
* update the inode timestamp, mode, and prealloc flag bits
*/
- error = -libxfs_trans_alloc_rollable(mp, 0, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
if (error)
fail(_("allocating transaction for a file"), error);
libxfs_trans_ijoin(tp, ip, 0);
@@ -1037,7 +1038,8 @@ create_sb_metadata_file(
xfs_ino_t ino;
int error;
- error = -libxfs_trans_alloc_rollable(mp, MKFS_BLOCKRES_INODE, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_create,
+ MKFS_BLOCKRES_INODE, 0, 0, &tp);
if (error)
res_failed(error);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index aa87951db0d0..eb863827d19c 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -5706,7 +5706,8 @@ initialise_ag_freespace(
struct xfs_trans *tp;
int c;
- c = -libxfs_trans_alloc_rollable(mp, worst_freelist, &tp);
+ c = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, worst_freelist,
+ 0, 0, &tp);
if (c)
res_failed(c);
diff --git a/repair/phase5.c b/repair/phase5.c
index e44c26885717..4c67d049702b 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -610,7 +610,8 @@ inject_lost_extent(
xfs_agblock_t agbno;
int error;
- error = -libxfs_trans_alloc_rollable(mp, 16, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 16, 0, 0,
+ &tp);
if (error)
return error;
diff --git a/repair/phase6.c b/repair/phase6.c
index f3951a3d0709..f6f985a92541 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -507,7 +507,8 @@ mk_rtino(
libxfs_rtginode_metafile_type(type);
int error;
- error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 10, 0, 0,
+ &tp);
if (error)
res_failed(error);
diff --git a/repair/rmap.c b/repair/rmap.c
index 55c2b0928c52..9f824f848edc 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -714,7 +714,8 @@ rmap_commit_agbtree_mappings(
struct xfs_owner_info oinfo = {};
struct xfs_perag *pag;
- error = -libxfs_trans_alloc_rollable(mp, 16, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 16, 0,
+ 0, &tp);
if (error)
goto err_slab;
@@ -1952,7 +1953,7 @@ fix_freelist(
args.agno = agno;
args.alignment = 1;
args.pag = libxfs_perag_get(mp, agno);
- error = -libxfs_trans_alloc_rollable(mp, 0, &tp);
+ error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
if (error)
do_error(_("failed to fix AGFL on AG %d, error %d\n"),
agno, error);
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 08/13] libxfs: remove libxfs_trans_alloc_rollable
2026-10-05 12:56 ` [PATCH 08/13] libxfs: remove libxfs_trans_alloc_rollable Christoph Hellwig
@ 2026-10-05 21:47 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:47 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:18PM +0200, Christoph Hellwig wrote:
> There is no real value in this userland-only wrapper. Remove it and
> open code the calls, and switch to clearly better fitting transaction
> reservations where applicable.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
I think that's fine. Log reservations don't mean much of anything right
now in userspace, but in general it's a better idea to use the correct
reservation for the operation that's about to happen.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/stubs/xfs_trans.h | 2 --
> libxfs/trans.c | 15 ---------------
> mkfs/proto.c | 8 +++++---
> mkfs/xfs_mkfs.c | 3 ++-
> repair/phase5.c | 3 ++-
> repair/phase6.c | 3 ++-
> repair/rmap.c | 5 +++--
> 7 files changed, 14 insertions(+), 25 deletions(-)
>
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index 1117aad80c2f..9e8737f09d8e 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -88,8 +88,6 @@ int libxfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
> int libxfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
> struct xfs_inode *ip, unsigned int *dblocks,
> struct xfs_trans **tpp, int *nospace_error);
> -int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks,
> - struct xfs_trans **tpp);
> struct xfs_trans *libxfs_trans_alloc_empty(struct xfs_mount *mp);
> int libxfs_trans_commit(struct xfs_trans *);
> void libxfs_trans_cancel(struct xfs_trans *);
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index aa303288a81c..f36c54b9c806 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -306,21 +306,6 @@ libxfs_trans_alloc_empty(
> return __libxfs_trans_alloc(mp, XFS_TRANS_NO_WRITECOUNT);
> }
>
> -/*
> - * Allocate a transaction that can be rolled. Since userspace doesn't have
> - * a need for log reservations, we really only tr_itruncate to get the
> - * permanent log reservation flag to avoid blowing asserts.
> - */
> -int
> -libxfs_trans_alloc_rollable(
> - struct xfs_mount *mp,
> - unsigned int blocks,
> - struct xfs_trans **tpp)
> -{
> - return libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, blocks,
> - 0, 0, tpp);
> -}
> -
> void
> libxfs_trans_cancel(
> struct xfs_trans *tp)
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index bdd0fadda517..f17ed3b88112 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -161,7 +161,8 @@ getres(
> uint r;
>
> for (i = 0, r = MKFS_BLOCKRES(blocks); r >= blocks; r--) {
> - i = -libxfs_trans_alloc_rollable(mp, r, &tp);
> + i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, r, 0, 0,
> + &tp);
> if (i == 0)
> return tp;
> }
> @@ -251,7 +252,7 @@ rsvfile(
> /*
> * update the inode timestamp, mode, and prealloc flag bits
> */
> - error = -libxfs_trans_alloc_rollable(mp, 0, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
> if (error)
> fail(_("allocating transaction for a file"), error);
> libxfs_trans_ijoin(tp, ip, 0);
> @@ -1037,7 +1038,8 @@ create_sb_metadata_file(
> xfs_ino_t ino;
> int error;
>
> - error = -libxfs_trans_alloc_rollable(mp, MKFS_BLOCKRES_INODE, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_create,
> + MKFS_BLOCKRES_INODE, 0, 0, &tp);
> if (error)
> res_failed(error);
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index aa87951db0d0..eb863827d19c 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -5706,7 +5706,8 @@ initialise_ag_freespace(
> struct xfs_trans *tp;
> int c;
>
> - c = -libxfs_trans_alloc_rollable(mp, worst_freelist, &tp);
> + c = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, worst_freelist,
> + 0, 0, &tp);
> if (c)
> res_failed(c);
>
> diff --git a/repair/phase5.c b/repair/phase5.c
> index e44c26885717..4c67d049702b 100644
> --- a/repair/phase5.c
> +++ b/repair/phase5.c
> @@ -610,7 +610,8 @@ inject_lost_extent(
> xfs_agblock_t agbno;
> int error;
>
> - error = -libxfs_trans_alloc_rollable(mp, 16, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 16, 0, 0,
> + &tp);
> if (error)
> return error;
>
> diff --git a/repair/phase6.c b/repair/phase6.c
> index f3951a3d0709..f6f985a92541 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -507,7 +507,8 @@ mk_rtino(
> libxfs_rtginode_metafile_type(type);
> int error;
>
> - error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 10, 0, 0,
> + &tp);
> if (error)
> res_failed(error);
>
> diff --git a/repair/rmap.c b/repair/rmap.c
> index 55c2b0928c52..9f824f848edc 100644
> --- a/repair/rmap.c
> +++ b/repair/rmap.c
> @@ -714,7 +714,8 @@ rmap_commit_agbtree_mappings(
> struct xfs_owner_info oinfo = {};
> struct xfs_perag *pag;
>
> - error = -libxfs_trans_alloc_rollable(mp, 16, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 16, 0,
> + 0, &tp);
> if (error)
> goto err_slab;
>
> @@ -1952,7 +1953,7 @@ fix_freelist(
> args.agno = agno;
> args.alignment = 1;
> args.pag = libxfs_perag_get(mp, agno);
> - error = -libxfs_trans_alloc_rollable(mp, 0, &tp);
> + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
> if (error)
> do_error(_("failed to fix AGFL on AG %d, error %d\n"),
> agno, error);
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 09/13] libxfs: return int from xfs_buf_item_init
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (7 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 08/13] libxfs: remove libxfs_trans_alloc_rollable Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:48 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 10/13] libxfs: use xfs_buf_item.h and xfs_inode_item.h from the kernel source Christoph Hellwig
` (3 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Match the kernel version.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/logitem.c | 6 +++---
libxfs/xfs_platform.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libxfs/logitem.c b/libxfs/logitem.c
index 0bb9088db351..2e050ad92a1e 100644
--- a/libxfs/logitem.c
+++ b/libxfs/logitem.c
@@ -71,7 +71,7 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
* buffer (see xfs_buf_attach_iodone() below), then put the
* buf log item at the front.
*/
-void
+int
xfs_buf_item_init(
struct xfs_buf *bp,
struct xfs_mount *mp)
@@ -97,7 +97,7 @@ xfs_buf_item_init(
"reused buf item %p for pre-logged buffer %p\n",
lip, bp);
#endif
- return;
+ return 0;
}
}
@@ -112,9 +112,9 @@ xfs_buf_item_init(
bip->__bli_format.blf_blkno = (int64_t)xfs_buf_daddr(bp);
bip->__bli_format.blf_len = (unsigned short)bp->b_length;
bp->b_log_item = bip;
+ return 0;
}
-
/*
* Mark bytes first through last inclusive as dirty in the buf
* item's bitmap.
diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
index 9aa898200da8..2e3d323505c5 100644
--- a/libxfs/xfs_platform.h
+++ b/libxfs/xfs_platform.h
@@ -408,7 +408,7 @@ void xfs_trans_del_item(struct xfs_log_item *);
void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
/* xfs_buf_item.c */
-void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
+int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
/* xfs_trans_buf.c */
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 09/13] libxfs: return int from xfs_buf_item_init
2026-10-05 12:56 ` [PATCH 09/13] libxfs: return int from xfs_buf_item_init Christoph Hellwig
@ 2026-10-05 21:48 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:48 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:19PM +0200, Christoph Hellwig wrote:
> Match the kernel version.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks fine to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/logitem.c | 6 +++---
> libxfs/xfs_platform.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libxfs/logitem.c b/libxfs/logitem.c
> index 0bb9088db351..2e050ad92a1e 100644
> --- a/libxfs/logitem.c
> +++ b/libxfs/logitem.c
> @@ -71,7 +71,7 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
> * buffer (see xfs_buf_attach_iodone() below), then put the
> * buf log item at the front.
> */
> -void
> +int
> xfs_buf_item_init(
> struct xfs_buf *bp,
> struct xfs_mount *mp)
> @@ -97,7 +97,7 @@ xfs_buf_item_init(
> "reused buf item %p for pre-logged buffer %p\n",
> lip, bp);
> #endif
> - return;
> + return 0;
> }
> }
>
> @@ -112,9 +112,9 @@ xfs_buf_item_init(
> bip->__bli_format.blf_blkno = (int64_t)xfs_buf_daddr(bp);
> bip->__bli_format.blf_len = (unsigned short)bp->b_length;
> bp->b_log_item = bip;
> + return 0;
> }
>
> -
> /*
> * Mark bytes first through last inclusive as dirty in the buf
> * item's bitmap.
> diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
> index 9aa898200da8..2e3d323505c5 100644
> --- a/libxfs/xfs_platform.h
> +++ b/libxfs/xfs_platform.h
> @@ -408,7 +408,7 @@ void xfs_trans_del_item(struct xfs_log_item *);
> void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
>
> /* xfs_buf_item.c */
> -void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
> +int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
> void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
>
> /* xfs_trans_buf.c */
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 10/13] libxfs: use xfs_buf_item.h and xfs_inode_item.h from the kernel source
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (8 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 09/13] libxfs: return int from xfs_buf_item_init Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:48 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 11/13] libxfs: cleanup xfs_trans.h Christoph Hellwig
` (2 subsequent siblings)
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Replace the partial copy and paste in xfs_trans.h with full copies of
the kernel versions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/Makefile | 2 ++
libxfs/buf_mem.c | 1 +
libxfs/init.c | 2 ++
libxfs/inode.c | 1 +
libxfs/logitem.c | 4 ++-
libxfs/stubs/xfs_trans.h | 24 -------------
libxfs/trans.c | 6 ++--
libxfs/xfs_alloc.c | 1 +
libxfs/xfs_attr_leaf.c | 1 +
libxfs/xfs_bmap.c | 1 +
libxfs/xfs_btree.c | 1 +
libxfs/xfs_btree_mem.c | 1 +
libxfs/xfs_buf_item.h | 71 +++++++++++++++++++++++++++++++++++++
libxfs/xfs_da_btree.c | 1 +
libxfs/xfs_defer.c | 2 ++
libxfs/xfs_dir2_block.c | 1 +
libxfs/xfs_dir2_data.c | 1 +
libxfs/xfs_dir2_leaf.c | 1 +
libxfs/xfs_dir2_node.c | 1 +
libxfs/xfs_ialloc.c | 1 +
libxfs/xfs_inode_fork.c | 1 +
libxfs/xfs_inode_item.h | 62 ++++++++++++++++++++++++++++++++
libxfs/xfs_inode_util.c | 2 ++
libxfs/xfs_platform.h | 7 ----
libxfs/xfs_rtbitmap.c | 1 +
libxfs/xfs_rtgroup.c | 1 +
libxfs/xfs_sb.c | 1 +
libxfs/xfs_symlink_remote.c | 1 +
libxfs/xfs_trans_inode.c | 2 +-
29 files changed, 167 insertions(+), 35 deletions(-)
create mode 100644 libxfs/xfs_buf_item.h
create mode 100644 libxfs/xfs_inode_item.h
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 9795982b0e83..722e99168f63 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -37,6 +37,7 @@ HFILES = \
xfs_attr_leaf.h \
xfs_attr_sf.h \
xfs_bit.h \
+ xfs_buf_item.h \
xfs_bmap.h \
xfs_bmap_btree.h \
xfs_btree.h \
@@ -53,6 +54,7 @@ HFILES = \
xfs_ialloc_btree.h \
xfs_inode_buf.h \
xfs_inode_fork.h \
+ xfs_inode_item.h \
xfs_inode_util.h \
xfs_log_recover.h \
xfs_metadir.h \
diff --git a/libxfs/buf_mem.c b/libxfs/buf_mem.c
index 3c8452de9689..cb7e55129d18 100644
--- a/libxfs/buf_mem.c
+++ b/libxfs/buf_mem.c
@@ -6,6 +6,7 @@
#include "xfs_platform.h"
#include "libxfs.h"
#include "xfs_buf_mem.h"
+#include "xfs_buf_item.h"
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/libxfs/init.c b/libxfs/init.c
index b89c9fe360d4..5f0b7dd6a9f2 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -19,6 +19,8 @@
#include "xfs_inode_fork.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
+#include "xfs_inode_item.h"
+#include "xfs_buf_item.h"
#include "xfs_rmap_btree.h"
#include "xfs_refcount_btree.h"
#include "xfs_metafile.h"
diff --git a/libxfs/inode.c b/libxfs/inode.c
index b6838d3d4bd3..482b2d4b55bb 100644
--- a/libxfs/inode.c
+++ b/libxfs/inode.c
@@ -19,6 +19,7 @@
#include "xfs_inode_fork.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
+#include "xfs_inode_item.h"
#include "xfs_bmap.h"
#include "xfs_bmap_btree.h"
#include "xfs_trans_space.h"
diff --git a/libxfs/logitem.c b/libxfs/logitem.c
index 2e050ad92a1e..432dccbe5649 100644
--- a/libxfs/logitem.c
+++ b/libxfs/logitem.c
@@ -11,10 +11,12 @@
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
+#include "xfs_trans.h"
#include "xfs_inode_buf.h"
#include "xfs_inode_fork.h"
#include "xfs_inode.h"
-#include "xfs_trans.h"
+#include "xfs_inode_item.h"
+#include "xfs_buf_item.h"
#include "xfs_rtbitmap.h"
#include "xfs_ag.h"
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index 9e8737f09d8e..aa4de91b43a9 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -33,30 +33,6 @@ struct xfs_log_item {
#define XFS_LI_DIRTY 3 /* log item dirty in transaction */
-struct xfs_inode_log_item {
- struct xfs_log_item ili_item; /* common portion */
- struct xfs_inode *ili_inode; /* inode pointer */
- unsigned short ili_lock_flags; /* lock flags */
- unsigned int ili_dirty_flags; /* dirty in current tx */
- unsigned int ili_last_fields; /* fields when flushed*/
- unsigned int ili_fields; /* fields to be logged */
- spinlock_t ili_lock;
-};
-
- struct xfs_buf_log_item {
- struct xfs_log_item bli_item; /* common item structure */
- struct xfs_buf *bli_buf; /* real buffer pointer */
- unsigned int bli_flags; /* misc flags */
- unsigned int bli_recur; /* recursion count */
- struct xfs_buf_log_format __bli_format; /* in-log header */
-};
-
-#define XFS_BLI_DIRTY (1<<0)
-#define XFS_BLI_HOLD (1<<1)
-#define XFS_BLI_STALE (1<<2)
-#define XFS_BLI_INODE_ALLOC_BUF (1<<3)
-#define XFS_BLI_ORDERED (1<<4)
-
typedef struct xfs_trans {
unsigned int t_log_res; /* amt of log space resvd */
unsigned int t_log_count; /* count for perm log res */
diff --git a/libxfs/trans.c b/libxfs/trans.c
index f36c54b9c806..77a2a574809e 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -12,10 +12,12 @@
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
+#include "xfs_trans.h"
#include "xfs_inode_buf.h"
#include "xfs_inode_fork.h"
#include "xfs_inode.h"
-#include "xfs_trans.h"
+#include "xfs_inode_item.h"
+#include "xfs_buf_item.h"
#include "xfs_sb.h"
#include "xfs_defer.h"
#include "xfs_trace.h"
@@ -339,7 +341,7 @@ libxfs_trans_cancel(
xfs_trans_free(tp);
}
-static void
+void
xfs_buf_item_put(
struct xfs_buf_log_item *bip)
{
diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index 4cad09d8be61..13ec03c3b45a 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -21,6 +21,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_ag.h"
#include "xfs_ag_resv.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
index 0ac2ae28efa6..240864676aec 100644
--- a/libxfs/xfs_attr_leaf.c
+++ b/libxfs/xfs_attr_leaf.c
@@ -24,6 +24,7 @@
#include "xfs_attr_leaf.h"
#include "xfs_error.h"
#include "xfs_trace.h"
+#include "xfs_buf_item.h"
#include "xfs_dir2.h"
#include "xfs_ag.h"
#include "xfs_errortag.h"
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index cfce4358e2bf..18308d65f92d 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -25,6 +25,7 @@
#include "xfs_error.h"
#include "xfs_quota.h"
#include "xfs_trans_space.h"
+#include "xfs_buf_item.h"
#include "xfs_trace.h"
#include "xfs_attr_leaf.h"
#include "xfs_rmap.h"
diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 425fbefc31ad..9fcb6c349523 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -13,6 +13,7 @@
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_btree.h"
#include "xfs_errortag.h"
#include "xfs_error.h"
diff --git a/libxfs/xfs_btree_mem.c b/libxfs/xfs_btree_mem.c
index c2fa836a2ae2..37136a70e56d 100644
--- a/libxfs/xfs_btree_mem.c
+++ b/libxfs/xfs_btree_mem.c
@@ -16,6 +16,7 @@
#include "xfs_buf_mem.h"
#include "xfs_btree_mem.h"
#include "xfs_ag.h"
+#include "xfs_buf_item.h"
#include "xfs_trace.h"
#include "xfs_rtgroup.h"
diff --git a/libxfs/xfs_buf_item.h b/libxfs/xfs_buf_item.h
new file mode 100644
index 000000000000..3159325dd17b
--- /dev/null
+++ b/libxfs/xfs_buf_item.h
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __XFS_BUF_ITEM_H__
+#define __XFS_BUF_ITEM_H__
+
+/* kernel only definitions */
+
+struct xfs_buf;
+struct xfs_mount;
+
+/* buf log item flags */
+#define XFS_BLI_HOLD (1u << 0)
+#define XFS_BLI_DIRTY (1u << 1)
+#define XFS_BLI_STALE (1u << 2)
+#define XFS_BLI_LOGGED (1u << 3)
+#define XFS_BLI_INODE_ALLOC_BUF (1u << 4)
+#define XFS_BLI_STALE_INODE (1u << 5)
+#define XFS_BLI_INODE_BUF (1u << 6)
+#define XFS_BLI_ORDERED (1u << 7)
+
+#define XFS_BLI_FLAGS \
+ { XFS_BLI_HOLD, "HOLD" }, \
+ { XFS_BLI_DIRTY, "DIRTY" }, \
+ { XFS_BLI_STALE, "STALE" }, \
+ { XFS_BLI_LOGGED, "LOGGED" }, \
+ { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
+ { XFS_BLI_STALE_INODE, "STALE_INODE" }, \
+ { XFS_BLI_INODE_BUF, "INODE_BUF" }, \
+ { XFS_BLI_ORDERED, "ORDERED" }
+
+/*
+ * This is the in core log item structure used to track information
+ * needed to log buffers. It tracks how many times the lock has been
+ * locked, and which 128 byte chunks of the buffer are dirty.
+ */
+struct xfs_buf_log_item {
+ struct xfs_log_item bli_item; /* common item structure */
+ struct xfs_buf *bli_buf; /* real buffer pointer */
+ unsigned int bli_flags; /* misc flags */
+ unsigned int bli_recur; /* lock recursion count */
+ atomic_t bli_refcount; /* cnt of tp refs */
+ int bli_format_count; /* count of headers */
+ struct xfs_buf_log_format *bli_formats; /* array of in-log header ptrs */
+ struct xfs_buf_log_format __bli_format; /* embedded in-log header */
+};
+
+int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
+void xfs_buf_item_done(struct xfs_buf *bp);
+void xfs_buf_item_put(struct xfs_buf_log_item *bip);
+void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
+bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
+void xfs_buf_inode_iodone(struct xfs_buf *);
+#ifdef CONFIG_XFS_QUOTA
+void xfs_buf_dquot_iodone(struct xfs_buf *);
+#else
+static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
+{
+}
+#endif /* CONFIG_XFS_QUOTA */
+void xfs_buf_iodone(struct xfs_buf *);
+bool xfs_buf_log_check_iovec(struct kvec *iovec);
+
+unsigned int xfs_buf_inval_log_space(unsigned int map_count,
+ unsigned int blocksize);
+
+extern struct kmem_cache *xfs_buf_item_cache;
+
+#endif /* __XFS_BUF_ITEM_H__ */
diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
index 9f25f1658b07..a3a3a1aa4c57 100644
--- a/libxfs/xfs_da_btree.c
+++ b/libxfs/xfs_da_btree.c
@@ -20,6 +20,7 @@
#include "xfs_attr_leaf.h"
#include "xfs_error.h"
#include "xfs_trace.h"
+#include "xfs_buf_item.h"
#include "xfs_errortag.h"
#include "xfs_health.h"
diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c
index eae2397fbff8..28e8dcf14475 100644
--- a/libxfs/xfs_defer.c
+++ b/libxfs/xfs_defer.c
@@ -12,7 +12,9 @@
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_inode.h"
+#include "xfs_inode_item.h"
#include "xfs_trace.h"
#include "xfs_rmap.h"
#include "xfs_refcount.h"
diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c
index 0e9dd19eafae..54cb8b645c9c 100644
--- a/libxfs/xfs_dir2_block.c
+++ b/libxfs/xfs_dir2_block.c
@@ -14,6 +14,7 @@
#include "xfs_inode.h"
#include "xfs_trans.h"
#include "xfs_bmap.h"
+#include "xfs_buf_item.h"
#include "xfs_dir2.h"
#include "xfs_dir2_priv.h"
#include "xfs_error.h"
diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
index 0fafe7826ec9..23625d647da4 100644
--- a/libxfs/xfs_dir2_data.c
+++ b/libxfs/xfs_dir2_data.c
@@ -16,6 +16,7 @@
#include "xfs_dir2_priv.h"
#include "xfs_error.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_health.h"
static xfs_failaddr_t xfs_dir2_data_freefind_verify(
diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c
index ea8ab6d46c6c..bc909543eb74 100644
--- a/libxfs/xfs_dir2_leaf.c
+++ b/libxfs/xfs_dir2_leaf.c
@@ -18,6 +18,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_health.h"
/*
diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
index a0aaa21b12cf..7641cbdb8e10 100644
--- a/libxfs/xfs_dir2_node.c
+++ b/libxfs/xfs_dir2_node.c
@@ -18,6 +18,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_health.h"
/*
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index aa895c0decbc..07f6c0094281 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -20,6 +20,7 @@
#include "xfs_error.h"
#include "xfs_bmap.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_trace.h"
#include "xfs_rmap.h"
#include "xfs_ag.h"
diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
index df89ae420617..606a36526ce2 100644
--- a/libxfs/xfs_inode_fork.c
+++ b/libxfs/xfs_inode_fork.c
@@ -13,6 +13,7 @@
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
+#include "xfs_inode_item.h"
#include "xfs_btree.h"
#include "xfs_bmap_btree.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_inode_item.h b/libxfs/xfs_inode_item.h
new file mode 100644
index 000000000000..2ddcca41714f
--- /dev/null
+++ b/libxfs/xfs_inode_item.h
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __XFS_INODE_ITEM_H__
+#define __XFS_INODE_ITEM_H__
+
+/* kernel only definitions */
+
+struct xfs_buf;
+struct xfs_bmbt_rec;
+struct xfs_inode;
+struct xfs_mount;
+
+struct xfs_inode_log_item {
+ struct xfs_log_item ili_item; /* common portion */
+ struct xfs_inode *ili_inode; /* inode ptr */
+ unsigned short ili_lock_flags; /* inode lock flags */
+ unsigned int ili_dirty_flags; /* dirty in current tx */
+ /*
+ * The ili_lock protects the interactions between the dirty state and
+ * the flush state of the inode log item. This allows us to do atomic
+ * modifications of multiple state fields without having to hold a
+ * specific inode lock to serialise them.
+ *
+ * We need atomic changes between inode dirtying, inode flushing and
+ * inode completion, but these all hold different combinations of
+ * ILOCK and IFLUSHING and hence we need some other method of
+ * serialising updates to the flush state.
+ */
+ spinlock_t ili_lock; /* flush state lock */
+ unsigned int ili_last_fields; /* fields when flushed */
+ unsigned int ili_fields; /* fields to be logged */
+ xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
+
+ /*
+ * We record the sequence number for every inode modification, as
+ * well as those that only require fdatasync operations for data
+ * integrity. This allows optimisation of the O_DSYNC/fdatasync path
+ * without needing to track what modifications the journal is currently
+ * carrying for the inode. These are protected by the above ili_lock.
+ */
+ xfs_csn_t ili_commit_seq; /* last transaction commit */
+ xfs_csn_t ili_datasync_seq; /* for datasync optimisation */
+};
+
+static inline int xfs_inode_clean(struct xfs_inode *ip)
+{
+ return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL);
+}
+
+extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
+extern void xfs_inode_item_destroy(struct xfs_inode *);
+extern void xfs_iflush_abort(struct xfs_inode *);
+extern void xfs_iflush_shutdown_abort(struct xfs_inode *);
+int xfs_inode_item_format_convert(struct kvec *buf,
+ struct xfs_inode_log_format *in_f);
+
+extern struct kmem_cache *xfs_ili_cache;
+
+#endif /* __XFS_INODE_ITEM_H__ */
diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c
index 9de455088568..b4f556df64ed 100644
--- a/libxfs/xfs_inode_util.c
+++ b/libxfs/xfs_inode_util.c
@@ -20,7 +20,9 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_ag.h"
+#include "xfs_inode_item.h"
#include "iunlink.h"
+#include "xfs_inode_item.h"
uint16_t
xfs_flags2diflags(
diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
index 2e3d323505c5..4a899dcc6461 100644
--- a/libxfs/xfs_platform.h
+++ b/libxfs/xfs_platform.h
@@ -404,13 +404,6 @@ int xfs_trans_roll(struct xfs_trans **);
void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
void xfs_trans_del_item(struct xfs_log_item *);
-/* xfs_inode_item.c */
-void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
-
-/* xfs_buf_item.c */
-int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
-void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
-
/* xfs_trans_buf.c */
struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *,
struct xfs_buftarg *, struct xfs_buf_map *, int);
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 6a0fc1032753..d4b90548718c 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -21,6 +21,7 @@
#include "xfs_health.h"
#include "xfs_sb.h"
#include "xfs_errortag.h"
+#include "xfs_buf_item.h"
#include "xfs_extent_busy.h"
/*
diff --git a/libxfs/xfs_rtgroup.c b/libxfs/xfs_rtgroup.c
index c1f8d2cb186a..2bbe651b773a 100644
--- a/libxfs/xfs_rtgroup.c
+++ b/libxfs/xfs_rtgroup.c
@@ -27,6 +27,7 @@
#include "xfs_trans.h"
#include "xfs_trace.h"
#include "xfs_inode.h"
+#include "xfs_buf_item.h"
#include "xfs_rtgroup.h"
#include "xfs_rtbitmap.h"
#include "xfs_metafile.h"
diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index cccbcd153316..696bafd2cc3e 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -16,6 +16,7 @@
#include "xfs_alloc.h"
#include "xfs_error.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_rmap_btree.h"
diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c
index de487b1caa4b..008953d402f6 100644
--- a/libxfs/xfs_symlink_remote.c
+++ b/libxfs/xfs_symlink_remote.c
@@ -14,6 +14,7 @@
#include "xfs_inode.h"
#include "xfs_error.h"
#include "xfs_trans.h"
+#include "xfs_buf_item.h"
#include "xfs_symlink_remote.h"
#include "xfs_bit.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
index ef404e7f0f6e..697671007561 100644
--- a/libxfs/xfs_trans_inode.c
+++ b/libxfs/xfs_trans_inode.c
@@ -12,7 +12,7 @@
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
-
+#include "xfs_inode_item.h"
/*
* Add a locked inode to the transaction.
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 10/13] libxfs: use xfs_buf_item.h and xfs_inode_item.h from the kernel source
2026-10-05 12:56 ` [PATCH 10/13] libxfs: use xfs_buf_item.h and xfs_inode_item.h from the kernel source Christoph Hellwig
@ 2026-10-05 21:48 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:48 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:20PM +0200, Christoph Hellwig wrote:
> Replace the partial copy and paste in xfs_trans.h with full copies of
> the kernel versions.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Much less hacky/nicer now! :)
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/Makefile | 2 ++
> libxfs/buf_mem.c | 1 +
> libxfs/init.c | 2 ++
> libxfs/inode.c | 1 +
> libxfs/logitem.c | 4 ++-
> libxfs/stubs/xfs_trans.h | 24 -------------
> libxfs/trans.c | 6 ++--
> libxfs/xfs_alloc.c | 1 +
> libxfs/xfs_attr_leaf.c | 1 +
> libxfs/xfs_bmap.c | 1 +
> libxfs/xfs_btree.c | 1 +
> libxfs/xfs_btree_mem.c | 1 +
> libxfs/xfs_buf_item.h | 71 +++++++++++++++++++++++++++++++++++++
> libxfs/xfs_da_btree.c | 1 +
> libxfs/xfs_defer.c | 2 ++
> libxfs/xfs_dir2_block.c | 1 +
> libxfs/xfs_dir2_data.c | 1 +
> libxfs/xfs_dir2_leaf.c | 1 +
> libxfs/xfs_dir2_node.c | 1 +
> libxfs/xfs_ialloc.c | 1 +
> libxfs/xfs_inode_fork.c | 1 +
> libxfs/xfs_inode_item.h | 62 ++++++++++++++++++++++++++++++++
> libxfs/xfs_inode_util.c | 2 ++
> libxfs/xfs_platform.h | 7 ----
> libxfs/xfs_rtbitmap.c | 1 +
> libxfs/xfs_rtgroup.c | 1 +
> libxfs/xfs_sb.c | 1 +
> libxfs/xfs_symlink_remote.c | 1 +
> libxfs/xfs_trans_inode.c | 2 +-
> 29 files changed, 167 insertions(+), 35 deletions(-)
> create mode 100644 libxfs/xfs_buf_item.h
> create mode 100644 libxfs/xfs_inode_item.h
>
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index 9795982b0e83..722e99168f63 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -37,6 +37,7 @@ HFILES = \
> xfs_attr_leaf.h \
> xfs_attr_sf.h \
> xfs_bit.h \
> + xfs_buf_item.h \
> xfs_bmap.h \
> xfs_bmap_btree.h \
> xfs_btree.h \
> @@ -53,6 +54,7 @@ HFILES = \
> xfs_ialloc_btree.h \
> xfs_inode_buf.h \
> xfs_inode_fork.h \
> + xfs_inode_item.h \
> xfs_inode_util.h \
> xfs_log_recover.h \
> xfs_metadir.h \
> diff --git a/libxfs/buf_mem.c b/libxfs/buf_mem.c
> index 3c8452de9689..cb7e55129d18 100644
> --- a/libxfs/buf_mem.c
> +++ b/libxfs/buf_mem.c
> @@ -6,6 +6,7 @@
> #include "xfs_platform.h"
> #include "libxfs.h"
> #include "xfs_buf_mem.h"
> +#include "xfs_buf_item.h"
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/wait.h>
> diff --git a/libxfs/init.c b/libxfs/init.c
> index b89c9fe360d4..5f0b7dd6a9f2 100644
> --- a/libxfs/init.c
> +++ b/libxfs/init.c
> @@ -19,6 +19,8 @@
> #include "xfs_inode_fork.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> +#include "xfs_inode_item.h"
> +#include "xfs_buf_item.h"
> #include "xfs_rmap_btree.h"
> #include "xfs_refcount_btree.h"
> #include "xfs_metafile.h"
> diff --git a/libxfs/inode.c b/libxfs/inode.c
> index b6838d3d4bd3..482b2d4b55bb 100644
> --- a/libxfs/inode.c
> +++ b/libxfs/inode.c
> @@ -19,6 +19,7 @@
> #include "xfs_inode_fork.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> +#include "xfs_inode_item.h"
> #include "xfs_bmap.h"
> #include "xfs_bmap_btree.h"
> #include "xfs_trans_space.h"
> diff --git a/libxfs/logitem.c b/libxfs/logitem.c
> index 2e050ad92a1e..432dccbe5649 100644
> --- a/libxfs/logitem.c
> +++ b/libxfs/logitem.c
> @@ -11,10 +11,12 @@
> #include "xfs_log_format.h"
> #include "xfs_trans_resv.h"
> #include "xfs_mount.h"
> +#include "xfs_trans.h"
> #include "xfs_inode_buf.h"
> #include "xfs_inode_fork.h"
> #include "xfs_inode.h"
> -#include "xfs_trans.h"
> +#include "xfs_inode_item.h"
> +#include "xfs_buf_item.h"
> #include "xfs_rtbitmap.h"
> #include "xfs_ag.h"
>
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index 9e8737f09d8e..aa4de91b43a9 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -33,30 +33,6 @@ struct xfs_log_item {
>
> #define XFS_LI_DIRTY 3 /* log item dirty in transaction */
>
> -struct xfs_inode_log_item {
> - struct xfs_log_item ili_item; /* common portion */
> - struct xfs_inode *ili_inode; /* inode pointer */
> - unsigned short ili_lock_flags; /* lock flags */
> - unsigned int ili_dirty_flags; /* dirty in current tx */
> - unsigned int ili_last_fields; /* fields when flushed*/
> - unsigned int ili_fields; /* fields to be logged */
> - spinlock_t ili_lock;
> -};
> -
> - struct xfs_buf_log_item {
> - struct xfs_log_item bli_item; /* common item structure */
> - struct xfs_buf *bli_buf; /* real buffer pointer */
> - unsigned int bli_flags; /* misc flags */
> - unsigned int bli_recur; /* recursion count */
> - struct xfs_buf_log_format __bli_format; /* in-log header */
> -};
> -
> -#define XFS_BLI_DIRTY (1<<0)
> -#define XFS_BLI_HOLD (1<<1)
> -#define XFS_BLI_STALE (1<<2)
> -#define XFS_BLI_INODE_ALLOC_BUF (1<<3)
> -#define XFS_BLI_ORDERED (1<<4)
> -
> typedef struct xfs_trans {
> unsigned int t_log_res; /* amt of log space resvd */
> unsigned int t_log_count; /* count for perm log res */
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index f36c54b9c806..77a2a574809e 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -12,10 +12,12 @@
> #include "xfs_log_format.h"
> #include "xfs_trans_resv.h"
> #include "xfs_mount.h"
> +#include "xfs_trans.h"
> #include "xfs_inode_buf.h"
> #include "xfs_inode_fork.h"
> #include "xfs_inode.h"
> -#include "xfs_trans.h"
> +#include "xfs_inode_item.h"
> +#include "xfs_buf_item.h"
> #include "xfs_sb.h"
> #include "xfs_defer.h"
> #include "xfs_trace.h"
> @@ -339,7 +341,7 @@ libxfs_trans_cancel(
> xfs_trans_free(tp);
> }
>
> -static void
> +void
> xfs_buf_item_put(
> struct xfs_buf_log_item *bip)
> {
> diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
> index 4cad09d8be61..13ec03c3b45a 100644
> --- a/libxfs/xfs_alloc.c
> +++ b/libxfs/xfs_alloc.c
> @@ -21,6 +21,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_ag.h"
> #include "xfs_ag_resv.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
> index 0ac2ae28efa6..240864676aec 100644
> --- a/libxfs/xfs_attr_leaf.c
> +++ b/libxfs/xfs_attr_leaf.c
> @@ -24,6 +24,7 @@
> #include "xfs_attr_leaf.h"
> #include "xfs_error.h"
> #include "xfs_trace.h"
> +#include "xfs_buf_item.h"
> #include "xfs_dir2.h"
> #include "xfs_ag.h"
> #include "xfs_errortag.h"
> diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> index cfce4358e2bf..18308d65f92d 100644
> --- a/libxfs/xfs_bmap.c
> +++ b/libxfs/xfs_bmap.c
> @@ -25,6 +25,7 @@
> #include "xfs_error.h"
> #include "xfs_quota.h"
> #include "xfs_trans_space.h"
> +#include "xfs_buf_item.h"
> #include "xfs_trace.h"
> #include "xfs_attr_leaf.h"
> #include "xfs_rmap.h"
> diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
> index 425fbefc31ad..9fcb6c349523 100644
> --- a/libxfs/xfs_btree.c
> +++ b/libxfs/xfs_btree.c
> @@ -13,6 +13,7 @@
> #include "xfs_mount.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_btree.h"
> #include "xfs_errortag.h"
> #include "xfs_error.h"
> diff --git a/libxfs/xfs_btree_mem.c b/libxfs/xfs_btree_mem.c
> index c2fa836a2ae2..37136a70e56d 100644
> --- a/libxfs/xfs_btree_mem.c
> +++ b/libxfs/xfs_btree_mem.c
> @@ -16,6 +16,7 @@
> #include "xfs_buf_mem.h"
> #include "xfs_btree_mem.h"
> #include "xfs_ag.h"
> +#include "xfs_buf_item.h"
> #include "xfs_trace.h"
> #include "xfs_rtgroup.h"
>
> diff --git a/libxfs/xfs_buf_item.h b/libxfs/xfs_buf_item.h
> new file mode 100644
> index 000000000000..3159325dd17b
> --- /dev/null
> +++ b/libxfs/xfs_buf_item.h
> @@ -0,0 +1,71 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + */
> +#ifndef __XFS_BUF_ITEM_H__
> +#define __XFS_BUF_ITEM_H__
> +
> +/* kernel only definitions */
> +
> +struct xfs_buf;
> +struct xfs_mount;
> +
> +/* buf log item flags */
> +#define XFS_BLI_HOLD (1u << 0)
> +#define XFS_BLI_DIRTY (1u << 1)
> +#define XFS_BLI_STALE (1u << 2)
> +#define XFS_BLI_LOGGED (1u << 3)
> +#define XFS_BLI_INODE_ALLOC_BUF (1u << 4)
> +#define XFS_BLI_STALE_INODE (1u << 5)
> +#define XFS_BLI_INODE_BUF (1u << 6)
> +#define XFS_BLI_ORDERED (1u << 7)
> +
> +#define XFS_BLI_FLAGS \
> + { XFS_BLI_HOLD, "HOLD" }, \
> + { XFS_BLI_DIRTY, "DIRTY" }, \
> + { XFS_BLI_STALE, "STALE" }, \
> + { XFS_BLI_LOGGED, "LOGGED" }, \
> + { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
> + { XFS_BLI_STALE_INODE, "STALE_INODE" }, \
> + { XFS_BLI_INODE_BUF, "INODE_BUF" }, \
> + { XFS_BLI_ORDERED, "ORDERED" }
> +
> +/*
> + * This is the in core log item structure used to track information
> + * needed to log buffers. It tracks how many times the lock has been
> + * locked, and which 128 byte chunks of the buffer are dirty.
> + */
> +struct xfs_buf_log_item {
> + struct xfs_log_item bli_item; /* common item structure */
> + struct xfs_buf *bli_buf; /* real buffer pointer */
> + unsigned int bli_flags; /* misc flags */
> + unsigned int bli_recur; /* lock recursion count */
> + atomic_t bli_refcount; /* cnt of tp refs */
> + int bli_format_count; /* count of headers */
> + struct xfs_buf_log_format *bli_formats; /* array of in-log header ptrs */
> + struct xfs_buf_log_format __bli_format; /* embedded in-log header */
> +};
> +
> +int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
> +void xfs_buf_item_done(struct xfs_buf *bp);
> +void xfs_buf_item_put(struct xfs_buf_log_item *bip);
> +void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
> +bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
> +void xfs_buf_inode_iodone(struct xfs_buf *);
> +#ifdef CONFIG_XFS_QUOTA
> +void xfs_buf_dquot_iodone(struct xfs_buf *);
> +#else
> +static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
> +{
> +}
> +#endif /* CONFIG_XFS_QUOTA */
> +void xfs_buf_iodone(struct xfs_buf *);
> +bool xfs_buf_log_check_iovec(struct kvec *iovec);
> +
> +unsigned int xfs_buf_inval_log_space(unsigned int map_count,
> + unsigned int blocksize);
> +
> +extern struct kmem_cache *xfs_buf_item_cache;
> +
> +#endif /* __XFS_BUF_ITEM_H__ */
> diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
> index 9f25f1658b07..a3a3a1aa4c57 100644
> --- a/libxfs/xfs_da_btree.c
> +++ b/libxfs/xfs_da_btree.c
> @@ -20,6 +20,7 @@
> #include "xfs_attr_leaf.h"
> #include "xfs_error.h"
> #include "xfs_trace.h"
> +#include "xfs_buf_item.h"
> #include "xfs_errortag.h"
> #include "xfs_health.h"
>
> diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c
> index eae2397fbff8..28e8dcf14475 100644
> --- a/libxfs/xfs_defer.c
> +++ b/libxfs/xfs_defer.c
> @@ -12,7 +12,9 @@
> #include "xfs_mount.h"
> #include "xfs_defer.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_inode.h"
> +#include "xfs_inode_item.h"
> #include "xfs_trace.h"
> #include "xfs_rmap.h"
> #include "xfs_refcount.h"
> diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c
> index 0e9dd19eafae..54cb8b645c9c 100644
> --- a/libxfs/xfs_dir2_block.c
> +++ b/libxfs/xfs_dir2_block.c
> @@ -14,6 +14,7 @@
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> #include "xfs_bmap.h"
> +#include "xfs_buf_item.h"
> #include "xfs_dir2.h"
> #include "xfs_dir2_priv.h"
> #include "xfs_error.h"
> diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
> index 0fafe7826ec9..23625d647da4 100644
> --- a/libxfs/xfs_dir2_data.c
> +++ b/libxfs/xfs_dir2_data.c
> @@ -16,6 +16,7 @@
> #include "xfs_dir2_priv.h"
> #include "xfs_error.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_health.h"
>
> static xfs_failaddr_t xfs_dir2_data_freefind_verify(
> diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c
> index ea8ab6d46c6c..bc909543eb74 100644
> --- a/libxfs/xfs_dir2_leaf.c
> +++ b/libxfs/xfs_dir2_leaf.c
> @@ -18,6 +18,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_health.h"
>
> /*
> diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
> index a0aaa21b12cf..7641cbdb8e10 100644
> --- a/libxfs/xfs_dir2_node.c
> +++ b/libxfs/xfs_dir2_node.c
> @@ -18,6 +18,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_health.h"
>
> /*
> diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
> index aa895c0decbc..07f6c0094281 100644
> --- a/libxfs/xfs_ialloc.c
> +++ b/libxfs/xfs_ialloc.c
> @@ -20,6 +20,7 @@
> #include "xfs_error.h"
> #include "xfs_bmap.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_trace.h"
> #include "xfs_rmap.h"
> #include "xfs_ag.h"
> diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
> index df89ae420617..606a36526ce2 100644
> --- a/libxfs/xfs_inode_fork.c
> +++ b/libxfs/xfs_inode_fork.c
> @@ -13,6 +13,7 @@
> #include "xfs_mount.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> +#include "xfs_inode_item.h"
> #include "xfs_btree.h"
> #include "xfs_bmap_btree.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_inode_item.h b/libxfs/xfs_inode_item.h
> new file mode 100644
> index 000000000000..2ddcca41714f
> --- /dev/null
> +++ b/libxfs/xfs_inode_item.h
> @@ -0,0 +1,62 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2000,2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + */
> +#ifndef __XFS_INODE_ITEM_H__
> +#define __XFS_INODE_ITEM_H__
> +
> +/* kernel only definitions */
> +
> +struct xfs_buf;
> +struct xfs_bmbt_rec;
> +struct xfs_inode;
> +struct xfs_mount;
> +
> +struct xfs_inode_log_item {
> + struct xfs_log_item ili_item; /* common portion */
> + struct xfs_inode *ili_inode; /* inode ptr */
> + unsigned short ili_lock_flags; /* inode lock flags */
> + unsigned int ili_dirty_flags; /* dirty in current tx */
> + /*
> + * The ili_lock protects the interactions between the dirty state and
> + * the flush state of the inode log item. This allows us to do atomic
> + * modifications of multiple state fields without having to hold a
> + * specific inode lock to serialise them.
> + *
> + * We need atomic changes between inode dirtying, inode flushing and
> + * inode completion, but these all hold different combinations of
> + * ILOCK and IFLUSHING and hence we need some other method of
> + * serialising updates to the flush state.
> + */
> + spinlock_t ili_lock; /* flush state lock */
> + unsigned int ili_last_fields; /* fields when flushed */
> + unsigned int ili_fields; /* fields to be logged */
> + xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
> +
> + /*
> + * We record the sequence number for every inode modification, as
> + * well as those that only require fdatasync operations for data
> + * integrity. This allows optimisation of the O_DSYNC/fdatasync path
> + * without needing to track what modifications the journal is currently
> + * carrying for the inode. These are protected by the above ili_lock.
> + */
> + xfs_csn_t ili_commit_seq; /* last transaction commit */
> + xfs_csn_t ili_datasync_seq; /* for datasync optimisation */
> +};
> +
> +static inline int xfs_inode_clean(struct xfs_inode *ip)
> +{
> + return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL);
> +}
> +
> +extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
> +extern void xfs_inode_item_destroy(struct xfs_inode *);
> +extern void xfs_iflush_abort(struct xfs_inode *);
> +extern void xfs_iflush_shutdown_abort(struct xfs_inode *);
> +int xfs_inode_item_format_convert(struct kvec *buf,
> + struct xfs_inode_log_format *in_f);
> +
> +extern struct kmem_cache *xfs_ili_cache;
> +
> +#endif /* __XFS_INODE_ITEM_H__ */
> diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c
> index 9de455088568..b4f556df64ed 100644
> --- a/libxfs/xfs_inode_util.c
> +++ b/libxfs/xfs_inode_util.c
> @@ -20,7 +20,9 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_ag.h"
> +#include "xfs_inode_item.h"
> #include "iunlink.h"
> +#include "xfs_inode_item.h"
>
> uint16_t
> xfs_flags2diflags(
> diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
> index 2e3d323505c5..4a899dcc6461 100644
> --- a/libxfs/xfs_platform.h
> +++ b/libxfs/xfs_platform.h
> @@ -404,13 +404,6 @@ int xfs_trans_roll(struct xfs_trans **);
> void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
> void xfs_trans_del_item(struct xfs_log_item *);
>
> -/* xfs_inode_item.c */
> -void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
> -
> -/* xfs_buf_item.c */
> -int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
> -void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
> -
> /* xfs_trans_buf.c */
> struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *,
> struct xfs_buftarg *, struct xfs_buf_map *, int);
> diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
> index 6a0fc1032753..d4b90548718c 100644
> --- a/libxfs/xfs_rtbitmap.c
> +++ b/libxfs/xfs_rtbitmap.c
> @@ -21,6 +21,7 @@
> #include "xfs_health.h"
> #include "xfs_sb.h"
> #include "xfs_errortag.h"
> +#include "xfs_buf_item.h"
> #include "xfs_extent_busy.h"
>
> /*
> diff --git a/libxfs/xfs_rtgroup.c b/libxfs/xfs_rtgroup.c
> index c1f8d2cb186a..2bbe651b773a 100644
> --- a/libxfs/xfs_rtgroup.c
> +++ b/libxfs/xfs_rtgroup.c
> @@ -27,6 +27,7 @@
> #include "xfs_trans.h"
> #include "xfs_trace.h"
> #include "xfs_inode.h"
> +#include "xfs_buf_item.h"
> #include "xfs_rtgroup.h"
> #include "xfs_rtbitmap.h"
> #include "xfs_metafile.h"
> diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
> index cccbcd153316..696bafd2cc3e 100644
> --- a/libxfs/xfs_sb.c
> +++ b/libxfs/xfs_sb.c
> @@ -16,6 +16,7 @@
> #include "xfs_alloc.h"
> #include "xfs_error.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_bmap_btree.h"
> #include "xfs_alloc_btree.h"
> #include "xfs_rmap_btree.h"
> diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c
> index de487b1caa4b..008953d402f6 100644
> --- a/libxfs/xfs_symlink_remote.c
> +++ b/libxfs/xfs_symlink_remote.c
> @@ -14,6 +14,7 @@
> #include "xfs_inode.h"
> #include "xfs_error.h"
> #include "xfs_trans.h"
> +#include "xfs_buf_item.h"
> #include "xfs_symlink_remote.h"
> #include "xfs_bit.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
> index ef404e7f0f6e..697671007561 100644
> --- a/libxfs/xfs_trans_inode.c
> +++ b/libxfs/xfs_trans_inode.c
> @@ -12,7 +12,7 @@
> #include "xfs_mount.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> -
> +#include "xfs_inode_item.h"
>
> /*
> * Add a locked inode to the transaction.
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 11/13] libxfs: cleanup xfs_trans.h
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (9 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 10/13] libxfs: use xfs_buf_item.h and xfs_inode_item.h from the kernel source Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:48 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source Christoph Hellwig
2026-10-05 12:56 ` [PATCH 13/13] libxfs: use all log item headers from the kernel Christoph Hellwig
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Add new xfs_trans_priv.h and xfs_log.h stubs for definitions that aren't
in xfs_trans.h in the kernel. This prepares for pulling in the kernel
version of xfs_trans.h.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/Makefile | 4 +++-
libxfs/stubs/xfs_log.h | 7 +++++++
libxfs/stubs/xfs_trans.h | 7 -------
libxfs/stubs/xfs_trans_priv.h | 16 ++++++++++++++++
libxfs/xfs_alloc.c | 1 +
libxfs/xfs_attr_leaf.c | 1 +
libxfs/xfs_btree.c | 1 +
libxfs/xfs_da_btree.c | 1 +
libxfs/xfs_defer.c | 2 ++
libxfs/xfs_dir2_block.c | 1 +
libxfs/xfs_dir2_data.c | 1 +
libxfs/xfs_dir2_node.c | 1 +
libxfs/xfs_ialloc.c | 1 +
libxfs/xfs_rtbitmap.c | 1 +
libxfs/xfs_sb.c | 1 +
libxfs/xfs_symlink_remote.c | 1 +
libxfs/xfs_trans_inode.c | 1 +
libxfs/xfs_trans_resv.c | 1 +
repair/phase2.c | 1 +
19 files changed, 42 insertions(+), 8 deletions(-)
create mode 100644 libxfs/stubs/xfs_log.h
create mode 100644 libxfs/stubs/xfs_trans_priv.h
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 722e99168f63..f64dd596b645 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -79,10 +79,12 @@ HFILES = \
stubs/xfs_error.h \
stubs/xfs_extent_busy.h \
stubs/xfs_inode.h \
+ stubs/xfs_log.h \
stubs/xfs_mount.h \
stubs/xfs_quota.h \
stubs/xfs_trace.h \
- stubs/xfs_trans.h
+ stubs/xfs_trans.h \
+ stubs/xfs_trans_priv.h
CFILES = buf_mem.c \
cache.c \
diff --git a/libxfs/stubs/xfs_log.h b/libxfs/stubs/xfs_log.h
new file mode 100644
index 000000000000..98251ee06688
--- /dev/null
+++ b/libxfs/stubs/xfs_log.h
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef __XFS_LOG_H__
+#define __XFS_LOG_H__
+
+#define xfs_log_item_in_current_chkpt(lip) (false)
+
+#endif /* __XFS_LOG_H__ */
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
index aa4de91b43a9..2619347df923 100644
--- a/libxfs/stubs/xfs_trans.h
+++ b/libxfs/stubs/xfs_trans.h
@@ -52,7 +52,6 @@ typedef struct xfs_trans {
struct list_head t_dfops; /* deferred operations */
} xfs_trans_t;
-void xfs_trans_init(struct xfs_mount *);
int xfs_trans_roll(struct xfs_trans **);
int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
@@ -130,10 +129,4 @@ libxfs_trans_read_buf(
return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
}
-#define xfs_log_item_in_current_chkpt(lip) (false)
-
-/* Contorted mess to make gcc shut up about unused vars. */
-#define xfs_ail_get_push_target(ail) \
- ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN)
-
#endif /* __XFS_TRANS_H__ */
diff --git a/libxfs/stubs/xfs_trans_priv.h b/libxfs/stubs/xfs_trans_priv.h
new file mode 100644
index 000000000000..bab4e6c2b6c2
--- /dev/null
+++ b/libxfs/stubs/xfs_trans_priv.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+
+#ifndef __XFS_TRANS_PRIV_H__
+#define __XFS_TRANS_PRIV_H__
+
+void xfs_trans_init(struct xfs_mount *);
+
+/* Contorted mess to make gcc shut up about unused vars. */
+#define xfs_ail_get_push_target(ail) \
+ ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN)
+
+#endif /* __XFS_TRANS_PRIV_H__ */
diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index 13ec03c3b45a..8feaa0edace1 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -22,6 +22,7 @@
#include "xfs_trace.h"
#include "xfs_trans.h"
#include "xfs_buf_item.h"
+#include "xfs_log.h"
#include "xfs_ag.h"
#include "xfs_ag_resv.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
index 240864676aec..86c5c09a5db4 100644
--- a/libxfs/xfs_attr_leaf.c
+++ b/libxfs/xfs_attr_leaf.c
@@ -26,6 +26,7 @@
#include "xfs_trace.h"
#include "xfs_buf_item.h"
#include "xfs_dir2.h"
+#include "xfs_log.h"
#include "xfs_ag.h"
#include "xfs_errortag.h"
#include "xfs_health.h"
diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 9fcb6c349523..60ef7f08b1d3 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -19,6 +19,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_alloc.h"
+#include "xfs_log.h"
#include "xfs_btree_staging.h"
#include "xfs_ag.h"
#include "xfs_alloc_btree.h"
diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
index a3a3a1aa4c57..9debb95d86fa 100644
--- a/libxfs/xfs_da_btree.c
+++ b/libxfs/xfs_da_btree.c
@@ -21,6 +21,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_buf_item.h"
+#include "xfs_log.h"
#include "xfs_errortag.h"
#include "xfs_health.h"
diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c
index 28e8dcf14475..ab1f81d8bcd2 100644
--- a/libxfs/xfs_defer.c
+++ b/libxfs/xfs_defer.c
@@ -12,10 +12,12 @@
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_trans.h"
+#include "xfs_trans_priv.h"
#include "xfs_buf_item.h"
#include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_trace.h"
+#include "xfs_log.h"
#include "xfs_rmap.h"
#include "xfs_refcount.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c
index 54cb8b645c9c..6d70e6b429e7 100644
--- a/libxfs/xfs_dir2_block.c
+++ b/libxfs/xfs_dir2_block.c
@@ -19,6 +19,7 @@
#include "xfs_dir2_priv.h"
#include "xfs_error.h"
#include "xfs_trace.h"
+#include "xfs_log.h"
#include "xfs_health.h"
/*
diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
index 23625d647da4..aecbab61014c 100644
--- a/libxfs/xfs_dir2_data.c
+++ b/libxfs/xfs_dir2_data.c
@@ -17,6 +17,7 @@
#include "xfs_error.h"
#include "xfs_trans.h"
#include "xfs_buf_item.h"
+#include "xfs_log.h"
#include "xfs_health.h"
static xfs_failaddr_t xfs_dir2_data_freefind_verify(
diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
index 7641cbdb8e10..19cb536e53ef 100644
--- a/libxfs/xfs_dir2_node.c
+++ b/libxfs/xfs_dir2_node.c
@@ -19,6 +19,7 @@
#include "xfs_trace.h"
#include "xfs_trans.h"
#include "xfs_buf_item.h"
+#include "xfs_log.h"
#include "xfs_health.h"
/*
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 07f6c0094281..91f4cdf2e4f3 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -22,6 +22,7 @@
#include "xfs_trans.h"
#include "xfs_buf_item.h"
#include "xfs_trace.h"
+#include "xfs_log.h"
#include "xfs_rmap.h"
#include "xfs_ag.h"
#include "xfs_health.h"
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index d4b90548718c..590e0641ff0d 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -21,6 +21,7 @@
#include "xfs_health.h"
#include "xfs_sb.h"
#include "xfs_errortag.h"
+#include "xfs_log.h"
#include "xfs_buf_item.h"
#include "xfs_extent_busy.h"
diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index 696bafd2cc3e..aae63ccdb6b5 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -19,6 +19,7 @@
#include "xfs_buf_item.h"
#include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
+#include "xfs_log.h"
#include "xfs_rmap_btree.h"
#include "xfs_refcount_btree.h"
#include "xfs_da_format.h"
diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c
index 008953d402f6..b0dc3888bf1b 100644
--- a/libxfs/xfs_symlink_remote.c
+++ b/libxfs/xfs_symlink_remote.c
@@ -15,6 +15,7 @@
#include "xfs_error.h"
#include "xfs_trans.h"
#include "xfs_buf_item.h"
+#include "xfs_log.h"
#include "xfs_symlink_remote.h"
#include "xfs_bit.h"
#include "xfs_bmap.h"
diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
index 697671007561..e3dca0652d26 100644
--- a/libxfs/xfs_trans_inode.c
+++ b/libxfs/xfs_trans_inode.c
@@ -12,6 +12,7 @@
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
+#include "xfs_trans_priv.h"
#include "xfs_inode_item.h"
/*
diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
index 5b7660b1cd8a..d15ca0427584 100644
--- a/libxfs/xfs_trans_resv.c
+++ b/libxfs/xfs_trans_resv.c
@@ -19,6 +19,7 @@
#include "xfs_trans.h"
#include "xfs_trans_space.h"
#include "xfs_rtbitmap.h"
+#include "xfs_log.h"
#include "xfs_trace.h"
#include "defer_item.h"
diff --git a/repair/phase2.c b/repair/phase2.c
index fc96f9c4223c..ee166e62a002 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -16,6 +16,7 @@
#include "scan.h"
#include "rt.h"
#include "quotacheck.h"
+#include "xfs_trans_priv.h"
/* workaround craziness in the xlog routines */
int xlog_recover_do_trans(struct xlog *log, struct xlog_recover *t, int p)
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 11/13] libxfs: cleanup xfs_trans.h
2026-10-05 12:56 ` [PATCH 11/13] libxfs: cleanup xfs_trans.h Christoph Hellwig
@ 2026-10-05 21:48 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:48 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:21PM +0200, Christoph Hellwig wrote:
> Add new xfs_trans_priv.h and xfs_log.h stubs for definitions that aren't
> in xfs_trans.h in the kernel. This prepares for pulling in the kernel
> version of xfs_trans.h.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/Makefile | 4 +++-
> libxfs/stubs/xfs_log.h | 7 +++++++
> libxfs/stubs/xfs_trans.h | 7 -------
> libxfs/stubs/xfs_trans_priv.h | 16 ++++++++++++++++
> libxfs/xfs_alloc.c | 1 +
> libxfs/xfs_attr_leaf.c | 1 +
> libxfs/xfs_btree.c | 1 +
> libxfs/xfs_da_btree.c | 1 +
> libxfs/xfs_defer.c | 2 ++
> libxfs/xfs_dir2_block.c | 1 +
> libxfs/xfs_dir2_data.c | 1 +
> libxfs/xfs_dir2_node.c | 1 +
> libxfs/xfs_ialloc.c | 1 +
> libxfs/xfs_rtbitmap.c | 1 +
> libxfs/xfs_sb.c | 1 +
> libxfs/xfs_symlink_remote.c | 1 +
> libxfs/xfs_trans_inode.c | 1 +
> libxfs/xfs_trans_resv.c | 1 +
> repair/phase2.c | 1 +
> 19 files changed, 42 insertions(+), 8 deletions(-)
> create mode 100644 libxfs/stubs/xfs_log.h
> create mode 100644 libxfs/stubs/xfs_trans_priv.h
>
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index 722e99168f63..f64dd596b645 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -79,10 +79,12 @@ HFILES = \
> stubs/xfs_error.h \
> stubs/xfs_extent_busy.h \
> stubs/xfs_inode.h \
> + stubs/xfs_log.h \
> stubs/xfs_mount.h \
> stubs/xfs_quota.h \
> stubs/xfs_trace.h \
> - stubs/xfs_trans.h
> + stubs/xfs_trans.h \
> + stubs/xfs_trans_priv.h
>
> CFILES = buf_mem.c \
> cache.c \
> diff --git a/libxfs/stubs/xfs_log.h b/libxfs/stubs/xfs_log.h
> new file mode 100644
> index 000000000000..98251ee06688
> --- /dev/null
> +++ b/libxfs/stubs/xfs_log.h
> @@ -0,0 +1,7 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#ifndef __XFS_LOG_H__
> +#define __XFS_LOG_H__
> +
> +#define xfs_log_item_in_current_chkpt(lip) (false)
> +
> +#endif /* __XFS_LOG_H__ */
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> index aa4de91b43a9..2619347df923 100644
> --- a/libxfs/stubs/xfs_trans.h
> +++ b/libxfs/stubs/xfs_trans.h
> @@ -52,7 +52,6 @@ typedef struct xfs_trans {
> struct list_head t_dfops; /* deferred operations */
> } xfs_trans_t;
>
> -void xfs_trans_init(struct xfs_mount *);
> int xfs_trans_roll(struct xfs_trans **);
>
> int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
> @@ -130,10 +129,4 @@ libxfs_trans_read_buf(
> return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
> }
>
> -#define xfs_log_item_in_current_chkpt(lip) (false)
> -
> -/* Contorted mess to make gcc shut up about unused vars. */
> -#define xfs_ail_get_push_target(ail) \
> - ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN)
> -
> #endif /* __XFS_TRANS_H__ */
> diff --git a/libxfs/stubs/xfs_trans_priv.h b/libxfs/stubs/xfs_trans_priv.h
> new file mode 100644
> index 000000000000..bab4e6c2b6c2
> --- /dev/null
> +++ b/libxfs/stubs/xfs_trans_priv.h
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2000-2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + */
> +
> +#ifndef __XFS_TRANS_PRIV_H__
> +#define __XFS_TRANS_PRIV_H__
> +
> +void xfs_trans_init(struct xfs_mount *);
> +
> +/* Contorted mess to make gcc shut up about unused vars. */
> +#define xfs_ail_get_push_target(ail) \
> + ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN)
> +
> +#endif /* __XFS_TRANS_PRIV_H__ */
> diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
> index 13ec03c3b45a..8feaa0edace1 100644
> --- a/libxfs/xfs_alloc.c
> +++ b/libxfs/xfs_alloc.c
> @@ -22,6 +22,7 @@
> #include "xfs_trace.h"
> #include "xfs_trans.h"
> #include "xfs_buf_item.h"
> +#include "xfs_log.h"
> #include "xfs_ag.h"
> #include "xfs_ag_resv.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
> index 240864676aec..86c5c09a5db4 100644
> --- a/libxfs/xfs_attr_leaf.c
> +++ b/libxfs/xfs_attr_leaf.c
> @@ -26,6 +26,7 @@
> #include "xfs_trace.h"
> #include "xfs_buf_item.h"
> #include "xfs_dir2.h"
> +#include "xfs_log.h"
> #include "xfs_ag.h"
> #include "xfs_errortag.h"
> #include "xfs_health.h"
> diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
> index 9fcb6c349523..60ef7f08b1d3 100644
> --- a/libxfs/xfs_btree.c
> +++ b/libxfs/xfs_btree.c
> @@ -19,6 +19,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_alloc.h"
> +#include "xfs_log.h"
> #include "xfs_btree_staging.h"
> #include "xfs_ag.h"
> #include "xfs_alloc_btree.h"
> diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
> index a3a3a1aa4c57..9debb95d86fa 100644
> --- a/libxfs/xfs_da_btree.c
> +++ b/libxfs/xfs_da_btree.c
> @@ -21,6 +21,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_buf_item.h"
> +#include "xfs_log.h"
> #include "xfs_errortag.h"
> #include "xfs_health.h"
>
> diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c
> index 28e8dcf14475..ab1f81d8bcd2 100644
> --- a/libxfs/xfs_defer.c
> +++ b/libxfs/xfs_defer.c
> @@ -12,10 +12,12 @@
> #include "xfs_mount.h"
> #include "xfs_defer.h"
> #include "xfs_trans.h"
> +#include "xfs_trans_priv.h"
> #include "xfs_buf_item.h"
> #include "xfs_inode.h"
> #include "xfs_inode_item.h"
> #include "xfs_trace.h"
> +#include "xfs_log.h"
> #include "xfs_rmap.h"
> #include "xfs_refcount.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c
> index 54cb8b645c9c..6d70e6b429e7 100644
> --- a/libxfs/xfs_dir2_block.c
> +++ b/libxfs/xfs_dir2_block.c
> @@ -19,6 +19,7 @@
> #include "xfs_dir2_priv.h"
> #include "xfs_error.h"
> #include "xfs_trace.h"
> +#include "xfs_log.h"
> #include "xfs_health.h"
>
> /*
> diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
> index 23625d647da4..aecbab61014c 100644
> --- a/libxfs/xfs_dir2_data.c
> +++ b/libxfs/xfs_dir2_data.c
> @@ -17,6 +17,7 @@
> #include "xfs_error.h"
> #include "xfs_trans.h"
> #include "xfs_buf_item.h"
> +#include "xfs_log.h"
> #include "xfs_health.h"
>
> static xfs_failaddr_t xfs_dir2_data_freefind_verify(
> diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
> index 7641cbdb8e10..19cb536e53ef 100644
> --- a/libxfs/xfs_dir2_node.c
> +++ b/libxfs/xfs_dir2_node.c
> @@ -19,6 +19,7 @@
> #include "xfs_trace.h"
> #include "xfs_trans.h"
> #include "xfs_buf_item.h"
> +#include "xfs_log.h"
> #include "xfs_health.h"
>
> /*
> diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
> index 07f6c0094281..91f4cdf2e4f3 100644
> --- a/libxfs/xfs_ialloc.c
> +++ b/libxfs/xfs_ialloc.c
> @@ -22,6 +22,7 @@
> #include "xfs_trans.h"
> #include "xfs_buf_item.h"
> #include "xfs_trace.h"
> +#include "xfs_log.h"
> #include "xfs_rmap.h"
> #include "xfs_ag.h"
> #include "xfs_health.h"
> diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
> index d4b90548718c..590e0641ff0d 100644
> --- a/libxfs/xfs_rtbitmap.c
> +++ b/libxfs/xfs_rtbitmap.c
> @@ -21,6 +21,7 @@
> #include "xfs_health.h"
> #include "xfs_sb.h"
> #include "xfs_errortag.h"
> +#include "xfs_log.h"
> #include "xfs_buf_item.h"
> #include "xfs_extent_busy.h"
>
> diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
> index 696bafd2cc3e..aae63ccdb6b5 100644
> --- a/libxfs/xfs_sb.c
> +++ b/libxfs/xfs_sb.c
> @@ -19,6 +19,7 @@
> #include "xfs_buf_item.h"
> #include "xfs_bmap_btree.h"
> #include "xfs_alloc_btree.h"
> +#include "xfs_log.h"
> #include "xfs_rmap_btree.h"
> #include "xfs_refcount_btree.h"
> #include "xfs_da_format.h"
> diff --git a/libxfs/xfs_symlink_remote.c b/libxfs/xfs_symlink_remote.c
> index 008953d402f6..b0dc3888bf1b 100644
> --- a/libxfs/xfs_symlink_remote.c
> +++ b/libxfs/xfs_symlink_remote.c
> @@ -15,6 +15,7 @@
> #include "xfs_error.h"
> #include "xfs_trans.h"
> #include "xfs_buf_item.h"
> +#include "xfs_log.h"
> #include "xfs_symlink_remote.h"
> #include "xfs_bit.h"
> #include "xfs_bmap.h"
> diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
> index 697671007561..e3dca0652d26 100644
> --- a/libxfs/xfs_trans_inode.c
> +++ b/libxfs/xfs_trans_inode.c
> @@ -12,6 +12,7 @@
> #include "xfs_mount.h"
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> +#include "xfs_trans_priv.h"
> #include "xfs_inode_item.h"
>
> /*
> diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
> index 5b7660b1cd8a..d15ca0427584 100644
> --- a/libxfs/xfs_trans_resv.c
> +++ b/libxfs/xfs_trans_resv.c
> @@ -19,6 +19,7 @@
> #include "xfs_trans.h"
> #include "xfs_trans_space.h"
> #include "xfs_rtbitmap.h"
> +#include "xfs_log.h"
> #include "xfs_trace.h"
> #include "defer_item.h"
>
> diff --git a/repair/phase2.c b/repair/phase2.c
> index fc96f9c4223c..ee166e62a002 100644
> --- a/repair/phase2.c
> +++ b/repair/phase2.c
> @@ -16,6 +16,7 @@
> #include "scan.h"
> #include "rt.h"
> #include "quotacheck.h"
> +#include "xfs_trans_priv.h"
>
> /* workaround craziness in the xlog routines */
> int xlog_recover_do_trans(struct xlog *log, struct xlog_recover *t, int p)
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (10 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 11/13] libxfs: cleanup xfs_trans.h Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:49 ` Darrick J. Wong
2026-10-05 12:56 ` [PATCH 13/13] libxfs: use all log item headers from the kernel Christoph Hellwig
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Replace the the existing xfs_trans.h with a copy of the kernel versions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/Makefile | 4 +-
libxfs/libxfs_api_defs.h | 1 +
libxfs/stubs/xfs_trans.h | 132 ------------------
libxfs/trans.c | 22 +++
libxfs/xfs_platform.h | 12 --
libxfs/xfs_trans.h | 283 +++++++++++++++++++++++++++++++++++++++
6 files changed, 308 insertions(+), 146 deletions(-)
delete mode 100644 libxfs/stubs/xfs_trans.h
create mode 100644 libxfs/xfs_trans.h
diff --git a/libxfs/Makefile b/libxfs/Makefile
index f64dd596b645..ac7ddac5acec 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -47,6 +47,7 @@ HFILES = \
xfs_cksum.h \
xfs_da_btree.h \
xfs_dir2.h \
+ xfs_dir2_priv.h \
xfs_errortag.h \
xfs_exchmaps.h \
xfs_group.h \
@@ -73,7 +74,7 @@ HFILES = \
xfs_shared.h \
xfs_trans_resv.h \
xfs_trans_space.h \
- xfs_dir2_priv.h \
+ xfs_trans.h \
xfs_zones.h \
stubs/xfs_buf_mem.h \
stubs/xfs_error.h \
@@ -83,7 +84,6 @@ HFILES = \
stubs/xfs_mount.h \
stubs/xfs_quota.h \
stubs/xfs_trace.h \
- stubs/xfs_trans.h \
stubs/xfs_trans_priv.h
CFILES = buf_mem.c \
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 4f542ae7267e..300135fcac8b 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -391,6 +391,7 @@
#define xfs_trans_ordered_buf libxfs_trans_ordered_buf
#define xfs_trans_read_buf libxfs_trans_read_buf
#define xfs_trans_read_buf_map libxfs_trans_read_buf_map
+#define xfs_trans_reserve_more libxfs_trans_reserve_more
#define xfs_trans_resv_calc libxfs_trans_resv_calc
#define xfs_trans_roll_inode libxfs_trans_roll_inode
#define xfs_trans_roll libxfs_trans_roll
diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
deleted file mode 100644
index 2619347df923..000000000000
--- a/libxfs/stubs/xfs_trans.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
-#ifndef __XFS_TRANS_H__
-#define __XFS_TRANS_H__
-
-struct xfs_mount;
-struct xfs_buftarg;
-struct xfs_buf;
-struct xfs_buf_map;
-
-/*
- * Userspace Transaction interface
- */
-
-struct xfs_item_ops {
- uint64_t (*iop_sort)(struct xfs_log_item *lip);
- int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
-};
-
-struct xfs_log_item {
- struct list_head li_trans; /* transaction list */
- xfs_lsn_t li_lsn; /* last on-disk lsn */
- uint li_type; /* item type */
- unsigned long li_flags; /* misc flags */
- struct xfs_buf *li_buf; /* real buffer pointer */
- struct list_head li_bio_list; /* buffer item list */
- const struct xfs_item_ops *li_ops; /* function list */
-};
-
-#define XFS_LI_DIRTY 3 /* log item dirty in transaction */
-
-typedef struct xfs_trans {
- unsigned int t_log_res; /* amt of log space resvd */
- unsigned int t_log_count; /* count for perm log res */
- unsigned int t_blk_res; /* # of blocks resvd */
- unsigned int t_blk_res_used; /* # of resvd blocks used */
- unsigned int t_rtx_res; /* # of rt extents resvd */
- unsigned int t_rtx_res_used; /* # of resvd rt extents used */
- unsigned int t_flags; /* misc flags */
- xfs_agnumber_t t_highest_agno; /* highest AGF locked */
- struct xfs_mount *t_mountp; /* ptr to fs mount struct */
- struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
- long t_icount_delta; /* superblock icount change */
- long t_ifree_delta; /* superblock ifree change */
- long t_fdblocks_delta;/* superblock fdblocks chg */
- long t_frextents_delta;/* superblock freextents chg*/
- struct list_head t_items; /* log item descriptors */
- struct list_head t_dfops; /* deferred operations */
-} xfs_trans_t;
-
-int xfs_trans_roll(struct xfs_trans **);
-
-int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
- uint blocks, uint rtextents, uint flags,
- struct xfs_trans **tpp);
-int libxfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
- unsigned int dblocks, unsigned int rblocks, bool force,
- struct xfs_trans **tpp);
-int libxfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
- struct xfs_inode *ip, unsigned int *dblocks,
- struct xfs_trans **tpp, int *nospace_error);
-struct xfs_trans *libxfs_trans_alloc_empty(struct xfs_mount *mp);
-int libxfs_trans_commit(struct xfs_trans *);
-void libxfs_trans_cancel(struct xfs_trans *);
-int libxfs_trans_reserve_more(struct xfs_trans *tp, uint blocks,
- uint rtextents);
-
-/* cancel dfops associated with a transaction */
-void xfs_defer_cancel(struct xfs_trans *);
-
-struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *);
-struct xfs_buf *libxfs_trans_getrtsb(struct xfs_trans *tp);
-
-void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
-void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *,
- uint);
-int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *);
-
-void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
-void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_bhold_release(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
-void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *,
- uint, uint);
-bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
-
-int libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp,
- struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
- struct xfs_buf **bpp);
-
-int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
- struct xfs_buftarg *btp,
- struct xfs_buf_map *map, int nmaps,
- xfs_buf_flags_t flags, struct xfs_buf **bpp,
- const struct xfs_buf_ops *ops);
-static inline int
-libxfs_trans_get_buf(
- struct xfs_trans *tp,
- struct xfs_buftarg *btp,
- xfs_daddr_t blkno,
- int numblks,
- uint flags,
- struct xfs_buf **bpp)
-{
- DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
-
- return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp);
-}
-
-static inline int
-libxfs_trans_read_buf(
- struct xfs_mount *mp,
- struct xfs_trans *tp,
- struct xfs_buftarg *btp,
- xfs_daddr_t blkno,
- int numblks,
- xfs_buf_flags_t flags,
- struct xfs_buf **bpp,
- const struct xfs_buf_ops *ops)
-{
- DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
-}
-
-#endif /* __XFS_TRANS_H__ */
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 77a2a574809e..25015ad2795c 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -353,6 +353,21 @@ xfs_buf_item_put(
/* from xfs_trans_buf.c */
+void
+xfs_trans_buf_set_type(
+ struct xfs_trans *tp,
+ struct xfs_buf *bp,
+ enum xfs_blft type)
+{
+}
+
+void
+xfs_trans_buf_copy_type(
+ struct xfs_buf *dst_bp,
+ struct xfs_buf *src_bp)
+{
+}
+
/*
* Add the locked buffer to the transaction.
*
@@ -765,6 +780,13 @@ libxfs_trans_binval(
tp->t_flags |= XFS_TRANS_DIRTY;
}
+void
+xfs_trans_inode_buf(
+ struct xfs_trans *tp,
+ struct xfs_buf *bp)
+{
+}
+
/*
* Mark the buffer as being one which contains newly allocated
* inodes. We need to make sure that even if this buffer is
diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
index 4a899dcc6461..4b0069fd70d7 100644
--- a/libxfs/xfs_platform.h
+++ b/libxfs/xfs_platform.h
@@ -314,16 +314,6 @@ xfs_buf_incore(
void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);
#define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address)
-/* mount stuff */
-#define xfs_trans_set_sync(tp) ((void) 0)
-#define xfs_trans_buf_set_type(tp, bp, t) ({ \
- int __t = (t); \
- __t = __t; /* no set-but-unused warning */ \
- tp = tp; /* no set-but-unused warning */ \
-})
-
-#define xfs_trans_buf_copy_type(dbp, sbp)
-
static inline void
xfs_buf_readahead(
struct xfs_buftarg *target,
@@ -357,8 +347,6 @@ xfs_buf_readahead(
#define xfs_filestream_new_ag(ip,ag) (0)
#define xfs_filestream_select_ag(...) (-ENOSYS)
-#define xfs_trans_inode_buf(tp, bp) ((void) 0)
-
#define uuid_copy(s,d) platform_uuid_copy((s),(d))
#define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
diff --git a/libxfs/xfs_trans.h b/libxfs/xfs_trans.h
new file mode 100644
index 000000000000..eb83c5dac032
--- /dev/null
+++ b/libxfs/xfs_trans.h
@@ -0,0 +1,283 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __XFS_TRANS_H__
+#define __XFS_TRANS_H__
+
+/* kernel only transaction subsystem defines */
+
+struct xlog;
+struct xlog_format_buf;
+struct xfs_buf;
+struct xfs_buftarg;
+struct xfs_efd_log_item;
+struct xfs_efi_log_item;
+struct xfs_inode;
+struct xfs_item_ops;
+struct xfs_mount;
+struct xfs_trans;
+struct xfs_trans_res;
+struct xfs_dquot_acct;
+struct xfs_rud_log_item;
+struct xfs_rui_log_item;
+struct xfs_btree_cur;
+struct xfs_cui_log_item;
+struct xfs_cud_log_item;
+struct xfs_bui_log_item;
+struct xfs_bud_log_item;
+
+struct xfs_log_item {
+ struct list_head li_ail; /* AIL pointers */
+ struct list_head li_trans; /* transaction list */
+ xfs_lsn_t li_lsn; /* last on-disk lsn */
+ struct xlog *li_log;
+ struct xfs_ail *li_ailp; /* ptr to AIL */
+ uint li_type; /* item type */
+ unsigned long li_flags; /* misc flags */
+ struct xfs_buf *li_buf; /* real buffer pointer */
+ struct list_head li_bio_list; /* buffer item list */
+ const struct xfs_item_ops *li_ops; /* function list */
+
+ /* delayed logging */
+ struct list_head li_cil; /* CIL pointers */
+ struct xfs_log_vec *li_lv; /* active log vector */
+ struct xfs_log_vec *li_lv_shadow; /* standby vector */
+ xfs_csn_t li_seq; /* CIL commit seq */
+ uint32_t li_order_id; /* CIL commit order */
+};
+
+/*
+ * li_flags use the (set/test/clear)_bit atomic interfaces because updates can
+ * race with each other and we don't want to have to use the AIL lock to
+ * serialise all updates.
+ */
+#define XFS_LI_IN_AIL 0
+#define XFS_LI_ABORTED 1
+#define XFS_LI_FAILED 2
+#define XFS_LI_DIRTY 3
+#define XFS_LI_WHITEOUT 4
+#define XFS_LI_FLUSHING 5
+
+#define XFS_LI_FLAGS \
+ { (1u << XFS_LI_IN_AIL), "IN_AIL" }, \
+ { (1u << XFS_LI_ABORTED), "ABORTED" }, \
+ { (1u << XFS_LI_FAILED), "FAILED" }, \
+ { (1u << XFS_LI_DIRTY), "DIRTY" }, \
+ { (1u << XFS_LI_WHITEOUT), "WHITEOUT" }, \
+ { (1u << XFS_LI_FLUSHING), "FLUSHING" }
+
+struct xfs_item_ops {
+ unsigned flags;
+ void (*iop_size)(struct xfs_log_item *, int *, int *);
+ void (*iop_format)(struct xfs_log_item *lip,
+ struct xlog_format_buf *lfb);
+ void (*iop_pin)(struct xfs_log_item *);
+ void (*iop_unpin)(struct xfs_log_item *, int remove);
+ uint64_t (*iop_sort)(struct xfs_log_item *lip);
+ int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
+ void (*iop_committing)(struct xfs_log_item *lip, xfs_csn_t seq);
+ xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
+ uint (*iop_push)(struct xfs_log_item *, struct list_head *);
+ void (*iop_release)(struct xfs_log_item *);
+ bool (*iop_match)(struct xfs_log_item *item, uint64_t id);
+ struct xfs_log_item *(*iop_intent)(struct xfs_log_item *intent_done);
+};
+
+/*
+ * Log item ops flags
+ */
+/*
+ * Release the log item when the journal commits instead of inserting into the
+ * AIL for writeback tracking and/or log tail pinning.
+ */
+#define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0)
+#define XFS_ITEM_INTENT (1 << 1)
+#define XFS_ITEM_INTENT_DONE (1 << 2)
+
+static inline bool
+xlog_item_is_intent(struct xfs_log_item *lip)
+{
+ return lip->li_ops->flags & XFS_ITEM_INTENT;
+}
+
+static inline bool
+xlog_item_is_intent_done(struct xfs_log_item *lip)
+{
+ return lip->li_ops->flags & XFS_ITEM_INTENT_DONE;
+}
+
+void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
+ int type, const struct xfs_item_ops *ops);
+
+/*
+ * Return values for the iop_push() routines.
+ */
+#define XFS_ITEM_SUCCESS 0
+#define XFS_ITEM_PINNED 1
+#define XFS_ITEM_LOCKED 2
+#define XFS_ITEM_FLUSHING 3
+
+/*
+ * This is the structure maintained for every active transaction.
+ */
+typedef struct xfs_trans {
+ unsigned int t_log_res; /* amt of log space resvd */
+ unsigned int t_log_count; /* count for perm log res */
+ unsigned int t_blk_res; /* # of blocks resvd */
+ unsigned int t_blk_res_used; /* # of resvd blocks used */
+ unsigned int t_rtx_res; /* # of rt extents resvd */
+ unsigned int t_rtx_res_used; /* # of resvd rt extents used */
+ unsigned int t_flags; /* misc flags */
+ xfs_agnumber_t t_highest_agno; /* highest AGF locked */
+ struct xlog_ticket *t_ticket; /* log mgr ticket */
+ struct xfs_mount *t_mountp; /* ptr to fs mount struct */
+ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
+ int64_t t_icount_delta; /* superblock icount change */
+ int64_t t_ifree_delta; /* superblock ifree change */
+ int64_t t_fdblocks_delta; /* superblock fdblocks chg */
+ int64_t t_res_fdblocks_delta; /* on-disk only chg */
+ int64_t t_frextents_delta;/* superblock freextents chg*/
+ int64_t t_res_frextents_delta; /* on-disk only chg */
+ int64_t t_dblocks_delta;/* superblock dblocks change */
+ int64_t t_agcount_delta;/* superblock agcount change */
+ int64_t t_imaxpct_delta;/* superblock imaxpct change */
+ int64_t t_rextsize_delta;/* superblock rextsize chg */
+ int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
+ int64_t t_rblocks_delta;/* superblock rblocks change */
+ int64_t t_rextents_delta;/* superblocks rextents chg */
+ int64_t t_rextslog_delta;/* superblocks rextslog chg */
+ int64_t t_rgcount_delta; /* realtime group count */
+ struct list_head t_items; /* log item descriptors */
+ struct list_head t_busy; /* list of busy extents */
+ struct list_head t_dfops; /* deferred operations */
+ unsigned long t_pflags; /* saved process flags state */
+} xfs_trans_t;
+
+/*
+ * XFS transaction mechanism exported interfaces that are
+ * actually macros.
+ */
+#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
+
+/*
+ * XFS transaction mechanism exported interfaces.
+ */
+int xfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
+ uint blocks, uint rtextents, uint flags,
+ struct xfs_trans **tpp);
+int xfs_trans_reserve_more(struct xfs_trans *tp,
+ unsigned int blocks, unsigned int rtextents);
+struct xfs_trans *xfs_trans_alloc_empty(struct xfs_mount *mp);
+void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
+
+int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
+ struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
+ struct xfs_buf **bpp);
+
+static inline int
+xfs_trans_get_buf(
+ struct xfs_trans *tp,
+ struct xfs_buftarg *target,
+ xfs_daddr_t blkno,
+ int numblks,
+ xfs_buf_flags_t flags,
+ struct xfs_buf **bpp)
+{
+ DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
+ return xfs_trans_get_buf_map(tp, target, &map, 1, flags, bpp);
+}
+
+int xfs_trans_read_buf_map(struct xfs_mount *mp,
+ struct xfs_trans *tp,
+ struct xfs_buftarg *target,
+ struct xfs_buf_map *map, int nmaps,
+ xfs_buf_flags_t flags,
+ struct xfs_buf **bpp,
+ const struct xfs_buf_ops *ops);
+
+static inline int
+xfs_trans_read_buf(
+ struct xfs_mount *mp,
+ struct xfs_trans *tp,
+ struct xfs_buftarg *target,
+ xfs_daddr_t blkno,
+ int numblks,
+ xfs_buf_flags_t flags,
+ struct xfs_buf **bpp,
+ const struct xfs_buf_ops *ops)
+{
+ DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
+ return xfs_trans_read_buf_map(mp, tp, target, &map, 1,
+ flags, bpp, ops);
+}
+
+struct xfs_buf *xfs_trans_getsb(struct xfs_trans *);
+struct xfs_buf *xfs_trans_getrtsb(struct xfs_trans *tp);
+
+void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
+void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);
+bool xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
+void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
+void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
+void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint,
+ uint);
+void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
+bool xfs_trans_buf_is_dirty(struct xfs_buf *bp);
+void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
+
+int xfs_trans_commit(struct xfs_trans *);
+int xfs_trans_roll(struct xfs_trans **);
+int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *);
+void xfs_trans_cancel(xfs_trans_t *);
+int xfs_trans_ail_init(struct xfs_mount *);
+void xfs_trans_ail_destroy(struct xfs_mount *);
+
+void xfs_trans_buf_set_type(struct xfs_trans *, struct xfs_buf *,
+ enum xfs_blft);
+void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
+ struct xfs_buf *src_bp);
+
+extern struct kmem_cache *xfs_trans_cache;
+
+struct xfs_dquot;
+
+int xfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
+ unsigned int dblocks, unsigned int rblocks, bool force,
+ struct xfs_trans **tpp);
+int xfs_trans_reserve_more_inode(struct xfs_trans *tp, struct xfs_inode *ip,
+ unsigned int dblocks, unsigned int rblocks, bool force_quota);
+int xfs_trans_alloc_icreate(struct xfs_mount *mp, struct xfs_trans_res *resv,
+ struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
+ struct xfs_dquot *pdqp, unsigned int dblocks,
+ struct xfs_trans **tpp);
+int xfs_trans_alloc_ichange(struct xfs_inode *ip, struct xfs_dquot *udqp,
+ struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, bool force,
+ struct xfs_trans **tpp);
+int xfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
+ struct xfs_inode *ip, unsigned int *dblocks,
+ struct xfs_trans **tpp, int *nospace_error);
+
+static inline void
+xfs_trans_set_context(
+ struct xfs_trans *tp)
+{
+ tp->t_pflags = memalloc_nofs_save();
+}
+
+static inline void
+xfs_trans_clear_context(
+ struct xfs_trans *tp)
+{
+ memalloc_nofs_restore(tp->t_pflags);
+}
+
+#endif /* __XFS_TRANS_H__ */
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source
2026-10-05 12:56 ` [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source Christoph Hellwig
@ 2026-10-05 21:49 ` Darrick J. Wong
2026-10-07 13:41 ` Christoph Hellwig
0 siblings, 1 reply; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:49 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:22PM +0200, Christoph Hellwig wrote:
> Replace the the existing xfs_trans.h with a copy of the kernel versions.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Much nicer to have the same header, though I wonder if we ought some day
to move the kernel xfs_trans.h into libxfs/ ?
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> libxfs/Makefile | 4 +-
> libxfs/libxfs_api_defs.h | 1 +
> libxfs/stubs/xfs_trans.h | 132 ------------------
> libxfs/trans.c | 22 +++
> libxfs/xfs_platform.h | 12 --
> libxfs/xfs_trans.h | 283 +++++++++++++++++++++++++++++++++++++++
> 6 files changed, 308 insertions(+), 146 deletions(-)
> delete mode 100644 libxfs/stubs/xfs_trans.h
> create mode 100644 libxfs/xfs_trans.h
>
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index f64dd596b645..ac7ddac5acec 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -47,6 +47,7 @@ HFILES = \
> xfs_cksum.h \
> xfs_da_btree.h \
> xfs_dir2.h \
> + xfs_dir2_priv.h \
> xfs_errortag.h \
> xfs_exchmaps.h \
> xfs_group.h \
> @@ -73,7 +74,7 @@ HFILES = \
> xfs_shared.h \
> xfs_trans_resv.h \
> xfs_trans_space.h \
> - xfs_dir2_priv.h \
> + xfs_trans.h \
> xfs_zones.h \
> stubs/xfs_buf_mem.h \
> stubs/xfs_error.h \
> @@ -83,7 +84,6 @@ HFILES = \
> stubs/xfs_mount.h \
> stubs/xfs_quota.h \
> stubs/xfs_trace.h \
> - stubs/xfs_trans.h \
> stubs/xfs_trans_priv.h
>
> CFILES = buf_mem.c \
> diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> index 4f542ae7267e..300135fcac8b 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -391,6 +391,7 @@
> #define xfs_trans_ordered_buf libxfs_trans_ordered_buf
> #define xfs_trans_read_buf libxfs_trans_read_buf
> #define xfs_trans_read_buf_map libxfs_trans_read_buf_map
> +#define xfs_trans_reserve_more libxfs_trans_reserve_more
> #define xfs_trans_resv_calc libxfs_trans_resv_calc
> #define xfs_trans_roll_inode libxfs_trans_roll_inode
> #define xfs_trans_roll libxfs_trans_roll
> diff --git a/libxfs/stubs/xfs_trans.h b/libxfs/stubs/xfs_trans.h
> deleted file mode 100644
> index 2619347df923..000000000000
> --- a/libxfs/stubs/xfs_trans.h
> +++ /dev/null
> @@ -1,132 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Copyright (c) 2000-2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - */
> -
> -#ifndef __XFS_TRANS_H__
> -#define __XFS_TRANS_H__
> -
> -struct xfs_mount;
> -struct xfs_buftarg;
> -struct xfs_buf;
> -struct xfs_buf_map;
> -
> -/*
> - * Userspace Transaction interface
> - */
> -
> -struct xfs_item_ops {
> - uint64_t (*iop_sort)(struct xfs_log_item *lip);
> - int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
> -};
> -
> -struct xfs_log_item {
> - struct list_head li_trans; /* transaction list */
> - xfs_lsn_t li_lsn; /* last on-disk lsn */
> - uint li_type; /* item type */
> - unsigned long li_flags; /* misc flags */
> - struct xfs_buf *li_buf; /* real buffer pointer */
> - struct list_head li_bio_list; /* buffer item list */
> - const struct xfs_item_ops *li_ops; /* function list */
> -};
> -
> -#define XFS_LI_DIRTY 3 /* log item dirty in transaction */
> -
> -typedef struct xfs_trans {
> - unsigned int t_log_res; /* amt of log space resvd */
> - unsigned int t_log_count; /* count for perm log res */
> - unsigned int t_blk_res; /* # of blocks resvd */
> - unsigned int t_blk_res_used; /* # of resvd blocks used */
> - unsigned int t_rtx_res; /* # of rt extents resvd */
> - unsigned int t_rtx_res_used; /* # of resvd rt extents used */
> - unsigned int t_flags; /* misc flags */
> - xfs_agnumber_t t_highest_agno; /* highest AGF locked */
> - struct xfs_mount *t_mountp; /* ptr to fs mount struct */
> - struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
> - long t_icount_delta; /* superblock icount change */
> - long t_ifree_delta; /* superblock ifree change */
> - long t_fdblocks_delta;/* superblock fdblocks chg */
> - long t_frextents_delta;/* superblock freextents chg*/
> - struct list_head t_items; /* log item descriptors */
> - struct list_head t_dfops; /* deferred operations */
> -} xfs_trans_t;
> -
> -int xfs_trans_roll(struct xfs_trans **);
> -
> -int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
> - uint blocks, uint rtextents, uint flags,
> - struct xfs_trans **tpp);
> -int libxfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
> - unsigned int dblocks, unsigned int rblocks, bool force,
> - struct xfs_trans **tpp);
> -int libxfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
> - struct xfs_inode *ip, unsigned int *dblocks,
> - struct xfs_trans **tpp, int *nospace_error);
> -struct xfs_trans *libxfs_trans_alloc_empty(struct xfs_mount *mp);
> -int libxfs_trans_commit(struct xfs_trans *);
> -void libxfs_trans_cancel(struct xfs_trans *);
> -int libxfs_trans_reserve_more(struct xfs_trans *tp, uint blocks,
> - uint rtextents);
> -
> -/* cancel dfops associated with a transaction */
> -void xfs_defer_cancel(struct xfs_trans *);
> -
> -struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *);
> -struct xfs_buf *libxfs_trans_getrtsb(struct xfs_trans *tp);
> -
> -void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
> -void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *,
> - uint);
> -int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *);
> -
> -void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
> -void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_bhold_release(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
> -void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *,
> - uint, uint);
> -bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
> -
> -int libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp,
> - struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
> - struct xfs_buf **bpp);
> -
> -int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
> - struct xfs_buftarg *btp,
> - struct xfs_buf_map *map, int nmaps,
> - xfs_buf_flags_t flags, struct xfs_buf **bpp,
> - const struct xfs_buf_ops *ops);
> -static inline int
> -libxfs_trans_get_buf(
> - struct xfs_trans *tp,
> - struct xfs_buftarg *btp,
> - xfs_daddr_t blkno,
> - int numblks,
> - uint flags,
> - struct xfs_buf **bpp)
> -{
> - DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
> -
> - return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp);
> -}
> -
> -static inline int
> -libxfs_trans_read_buf(
> - struct xfs_mount *mp,
> - struct xfs_trans *tp,
> - struct xfs_buftarg *btp,
> - xfs_daddr_t blkno,
> - int numblks,
> - xfs_buf_flags_t flags,
> - struct xfs_buf **bpp,
> - const struct xfs_buf_ops *ops)
> -{
> - DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
> - return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
> -}
> -
> -#endif /* __XFS_TRANS_H__ */
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index 77a2a574809e..25015ad2795c 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -353,6 +353,21 @@ xfs_buf_item_put(
>
> /* from xfs_trans_buf.c */
>
> +void
> +xfs_trans_buf_set_type(
> + struct xfs_trans *tp,
> + struct xfs_buf *bp,
> + enum xfs_blft type)
> +{
> +}
> +
> +void
> +xfs_trans_buf_copy_type(
> + struct xfs_buf *dst_bp,
> + struct xfs_buf *src_bp)
> +{
> +}
> +
> /*
> * Add the locked buffer to the transaction.
> *
> @@ -765,6 +780,13 @@ libxfs_trans_binval(
> tp->t_flags |= XFS_TRANS_DIRTY;
> }
>
> +void
> +xfs_trans_inode_buf(
> + struct xfs_trans *tp,
> + struct xfs_buf *bp)
> +{
> +}
> +
> /*
> * Mark the buffer as being one which contains newly allocated
> * inodes. We need to make sure that even if this buffer is
> diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
> index 4a899dcc6461..4b0069fd70d7 100644
> --- a/libxfs/xfs_platform.h
> +++ b/libxfs/xfs_platform.h
> @@ -314,16 +314,6 @@ xfs_buf_incore(
> void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);
> #define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address)
>
> -/* mount stuff */
> -#define xfs_trans_set_sync(tp) ((void) 0)
> -#define xfs_trans_buf_set_type(tp, bp, t) ({ \
> - int __t = (t); \
> - __t = __t; /* no set-but-unused warning */ \
> - tp = tp; /* no set-but-unused warning */ \
> -})
> -
> -#define xfs_trans_buf_copy_type(dbp, sbp)
> -
> static inline void
> xfs_buf_readahead(
> struct xfs_buftarg *target,
> @@ -357,8 +347,6 @@ xfs_buf_readahead(
> #define xfs_filestream_new_ag(ip,ag) (0)
> #define xfs_filestream_select_ag(...) (-ENOSYS)
>
> -#define xfs_trans_inode_buf(tp, bp) ((void) 0)
> -
> #define uuid_copy(s,d) platform_uuid_copy((s),(d))
> #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
>
> diff --git a/libxfs/xfs_trans.h b/libxfs/xfs_trans.h
> new file mode 100644
> index 000000000000..eb83c5dac032
> --- /dev/null
> +++ b/libxfs/xfs_trans.h
> @@ -0,0 +1,283 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + */
> +#ifndef __XFS_TRANS_H__
> +#define __XFS_TRANS_H__
> +
> +/* kernel only transaction subsystem defines */
> +
> +struct xlog;
> +struct xlog_format_buf;
> +struct xfs_buf;
> +struct xfs_buftarg;
> +struct xfs_efd_log_item;
> +struct xfs_efi_log_item;
> +struct xfs_inode;
> +struct xfs_item_ops;
> +struct xfs_mount;
> +struct xfs_trans;
> +struct xfs_trans_res;
> +struct xfs_dquot_acct;
> +struct xfs_rud_log_item;
> +struct xfs_rui_log_item;
> +struct xfs_btree_cur;
> +struct xfs_cui_log_item;
> +struct xfs_cud_log_item;
> +struct xfs_bui_log_item;
> +struct xfs_bud_log_item;
> +
> +struct xfs_log_item {
> + struct list_head li_ail; /* AIL pointers */
> + struct list_head li_trans; /* transaction list */
> + xfs_lsn_t li_lsn; /* last on-disk lsn */
> + struct xlog *li_log;
> + struct xfs_ail *li_ailp; /* ptr to AIL */
> + uint li_type; /* item type */
> + unsigned long li_flags; /* misc flags */
> + struct xfs_buf *li_buf; /* real buffer pointer */
> + struct list_head li_bio_list; /* buffer item list */
> + const struct xfs_item_ops *li_ops; /* function list */
> +
> + /* delayed logging */
> + struct list_head li_cil; /* CIL pointers */
> + struct xfs_log_vec *li_lv; /* active log vector */
> + struct xfs_log_vec *li_lv_shadow; /* standby vector */
> + xfs_csn_t li_seq; /* CIL commit seq */
> + uint32_t li_order_id; /* CIL commit order */
> +};
> +
> +/*
> + * li_flags use the (set/test/clear)_bit atomic interfaces because updates can
> + * race with each other and we don't want to have to use the AIL lock to
> + * serialise all updates.
> + */
> +#define XFS_LI_IN_AIL 0
> +#define XFS_LI_ABORTED 1
> +#define XFS_LI_FAILED 2
> +#define XFS_LI_DIRTY 3
> +#define XFS_LI_WHITEOUT 4
> +#define XFS_LI_FLUSHING 5
> +
> +#define XFS_LI_FLAGS \
> + { (1u << XFS_LI_IN_AIL), "IN_AIL" }, \
> + { (1u << XFS_LI_ABORTED), "ABORTED" }, \
> + { (1u << XFS_LI_FAILED), "FAILED" }, \
> + { (1u << XFS_LI_DIRTY), "DIRTY" }, \
> + { (1u << XFS_LI_WHITEOUT), "WHITEOUT" }, \
> + { (1u << XFS_LI_FLUSHING), "FLUSHING" }
> +
> +struct xfs_item_ops {
> + unsigned flags;
> + void (*iop_size)(struct xfs_log_item *, int *, int *);
> + void (*iop_format)(struct xfs_log_item *lip,
> + struct xlog_format_buf *lfb);
> + void (*iop_pin)(struct xfs_log_item *);
> + void (*iop_unpin)(struct xfs_log_item *, int remove);
> + uint64_t (*iop_sort)(struct xfs_log_item *lip);
> + int (*iop_precommit)(struct xfs_trans *tp, struct xfs_log_item *lip);
> + void (*iop_committing)(struct xfs_log_item *lip, xfs_csn_t seq);
> + xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
> + uint (*iop_push)(struct xfs_log_item *, struct list_head *);
> + void (*iop_release)(struct xfs_log_item *);
> + bool (*iop_match)(struct xfs_log_item *item, uint64_t id);
> + struct xfs_log_item *(*iop_intent)(struct xfs_log_item *intent_done);
> +};
> +
> +/*
> + * Log item ops flags
> + */
> +/*
> + * Release the log item when the journal commits instead of inserting into the
> + * AIL for writeback tracking and/or log tail pinning.
> + */
> +#define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0)
> +#define XFS_ITEM_INTENT (1 << 1)
> +#define XFS_ITEM_INTENT_DONE (1 << 2)
> +
> +static inline bool
> +xlog_item_is_intent(struct xfs_log_item *lip)
> +{
> + return lip->li_ops->flags & XFS_ITEM_INTENT;
> +}
> +
> +static inline bool
> +xlog_item_is_intent_done(struct xfs_log_item *lip)
> +{
> + return lip->li_ops->flags & XFS_ITEM_INTENT_DONE;
> +}
> +
> +void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
> + int type, const struct xfs_item_ops *ops);
> +
> +/*
> + * Return values for the iop_push() routines.
> + */
> +#define XFS_ITEM_SUCCESS 0
> +#define XFS_ITEM_PINNED 1
> +#define XFS_ITEM_LOCKED 2
> +#define XFS_ITEM_FLUSHING 3
> +
> +/*
> + * This is the structure maintained for every active transaction.
> + */
> +typedef struct xfs_trans {
> + unsigned int t_log_res; /* amt of log space resvd */
> + unsigned int t_log_count; /* count for perm log res */
> + unsigned int t_blk_res; /* # of blocks resvd */
> + unsigned int t_blk_res_used; /* # of resvd blocks used */
> + unsigned int t_rtx_res; /* # of rt extents resvd */
> + unsigned int t_rtx_res_used; /* # of resvd rt extents used */
> + unsigned int t_flags; /* misc flags */
> + xfs_agnumber_t t_highest_agno; /* highest AGF locked */
> + struct xlog_ticket *t_ticket; /* log mgr ticket */
> + struct xfs_mount *t_mountp; /* ptr to fs mount struct */
> + struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
> + int64_t t_icount_delta; /* superblock icount change */
> + int64_t t_ifree_delta; /* superblock ifree change */
> + int64_t t_fdblocks_delta; /* superblock fdblocks chg */
> + int64_t t_res_fdblocks_delta; /* on-disk only chg */
> + int64_t t_frextents_delta;/* superblock freextents chg*/
> + int64_t t_res_frextents_delta; /* on-disk only chg */
> + int64_t t_dblocks_delta;/* superblock dblocks change */
> + int64_t t_agcount_delta;/* superblock agcount change */
> + int64_t t_imaxpct_delta;/* superblock imaxpct change */
> + int64_t t_rextsize_delta;/* superblock rextsize chg */
> + int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
> + int64_t t_rblocks_delta;/* superblock rblocks change */
> + int64_t t_rextents_delta;/* superblocks rextents chg */
> + int64_t t_rextslog_delta;/* superblocks rextslog chg */
> + int64_t t_rgcount_delta; /* realtime group count */
> + struct list_head t_items; /* log item descriptors */
> + struct list_head t_busy; /* list of busy extents */
> + struct list_head t_dfops; /* deferred operations */
> + unsigned long t_pflags; /* saved process flags state */
> +} xfs_trans_t;
> +
> +/*
> + * XFS transaction mechanism exported interfaces that are
> + * actually macros.
> + */
> +#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
> +
> +/*
> + * XFS transaction mechanism exported interfaces.
> + */
> +int xfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
> + uint blocks, uint rtextents, uint flags,
> + struct xfs_trans **tpp);
> +int xfs_trans_reserve_more(struct xfs_trans *tp,
> + unsigned int blocks, unsigned int rtextents);
> +struct xfs_trans *xfs_trans_alloc_empty(struct xfs_mount *mp);
> +void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
> +
> +int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
> + struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
> + struct xfs_buf **bpp);
> +
> +static inline int
> +xfs_trans_get_buf(
> + struct xfs_trans *tp,
> + struct xfs_buftarg *target,
> + xfs_daddr_t blkno,
> + int numblks,
> + xfs_buf_flags_t flags,
> + struct xfs_buf **bpp)
> +{
> + DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
> + return xfs_trans_get_buf_map(tp, target, &map, 1, flags, bpp);
> +}
> +
> +int xfs_trans_read_buf_map(struct xfs_mount *mp,
> + struct xfs_trans *tp,
> + struct xfs_buftarg *target,
> + struct xfs_buf_map *map, int nmaps,
> + xfs_buf_flags_t flags,
> + struct xfs_buf **bpp,
> + const struct xfs_buf_ops *ops);
> +
> +static inline int
> +xfs_trans_read_buf(
> + struct xfs_mount *mp,
> + struct xfs_trans *tp,
> + struct xfs_buftarg *target,
> + xfs_daddr_t blkno,
> + int numblks,
> + xfs_buf_flags_t flags,
> + struct xfs_buf **bpp,
> + const struct xfs_buf_ops *ops)
> +{
> + DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
> + return xfs_trans_read_buf_map(mp, tp, target, &map, 1,
> + flags, bpp, ops);
> +}
> +
> +struct xfs_buf *xfs_trans_getsb(struct xfs_trans *);
> +struct xfs_buf *xfs_trans_getrtsb(struct xfs_trans *tp);
> +
> +void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
> +void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);
> +bool xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
> +void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
> +void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
> +void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint,
> + uint);
> +void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
> +bool xfs_trans_buf_is_dirty(struct xfs_buf *bp);
> +void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
> +
> +int xfs_trans_commit(struct xfs_trans *);
> +int xfs_trans_roll(struct xfs_trans **);
> +int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *);
> +void xfs_trans_cancel(xfs_trans_t *);
> +int xfs_trans_ail_init(struct xfs_mount *);
> +void xfs_trans_ail_destroy(struct xfs_mount *);
> +
> +void xfs_trans_buf_set_type(struct xfs_trans *, struct xfs_buf *,
> + enum xfs_blft);
> +void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
> + struct xfs_buf *src_bp);
> +
> +extern struct kmem_cache *xfs_trans_cache;
> +
> +struct xfs_dquot;
> +
> +int xfs_trans_alloc_inode(struct xfs_inode *ip, struct xfs_trans_res *resv,
> + unsigned int dblocks, unsigned int rblocks, bool force,
> + struct xfs_trans **tpp);
> +int xfs_trans_reserve_more_inode(struct xfs_trans *tp, struct xfs_inode *ip,
> + unsigned int dblocks, unsigned int rblocks, bool force_quota);
> +int xfs_trans_alloc_icreate(struct xfs_mount *mp, struct xfs_trans_res *resv,
> + struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
> + struct xfs_dquot *pdqp, unsigned int dblocks,
> + struct xfs_trans **tpp);
> +int xfs_trans_alloc_ichange(struct xfs_inode *ip, struct xfs_dquot *udqp,
> + struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, bool force,
> + struct xfs_trans **tpp);
> +int xfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv,
> + struct xfs_inode *ip, unsigned int *dblocks,
> + struct xfs_trans **tpp, int *nospace_error);
> +
> +static inline void
> +xfs_trans_set_context(
> + struct xfs_trans *tp)
> +{
> + tp->t_pflags = memalloc_nofs_save();
> +}
> +
> +static inline void
> +xfs_trans_clear_context(
> + struct xfs_trans *tp)
> +{
> + memalloc_nofs_restore(tp->t_pflags);
> +}
> +
> +#endif /* __XFS_TRANS_H__ */
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source
2026-10-05 21:49 ` Darrick J. Wong
@ 2026-10-07 13:41 ` Christoph Hellwig
2026-10-07 15:18 ` Darrick J. Wong
2026-10-08 10:59 ` Carlos Maiolino
0 siblings, 2 replies; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-07 13:41 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Christoph Hellwig, Andrey Albershteyn, Eric Sandeen,
Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:49:39PM -0700, Darrick J. Wong wrote:
> On Mon, Oct 05, 2026 at 02:56:22PM +0200, Christoph Hellwig wrote:
> > Replace the the existing xfs_trans.h with a copy of the kernel versions.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Much nicer to have the same header, though I wonder if we ought some day
> to move the kernel xfs_trans.h into libxfs/ ?
That's what the:
small cleanups to help code sharing with xfsprogs
kernel series sent on Sep 25th does. It got your reviews, so maybe it's
time to just merge it.
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source
2026-10-07 13:41 ` Christoph Hellwig
@ 2026-10-07 15:18 ` Darrick J. Wong
2026-10-08 10:59 ` Carlos Maiolino
1 sibling, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-07 15:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Wed, Oct 07, 2026 at 03:41:05PM +0200, Christoph Hellwig wrote:
> On Mon, Oct 05, 2026 at 02:49:39PM -0700, Darrick J. Wong wrote:
> > On Mon, Oct 05, 2026 at 02:56:22PM +0200, Christoph Hellwig wrote:
> > > Replace the the existing xfs_trans.h with a copy of the kernel versions.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > Much nicer to have the same header, though I wonder if we ought some day
> > to move the kernel xfs_trans.h into libxfs/ ?
>
> That's what the:
>
> small cleanups to help code sharing with xfsprogs
>
> kernel series sent on Sep 25th does. It got your reviews, so maybe it's
> time to just merge it.
Yeah, I can't keep all your patches and all my patches in my context
window. ;(
--D
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source
2026-10-07 13:41 ` Christoph Hellwig
2026-10-07 15:18 ` Darrick J. Wong
@ 2026-10-08 10:59 ` Carlos Maiolino
1 sibling, 0 replies; 31+ messages in thread
From: Carlos Maiolino @ 2026-10-08 10:59 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Darrick J. Wong, Andrey Albershteyn, Eric Sandeen, linux-xfs
On Wed, Oct 07, 2026 at 03:41:05PM +0200, Christoph Hellwig wrote:
> On Mon, Oct 05, 2026 at 02:49:39PM -0700, Darrick J. Wong wrote:
> > On Mon, Oct 05, 2026 at 02:56:22PM +0200, Christoph Hellwig wrote:
> > > Replace the the existing xfs_trans.h with a copy of the kernel versions.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > Much nicer to have the same header, though I wonder if we ought some day
> > to move the kernel xfs_trans.h into libxfs/ ?
>
> That's what the:
>
> small cleanups to help code sharing with xfsprogs
>
> kernel series sent on Sep 25th does. It got your reviews, so maybe it's
> time to just merge it.
>
>
It's going on the next batch, now I'm finally back home I can get back
to my backlog :)
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 13/13] libxfs: use all log item headers from the kernel
2026-10-05 12:56 reduce libxfs to kernel differences v2 Christoph Hellwig
` (11 preceding siblings ...)
2026-10-05 12:56 ` [PATCH 12/13] libxfs: use xfs_trans.h from the kernel source Christoph Hellwig
@ 2026-10-05 12:56 ` Christoph Hellwig
2026-10-05 21:50 ` Darrick J. Wong
12 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2026-10-05 12:56 UTC (permalink / raw)
To: Andrey Albershteyn
Cc: Darrick J . Wong , Eric Sandeen, Carlos Maiolino, linux-xfs
Wire up all the xfs_*_item.h headers from the kernel instead of
duplicating the definitions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
db/logformat.c | 4 +
include/atomic.h | 1 +
include/libxfs.h | 1 -
libxfs/Makefile | 10 ++-
libxfs/defer_item.c | 3 +-
libxfs/defer_item.h | 56 -------------
libxfs/iunlink.c | 10 +--
libxfs/stubs/xfs_inode.h | 8 ++
libxfs/trans.c | 12 +++
libxfs/xfs_alloc.c | 2 +-
libxfs/xfs_attr.c | 2 +-
libxfs/xfs_attr_item.h | 64 +++++++++++++++
libxfs/xfs_bmap.c | 2 +-
libxfs/xfs_bmap_item.h | 78 ++++++++++++++++++
libxfs/xfs_exchmaps.c | 2 +-
libxfs/xfs_exchmaps_item.h | 64 +++++++++++++++
libxfs/xfs_extfree_item.h | 100 +++++++++++++++++++++++
libxfs/xfs_ialloc.c | 1 +
libxfs/xfs_icreate_item.h | 22 +++++
libxfs/xfs_inode_util.c | 3 +-
libxfs/{iunlink.h => xfs_iunlink_item.h} | 17 ++--
libxfs/xfs_parent.c | 2 +-
libxfs/xfs_platform.h | 1 -
libxfs/xfs_refcount.c | 2 +-
libxfs/xfs_refcount_item.h | 82 +++++++++++++++++++
libxfs/xfs_rmap.c | 2 +-
libxfs/xfs_rmap_item.h | 81 ++++++++++++++++++
libxfs/xfs_trans_resv.c | 7 +-
28 files changed, 551 insertions(+), 88 deletions(-)
delete mode 100644 libxfs/defer_item.h
create mode 100644 libxfs/xfs_attr_item.h
create mode 100644 libxfs/xfs_bmap_item.h
create mode 100644 libxfs/xfs_exchmaps_item.h
create mode 100644 libxfs/xfs_extfree_item.h
create mode 100644 libxfs/xfs_icreate_item.h
rename libxfs/{iunlink.h => xfs_iunlink_item.h} (61%)
create mode 100644 libxfs/xfs_refcount_item.h
create mode 100644 libxfs/xfs_rmap_item.h
diff --git a/db/logformat.c b/db/logformat.c
index aba5b0b1b050..5d3d818d5575 100644
--- a/db/logformat.c
+++ b/db/logformat.c
@@ -10,6 +10,10 @@
#include "output.h"
#include "libxlog.h"
#include "logformat.h"
+#include "xfs_extfree_item.h"
+#include "xfs_bmap_item.h"
+#include "xfs_rmap_item.h"
+#include "xfs_refcount_item.h"
#define MAX_LSUNIT 256 * 1024 /* max log buf. size */
diff --git a/include/atomic.h b/include/atomic.h
index 3b7eabd0faa7..ee2161fdf9cc 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -18,6 +18,7 @@
#include <urcu/uatomic.h>
#include "spinlock.h"
+typedef int32_t refcount_t;
typedef int32_t atomic_t;
typedef int64_t atomic64_t;
diff --git a/include/libxfs.h b/include/libxfs.h
index 549176cf0b2c..e28b79d80143 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -105,7 +105,6 @@ struct iomap;
#include "xfs_rtbitmap.h"
#include "xfs_rtrmap_btree.h"
#include "xfs_ag_resv.h"
-#include "defer_item.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
diff --git a/libxfs/Makefile b/libxfs/Makefile
index ac7ddac5acec..df11c119c465 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -20,12 +20,10 @@ PKGHFILES = xfs_fs.h \
xfs_log_format.h
HFILES = \
- defer_item.h \
libxfs_io.h \
libxfs_api_defs.h \
listxattr.h \
init.h \
- iunlink.h \
xfs_platform.h \
linux-err.h \
topology.h \
@@ -35,10 +33,12 @@ HFILES = \
xfs_alloc.h \
xfs_alloc_btree.h \
xfs_attr_leaf.h \
+ xfs_attr_item.h \
xfs_attr_sf.h \
xfs_bit.h \
xfs_buf_item.h \
xfs_bmap.h \
+ xfs_bmap_item.h \
xfs_bmap_btree.h \
xfs_btree.h \
xfs_btree_mem.h \
@@ -50,13 +50,17 @@ HFILES = \
xfs_dir2_priv.h \
xfs_errortag.h \
xfs_exchmaps.h \
+ xfs_exchmaps_item.h \
+ xfs_extfree_item.h \
xfs_group.h \
xfs_ialloc.h \
xfs_ialloc_btree.h \
+ xfs_icreate_item.h \
xfs_inode_buf.h \
xfs_inode_fork.h \
xfs_inode_item.h \
xfs_inode_util.h \
+ xfs_iunlink_item.h \
xfs_log_recover.h \
xfs_metadir.h \
xfs_metafile.h \
@@ -64,9 +68,11 @@ HFILES = \
xfs_quota_defs.h \
xfs_refcount.h \
xfs_refcount_btree.h \
+ xfs_refcount_item.h \
xfs_rtrefcount_btree.h \
xfs_rmap.h \
xfs_rmap_btree.h \
+ xfs_rmap_item.h \
xfs_rtbitmap.h \
xfs_rtgroup.h \
xfs_rtrmap_btree.h \
diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
index fada5b6db2a6..72d79b10d820 100644
--- a/libxfs/defer_item.c
+++ b/libxfs/defer_item.c
@@ -25,12 +25,11 @@
#include "xfs_da_btree.h"
#include "xfs_attr.h"
#include "libxfs.h"
-#include "defer_item.h"
#include "xfs_ag.h"
#include "xfs_exchmaps.h"
-#include "defer_item.h"
#include "xfs_group.h"
#include "xfs_rtgroup.h"
+#include "xfs_attr_item.h"
/* Dummy defer item ops, since we don't do logging. */
diff --git a/libxfs/defer_item.h b/libxfs/defer_item.h
deleted file mode 100644
index 325a6f7b2dcb..000000000000
--- a/libxfs/defer_item.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (c) 2023-2024 Oracle. All Rights Reserved.
- * Author: Darrick J. Wong <djwong@kernel.org>
- */
-#ifndef __LIBXFS_DEFER_ITEM_H_
-#define __LIBXFS_DEFER_ITEM_H_
-
-struct xfs_bmap_intent;
-
-void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
-
-enum xfs_attr_defer_op {
- XFS_ATTR_DEFER_SET,
- XFS_ATTR_DEFER_REMOVE,
- XFS_ATTR_DEFER_REPLACE,
-};
-
-void xfs_attr_defer_add(struct xfs_da_args *args, enum xfs_attr_defer_op op);
-
-struct xfs_exchmaps_intent;
-
-void xfs_exchmaps_defer_add(struct xfs_trans *tp,
- struct xfs_exchmaps_intent *xmi);
-
-struct xfs_extent_free_item;
-struct xfs_defer_pending;
-
-void xfs_extent_free_defer_add(struct xfs_trans *tp,
- struct xfs_extent_free_item *xefi,
- struct xfs_defer_pending **dfpp);
-
-struct xfs_rmap_intent;
-
-void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
-
-struct xfs_refcount_intent;
-
-void xfs_refcount_defer_add(struct xfs_trans *tp,
- struct xfs_refcount_intent *ri);
-
-/* log intent size calculations */
-
-unsigned int xfs_efi_log_space(unsigned int nr);
-unsigned int xfs_efd_log_space(unsigned int nr);
-
-unsigned int xfs_rui_log_space(unsigned int nr);
-unsigned int xfs_rud_log_space(void);
-
-unsigned int xfs_bui_log_space(unsigned int nr);
-unsigned int xfs_bud_log_space(void);
-
-unsigned int xfs_cui_log_space(unsigned int nr);
-unsigned int xfs_cud_log_space(void);
-
-#endif /* __LIBXFS_DEFER_ITEM_H_ */
diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c
index 875e0caae988..8008c24a87a5 100644
--- a/libxfs/iunlink.c
+++ b/libxfs/iunlink.c
@@ -17,17 +17,9 @@
#include "xfs_inode.h"
#include "xfs_trans.h"
#include "xfs_ag.h"
-#include "iunlink.h"
+#include "xfs_iunlink_item.h"
#include "xfs_trace.h"
-/* in memory log item structure */
-struct xfs_iunlink_item {
- struct xfs_inode *ip;
- struct xfs_perag *pag;
- xfs_agino_t next_agino;
- xfs_agino_t old_agino;
-};
-
/*
* Look up the inode cluster buffer and log the on-disk unlinked inode change
* we need to make.
diff --git a/libxfs/stubs/xfs_inode.h b/libxfs/stubs/xfs_inode.h
index 0292beecf903..e6cfdd22c323 100644
--- a/libxfs/stubs/xfs_inode.h
+++ b/libxfs/stubs/xfs_inode.h
@@ -442,4 +442,12 @@ extern void libxfs_irele(struct xfs_inode *ip);
#define xfs_inherit_nosymlinks (false)
#define xfs_inherit_nodefrag (false)
+static inline struct xfs_inode *
+xfs_iunlink_lookup(struct xfs_perag *pag, xfs_agino_t agino)
+{
+ return NULL;
+}
+int xfs_iunlink_reload_next(struct xfs_trans *tp, struct xfs_buf *agibp,
+ xfs_agino_t prev_agino, xfs_agino_t next_agino);
+
#endif /* __XFS_INODE_H__ */
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 25015ad2795c..c71c9111187f 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -1315,3 +1315,15 @@ out_blocks:
return error;
}
+
+void
+xfs_icreate_log(
+ struct xfs_trans *tp,
+ xfs_agnumber_t agno,
+ xfs_agblock_t agbno,
+ unsigned int count,
+ unsigned int inode_size,
+ xfs_agblock_t length,
+ unsigned int generation)
+{
+}
diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index 8feaa0edace1..d99602bcc16f 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -27,7 +27,7 @@
#include "xfs_ag_resv.h"
#include "xfs_bmap.h"
#include "xfs_health.h"
-#include "defer_item.h"
+#include "xfs_extfree_item.h"
struct kmem_cache *xfs_extfree_item_cache;
diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index 57a0a175c286..aaf1f9f83c20 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -24,7 +24,7 @@
#include "xfs_quota.h"
#include "xfs_trans_space.h"
#include "xfs_trace.h"
-#include "defer_item.h"
+#include "xfs_attr_item.h"
#include "xfs_parent.h"
struct kmem_cache *xfs_attr_intent_cache;
diff --git a/libxfs/xfs_attr_item.h b/libxfs/xfs_attr_item.h
new file mode 100644
index 000000000000..d108a11b55ae
--- /dev/null
+++ b/libxfs/xfs_attr_item.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright (C) 2022 Oracle. All Rights Reserved.
+ * Author: Allison Henderson <allison.henderson@oracle.com>
+ */
+#ifndef __XFS_ATTR_ITEM_H__
+#define __XFS_ATTR_ITEM_H__
+
+/* kernel only ATTRI/ATTRD definitions */
+
+struct xfs_mount;
+struct kmem_zone;
+
+struct xfs_attri_log_nameval {
+ struct kvec name;
+ struct kvec new_name; /* PPTR_REPLACE only */
+ struct kvec value;
+ struct kvec new_value; /* PPTR_REPLACE only */
+ refcount_t refcount;
+
+ /* name and value follow the end of this struct */
+};
+
+/*
+ * This is the "attr intention" log item. It is used to log the fact that some
+ * extended attribute operations need to be processed. An operation is
+ * currently either a set or remove. Set or remove operations are described by
+ * the xfs_attr_intent which may be logged to this intent.
+ *
+ * During a normal attr operation, name and value point to the name and value
+ * fields of the caller's xfs_da_args structure. During a recovery, the name
+ * and value buffers are copied from the log, and stored in a trailing buffer
+ * attached to the xfs_attr_intent until they are committed. They are freed
+ * when the xfs_attr_intent itself is freed when the work is done.
+ */
+struct xfs_attri_log_item {
+ struct xfs_log_item attri_item;
+ atomic_t attri_refcount;
+ struct xfs_attri_log_nameval *attri_nameval;
+ struct xfs_attri_log_format attri_format;
+};
+
+/*
+ * This is the "attr done" log item. It is used to log the fact that some attrs
+ * earlier mentioned in an attri item have been freed.
+ */
+struct xfs_attrd_log_item {
+ struct xfs_log_item attrd_item;
+ struct xfs_attri_log_item *attrd_attrip;
+ struct xfs_attrd_log_format attrd_format;
+};
+
+extern struct kmem_cache *xfs_attri_cache;
+extern struct kmem_cache *xfs_attrd_cache;
+
+enum xfs_attr_defer_op {
+ XFS_ATTR_DEFER_SET,
+ XFS_ATTR_DEFER_REMOVE,
+ XFS_ATTR_DEFER_REPLACE,
+};
+
+void xfs_attr_defer_add(struct xfs_da_args *args, enum xfs_attr_defer_op op);
+
+#endif /* __XFS_ATTR_ITEM_H__ */
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index 18308d65f92d..148d036bab67 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -33,7 +33,7 @@
#include "xfs_ag_resv.h"
#include "xfs_refcount.h"
#include "xfs_health.h"
-#include "defer_item.h"
+#include "xfs_bmap_item.h"
#include "xfs_symlink_remote.h"
#include "xfs_inode_util.h"
#include "xfs_rtgroup.h"
diff --git a/libxfs/xfs_bmap_item.h b/libxfs/xfs_bmap_item.h
new file mode 100644
index 000000000000..b42fee06899d
--- /dev/null
+++ b/libxfs/xfs_bmap_item.h
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <darrick.wong@oracle.com>
+ */
+#ifndef __XFS_BMAP_ITEM_H__
+#define __XFS_BMAP_ITEM_H__
+
+/*
+ * There are (currently) two pairs of bmap btree redo item types: map & unmap.
+ * The common abbreviations for these are BUI (bmap update intent) and BUD
+ * (bmap update done). The redo item type is encoded in the flags field of
+ * each xfs_map_extent.
+ *
+ * *I items should be recorded in the *first* of a series of rolled
+ * transactions, and the *D items should be recorded in the same transaction
+ * that records the associated bmbt updates.
+ *
+ * Should the system crash after the commit of the first transaction but
+ * before the commit of the final transaction in a series, log recovery will
+ * use the redo information recorded by the intent items to replay the
+ * bmbt metadata updates in the non-first transaction.
+ */
+
+/* kernel only BUI/BUD definitions */
+
+struct xfs_mount;
+struct kmem_cache;
+
+/*
+ * Max number of extents in fast allocation path.
+ */
+#define XFS_BUI_MAX_FAST_EXTENTS 1
+
+/*
+ * This is the "bmap update intent" log item. It is used to log the fact that
+ * some reverse mappings need to change. It is used in conjunction with the
+ * "bmap update done" log item described below.
+ *
+ * These log items follow the same rules as struct xfs_efi_log_item; see the
+ * comments about that structure (in xfs_extfree_item.h) for more details.
+ */
+struct xfs_bui_log_item {
+ struct xfs_log_item bui_item;
+ atomic_t bui_refcount;
+ atomic_t bui_next_extent;
+ struct xfs_bui_log_format bui_format;
+};
+
+static inline size_t
+xfs_bui_log_item_sizeof(
+ unsigned int nr)
+{
+ return offsetof(struct xfs_bui_log_item, bui_format) +
+ xfs_bui_log_format_sizeof(nr);
+}
+
+/*
+ * This is the "bmap update done" log item. It is used to log the fact that
+ * some bmbt updates mentioned in an earlier bui item have been performed.
+ */
+struct xfs_bud_log_item {
+ struct xfs_log_item bud_item;
+ struct xfs_bui_log_item *bud_buip;
+ struct xfs_bud_log_format bud_format;
+};
+
+extern struct kmem_cache *xfs_bui_cache;
+extern struct kmem_cache *xfs_bud_cache;
+
+struct xfs_bmap_intent;
+
+void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
+
+unsigned int xfs_bui_log_space(unsigned int nr);
+unsigned int xfs_bud_log_space(void);
+
+#endif /* __XFS_BMAP_ITEM_H__ */
diff --git a/libxfs/xfs_exchmaps.c b/libxfs/xfs_exchmaps.c
index 7d6f949aa1f3..114463c101d6 100644
--- a/libxfs/xfs_exchmaps.c
+++ b/libxfs/xfs_exchmaps.c
@@ -22,7 +22,7 @@
#include "xfs_error.h"
#include "xfs_errortag.h"
#include "xfs_health.h"
-#include "defer_item.h"
+#include "xfs_exchmaps_item.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_attr_leaf.h"
diff --git a/libxfs/xfs_exchmaps_item.h b/libxfs/xfs_exchmaps_item.h
new file mode 100644
index 000000000000..efa368d25d09
--- /dev/null
+++ b/libxfs/xfs_exchmaps_item.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2020-2024 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
+ */
+#ifndef __XFS_EXCHMAPS_ITEM_H__
+#define __XFS_EXCHMAPS_ITEM_H__
+
+/*
+ * The file mapping exchange intent item helps us exchange multiple file
+ * mappings between two inode forks. It does this by tracking the range of
+ * file block offsets that still need to be exchanged, and relogs as progress
+ * happens.
+ *
+ * *I items should be recorded in the *first* of a series of rolled
+ * transactions, and the *D items should be recorded in the same transaction
+ * that records the associated bmbt updates.
+ *
+ * Should the system crash after the commit of the first transaction but
+ * before the commit of the final transaction in a series, log recovery will
+ * use the redo information recorded by the intent items to replay the
+ * rest of the mapping exchanges.
+ */
+
+/* kernel only XMI/XMD definitions */
+
+struct xfs_mount;
+struct kmem_cache;
+
+/*
+ * This is the incore file mapping exchange intent log item. It is used to log
+ * the fact that we are exchanging mappings between two files. It is used in
+ * conjunction with the incore file mapping exchange done log item described
+ * below.
+ *
+ * These log items follow the same rules as struct xfs_efi_log_item; see the
+ * comments about that structure (in xfs_extfree_item.h) for more details.
+ */
+struct xfs_xmi_log_item {
+ struct xfs_log_item xmi_item;
+ atomic_t xmi_refcount;
+ struct xfs_xmi_log_format xmi_format;
+};
+
+/*
+ * This is the incore file mapping exchange done log item. It is used to log
+ * the fact that an exchange mentioned in an earlier xmi item have been
+ * performed.
+ */
+struct xfs_xmd_log_item {
+ struct xfs_log_item xmd_item;
+ struct xfs_xmi_log_item *xmd_intent_log_item;
+ struct xfs_xmd_log_format xmd_format;
+};
+
+extern struct kmem_cache *xfs_xmi_cache;
+extern struct kmem_cache *xfs_xmd_cache;
+
+struct xfs_exchmaps_intent;
+
+void xfs_exchmaps_defer_add(struct xfs_trans *tp,
+ struct xfs_exchmaps_intent *xmi);
+
+#endif /* __XFS_EXCHMAPS_ITEM_H__ */
diff --git a/libxfs/xfs_extfree_item.h b/libxfs/xfs_extfree_item.h
new file mode 100644
index 000000000000..af1b0331f7af
--- /dev/null
+++ b/libxfs/xfs_extfree_item.h
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __XFS_EXTFREE_ITEM_H__
+#define __XFS_EXTFREE_ITEM_H__
+
+/* kernel only EFI/EFD definitions */
+
+struct xfs_mount;
+struct kmem_cache;
+
+/*
+ * Max number of extents in fast allocation path.
+ */
+#define XFS_EFI_MAX_FAST_EXTENTS 16
+
+/*
+ * This is the "extent free intention" log item. It is used to log the fact
+ * that some extents need to be free. It is used in conjunction with the
+ * "extent free done" log item described below.
+ *
+ * The EFI is reference counted so that it is not freed prior to both the EFI
+ * and EFD being committed and unpinned. This ensures the EFI is inserted into
+ * the AIL even in the event of out of order EFI/EFD processing. In other words,
+ * an EFI is born with two references:
+ *
+ * 1.) an EFI held reference to track EFI AIL insertion
+ * 2.) an EFD held reference to track EFD commit
+ *
+ * On allocation, both references are the responsibility of the caller. Once the
+ * EFI is added to and dirtied in a transaction, ownership of reference one
+ * transfers to the transaction. The reference is dropped once the EFI is
+ * inserted to the AIL or in the event of failure along the way (e.g., commit
+ * failure, log I/O error, etc.). Note that the caller remains responsible for
+ * the EFD reference under all circumstances to this point. The caller has no
+ * means to detect failure once the transaction is committed, however.
+ * Therefore, an EFD is required after this point, even in the event of
+ * unrelated failure.
+ *
+ * Once an EFD is allocated and dirtied in a transaction, reference two
+ * transfers to the transaction. The EFD reference is dropped once it reaches
+ * the unpin handler. Similar to the EFI, the reference also drops in the event
+ * of commit failure or log I/O errors. Note that the EFD is not inserted in the
+ * AIL, so at this point both the EFI and EFD are freed.
+ */
+struct xfs_efi_log_item {
+ struct xfs_log_item efi_item;
+ atomic_t efi_refcount;
+ atomic_t efi_next_extent;
+ struct xfs_efi_log_format efi_format;
+};
+
+static inline size_t
+xfs_efi_log_item_sizeof(
+ unsigned int nr)
+{
+ return offsetof(struct xfs_efi_log_item, efi_format) +
+ xfs_efi_log_format_sizeof(nr);
+}
+
+/*
+ * This is the "extent free done" log item. It is used to log
+ * the fact that some extents earlier mentioned in an efi item
+ * have been freed.
+ */
+struct xfs_efd_log_item {
+ struct xfs_log_item efd_item;
+ struct xfs_efi_log_item *efd_efip;
+ uint efd_next_extent;
+ struct xfs_efd_log_format efd_format;
+};
+
+static inline size_t
+xfs_efd_log_item_sizeof(
+ unsigned int nr)
+{
+ return offsetof(struct xfs_efd_log_item, efd_format) +
+ xfs_efd_log_format_sizeof(nr);
+}
+
+/*
+ * Max number of extents in fast allocation path.
+ */
+#define XFS_EFD_MAX_FAST_EXTENTS 16
+
+extern struct kmem_cache *xfs_efi_cache;
+extern struct kmem_cache *xfs_efd_cache;
+
+struct xfs_extent_free_item;
+
+void xfs_extent_free_defer_add(struct xfs_trans *tp,
+ struct xfs_extent_free_item *xefi,
+ struct xfs_defer_pending **dfpp);
+
+unsigned int xfs_efi_log_space(unsigned int nr);
+unsigned int xfs_efd_log_space(unsigned int nr);
+
+#endif /* __XFS_EXTFREE_ITEM_H__ */
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 91f4cdf2e4f3..a064289e1634 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -20,6 +20,7 @@
#include "xfs_error.h"
#include "xfs_bmap.h"
#include "xfs_trans.h"
+#include "xfs_icreate_item.h"
#include "xfs_buf_item.h"
#include "xfs_trace.h"
#include "xfs_log.h"
diff --git a/libxfs/xfs_icreate_item.h b/libxfs/xfs_icreate_item.h
new file mode 100644
index 000000000000..64992823108a
--- /dev/null
+++ b/libxfs/xfs_icreate_item.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2008-2010, Dave Chinner
+ * All Rights Reserved.
+ */
+#ifndef XFS_ICREATE_ITEM_H
+#define XFS_ICREATE_ITEM_H 1
+
+/* in memory log item structure */
+struct xfs_icreate_item {
+ struct xfs_log_item ic_item;
+ struct xfs_icreate_log ic_format;
+};
+
+extern struct kmem_cache *xfs_icreate_cache; /* inode create item */
+
+void xfs_icreate_log(struct xfs_trans *tp, xfs_agnumber_t agno,
+ xfs_agblock_t agbno, unsigned int count,
+ unsigned int inode_size, xfs_agblock_t length,
+ unsigned int generation);
+
+#endif /* XFS_ICREATE_ITEM_H */
diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c
index b4f556df64ed..16c4c2ccdbb8 100644
--- a/libxfs/xfs_inode_util.c
+++ b/libxfs/xfs_inode_util.c
@@ -20,8 +20,7 @@
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_ag.h"
-#include "xfs_inode_item.h"
-#include "iunlink.h"
+#include "xfs_iunlink_item.h"
#include "xfs_inode_item.h"
uint16_t
diff --git a/libxfs/iunlink.h b/libxfs/xfs_iunlink_item.h
similarity index 61%
rename from libxfs/iunlink.h
rename to libxfs/xfs_iunlink_item.h
index 8d8032cf9326..c793cdcaccde 100644
--- a/libxfs/iunlink.h
+++ b/libxfs/xfs_iunlink_item.h
@@ -10,15 +10,18 @@ struct xfs_trans;
struct xfs_inode;
struct xfs_perag;
-static inline struct xfs_inode *
-xfs_iunlink_lookup(struct xfs_perag *pag, xfs_agino_t agino)
-{
- return NULL;
-}
+/* in memory log item structure */
+struct xfs_iunlink_item {
+ struct xfs_log_item item;
+ struct xfs_inode *ip;
+ struct xfs_perag *pag;
+ xfs_agino_t next_agino;
+ xfs_agino_t old_agino;
+};
+
+extern struct kmem_cache *xfs_iunlink_cache;
int xfs_iunlink_log_inode(struct xfs_trans *tp, struct xfs_inode *ip,
struct xfs_perag *pag, xfs_agino_t next_agino);
-int xfs_iunlink_reload_next(struct xfs_trans *tp, struct xfs_buf *agibp,
- xfs_agino_t prev_agino, xfs_agino_t next_agino);
#endif /* XFS_IUNLINK_ITEM_H */
diff --git a/libxfs/xfs_parent.c b/libxfs/xfs_parent.c
index 9420d8089e8c..992263f810f8 100644
--- a/libxfs/xfs_parent.c
+++ b/libxfs/xfs_parent.c
@@ -25,7 +25,7 @@
#include "xfs_defer.h"
#include "xfs_parent.h"
#include "xfs_trans_space.h"
-#include "defer_item.h"
+#include "xfs_attr_item.h"
#include "xfs_health.h"
#include "xfs_attr_leaf.h"
diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
index 4b0069fd70d7..4f4990a20dad 100644
--- a/libxfs/xfs_platform.h
+++ b/libxfs/xfs_platform.h
@@ -350,7 +350,6 @@ xfs_buf_readahead(
#define uuid_copy(s,d) platform_uuid_copy((s),(d))
#define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
-#define xfs_icreate_log(tp, agno, agbno, cnt, isize, len, gen) ((void) 0)
#define xfs_sb_validate_fsb_count(sbp, nblks) (0)
#define xlog_calc_iovec_len(len) roundup(len, sizeof(uint32_t))
diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c
index 3615f747f82a..6b67308fa594 100644
--- a/libxfs/xfs_refcount.c
+++ b/libxfs/xfs_refcount.c
@@ -24,7 +24,7 @@
#include "xfs_rmap.h"
#include "xfs_ag.h"
#include "xfs_health.h"
-#include "defer_item.h"
+#include "xfs_refcount_item.h"
#include "xfs_rtgroup.h"
#include "xfs_rtrefcount_btree.h"
diff --git a/libxfs/xfs_refcount_item.h b/libxfs/xfs_refcount_item.h
new file mode 100644
index 000000000000..0fc3f493342b
--- /dev/null
+++ b/libxfs/xfs_refcount_item.h
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <darrick.wong@oracle.com>
+ */
+#ifndef __XFS_REFCOUNT_ITEM_H__
+#define __XFS_REFCOUNT_ITEM_H__
+
+/*
+ * There are (currently) two pairs of refcount btree redo item types:
+ * increase and decrease. The log items for these are CUI (refcount
+ * update intent) and CUD (refcount update done). The redo item type
+ * is encoded in the flags field of each xfs_map_extent.
+ *
+ * *I items should be recorded in the *first* of a series of rolled
+ * transactions, and the *D items should be recorded in the same
+ * transaction that records the associated refcountbt updates.
+ *
+ * Should the system crash after the commit of the first transaction
+ * but before the commit of the final transaction in a series, log
+ * recovery will use the redo information recorded by the intent items
+ * to replay the refcountbt metadata updates.
+ */
+
+/* kernel only CUI/CUD definitions */
+
+struct xfs_mount;
+struct kmem_cache;
+
+/*
+ * Max number of extents in fast allocation path.
+ */
+#define XFS_CUI_MAX_FAST_EXTENTS 16
+
+/*
+ * This is the "refcount update intent" log item. It is used to log
+ * the fact that some reverse mappings need to change. It is used in
+ * conjunction with the "refcount update done" log item described
+ * below.
+ *
+ * These log items follow the same rules as struct xfs_efi_log_item;
+ * see the comments about that structure (in xfs_extfree_item.h) for
+ * more details.
+ */
+struct xfs_cui_log_item {
+ struct xfs_log_item cui_item;
+ atomic_t cui_refcount;
+ atomic_t cui_next_extent;
+ struct xfs_cui_log_format cui_format;
+};
+
+static inline size_t
+xfs_cui_log_item_sizeof(
+ unsigned int nr)
+{
+ return offsetof(struct xfs_cui_log_item, cui_format) +
+ xfs_cui_log_format_sizeof(nr);
+}
+
+/*
+ * This is the "refcount update done" log item. It is used to log the
+ * fact that some refcountbt updates mentioned in an earlier cui item
+ * have been performed.
+ */
+struct xfs_cud_log_item {
+ struct xfs_log_item cud_item;
+ struct xfs_cui_log_item *cud_cuip;
+ struct xfs_cud_log_format cud_format;
+};
+
+extern struct kmem_cache *xfs_cui_cache;
+extern struct kmem_cache *xfs_cud_cache;
+
+struct xfs_refcount_intent;
+
+void xfs_refcount_defer_add(struct xfs_trans *tp,
+ struct xfs_refcount_intent *ri);
+
+unsigned int xfs_cui_log_space(unsigned int nr);
+unsigned int xfs_cud_log_space(void);
+
+#endif /* __XFS_REFCOUNT_ITEM_H__ */
diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c
index 74600c99172d..34d218de21a9 100644
--- a/libxfs/xfs_rmap.c
+++ b/libxfs/xfs_rmap.c
@@ -24,7 +24,7 @@
#include "xfs_inode.h"
#include "xfs_ag.h"
#include "xfs_health.h"
-#include "defer_item.h"
+#include "xfs_rmap_item.h"
#include "xfs_rtgroup.h"
#include "xfs_rtrmap_btree.h"
diff --git a/libxfs/xfs_rmap_item.h b/libxfs/xfs_rmap_item.h
new file mode 100644
index 000000000000..3a99f0117f2d
--- /dev/null
+++ b/libxfs/xfs_rmap_item.h
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <darrick.wong@oracle.com>
+ */
+#ifndef __XFS_RMAP_ITEM_H__
+#define __XFS_RMAP_ITEM_H__
+
+/*
+ * There are (currently) three pairs of rmap btree redo item types: map, unmap,
+ * and convert. The common abbreviations for these are RUI (rmap update
+ * intent) and RUD (rmap update done). The redo item type is encoded in the
+ * flags field of each xfs_map_extent.
+ *
+ * *I items should be recorded in the *first* of a series of rolled
+ * transactions, and the *D items should be recorded in the same transaction
+ * that records the associated rmapbt updates. Typically, the first
+ * transaction will record a bmbt update, followed by some number of
+ * transactions containing rmapbt updates, and finally transactions with any
+ * bnobt/cntbt updates.
+ *
+ * Should the system crash after the commit of the first transaction but
+ * before the commit of the final transaction in a series, log recovery will
+ * use the redo information recorded by the intent items to replay the
+ * (rmapbt/bnobt/cntbt) metadata updates in the non-first transaction.
+ */
+
+/* kernel only RUI/RUD definitions */
+
+struct xfs_mount;
+struct kmem_cache;
+
+/*
+ * Max number of extents in fast allocation path.
+ */
+#define XFS_RUI_MAX_FAST_EXTENTS 16
+
+/*
+ * This is the "rmap update intent" log item. It is used to log the fact that
+ * some reverse mappings need to change. It is used in conjunction with the
+ * "rmap update done" log item described below.
+ *
+ * These log items follow the same rules as struct xfs_efi_log_item; see the
+ * comments about that structure (in xfs_extfree_item.h) for more details.
+ */
+struct xfs_rui_log_item {
+ struct xfs_log_item rui_item;
+ atomic_t rui_refcount;
+ atomic_t rui_next_extent;
+ struct xfs_rui_log_format rui_format;
+};
+
+static inline size_t
+xfs_rui_log_item_sizeof(
+ unsigned int nr)
+{
+ return offsetof(struct xfs_rui_log_item, rui_format) +
+ xfs_rui_log_format_sizeof(nr);
+}
+
+/*
+ * This is the "rmap update done" log item. It is used to log the fact that
+ * some rmapbt updates mentioned in an earlier rui item have been performed.
+ */
+struct xfs_rud_log_item {
+ struct xfs_log_item rud_item;
+ struct xfs_rui_log_item *rud_ruip;
+ struct xfs_rud_log_format rud_format;
+};
+
+extern struct kmem_cache *xfs_rui_cache;
+extern struct kmem_cache *xfs_rud_cache;
+
+struct xfs_rmap_intent;
+
+void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
+
+unsigned int xfs_rui_log_space(unsigned int nr);
+unsigned int xfs_rud_log_space(void);
+
+#endif /* __XFS_RMAP_ITEM_H__ */
diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
index d15ca0427584..3a87ab154bb5 100644
--- a/libxfs/xfs_trans_resv.c
+++ b/libxfs/xfs_trans_resv.c
@@ -19,9 +19,14 @@
#include "xfs_trans.h"
#include "xfs_trans_space.h"
#include "xfs_rtbitmap.h"
+#include "xfs_attr_item.h"
#include "xfs_log.h"
+#include "xfs_defer.h"
+#include "xfs_bmap_item.h"
+#include "xfs_extfree_item.h"
+#include "xfs_rmap_item.h"
+#include "xfs_refcount_item.h"
#include "xfs_trace.h"
-#include "defer_item.h"
#define _ALLOC true
#define _FREE false
--
2.53.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 13/13] libxfs: use all log item headers from the kernel
2026-10-05 12:56 ` [PATCH 13/13] libxfs: use all log item headers from the kernel Christoph Hellwig
@ 2026-10-05 21:50 ` Darrick J. Wong
0 siblings, 0 replies; 31+ messages in thread
From: Darrick J. Wong @ 2026-10-05 21:50 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrey Albershteyn, Eric Sandeen, Carlos Maiolino, linux-xfs
On Mon, Oct 05, 2026 at 02:56:23PM +0200, Christoph Hellwig wrote:
> Wire up all the xfs_*_item.h headers from the kernel instead of
> duplicating the definitions.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Can't wait for the log item code to get ported too, though that's a much
bigger lift than the declarations.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> db/logformat.c | 4 +
> include/atomic.h | 1 +
> include/libxfs.h | 1 -
> libxfs/Makefile | 10 ++-
> libxfs/defer_item.c | 3 +-
> libxfs/defer_item.h | 56 -------------
> libxfs/iunlink.c | 10 +--
> libxfs/stubs/xfs_inode.h | 8 ++
> libxfs/trans.c | 12 +++
> libxfs/xfs_alloc.c | 2 +-
> libxfs/xfs_attr.c | 2 +-
> libxfs/xfs_attr_item.h | 64 +++++++++++++++
> libxfs/xfs_bmap.c | 2 +-
> libxfs/xfs_bmap_item.h | 78 ++++++++++++++++++
> libxfs/xfs_exchmaps.c | 2 +-
> libxfs/xfs_exchmaps_item.h | 64 +++++++++++++++
> libxfs/xfs_extfree_item.h | 100 +++++++++++++++++++++++
> libxfs/xfs_ialloc.c | 1 +
> libxfs/xfs_icreate_item.h | 22 +++++
> libxfs/xfs_inode_util.c | 3 +-
> libxfs/{iunlink.h => xfs_iunlink_item.h} | 17 ++--
> libxfs/xfs_parent.c | 2 +-
> libxfs/xfs_platform.h | 1 -
> libxfs/xfs_refcount.c | 2 +-
> libxfs/xfs_refcount_item.h | 82 +++++++++++++++++++
> libxfs/xfs_rmap.c | 2 +-
> libxfs/xfs_rmap_item.h | 81 ++++++++++++++++++
> libxfs/xfs_trans_resv.c | 7 +-
> 28 files changed, 551 insertions(+), 88 deletions(-)
> delete mode 100644 libxfs/defer_item.h
> create mode 100644 libxfs/xfs_attr_item.h
> create mode 100644 libxfs/xfs_bmap_item.h
> create mode 100644 libxfs/xfs_exchmaps_item.h
> create mode 100644 libxfs/xfs_extfree_item.h
> create mode 100644 libxfs/xfs_icreate_item.h
> rename libxfs/{iunlink.h => xfs_iunlink_item.h} (61%)
> create mode 100644 libxfs/xfs_refcount_item.h
> create mode 100644 libxfs/xfs_rmap_item.h
>
> diff --git a/db/logformat.c b/db/logformat.c
> index aba5b0b1b050..5d3d818d5575 100644
> --- a/db/logformat.c
> +++ b/db/logformat.c
> @@ -10,6 +10,10 @@
> #include "output.h"
> #include "libxlog.h"
> #include "logformat.h"
> +#include "xfs_extfree_item.h"
> +#include "xfs_bmap_item.h"
> +#include "xfs_rmap_item.h"
> +#include "xfs_refcount_item.h"
>
> #define MAX_LSUNIT 256 * 1024 /* max log buf. size */
>
> diff --git a/include/atomic.h b/include/atomic.h
> index 3b7eabd0faa7..ee2161fdf9cc 100644
> --- a/include/atomic.h
> +++ b/include/atomic.h
> @@ -18,6 +18,7 @@
> #include <urcu/uatomic.h>
> #include "spinlock.h"
>
> +typedef int32_t refcount_t;
> typedef int32_t atomic_t;
> typedef int64_t atomic64_t;
>
> diff --git a/include/libxfs.h b/include/libxfs.h
> index 549176cf0b2c..e28b79d80143 100644
> --- a/include/libxfs.h
> +++ b/include/libxfs.h
> @@ -105,7 +105,6 @@ struct iomap;
> #include "xfs_rtbitmap.h"
> #include "xfs_rtrmap_btree.h"
> #include "xfs_ag_resv.h"
> -#include "defer_item.h"
>
> #ifndef ARRAY_SIZE
> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index ac7ddac5acec..df11c119c465 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -20,12 +20,10 @@ PKGHFILES = xfs_fs.h \
> xfs_log_format.h
>
> HFILES = \
> - defer_item.h \
> libxfs_io.h \
> libxfs_api_defs.h \
> listxattr.h \
> init.h \
> - iunlink.h \
> xfs_platform.h \
> linux-err.h \
> topology.h \
> @@ -35,10 +33,12 @@ HFILES = \
> xfs_alloc.h \
> xfs_alloc_btree.h \
> xfs_attr_leaf.h \
> + xfs_attr_item.h \
> xfs_attr_sf.h \
> xfs_bit.h \
> xfs_buf_item.h \
> xfs_bmap.h \
> + xfs_bmap_item.h \
> xfs_bmap_btree.h \
> xfs_btree.h \
> xfs_btree_mem.h \
> @@ -50,13 +50,17 @@ HFILES = \
> xfs_dir2_priv.h \
> xfs_errortag.h \
> xfs_exchmaps.h \
> + xfs_exchmaps_item.h \
> + xfs_extfree_item.h \
> xfs_group.h \
> xfs_ialloc.h \
> xfs_ialloc_btree.h \
> + xfs_icreate_item.h \
> xfs_inode_buf.h \
> xfs_inode_fork.h \
> xfs_inode_item.h \
> xfs_inode_util.h \
> + xfs_iunlink_item.h \
> xfs_log_recover.h \
> xfs_metadir.h \
> xfs_metafile.h \
> @@ -64,9 +68,11 @@ HFILES = \
> xfs_quota_defs.h \
> xfs_refcount.h \
> xfs_refcount_btree.h \
> + xfs_refcount_item.h \
> xfs_rtrefcount_btree.h \
> xfs_rmap.h \
> xfs_rmap_btree.h \
> + xfs_rmap_item.h \
> xfs_rtbitmap.h \
> xfs_rtgroup.h \
> xfs_rtrmap_btree.h \
> diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
> index fada5b6db2a6..72d79b10d820 100644
> --- a/libxfs/defer_item.c
> +++ b/libxfs/defer_item.c
> @@ -25,12 +25,11 @@
> #include "xfs_da_btree.h"
> #include "xfs_attr.h"
> #include "libxfs.h"
> -#include "defer_item.h"
> #include "xfs_ag.h"
> #include "xfs_exchmaps.h"
> -#include "defer_item.h"
> #include "xfs_group.h"
> #include "xfs_rtgroup.h"
> +#include "xfs_attr_item.h"
>
> /* Dummy defer item ops, since we don't do logging. */
>
> diff --git a/libxfs/defer_item.h b/libxfs/defer_item.h
> deleted file mode 100644
> index 325a6f7b2dcb..000000000000
> --- a/libxfs/defer_item.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * Copyright (c) 2023-2024 Oracle. All Rights Reserved.
> - * Author: Darrick J. Wong <djwong@kernel.org>
> - */
> -#ifndef __LIBXFS_DEFER_ITEM_H_
> -#define __LIBXFS_DEFER_ITEM_H_
> -
> -struct xfs_bmap_intent;
> -
> -void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
> -
> -enum xfs_attr_defer_op {
> - XFS_ATTR_DEFER_SET,
> - XFS_ATTR_DEFER_REMOVE,
> - XFS_ATTR_DEFER_REPLACE,
> -};
> -
> -void xfs_attr_defer_add(struct xfs_da_args *args, enum xfs_attr_defer_op op);
> -
> -struct xfs_exchmaps_intent;
> -
> -void xfs_exchmaps_defer_add(struct xfs_trans *tp,
> - struct xfs_exchmaps_intent *xmi);
> -
> -struct xfs_extent_free_item;
> -struct xfs_defer_pending;
> -
> -void xfs_extent_free_defer_add(struct xfs_trans *tp,
> - struct xfs_extent_free_item *xefi,
> - struct xfs_defer_pending **dfpp);
> -
> -struct xfs_rmap_intent;
> -
> -void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
> -
> -struct xfs_refcount_intent;
> -
> -void xfs_refcount_defer_add(struct xfs_trans *tp,
> - struct xfs_refcount_intent *ri);
> -
> -/* log intent size calculations */
> -
> -unsigned int xfs_efi_log_space(unsigned int nr);
> -unsigned int xfs_efd_log_space(unsigned int nr);
> -
> -unsigned int xfs_rui_log_space(unsigned int nr);
> -unsigned int xfs_rud_log_space(void);
> -
> -unsigned int xfs_bui_log_space(unsigned int nr);
> -unsigned int xfs_bud_log_space(void);
> -
> -unsigned int xfs_cui_log_space(unsigned int nr);
> -unsigned int xfs_cud_log_space(void);
> -
> -#endif /* __LIBXFS_DEFER_ITEM_H_ */
> diff --git a/libxfs/iunlink.c b/libxfs/iunlink.c
> index 875e0caae988..8008c24a87a5 100644
> --- a/libxfs/iunlink.c
> +++ b/libxfs/iunlink.c
> @@ -17,17 +17,9 @@
> #include "xfs_inode.h"
> #include "xfs_trans.h"
> #include "xfs_ag.h"
> -#include "iunlink.h"
> +#include "xfs_iunlink_item.h"
> #include "xfs_trace.h"
>
> -/* in memory log item structure */
> -struct xfs_iunlink_item {
> - struct xfs_inode *ip;
> - struct xfs_perag *pag;
> - xfs_agino_t next_agino;
> - xfs_agino_t old_agino;
> -};
> -
> /*
> * Look up the inode cluster buffer and log the on-disk unlinked inode change
> * we need to make.
> diff --git a/libxfs/stubs/xfs_inode.h b/libxfs/stubs/xfs_inode.h
> index 0292beecf903..e6cfdd22c323 100644
> --- a/libxfs/stubs/xfs_inode.h
> +++ b/libxfs/stubs/xfs_inode.h
> @@ -442,4 +442,12 @@ extern void libxfs_irele(struct xfs_inode *ip);
> #define xfs_inherit_nosymlinks (false)
> #define xfs_inherit_nodefrag (false)
>
> +static inline struct xfs_inode *
> +xfs_iunlink_lookup(struct xfs_perag *pag, xfs_agino_t agino)
> +{
> + return NULL;
> +}
> +int xfs_iunlink_reload_next(struct xfs_trans *tp, struct xfs_buf *agibp,
> + xfs_agino_t prev_agino, xfs_agino_t next_agino);
> +
> #endif /* __XFS_INODE_H__ */
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index 25015ad2795c..c71c9111187f 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -1315,3 +1315,15 @@ out_blocks:
>
> return error;
> }
> +
> +void
> +xfs_icreate_log(
> + struct xfs_trans *tp,
> + xfs_agnumber_t agno,
> + xfs_agblock_t agbno,
> + unsigned int count,
> + unsigned int inode_size,
> + xfs_agblock_t length,
> + unsigned int generation)
> +{
> +}
> diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
> index 8feaa0edace1..d99602bcc16f 100644
> --- a/libxfs/xfs_alloc.c
> +++ b/libxfs/xfs_alloc.c
> @@ -27,7 +27,7 @@
> #include "xfs_ag_resv.h"
> #include "xfs_bmap.h"
> #include "xfs_health.h"
> -#include "defer_item.h"
> +#include "xfs_extfree_item.h"
>
> struct kmem_cache *xfs_extfree_item_cache;
>
> diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
> index 57a0a175c286..aaf1f9f83c20 100644
> --- a/libxfs/xfs_attr.c
> +++ b/libxfs/xfs_attr.c
> @@ -24,7 +24,7 @@
> #include "xfs_quota.h"
> #include "xfs_trans_space.h"
> #include "xfs_trace.h"
> -#include "defer_item.h"
> +#include "xfs_attr_item.h"
> #include "xfs_parent.h"
>
> struct kmem_cache *xfs_attr_intent_cache;
> diff --git a/libxfs/xfs_attr_item.h b/libxfs/xfs_attr_item.h
> new file mode 100644
> index 000000000000..d108a11b55ae
> --- /dev/null
> +++ b/libxfs/xfs_attr_item.h
> @@ -0,0 +1,64 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * Copyright (C) 2022 Oracle. All Rights Reserved.
> + * Author: Allison Henderson <allison.henderson@oracle.com>
> + */
> +#ifndef __XFS_ATTR_ITEM_H__
> +#define __XFS_ATTR_ITEM_H__
> +
> +/* kernel only ATTRI/ATTRD definitions */
> +
> +struct xfs_mount;
> +struct kmem_zone;
> +
> +struct xfs_attri_log_nameval {
> + struct kvec name;
> + struct kvec new_name; /* PPTR_REPLACE only */
> + struct kvec value;
> + struct kvec new_value; /* PPTR_REPLACE only */
> + refcount_t refcount;
> +
> + /* name and value follow the end of this struct */
> +};
> +
> +/*
> + * This is the "attr intention" log item. It is used to log the fact that some
> + * extended attribute operations need to be processed. An operation is
> + * currently either a set or remove. Set or remove operations are described by
> + * the xfs_attr_intent which may be logged to this intent.
> + *
> + * During a normal attr operation, name and value point to the name and value
> + * fields of the caller's xfs_da_args structure. During a recovery, the name
> + * and value buffers are copied from the log, and stored in a trailing buffer
> + * attached to the xfs_attr_intent until they are committed. They are freed
> + * when the xfs_attr_intent itself is freed when the work is done.
> + */
> +struct xfs_attri_log_item {
> + struct xfs_log_item attri_item;
> + atomic_t attri_refcount;
> + struct xfs_attri_log_nameval *attri_nameval;
> + struct xfs_attri_log_format attri_format;
> +};
> +
> +/*
> + * This is the "attr done" log item. It is used to log the fact that some attrs
> + * earlier mentioned in an attri item have been freed.
> + */
> +struct xfs_attrd_log_item {
> + struct xfs_log_item attrd_item;
> + struct xfs_attri_log_item *attrd_attrip;
> + struct xfs_attrd_log_format attrd_format;
> +};
> +
> +extern struct kmem_cache *xfs_attri_cache;
> +extern struct kmem_cache *xfs_attrd_cache;
> +
> +enum xfs_attr_defer_op {
> + XFS_ATTR_DEFER_SET,
> + XFS_ATTR_DEFER_REMOVE,
> + XFS_ATTR_DEFER_REPLACE,
> +};
> +
> +void xfs_attr_defer_add(struct xfs_da_args *args, enum xfs_attr_defer_op op);
> +
> +#endif /* __XFS_ATTR_ITEM_H__ */
> diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> index 18308d65f92d..148d036bab67 100644
> --- a/libxfs/xfs_bmap.c
> +++ b/libxfs/xfs_bmap.c
> @@ -33,7 +33,7 @@
> #include "xfs_ag_resv.h"
> #include "xfs_refcount.h"
> #include "xfs_health.h"
> -#include "defer_item.h"
> +#include "xfs_bmap_item.h"
> #include "xfs_symlink_remote.h"
> #include "xfs_inode_util.h"
> #include "xfs_rtgroup.h"
> diff --git a/libxfs/xfs_bmap_item.h b/libxfs/xfs_bmap_item.h
> new file mode 100644
> index 000000000000..b42fee06899d
> --- /dev/null
> +++ b/libxfs/xfs_bmap_item.h
> @@ -0,0 +1,78 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2016 Oracle. All Rights Reserved.
> + * Author: Darrick J. Wong <darrick.wong@oracle.com>
> + */
> +#ifndef __XFS_BMAP_ITEM_H__
> +#define __XFS_BMAP_ITEM_H__
> +
> +/*
> + * There are (currently) two pairs of bmap btree redo item types: map & unmap.
> + * The common abbreviations for these are BUI (bmap update intent) and BUD
> + * (bmap update done). The redo item type is encoded in the flags field of
> + * each xfs_map_extent.
> + *
> + * *I items should be recorded in the *first* of a series of rolled
> + * transactions, and the *D items should be recorded in the same transaction
> + * that records the associated bmbt updates.
> + *
> + * Should the system crash after the commit of the first transaction but
> + * before the commit of the final transaction in a series, log recovery will
> + * use the redo information recorded by the intent items to replay the
> + * bmbt metadata updates in the non-first transaction.
> + */
> +
> +/* kernel only BUI/BUD definitions */
> +
> +struct xfs_mount;
> +struct kmem_cache;
> +
> +/*
> + * Max number of extents in fast allocation path.
> + */
> +#define XFS_BUI_MAX_FAST_EXTENTS 1
> +
> +/*
> + * This is the "bmap update intent" log item. It is used to log the fact that
> + * some reverse mappings need to change. It is used in conjunction with the
> + * "bmap update done" log item described below.
> + *
> + * These log items follow the same rules as struct xfs_efi_log_item; see the
> + * comments about that structure (in xfs_extfree_item.h) for more details.
> + */
> +struct xfs_bui_log_item {
> + struct xfs_log_item bui_item;
> + atomic_t bui_refcount;
> + atomic_t bui_next_extent;
> + struct xfs_bui_log_format bui_format;
> +};
> +
> +static inline size_t
> +xfs_bui_log_item_sizeof(
> + unsigned int nr)
> +{
> + return offsetof(struct xfs_bui_log_item, bui_format) +
> + xfs_bui_log_format_sizeof(nr);
> +}
> +
> +/*
> + * This is the "bmap update done" log item. It is used to log the fact that
> + * some bmbt updates mentioned in an earlier bui item have been performed.
> + */
> +struct xfs_bud_log_item {
> + struct xfs_log_item bud_item;
> + struct xfs_bui_log_item *bud_buip;
> + struct xfs_bud_log_format bud_format;
> +};
> +
> +extern struct kmem_cache *xfs_bui_cache;
> +extern struct kmem_cache *xfs_bud_cache;
> +
> +struct xfs_bmap_intent;
> +
> +void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
> +
> +unsigned int xfs_bui_log_space(unsigned int nr);
> +unsigned int xfs_bud_log_space(void);
> +
> +#endif /* __XFS_BMAP_ITEM_H__ */
> diff --git a/libxfs/xfs_exchmaps.c b/libxfs/xfs_exchmaps.c
> index 7d6f949aa1f3..114463c101d6 100644
> --- a/libxfs/xfs_exchmaps.c
> +++ b/libxfs/xfs_exchmaps.c
> @@ -22,7 +22,7 @@
> #include "xfs_error.h"
> #include "xfs_errortag.h"
> #include "xfs_health.h"
> -#include "defer_item.h"
> +#include "xfs_exchmaps_item.h"
> #include "xfs_da_format.h"
> #include "xfs_da_btree.h"
> #include "xfs_attr_leaf.h"
> diff --git a/libxfs/xfs_exchmaps_item.h b/libxfs/xfs_exchmaps_item.h
> new file mode 100644
> index 000000000000..efa368d25d09
> --- /dev/null
> +++ b/libxfs/xfs_exchmaps_item.h
> @@ -0,0 +1,64 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2020-2024 Oracle. All Rights Reserved.
> + * Author: Darrick J. Wong <djwong@kernel.org>
> + */
> +#ifndef __XFS_EXCHMAPS_ITEM_H__
> +#define __XFS_EXCHMAPS_ITEM_H__
> +
> +/*
> + * The file mapping exchange intent item helps us exchange multiple file
> + * mappings between two inode forks. It does this by tracking the range of
> + * file block offsets that still need to be exchanged, and relogs as progress
> + * happens.
> + *
> + * *I items should be recorded in the *first* of a series of rolled
> + * transactions, and the *D items should be recorded in the same transaction
> + * that records the associated bmbt updates.
> + *
> + * Should the system crash after the commit of the first transaction but
> + * before the commit of the final transaction in a series, log recovery will
> + * use the redo information recorded by the intent items to replay the
> + * rest of the mapping exchanges.
> + */
> +
> +/* kernel only XMI/XMD definitions */
> +
> +struct xfs_mount;
> +struct kmem_cache;
> +
> +/*
> + * This is the incore file mapping exchange intent log item. It is used to log
> + * the fact that we are exchanging mappings between two files. It is used in
> + * conjunction with the incore file mapping exchange done log item described
> + * below.
> + *
> + * These log items follow the same rules as struct xfs_efi_log_item; see the
> + * comments about that structure (in xfs_extfree_item.h) for more details.
> + */
> +struct xfs_xmi_log_item {
> + struct xfs_log_item xmi_item;
> + atomic_t xmi_refcount;
> + struct xfs_xmi_log_format xmi_format;
> +};
> +
> +/*
> + * This is the incore file mapping exchange done log item. It is used to log
> + * the fact that an exchange mentioned in an earlier xmi item have been
> + * performed.
> + */
> +struct xfs_xmd_log_item {
> + struct xfs_log_item xmd_item;
> + struct xfs_xmi_log_item *xmd_intent_log_item;
> + struct xfs_xmd_log_format xmd_format;
> +};
> +
> +extern struct kmem_cache *xfs_xmi_cache;
> +extern struct kmem_cache *xfs_xmd_cache;
> +
> +struct xfs_exchmaps_intent;
> +
> +void xfs_exchmaps_defer_add(struct xfs_trans *tp,
> + struct xfs_exchmaps_intent *xmi);
> +
> +#endif /* __XFS_EXCHMAPS_ITEM_H__ */
> diff --git a/libxfs/xfs_extfree_item.h b/libxfs/xfs_extfree_item.h
> new file mode 100644
> index 000000000000..af1b0331f7af
> --- /dev/null
> +++ b/libxfs/xfs_extfree_item.h
> @@ -0,0 +1,100 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2000,2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + */
> +#ifndef __XFS_EXTFREE_ITEM_H__
> +#define __XFS_EXTFREE_ITEM_H__
> +
> +/* kernel only EFI/EFD definitions */
> +
> +struct xfs_mount;
> +struct kmem_cache;
> +
> +/*
> + * Max number of extents in fast allocation path.
> + */
> +#define XFS_EFI_MAX_FAST_EXTENTS 16
> +
> +/*
> + * This is the "extent free intention" log item. It is used to log the fact
> + * that some extents need to be free. It is used in conjunction with the
> + * "extent free done" log item described below.
> + *
> + * The EFI is reference counted so that it is not freed prior to both the EFI
> + * and EFD being committed and unpinned. This ensures the EFI is inserted into
> + * the AIL even in the event of out of order EFI/EFD processing. In other words,
> + * an EFI is born with two references:
> + *
> + * 1.) an EFI held reference to track EFI AIL insertion
> + * 2.) an EFD held reference to track EFD commit
> + *
> + * On allocation, both references are the responsibility of the caller. Once the
> + * EFI is added to and dirtied in a transaction, ownership of reference one
> + * transfers to the transaction. The reference is dropped once the EFI is
> + * inserted to the AIL or in the event of failure along the way (e.g., commit
> + * failure, log I/O error, etc.). Note that the caller remains responsible for
> + * the EFD reference under all circumstances to this point. The caller has no
> + * means to detect failure once the transaction is committed, however.
> + * Therefore, an EFD is required after this point, even in the event of
> + * unrelated failure.
> + *
> + * Once an EFD is allocated and dirtied in a transaction, reference two
> + * transfers to the transaction. The EFD reference is dropped once it reaches
> + * the unpin handler. Similar to the EFI, the reference also drops in the event
> + * of commit failure or log I/O errors. Note that the EFD is not inserted in the
> + * AIL, so at this point both the EFI and EFD are freed.
> + */
> +struct xfs_efi_log_item {
> + struct xfs_log_item efi_item;
> + atomic_t efi_refcount;
> + atomic_t efi_next_extent;
> + struct xfs_efi_log_format efi_format;
> +};
> +
> +static inline size_t
> +xfs_efi_log_item_sizeof(
> + unsigned int nr)
> +{
> + return offsetof(struct xfs_efi_log_item, efi_format) +
> + xfs_efi_log_format_sizeof(nr);
> +}
> +
> +/*
> + * This is the "extent free done" log item. It is used to log
> + * the fact that some extents earlier mentioned in an efi item
> + * have been freed.
> + */
> +struct xfs_efd_log_item {
> + struct xfs_log_item efd_item;
> + struct xfs_efi_log_item *efd_efip;
> + uint efd_next_extent;
> + struct xfs_efd_log_format efd_format;
> +};
> +
> +static inline size_t
> +xfs_efd_log_item_sizeof(
> + unsigned int nr)
> +{
> + return offsetof(struct xfs_efd_log_item, efd_format) +
> + xfs_efd_log_format_sizeof(nr);
> +}
> +
> +/*
> + * Max number of extents in fast allocation path.
> + */
> +#define XFS_EFD_MAX_FAST_EXTENTS 16
> +
> +extern struct kmem_cache *xfs_efi_cache;
> +extern struct kmem_cache *xfs_efd_cache;
> +
> +struct xfs_extent_free_item;
> +
> +void xfs_extent_free_defer_add(struct xfs_trans *tp,
> + struct xfs_extent_free_item *xefi,
> + struct xfs_defer_pending **dfpp);
> +
> +unsigned int xfs_efi_log_space(unsigned int nr);
> +unsigned int xfs_efd_log_space(unsigned int nr);
> +
> +#endif /* __XFS_EXTFREE_ITEM_H__ */
> diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
> index 91f4cdf2e4f3..a064289e1634 100644
> --- a/libxfs/xfs_ialloc.c
> +++ b/libxfs/xfs_ialloc.c
> @@ -20,6 +20,7 @@
> #include "xfs_error.h"
> #include "xfs_bmap.h"
> #include "xfs_trans.h"
> +#include "xfs_icreate_item.h"
> #include "xfs_buf_item.h"
> #include "xfs_trace.h"
> #include "xfs_log.h"
> diff --git a/libxfs/xfs_icreate_item.h b/libxfs/xfs_icreate_item.h
> new file mode 100644
> index 000000000000..64992823108a
> --- /dev/null
> +++ b/libxfs/xfs_icreate_item.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2008-2010, Dave Chinner
> + * All Rights Reserved.
> + */
> +#ifndef XFS_ICREATE_ITEM_H
> +#define XFS_ICREATE_ITEM_H 1
> +
> +/* in memory log item structure */
> +struct xfs_icreate_item {
> + struct xfs_log_item ic_item;
> + struct xfs_icreate_log ic_format;
> +};
> +
> +extern struct kmem_cache *xfs_icreate_cache; /* inode create item */
> +
> +void xfs_icreate_log(struct xfs_trans *tp, xfs_agnumber_t agno,
> + xfs_agblock_t agbno, unsigned int count,
> + unsigned int inode_size, xfs_agblock_t length,
> + unsigned int generation);
> +
> +#endif /* XFS_ICREATE_ITEM_H */
> diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c
> index b4f556df64ed..16c4c2ccdbb8 100644
> --- a/libxfs/xfs_inode_util.c
> +++ b/libxfs/xfs_inode_util.c
> @@ -20,8 +20,7 @@
> #include "xfs_error.h"
> #include "xfs_trace.h"
> #include "xfs_ag.h"
> -#include "xfs_inode_item.h"
> -#include "iunlink.h"
> +#include "xfs_iunlink_item.h"
> #include "xfs_inode_item.h"
>
> uint16_t
> diff --git a/libxfs/iunlink.h b/libxfs/xfs_iunlink_item.h
> similarity index 61%
> rename from libxfs/iunlink.h
> rename to libxfs/xfs_iunlink_item.h
> index 8d8032cf9326..c793cdcaccde 100644
> --- a/libxfs/iunlink.h
> +++ b/libxfs/xfs_iunlink_item.h
> @@ -10,15 +10,18 @@ struct xfs_trans;
> struct xfs_inode;
> struct xfs_perag;
>
> -static inline struct xfs_inode *
> -xfs_iunlink_lookup(struct xfs_perag *pag, xfs_agino_t agino)
> -{
> - return NULL;
> -}
> +/* in memory log item structure */
> +struct xfs_iunlink_item {
> + struct xfs_log_item item;
> + struct xfs_inode *ip;
> + struct xfs_perag *pag;
> + xfs_agino_t next_agino;
> + xfs_agino_t old_agino;
> +};
> +
> +extern struct kmem_cache *xfs_iunlink_cache;
>
> int xfs_iunlink_log_inode(struct xfs_trans *tp, struct xfs_inode *ip,
> struct xfs_perag *pag, xfs_agino_t next_agino);
> -int xfs_iunlink_reload_next(struct xfs_trans *tp, struct xfs_buf *agibp,
> - xfs_agino_t prev_agino, xfs_agino_t next_agino);
>
> #endif /* XFS_IUNLINK_ITEM_H */
> diff --git a/libxfs/xfs_parent.c b/libxfs/xfs_parent.c
> index 9420d8089e8c..992263f810f8 100644
> --- a/libxfs/xfs_parent.c
> +++ b/libxfs/xfs_parent.c
> @@ -25,7 +25,7 @@
> #include "xfs_defer.h"
> #include "xfs_parent.h"
> #include "xfs_trans_space.h"
> -#include "defer_item.h"
> +#include "xfs_attr_item.h"
> #include "xfs_health.h"
> #include "xfs_attr_leaf.h"
>
> diff --git a/libxfs/xfs_platform.h b/libxfs/xfs_platform.h
> index 4b0069fd70d7..4f4990a20dad 100644
> --- a/libxfs/xfs_platform.h
> +++ b/libxfs/xfs_platform.h
> @@ -350,7 +350,6 @@ xfs_buf_readahead(
> #define uuid_copy(s,d) platform_uuid_copy((s),(d))
> #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
>
> -#define xfs_icreate_log(tp, agno, agbno, cnt, isize, len, gen) ((void) 0)
> #define xfs_sb_validate_fsb_count(sbp, nblks) (0)
> #define xlog_calc_iovec_len(len) roundup(len, sizeof(uint32_t))
>
> diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c
> index 3615f747f82a..6b67308fa594 100644
> --- a/libxfs/xfs_refcount.c
> +++ b/libxfs/xfs_refcount.c
> @@ -24,7 +24,7 @@
> #include "xfs_rmap.h"
> #include "xfs_ag.h"
> #include "xfs_health.h"
> -#include "defer_item.h"
> +#include "xfs_refcount_item.h"
> #include "xfs_rtgroup.h"
> #include "xfs_rtrefcount_btree.h"
>
> diff --git a/libxfs/xfs_refcount_item.h b/libxfs/xfs_refcount_item.h
> new file mode 100644
> index 000000000000..0fc3f493342b
> --- /dev/null
> +++ b/libxfs/xfs_refcount_item.h
> @@ -0,0 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2016 Oracle. All Rights Reserved.
> + * Author: Darrick J. Wong <darrick.wong@oracle.com>
> + */
> +#ifndef __XFS_REFCOUNT_ITEM_H__
> +#define __XFS_REFCOUNT_ITEM_H__
> +
> +/*
> + * There are (currently) two pairs of refcount btree redo item types:
> + * increase and decrease. The log items for these are CUI (refcount
> + * update intent) and CUD (refcount update done). The redo item type
> + * is encoded in the flags field of each xfs_map_extent.
> + *
> + * *I items should be recorded in the *first* of a series of rolled
> + * transactions, and the *D items should be recorded in the same
> + * transaction that records the associated refcountbt updates.
> + *
> + * Should the system crash after the commit of the first transaction
> + * but before the commit of the final transaction in a series, log
> + * recovery will use the redo information recorded by the intent items
> + * to replay the refcountbt metadata updates.
> + */
> +
> +/* kernel only CUI/CUD definitions */
> +
> +struct xfs_mount;
> +struct kmem_cache;
> +
> +/*
> + * Max number of extents in fast allocation path.
> + */
> +#define XFS_CUI_MAX_FAST_EXTENTS 16
> +
> +/*
> + * This is the "refcount update intent" log item. It is used to log
> + * the fact that some reverse mappings need to change. It is used in
> + * conjunction with the "refcount update done" log item described
> + * below.
> + *
> + * These log items follow the same rules as struct xfs_efi_log_item;
> + * see the comments about that structure (in xfs_extfree_item.h) for
> + * more details.
> + */
> +struct xfs_cui_log_item {
> + struct xfs_log_item cui_item;
> + atomic_t cui_refcount;
> + atomic_t cui_next_extent;
> + struct xfs_cui_log_format cui_format;
> +};
> +
> +static inline size_t
> +xfs_cui_log_item_sizeof(
> + unsigned int nr)
> +{
> + return offsetof(struct xfs_cui_log_item, cui_format) +
> + xfs_cui_log_format_sizeof(nr);
> +}
> +
> +/*
> + * This is the "refcount update done" log item. It is used to log the
> + * fact that some refcountbt updates mentioned in an earlier cui item
> + * have been performed.
> + */
> +struct xfs_cud_log_item {
> + struct xfs_log_item cud_item;
> + struct xfs_cui_log_item *cud_cuip;
> + struct xfs_cud_log_format cud_format;
> +};
> +
> +extern struct kmem_cache *xfs_cui_cache;
> +extern struct kmem_cache *xfs_cud_cache;
> +
> +struct xfs_refcount_intent;
> +
> +void xfs_refcount_defer_add(struct xfs_trans *tp,
> + struct xfs_refcount_intent *ri);
> +
> +unsigned int xfs_cui_log_space(unsigned int nr);
> +unsigned int xfs_cud_log_space(void);
> +
> +#endif /* __XFS_REFCOUNT_ITEM_H__ */
> diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c
> index 74600c99172d..34d218de21a9 100644
> --- a/libxfs/xfs_rmap.c
> +++ b/libxfs/xfs_rmap.c
> @@ -24,7 +24,7 @@
> #include "xfs_inode.h"
> #include "xfs_ag.h"
> #include "xfs_health.h"
> -#include "defer_item.h"
> +#include "xfs_rmap_item.h"
> #include "xfs_rtgroup.h"
> #include "xfs_rtrmap_btree.h"
>
> diff --git a/libxfs/xfs_rmap_item.h b/libxfs/xfs_rmap_item.h
> new file mode 100644
> index 000000000000..3a99f0117f2d
> --- /dev/null
> +++ b/libxfs/xfs_rmap_item.h
> @@ -0,0 +1,81 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2016 Oracle. All Rights Reserved.
> + * Author: Darrick J. Wong <darrick.wong@oracle.com>
> + */
> +#ifndef __XFS_RMAP_ITEM_H__
> +#define __XFS_RMAP_ITEM_H__
> +
> +/*
> + * There are (currently) three pairs of rmap btree redo item types: map, unmap,
> + * and convert. The common abbreviations for these are RUI (rmap update
> + * intent) and RUD (rmap update done). The redo item type is encoded in the
> + * flags field of each xfs_map_extent.
> + *
> + * *I items should be recorded in the *first* of a series of rolled
> + * transactions, and the *D items should be recorded in the same transaction
> + * that records the associated rmapbt updates. Typically, the first
> + * transaction will record a bmbt update, followed by some number of
> + * transactions containing rmapbt updates, and finally transactions with any
> + * bnobt/cntbt updates.
> + *
> + * Should the system crash after the commit of the first transaction but
> + * before the commit of the final transaction in a series, log recovery will
> + * use the redo information recorded by the intent items to replay the
> + * (rmapbt/bnobt/cntbt) metadata updates in the non-first transaction.
> + */
> +
> +/* kernel only RUI/RUD definitions */
> +
> +struct xfs_mount;
> +struct kmem_cache;
> +
> +/*
> + * Max number of extents in fast allocation path.
> + */
> +#define XFS_RUI_MAX_FAST_EXTENTS 16
> +
> +/*
> + * This is the "rmap update intent" log item. It is used to log the fact that
> + * some reverse mappings need to change. It is used in conjunction with the
> + * "rmap update done" log item described below.
> + *
> + * These log items follow the same rules as struct xfs_efi_log_item; see the
> + * comments about that structure (in xfs_extfree_item.h) for more details.
> + */
> +struct xfs_rui_log_item {
> + struct xfs_log_item rui_item;
> + atomic_t rui_refcount;
> + atomic_t rui_next_extent;
> + struct xfs_rui_log_format rui_format;
> +};
> +
> +static inline size_t
> +xfs_rui_log_item_sizeof(
> + unsigned int nr)
> +{
> + return offsetof(struct xfs_rui_log_item, rui_format) +
> + xfs_rui_log_format_sizeof(nr);
> +}
> +
> +/*
> + * This is the "rmap update done" log item. It is used to log the fact that
> + * some rmapbt updates mentioned in an earlier rui item have been performed.
> + */
> +struct xfs_rud_log_item {
> + struct xfs_log_item rud_item;
> + struct xfs_rui_log_item *rud_ruip;
> + struct xfs_rud_log_format rud_format;
> +};
> +
> +extern struct kmem_cache *xfs_rui_cache;
> +extern struct kmem_cache *xfs_rud_cache;
> +
> +struct xfs_rmap_intent;
> +
> +void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
> +
> +unsigned int xfs_rui_log_space(unsigned int nr);
> +unsigned int xfs_rud_log_space(void);
> +
> +#endif /* __XFS_RMAP_ITEM_H__ */
> diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
> index d15ca0427584..3a87ab154bb5 100644
> --- a/libxfs/xfs_trans_resv.c
> +++ b/libxfs/xfs_trans_resv.c
> @@ -19,9 +19,14 @@
> #include "xfs_trans.h"
> #include "xfs_trans_space.h"
> #include "xfs_rtbitmap.h"
> +#include "xfs_attr_item.h"
> #include "xfs_log.h"
> +#include "xfs_defer.h"
> +#include "xfs_bmap_item.h"
> +#include "xfs_extfree_item.h"
> +#include "xfs_rmap_item.h"
> +#include "xfs_refcount_item.h"
> #include "xfs_trace.h"
> -#include "defer_item.h"
>
> #define _ALLOC true
> #define _FREE false
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 31+ messages in thread