Skip to contentSkip to conversation

small cleanups to help code sharing with xfsprogs

PATCH New Christoph Hellwig 3 participants 9 messages Sep 25 – Oct 8 XFS filesystem

lore
Share & tools
lore
#0 lore raw

Hi all,

this series has a few trivial cleanups and code moves that help sharing more code with xfsprogs.

Diffstat:

 libxfs/xfs_attr_item.h     |    2 --
 libxfs/xfs_bmap_item.h     |    2 --
 libxfs/xfs_buf_item.h      |    2 --
 libxfs/xfs_defer.c         |    1 -
 libxfs/xfs_exchmaps_item.h |    2 --
 libxfs/xfs_extfree_item.h  |    2 --
 libxfs/xfs_inode_buf.c     |    3 ---
 libxfs/xfs_inode_item.h    |    2 --
 libxfs/xfs_inode_util.c    |    1 -
 libxfs/xfs_refcount.c      |    1 -
 libxfs/xfs_refcount_item.h |    2 --
 libxfs/xfs_rmap_item.h     |    2 --
 libxfs/xfs_rtbitmap.c      |    1 -
 libxfs/xfs_rtgroup.c       |    1 -
 libxfs/xfs_sb.c            |    1 -
 libxfs/xfs_trans.h         |    2 --
 libxfs/xfs_trans_inode.c   |    2 --
 xfs_platform.h             |    1 +
 18 files changed, 1 insertion(+), 29 deletions(-)
#1 lore raw

PATCH 1/4 xfs: remove various unused includes in libxfs/

Remove a few unused includes in libxfs/ that cause spurious differences between the kernel and userspace versions of these files.

---
 fs/xfs/libxfs/xfs_defer.c     | 1 -
 fs/xfs/libxfs/xfs_inode_buf.c | 1 -
 fs/xfs/libxfs/xfs_refcount.c  | 1 -
 fs/xfs/libxfs/xfs_rtbitmap.c  | 1 -
 fs/xfs/libxfs/xfs_rtgroup.c   | 1 -
 fs/xfs/libxfs/xfs_sb.c        | 1 -
 6 files changed, 6 deletions(-)
fs/xfs/libxfs/xfs_defer.c +0 -1
index 3152acdc335d..c5fa4450281d 100644
@@ -24,7 +24,6 @@
 #include "xfs_refcount.h"
 #include "xfs_bmap.h"
 #include "xfs_alloc.h"
-#include "xfs_buf.h"
 #include "xfs_da_format.h"
 #include "xfs_da_btree.h"
 #include "xfs_attr.h"
fs/xfs/libxfs/xfs_inode_buf.c +0 -1
index 0340e2189921..b82f067ca5b1 100644
@@ -14,7 +14,6 @@
 #include "xfs_inode.h"
 #include "xfs_errortag.h"
 #include "xfs_error.h"
-#include "xfs_icache.h"
 #include "xfs_trans.h"
 #include "xfs_ialloc.h"
 #include "xfs_dir2.h"
fs/xfs/libxfs/xfs_refcount.c +0 -1
index 0ec6ccd8b4dc..6b67308fa594 100644
@@ -26,7 +26,6 @@
 #include "xfs_health.h"
 #include "xfs_refcount_item.h"
 #include "xfs_rtgroup.h"
-#include "xfs_rtalloc.h"
 #include "xfs_rtrefcount_btree.h"
 
 struct kmem_cache	*xfs_refcount_intent_cache;
fs/xfs/libxfs/xfs_rtbitmap.c +0 -1
index e62786e90f7b..590e0641ff0d 100644
@@ -16,7 +16,6 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_trans_space.h"
 #include "xfs_trans.h"
-#include "xfs_rtalloc.h"
 #include "xfs_error.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_health.h"
fs/xfs/libxfs/xfs_rtgroup.c +0 -1
index fe7222bbe449..c6981f566860 100644
@@ -27,7 +27,6 @@
 #include "xfs_trans.h"
 #include "xfs_trace.h"
 #include "xfs_inode.h"
-#include "xfs_icache.h"
 #include "xfs_buf_item.h"
 #include "xfs_rtgroup.h"
 #include "xfs_rtbitmap.h"
fs/xfs/libxfs/xfs_sb.c +0 -1
index d2ef7b20a49f..ce44123c98ce 100644
@@ -26,7 +26,6 @@
 #include "xfs_health.h"
 #include "xfs_ag.h"
 #include "xfs_rtbitmap.h"
-#include "xfs_exchrange.h"
 #include "xfs_rtgroup.h"
 #include "xfs_rtrmap_btree.h"
 #include "xfs_rtrefcount_btree.h"
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/4 xfs: include <linux/iversion.h> in xfs_platform.h

In reply to Christoph Hellwig

This removes the only non-xfs inludes from libxfs/ and thus reduces the differences between the kernel and userspace versions of these files.

---
 fs/xfs/libxfs/xfs_inode_buf.c   | 2 --
 fs/xfs/libxfs/xfs_inode_util.c  | 1 -
 fs/xfs/libxfs/xfs_trans_inode.c | 2 --
 fs/xfs/xfs_platform.h           | 1 +
 4 files changed, 1 insertion(+), 5 deletions(-)
fs/xfs/libxfs/xfs_inode_buf.c +0 -2
index b82f067ca5b1..282e78e5e3e8 100644
@@ -20,8 +20,6 @@
 #include "xfs_health.h"
 #include "xfs_metafile.h"
 
-#include <linux/iversion.h>
-
 /*
  * If we are doing readahead on an inode buffer, we might be in log recovery
  * reading an inode allocation buffer that hasn't yet been replayed, and hence
fs/xfs/libxfs/xfs_inode_util.c +0 -1
index 258ac3d0d486..16c4c2ccdbb8 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
  */
-#include <linux/iversion.h>
 #include "xfs_platform.h"
 #include "xfs_fs.h"
 #include "xfs_shared.h"
fs/xfs/libxfs/xfs_trans_inode.c +0 -2
index 1a0fdcbf39fa..e3dca0652d26 100644
@@ -15,8 +15,6 @@
 #include "xfs_trans_priv.h"
 #include "xfs_inode_item.h"
 
-#include <linux/iversion.h>
-
 /*
  * Add a locked inode to the transaction.
  *
fs/xfs/xfs_platform.h +1 -0
index 745d715b4c64..7b63ea26b186 100644
@@ -50,6 +50,7 @@
 #include <linux/xattr.h>
 #include <linux/mnt_idmapping.h>
 #include <linux/debugfs.h>
+#include <linux/iversion.h>
 #include <asm/page.h>
 #include <asm/div64.h>
 #include <asm/param.h>
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/4 xfs: move xfs_*_item.h to libxfs

In reply to Christoph Hellwig

All these files can be used as-is in xfsprogs to replace various shades of copy and paste.

---
 fs/xfs/{ => libxfs}/xfs_attr_item.h     | 2 --
 fs/xfs/{ => libxfs}/xfs_bmap_item.h     | 2 --
 fs/xfs/{ => libxfs}/xfs_buf_item.h      | 2 --
 fs/xfs/{ => libxfs}/xfs_dquot_item.h    | 0
 fs/xfs/{ => libxfs}/xfs_exchmaps_item.h | 2 --
 fs/xfs/{ => libxfs}/xfs_extfree_item.h  | 2 --
 fs/xfs/{ => libxfs}/xfs_icreate_item.h  | 0
 fs/xfs/{ => libxfs}/xfs_inode_item.h    | 2 --
 fs/xfs/{ => libxfs}/xfs_iunlink_item.h  | 0
 fs/xfs/{ => libxfs}/xfs_refcount_item.h | 2 --
 fs/xfs/{ => libxfs}/xfs_rmap_item.h     | 2 --
 11 files changed, 16 deletions(-)
 rename fs/xfs/{ => libxfs}/xfs_attr_item.h (97%)
 rename fs/xfs/{ => libxfs}/xfs_bmap_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_buf_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_dquot_item.h (100%)
 rename fs/xfs/{ => libxfs}/xfs_exchmaps_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_extfree_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_icreate_item.h (100%)
 rename fs/xfs/{ => libxfs}/xfs_inode_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_iunlink_item.h (100%)
 rename fs/xfs/{ => libxfs}/xfs_refcount_item.h (98%)
 rename fs/xfs/{ => libxfs}/xfs_rmap_item.h (98%)
fs/xfs/libxfs/xfs_attr_item.h renamed from fs/xfs/xfs_attr_item.h +0 -2
similarity index 97%
rename from fs/xfs/xfs_attr_item.h
rename to fs/xfs/libxfs/xfs_attr_item.h
index d108a11b55ae..3bb3d7108a90 100644
@@ -6,8 +6,6 @@
 #ifndef	__XFS_ATTR_ITEM_H__
 #define	__XFS_ATTR_ITEM_H__
 
-/* kernel only ATTRI/ATTRD definitions */
-
 struct xfs_mount;
 struct kmem_zone;
 
fs/xfs/libxfs/xfs_bmap_item.h renamed from fs/xfs/xfs_bmap_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_bmap_item.h
rename to fs/xfs/libxfs/xfs_bmap_item.h
index b42fee06899d..381b8a62b47c 100644
@@ -22,8 +22,6 @@
  * bmbt metadata updates in the non-first transaction.
  */
 
-/* kernel only BUI/BUD definitions */
-
 struct xfs_mount;
 struct kmem_cache;
 
fs/xfs/libxfs/xfs_buf_item.h renamed from fs/xfs/xfs_buf_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_buf_item.h
rename to fs/xfs/libxfs/xfs_buf_item.h
index 28c79989d725..d0a1247d22c6 100644
@@ -6,8 +6,6 @@
 #ifndef	__XFS_BUF_ITEM_H__
 #define	__XFS_BUF_ITEM_H__
 
-/* kernel only definitions */
-
 struct xfs_buf;
 struct xfs_mount;
 
fs/xfs/libxfs/xfs_dquot_item.h renamed from fs/xfs/xfs_dquot_item.h +0 -0
similarity index 100%
rename from fs/xfs/xfs_dquot_item.h
rename to fs/xfs/libxfs/xfs_dquot_item.h
fs/xfs/libxfs/xfs_exchmaps_item.h renamed from fs/xfs/xfs_exchmaps_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_exchmaps_item.h
rename to fs/xfs/libxfs/xfs_exchmaps_item.h
index efa368d25d09..4a42f70237fb 100644
@@ -22,8 +22,6 @@
  * rest of the mapping exchanges.
  */
 
-/* kernel only XMI/XMD definitions */
-
 struct xfs_mount;
 struct kmem_cache;
 
fs/xfs/libxfs/xfs_extfree_item.h renamed from fs/xfs/xfs_extfree_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_extfree_item.h
rename to fs/xfs/libxfs/xfs_extfree_item.h
index af1b0331f7af..4d8ae7438b84 100644
@@ -6,8 +6,6 @@
 #ifndef	__XFS_EXTFREE_ITEM_H__
 #define	__XFS_EXTFREE_ITEM_H__
 
-/* kernel only EFI/EFD definitions */
-
 struct xfs_mount;
 struct kmem_cache;
 
fs/xfs/libxfs/xfs_icreate_item.h renamed from fs/xfs/xfs_icreate_item.h +0 -0
similarity index 100%
rename from fs/xfs/xfs_icreate_item.h
rename to fs/xfs/libxfs/xfs_icreate_item.h
fs/xfs/libxfs/xfs_inode_item.h renamed from fs/xfs/xfs_inode_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_inode_item.h
rename to fs/xfs/libxfs/xfs_inode_item.h
index 2ddcca41714f..226c9ec01434 100644
@@ -6,8 +6,6 @@
 #ifndef	__XFS_INODE_ITEM_H__
 #define	__XFS_INODE_ITEM_H__
 
-/* kernel only definitions */
-
 struct xfs_buf;
 struct xfs_bmbt_rec;
 struct xfs_inode;
fs/xfs/libxfs/xfs_iunlink_item.h renamed from fs/xfs/xfs_iunlink_item.h +0 -0
similarity index 100%
rename from fs/xfs/xfs_iunlink_item.h
rename to fs/xfs/libxfs/xfs_iunlink_item.h
fs/xfs/libxfs/xfs_refcount_item.h renamed from fs/xfs/xfs_refcount_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_refcount_item.h
rename to fs/xfs/libxfs/xfs_refcount_item.h
index 0fc3f493342b..c94b119624b3 100644
@@ -22,8 +22,6 @@
  * to replay the refcountbt metadata updates.
  */
 
-/* kernel only CUI/CUD definitions */
-
 struct xfs_mount;
 struct kmem_cache;
 
fs/xfs/libxfs/xfs_rmap_item.h renamed from fs/xfs/xfs_rmap_item.h +0 -2
similarity index 98%
rename from fs/xfs/xfs_rmap_item.h
rename to fs/xfs/libxfs/xfs_rmap_item.h
index 3a99f0117f2d..8e9a23e89fd1 100644
@@ -25,8 +25,6 @@
  * (rmapbt/bnobt/cntbt) metadata updates in the non-first transaction.
  */
 
-/* kernel only RUI/RUD definitions */
-
 struct xfs_mount;
 struct kmem_cache;
 
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/4 xfs: move xfs_trans.h to libxfs

In reply to Christoph Hellwig

This file can be reused in xfsprogs instead of carrying a slightly modified version.

---
 fs/xfs/{ => libxfs}/xfs_trans.h | 2 --
 1 file changed, 2 deletions(-)
 rename fs/xfs/{ => libxfs}/xfs_trans.h (99%)
fs/xfs/libxfs/xfs_trans.h renamed from fs/xfs/xfs_trans.h +0 -2
similarity index 99%
rename from fs/xfs/xfs_trans.h
rename to fs/xfs/libxfs/xfs_trans.h
index eb83c5dac032..8a98735b8e15 100644
@@ -6,8 +6,6 @@
 #ifndef	__XFS_TRANS_H__
 #define	__XFS_TRANS_H__
 
-/* kernel only transaction subsystem defines */
-
 struct xlog;
 struct xlog_format_buf;
 struct xfs_buf;
Signature · 1 line
2.53.0
Reviewed-by
#5 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

Hi all,

this series has a few trivial cleanups and code moves that help sharing more code with xfsprogs.

Hrmm. This is a somewhat different approach than what Chris Wedgwood did for his log port to userspace. What do the maintainers think? I'll defer to them as to whether pushing some of the log code into fs/xfs/libxfs is better than pushing all the log code to fs/xfs/libxlog.

The code changes look ok, so for the whole series,

--D

Quoted 22 lines

Diffstat:

 libxfs/xfs_attr_item.h     |    2 --
 libxfs/xfs_bmap_item.h     |    2 --
 libxfs/xfs_buf_item.h      |    2 --
 libxfs/xfs_defer.c         |    1 -
 libxfs/xfs_exchmaps_item.h |    2 --
 libxfs/xfs_extfree_item.h  |    2 --
 libxfs/xfs_inode_buf.c     |    3 ---
 libxfs/xfs_inode_item.h    |    2 --
 libxfs/xfs_inode_util.c    |    1 -
 libxfs/xfs_refcount.c      |    1 -
 libxfs/xfs_refcount_item.h |    2 --
 libxfs/xfs_rmap_item.h     |    2 --
 libxfs/xfs_rtbitmap.c      |    1 -
 libxfs/xfs_rtgroup.c       |    1 -
 libxfs/xfs_sb.c            |    1 -
 libxfs/xfs_trans.h         |    2 --
 libxfs/xfs_trans_inode.c   |    2 --
 xfs_platform.h             |    1 +
 18 files changed, 1 insertion(+), 29 deletions(-)
#6 lore raw
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Christoph Hellwig

Hi all,

this series has a few trivial cleanups and code moves that help sharing more code with xfsprogs.

Hrmm. This is a somewhat different approach than what Chris Wedgwood did for his log port to userspace.

Well, that seems to have been an AI slop dump without any further engagement from the LLM-herder, so I'm not sure it matters.

But it also is a bit of a different thing. This series tries to reduce the kernel/user libxfs differences, and reusing whatever we can from the kernel helps with that. What we do about the log becomes relevant if/when we want to update that or share more. My previously stated opinion is that splitting a single kernel code base into two libraries, which then generally are linked into the same programs again is not helpful. But someone comes up with a design that actually makes it work painlessly I would not complain. In the meantime I'd improve the maintainability of libxfs without touching the logging code at all.

maintainer Reviewed-by
#7 lore raw

Back from conferences. Sorry the late reply...

Quoted 4 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong
Quoted 2 lines · Christoph Hellwig

Hi all,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

this series has a few trivial cleanups and code moves that help sharing more code with xfsprogs.

Hrmm. This is a somewhat different approach than what Chris Wedgwood did for his log port to userspace.

Well, that seems to have been an AI slop dump without any further engagement from the LLM-herder, so I'm not sure it matters.

Indeed, I'd stay with this series, so for this series:

Quoted 10 lines

But it also is a bit of a different thing. This series tries to reduce the kernel/user libxfs differences, and reusing whatever we can from the kernel helps with that. What we do about the log becomes relevant if/when we want to update that or share more. My previously stated opinion is that splitting a single kernel code base into two libraries, which then generally are linked into the same programs again is not helpful. But someone comes up with a design that actually makes it work painlessly I would not complain. In the meantime I'd improve the maintainability of libxfs without touching the logging code at all.

Agreed.

maintainer Applied
#8 lore raw
In reply to Christoph Hellwig
Quoted 24 lines · Christoph Hellwig

this series has a few trivial cleanups and code moves that help sharing more code with xfsprogs.

Diffstat:

 libxfs/xfs_attr_item.h     |    2 --
 libxfs/xfs_bmap_item.h     |    2 --
 libxfs/xfs_buf_item.h      |    2 --
 libxfs/xfs_defer.c         |    1 -
 libxfs/xfs_exchmaps_item.h |    2 --
 libxfs/xfs_extfree_item.h  |    2 --
 libxfs/xfs_inode_buf.c     |    3 ---
 libxfs/xfs_inode_item.h    |    2 --
 libxfs/xfs_inode_util.c    |    1 -
 libxfs/xfs_refcount.c      |    1 -
 libxfs/xfs_refcount_item.h |    2 --
 libxfs/xfs_rmap_item.h     |    2 --
 libxfs/xfs_rtbitmap.c      |    1 -
 libxfs/xfs_rtgroup.c       |    1 -
 libxfs/xfs_sb.c            |    1 -
 libxfs/xfs_trans.h         |    2 --
 libxfs/xfs_trans_inode.c   |    2 --
 xfs_platform.h             |    1 +
 18 files changed, 1 insertion(+), 29 deletions(-)
Quoted 1 line

[...]

Applied to for-next, thanks!

[1/4] xfs: remove various unused includes in libxfs/

      commit: 6fe0d151eaada4f3ea4947b19ac048b8894b9e88
[2/4] xfs: include <linux/iversion.h> in xfs_platform.h
      commit: 5e68008e9c0d5ec602582dd659d4d1c6f910ef4a
[3/4] xfs: move xfs_*_item.h to libxfs
      commit: 834a6a1e9633722df3bfde5f4fa830432faa360a
[4/4] xfs: move xfs_trans.h to libxfs
      commit: ce47e8aab95d6bd4f70b9cbc7308ca13b9d57660

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>