Skip to contentSkip to conversation

xfs: remove XFS_ITEM_RELEASE_WHEN_COMMITTED

PATCH In review Dave Chinner 2 participants 3 messages May 4, 2021 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: remove XFS_ITEM_RELEASE_WHEN_COMMITTED

From: Dave Chinner <[email protected]>

Redundant functionality. Returning NULLCOMMITLSN from ->iop_committed means "release item as there is no further processing to be done", making this flag entirely redundant.

---
 fs/xfs/xfs_bmap_item.c     |  2 +-
 fs/xfs/xfs_dquot_item.c    |  2 +-
 fs/xfs/xfs_extfree_item.c  |  2 +-
 fs/xfs/xfs_icreate_item.c  |  2 +-
 fs/xfs/xfs_inode_item.c    |  4 ++--
 fs/xfs/xfs_log.c           | 12 ++++++++++++
 fs/xfs/xfs_refcount_item.c |  2 +-
 fs/xfs/xfs_rmap_item.c     |  2 +-
 fs/xfs/xfs_trans.c         |  9 ++-------
 fs/xfs/xfs_trans.h         | 13 ++++++-------
 10 files changed, 28 insertions(+), 22 deletions(-)
fs/xfs/xfs_bmap_item.c +1 -1
index 2344757ede63..e827ebaf815e 100644
@@ -203,10 +203,10 @@ xfs_bud_item_release(
 }
 
 static const struct xfs_item_ops xfs_bud_item_ops = {
-	.flags		= XFS_ITEM_RELEASE_WHEN_COMMITTED,
 	.iop_size	= xfs_bud_item_size,
 	.iop_format	= xfs_bud_item_format,
 	.iop_release	= xfs_bud_item_release,
+	.iop_comitted	= xfs_log_item_committed_done,
 };
 
 static struct xfs_bud_log_item *
fs/xfs/xfs_dquot_item.c +1 -1
index 8c1fdf37ee8f..4fcfc9e58ca1 100644
@@ -282,7 +282,7 @@ xfs_qm_qoffend_logitem_committed(
 
 	kmem_free(lip->li_lv_shadow);
 	kmem_free(qfe);
-	return (xfs_lsn_t)-1;
+	return NULLCOMMITLSN;
 }
 
 STATIC void
fs/xfs/xfs_extfree_item.c +1 -1
index 93223ebb3372..04a117645906 100644
@@ -307,10 +307,10 @@ xfs_efd_item_release(
 }
 
 static const struct xfs_item_ops xfs_efd_item_ops = {
-	.flags		= XFS_ITEM_RELEASE_WHEN_COMMITTED,
 	.iop_size	= xfs_efd_item_size,
 	.iop_format	= xfs_efd_item_format,
 	.iop_release	= xfs_efd_item_release,
+	.iop_comitted	= xfs_log_item_committed_done,
 };
 
 /*
fs/xfs/xfs_icreate_item.c +1 -1
index 9b3994b9c716..f1c5b04c805d 100644
@@ -67,10 +67,10 @@ xfs_icreate_item_release(
 }
 
 static const struct xfs_item_ops xfs_icreate_item_ops = {
-	.flags		= XFS_ITEM_RELEASE_WHEN_COMMITTED,
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
 	.iop_release	= xfs_icreate_item_release,
+	.iop_comitted	= xfs_log_item_committed_done,
 };
 
 
fs/xfs/xfs_inode_item.c +2 -2
index c1b32680f71c..8122defbf139 100644
@@ -607,7 +607,7 @@ xfs_inode_item_release(
  * triggers an assert in xfs_inode_free() complaining about freein an inode
  * still in the AIL.
  *
- * To avoid this, just unpin the inode directly and return a LSN of -1 so the
+ * To avoid this, just unpin the inode directly and return NULLCOMMITLSN so the
  * transaction committed code knows that it does not need to do any further
  * processing on the item.
  */
@@ -621,7 +621,7 @@ xfs_inode_item_committed(
 
 	if (xfs_iflags_test(ip, XFS_ISTALE)) {
 		xfs_inode_item_unpin(lip, 0);
-		return -1;
+		return NULLCOMMITLSN;
 	}
 	return lsn;
 }
fs/xfs/xfs_log.c +12 -0
index 06041834daa3..0a5ed64f1c7a 100644
@@ -1012,6 +1012,18 @@ xfs_log_item_init(
 	INIT_LIST_HEAD(&item->li_trans);
 }
 
+/*
+ * Log items that have no processing required after they are committed use this
+ * as their ->iop_committed method. xfs_trans_committed_bulk() will skip further
+ * processing for objects that return NULLCOMMITLSN to this method.
+ */
+xfs_lsn_t
+xfs_log_item_committed_done(
+	struct xfs_log_item *item)
+{
+	return NULLCOMMITLSN;
+}
+
 /*
  * Wake up processes waiting for log space after we have moved the log tail.
  */
fs/xfs/xfs_refcount_item.c +1 -1
index 07ebccbbf4df..6a606a2f9019 100644
@@ -208,10 +208,10 @@ xfs_cud_item_release(
 }
 
 static const struct xfs_item_ops xfs_cud_item_ops = {
-	.flags		= XFS_ITEM_RELEASE_WHEN_COMMITTED,
 	.iop_size	= xfs_cud_item_size,
 	.iop_format	= xfs_cud_item_format,
 	.iop_release	= xfs_cud_item_release,
+	.iop_comitted	= xfs_log_item_committed_done,
 };
 
 static struct xfs_cud_log_item *
fs/xfs/xfs_rmap_item.c +1 -1
index 49cebd68b672..1fc580548e72 100644
@@ -231,10 +231,10 @@ xfs_rud_item_release(
 }
 
 static const struct xfs_item_ops xfs_rud_item_ops = {
-	.flags		= XFS_ITEM_RELEASE_WHEN_COMMITTED,
 	.iop_size	= xfs_rud_item_size,
 	.iop_format	= xfs_rud_item_format,
 	.iop_release	= xfs_rud_item_release,
+	.iop_comitted	= xfs_log_item_committed_done,
 };
 
 static struct xfs_rud_log_item *
fs/xfs/xfs_trans.c +2 -7
index bcc978011869..641cfb753999 100644
@@ -763,18 +763,13 @@ xfs_trans_committed_bulk(
 		if (aborted)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
 
-		if (lip->li_ops->flags & XFS_ITEM_RELEASE_WHEN_COMMITTED) {
-			lip->li_ops->iop_release(lip);
-			continue;
-		}
-
 		if (lip->li_ops->iop_committed)
 			item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
 		else
 			item_lsn = commit_lsn;
 
-		/* item_lsn of -1 means the item needs no further processing */
-		if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
+		/* NULLCOMMITLSN means the item needs no further processing */
+		if (XFS_LSN_CMP(item_lsn, NULLCOMMITLSN) == 0)
 			continue;
 
 		/*
fs/xfs/xfs_trans.h +6 -7
index 9dd745cf77c9..de22b4046ebc 100644
@@ -63,7 +63,6 @@ struct xfs_log_item {
 	{ (1 << XFS_LI_DIRTY),		"DIRTY" }
 
 struct xfs_item_ops {
-	unsigned flags;
 	void (*iop_size)(struct xfs_log_item *, int *, int *);
 	void (*iop_format)(struct xfs_log_item *, struct xfs_log_vec *);
 	void (*iop_pin)(struct xfs_log_item *);
@@ -95,15 +94,15 @@ xlog_item_is_intent_done(struct xfs_log_item *lip)
 	       lip->li_ops->iop_push == NULL;
 }
 
-/*
- * Release the log item as soon as committed.  This is for items just logging
- * intents that never need to be written back in place.
- */
-#define XFS_ITEM_RELEASE_WHEN_COMMITTED	(1 << 0)
-
 void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
 			  int type, const struct xfs_item_ops *ops);
 
+/*
+ * Generic ->iop_committed callback to indicate that the log item should not be
+ * referenced by the caller once the callback returns.
+ */
+xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
+
 /*
  * Return values for the iop_push() routines.
  */
Signature · 1 line
2.31.1
#1 lore raw
Quoted 7 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Redundant functionality. Returning NULLCOMMITLSN from ->iop_committed means "release item as there is no further processing to be done", making this flag entirely redundant.

Self NACK on this - I jus t realised I'd snet the wrong branch to build and test so it "passed" when in fact it doesn't even compile, let alone work.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
In reply to Dave Chinner
Thank you for the patch! Yet something to improve:

Hi Dave,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on v5.12 next-20210504]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Dave-Chinner/xfs-remove-XFS_ITEM_RELEASE_WHEN_COMMITTED/20210504-123005
base:   https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
config: x86_64-randconfig-a002-20210504 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8f5a2a5836cc8e4c1def2bdeb022e7b496623439)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/49245f53b5151023638e214a6f0817452b67c887
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dave-Chinner/xfs-remove-XFS_ITEM_RELEASE_WHEN_COMMITTED/20210504-123005 git checkout 49245f53b5151023638e214a6f0817452b67c887
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from fs/xfs/xfs_trace.c:22:

>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
   1 error generated.
--
   In file included from fs/xfs/xfs_file.c:14:
>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
   In file included from fs/xfs/xfs_file.c:30:
   include/linux/mman.h:156:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:133:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.
--
   In file included from fs/xfs/xfs_bmap_item.c:16:
>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
>> fs/xfs/xfs_bmap_item.c:209:3: error: field designator 'iop_comitted' does not refer to any field in type 'const struct xfs_item_ops'; did you mean 'iop_committed'?
           .iop_comitted   = xfs_log_item_committed_done,
            ^~~~~~~~~~~~
            iop_committed
   fs/xfs/xfs_trans.h:73:14: note: 'iop_committed' declared here
           xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
                       ^
>> fs/xfs/xfs_bmap_item.c:209:18: error: incompatible function pointer types initializing 'xfs_lsn_t (*)(struct xfs_log_item *, xfs_lsn_t)' (aka 'long long (*)(struct xfs_log_item *, long long)') with an expression of type 'xfs_lsn_t (struct xfs_log_item *)' (aka 'long long (struct xfs_log_item *)') [-Werror,-Wincompatible-function-pointer-types]

.iop_comitted = xfs_log_item_committed_done,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
--
In file included from fs/xfs/xfs_extfree_item.c:15:

>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
>> fs/xfs/xfs_extfree_item.c:313:3: error: field designator 'iop_comitted' does not refer to any field in type 'const struct xfs_item_ops'; did you mean 'iop_committed'?
           .iop_comitted   = xfs_log_item_committed_done,
            ^~~~~~~~~~~~
            iop_committed
   fs/xfs/xfs_trans.h:73:14: note: 'iop_committed' declared here
           xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
                       ^
>> fs/xfs/xfs_extfree_item.c:313:18: error: incompatible function pointer types initializing 'xfs_lsn_t (*)(struct xfs_log_item *, xfs_lsn_t)' (aka 'long long (*)(struct xfs_log_item *, long long)') with an expression of type 'xfs_lsn_t (struct xfs_log_item *)' (aka 'long long (struct xfs_log_item *)') [-Werror,-Wincompatible-function-pointer-types]

.iop_comitted = xfs_log_item_committed_done,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
--
In file included from fs/xfs/xfs_icreate_item.c:14:

>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
>> fs/xfs/xfs_icreate_item.c:73:3: error: field designator 'iop_comitted' does not refer to any field in type 'const struct xfs_item_ops'; did you mean 'iop_committed'?
           .iop_comitted   = xfs_log_item_committed_done,
            ^~~~~~~~~~~~
            iop_committed
   fs/xfs/xfs_trans.h:73:14: note: 'iop_committed' declared here
           xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
                       ^
>> fs/xfs/xfs_icreate_item.c:73:18: error: incompatible function pointer types initializing 'xfs_lsn_t (*)(struct xfs_log_item *, xfs_lsn_t)' (aka 'long long (*)(struct xfs_log_item *, long long)') with an expression of type 'xfs_lsn_t (struct xfs_log_item *)' (aka 'long long (struct xfs_log_item *)') [-Werror,-Wincompatible-function-pointer-types]

.iop_comitted = xfs_log_item_committed_done,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
--
In file included from fs/xfs/xfs_refcount_item.c:15:

>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
>> fs/xfs/xfs_refcount_item.c:214:3: error: field designator 'iop_comitted' does not refer to any field in type 'const struct xfs_item_ops'; did you mean 'iop_committed'?
           .iop_comitted   = xfs_log_item_committed_done,
            ^~~~~~~~~~~~
            iop_committed
   fs/xfs/xfs_trans.h:73:14: note: 'iop_committed' declared here
           xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
                       ^
>> fs/xfs/xfs_refcount_item.c:214:18: error: incompatible function pointer types initializing 'xfs_lsn_t (*)(struct xfs_log_item *, xfs_lsn_t)' (aka 'long long (*)(struct xfs_log_item *, long long)') with an expression of type 'xfs_lsn_t (struct xfs_log_item *)' (aka 'long long (struct xfs_log_item *)') [-Werror,-Wincompatible-function-pointer-types]

.iop_comitted = xfs_log_item_committed_done,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
--
In file included from fs/xfs/xfs_rmap_item.c:15:

>> fs/xfs/xfs_trans.h:104:65: error: expected ';' after top level declarator
   xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)
                                                                   ^
                                                                   ;
>> fs/xfs/xfs_rmap_item.c:237:3: error: field designator 'iop_comitted' does not refer to any field in type 'const struct xfs_item_ops'; did you mean 'iop_committed'?
           .iop_comitted   = xfs_log_item_committed_done,
            ^~~~~~~~~~~~
            iop_committed
   fs/xfs/xfs_trans.h:73:14: note: 'iop_committed' declared here
           xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
                       ^
>> fs/xfs/xfs_rmap_item.c:237:18: error: incompatible function pointer types initializing 'xfs_lsn_t (*)(struct xfs_log_item *, xfs_lsn_t)' (aka 'long long (*)(struct xfs_log_item *, long long)') with an expression of type 'xfs_lsn_t (struct xfs_log_item *)' (aka 'long long (struct xfs_log_item *)') [-Werror,-Wincompatible-function-pointer-types]

.iop_comitted = xfs_log_item_committed_done,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.

vim +104 fs/xfs/xfs_trans.h

    96	
    97	void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
    98				  int type, const struct xfs_item_ops *ops);
    99	
   100	/*
   101	 * Generic ->iop_committed callback to indicate that the log item should not be
   102	 * referenced by the caller once the callback returns.
   103	 */
 > 104	xfs_lsn_t xfs_log_item_committed_done(struct xfs_log_item *item)

105

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org