Skip to contentSkip to conversation

trivial cleanups

PATCH In review Christoph Hellwig 3 participants 9 messages Jan 6, 2025 – Jan 14, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

Hi all,

this series has a few very trivial cleanups.

Diffstt:

 libxfs/xfs_dir2.c       |    6 +++---
 libxfs/xfs_dir2.h       |    1 -
 libxfs/xfs_log_format.h |    6 ------
 xfs_trans.c             |    2 --
 xfs_trans.h             |    1 -
 5 files changed, 3 insertions(+), 13 deletions(-)
#1 lore raw

PATCH 1/3 xfs: mark xfs_dir_isempty static

And return bool instead of a boolean condition as int.

---
 fs/xfs/libxfs/xfs_dir2.c | 6 +++---
 fs/xfs/libxfs/xfs_dir2.h | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_dir2.c +3 -3
index 202468223bf9..81aaef2f495e 100644
@@ -197,7 +197,7 @@ xfs_da_unmount(
 /*
  * Return 1 if directory contains only "." and "..".
  */
-int
+static bool
 xfs_dir_isempty(
 	xfs_inode_t	*dp)
 {
@@ -205,9 +205,9 @@ xfs_dir_isempty(
 
 	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	if (dp->i_disk_size == 0)	/* might happen during shutdown. */
-		return 1;
+		return true;
 	if (dp->i_disk_size > xfs_inode_data_fork_size(dp))
-		return 0;
+		return false;
 	sfp = dp->i_df.if_data;
 	return !sfp->count;
 }
fs/xfs/libxfs/xfs_dir2.h +0 -1
index 576068ed81fa..a6594a5a941d 100644
@@ -58,7 +58,6 @@ extern void xfs_dir_startup(void);
 extern int xfs_da_mount(struct xfs_mount *mp);
 extern void xfs_da_unmount(struct xfs_mount *mp);
 
-extern int xfs_dir_isempty(struct xfs_inode *dp);
 extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_inode *pdp);
 extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
Signature · 1 line
2.45.2
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] xfs: mark xfs_dir_isempty static

Quoted 3 lines · Christoph Hellwig

And return bool instead of a boolean condition as int.

Nice and straightfoward, so

--D

Quoted 46 lines
---
 fs/xfs/libxfs/xfs_dir2.c | 6 +++---
 fs/xfs/libxfs/xfs_dir2.h | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_dir2.c +3 -3
index 202468223bf9..81aaef2f495e 100644
@@ -197,7 +197,7 @@ xfs_da_unmount(
 /*
  * Return 1 if directory contains only "." and "..".
  */
-int
+static bool
 xfs_dir_isempty(
 	xfs_inode_t	*dp)
 {
@@ -205,9 +205,9 @@ xfs_dir_isempty(
 
 	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
 	if (dp->i_disk_size == 0)	/* might happen during shutdown. */
-		return 1;
+		return true;
 	if (dp->i_disk_size > xfs_inode_data_fork_size(dp))
-		return 0;
+		return false;
 	sfp = dp->i_df.if_data;
 	return !sfp->count;
 }
fs/xfs/libxfs/xfs_dir2.h +0 -1
index 576068ed81fa..a6594a5a941d 100644
@@ -58,7 +58,6 @@ extern void xfs_dir_startup(void);
 extern int xfs_da_mount(struct xfs_mount *mp);
 extern void xfs_da_unmount(struct xfs_mount *mp);
 
-extern int xfs_dir_isempty(struct xfs_inode *dp);
 extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_inode *pdp);
 extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
Signature · 1 line
2.45.2
#3 lore raw

PATCH 2/3 xfs: remove XFS_ILOG_NONCORE

In reply to Christoph Hellwig

XFS_ILOG_NONCORE is not used in the kernel code or xfsprogs, remove it.

---
 fs/xfs/libxfs/xfs_log_format.h | 6 ------
 1 file changed, 6 deletions(-)
fs/xfs/libxfs/xfs_log_format.h +0 -6
index 15dec19b6c32..41e974d17ce2 100644
@@ -351,12 +351,6 @@ struct xfs_inode_log_format_32 {
  */
 #define XFS_ILOG_IVERSION	0x8000
 
-#define	XFS_ILOG_NONCORE	(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
-				 XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
-				 XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
-				 XFS_ILOG_ABROOT | XFS_ILOG_DOWNER | \
-				 XFS_ILOG_AOWNER)
-
 #define	XFS_ILOG_DFORK		(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
 				 XFS_ILOG_DBROOT)
 
Signature · 1 line
2.45.2
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] xfs: remove XFS_ILOG_NONCORE

fs/xfs/libxfs/xfs_log_format.h

Quoted 11 lines · Christoph Hellwig

XFS_ILOG_NONCORE is not used in the kernel code or xfsprogs, remove it.

---
 fs/xfs/libxfs/xfs_log_format.h | 6 ------
 1 file changed, 6 deletions(-)
fs/xfs/libxfs/xfs_log_format.h +0 -0
index 15dec19b6c32..41e974d17ce2 100644

Technically this is part of the userspace ABI:

$ grep NONCORE /usr/include/
/usr/include/xfs/xfs_log_format.h:362:#define   XFS_ILOG_NONCORE        (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \

But it makes no sense for userspace to try to use that symbol and Debian codesearch says there are no users, so:

--D

Quoted 17 lines
fs/xfs/libxfs/xfs_log_format.h +0 -6
@@ -351,12 +351,6 @@ struct xfs_inode_log_format_32 {
  */
 #define XFS_ILOG_IVERSION	0x8000
 
-#define	XFS_ILOG_NONCORE	(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
-				 XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
-				 XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
-				 XFS_ILOG_ABROOT | XFS_ILOG_DOWNER | \
-				 XFS_ILOG_AOWNER)
-
 #define	XFS_ILOG_DFORK		(XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
 				 XFS_ILOG_DBROOT)
 
Signature · 1 line
2.45.2
#5 lore raw

Re: [PATCH 2/3] xfs: remove XFS_ILOG_NONCORE

Quoted 7 lines · Darrick J. Wong

fs/xfs/libxfs/xfs_log_format.h

Quoted 4 lines
fs/xfs/libxfs/xfs_log_format.h +0 -0
index 15dec19b6c32..41e974d17ce2 100644

Technically this is part of the userspace ABI:

Quoted 5 lines
$ grep NONCORE /usr/include/
/usr/include/xfs/xfs_log_format.h:362:#define   XFS_ILOG_NONCORE        (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \

But it makes no sense for userspace to try to use that symbol and Debian codesearch says there are no users, so:

In the past we've done plenty of refactoring of the format headers. Locking us out of that would be rather painful.

#6 lore raw

PATCH 3/3 xfs: remove the t_magic field in struct xfs_trans

In reply to Christoph Hellwig

The t_magic field is only ever assigned to, but never read. Remove it.

---
 fs/xfs/xfs_trans.c | 2 --
 fs/xfs/xfs_trans.h | 1 -
 2 files changed, 3 deletions(-)
fs/xfs/xfs_trans.c +0 -2
index 4cd25717c9d1..786fb659ee3f 100644
@@ -100,7 +100,6 @@ xfs_trans_dup(
 	/*
 	 * Initialize the new transaction structure.
 	 */
-	ntp->t_magic = XFS_TRANS_HEADER_MAGIC;
 	ntp->t_mountp = tp->t_mountp;
 	INIT_LIST_HEAD(&ntp->t_items);
 	INIT_LIST_HEAD(&ntp->t_busy);
@@ -275,7 +274,6 @@ xfs_trans_alloc(
 	ASSERT(!(flags & XFS_TRANS_RES_FDBLKS) ||
 	       xfs_has_lazysbcount(mp));
 
-	tp->t_magic = XFS_TRANS_HEADER_MAGIC;
 	tp->t_flags = flags;
 	tp->t_mountp = mp;
 	INIT_LIST_HEAD(&tp->t_items);
fs/xfs/xfs_trans.h +0 -1
index 71c2e82e4dad..2b366851e9a4 100644
@@ -122,7 +122,6 @@ void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
  * This is the structure maintained for every active transaction.
  */
 typedef struct xfs_trans {
-	unsigned int		t_magic;	/* magic number */
 	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 */
Signature · 1 line
2.45.2
Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] xfs: remove the t_magic field in struct xfs_trans

Quoted 3 lines · Christoph Hellwig

The t_magic field is only ever assigned to, but never read. Remove it.

And it eliminates a 4-byte hole!

--D

Quoted 41 lines
---
 fs/xfs/xfs_trans.c | 2 --
 fs/xfs/xfs_trans.h | 1 -
 2 files changed, 3 deletions(-)
fs/xfs/xfs_trans.c +0 -2
index 4cd25717c9d1..786fb659ee3f 100644
@@ -100,7 +100,6 @@ xfs_trans_dup(
 	/*
 	 * Initialize the new transaction structure.
 	 */
-	ntp->t_magic = XFS_TRANS_HEADER_MAGIC;
 	ntp->t_mountp = tp->t_mountp;
 	INIT_LIST_HEAD(&ntp->t_items);
 	INIT_LIST_HEAD(&ntp->t_busy);
@@ -275,7 +274,6 @@ xfs_trans_alloc(
 	ASSERT(!(flags & XFS_TRANS_RES_FDBLKS) ||
 	       xfs_has_lazysbcount(mp));
 
-	tp->t_magic = XFS_TRANS_HEADER_MAGIC;
 	tp->t_flags = flags;
 	tp->t_mountp = mp;
 	INIT_LIST_HEAD(&tp->t_items);
fs/xfs/xfs_trans.h +0 -1
index 71c2e82e4dad..2b366851e9a4 100644
@@ -122,7 +122,6 @@ void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
  * This is the structure maintained for every active transaction.
  */
 typedef struct xfs_trans {
-	unsigned int		t_magic;	/* magic number */
 	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 */
Signature · 1 line
2.45.2
maintainer Applied
#8 lore raw
In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig

this series has a few very trivial cleanups.

Diffstt:

 libxfs/xfs_dir2.c       |    6 +++---
 libxfs/xfs_dir2.h       |    1 -
 libxfs/xfs_log_format.h |    6 ------
 xfs_trans.c             |    2 --
 xfs_trans.h             |    1 -
 5 files changed, 3 insertions(+), 13 deletions(-)

[...]

Applied to for-next, thanks!

[1/3] xfs: mark xfs_dir_isempty static

      commit: 23ebf63925989adbe4c4277c8e9b04e0a37f6005
[2/3] xfs: remove XFS_ILOG_NONCORE
      commit: 415dee1e06da431f3d314641ceecb9018bb6fa53
[3/3] xfs: remove the t_magic field in struct xfs_trans
      commit: 471511d6ef7d00b40e65902ff47acfc194c6a952

Best regards,

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