All of lore.kernel.org
 help / color / mirror / Atom feed
* misc log item related cleanups
@ 2019-05-17  7:30 Christoph Hellwig
  2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
                   ` (19 more replies)
  0 siblings, 20 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:30 UTC (permalink / raw)
  To: linux-xfs

Hi all,

I've recently been trying to debug issue related to latencies related to
locked buffers and went all over our log item lifecycles for that.

It turns out a lot of code in that area is rather obsfucated and
redundant.  This series is almost entirely cleanups, but there are lots
of it.  The only exception is a fix for systematic memory leaks which
appears entirely theoretical.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:04   ` Brian Foster
  2019-05-20 22:08   ` Darrick J. Wong
  2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
                   ` (18 subsequent siblings)
  19 siblings, 2 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_trans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 912b42f5fe4a..19f91312561a 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -815,7 +815,7 @@ xfs_log_item_batch_insert(
  *
  * If we are called with the aborted flag set, it is because a log write during
  * a CIL checkpoint commit has failed. In this case, all the items in the
- * checkpoint have already gone through iop_commited and iop_unlock, which
+ * checkpoint have already gone through iop_committed and iop_unlock, which
  * means that checkpoint commit abort handling is treated exactly the same
  * as an iclog write error even though we haven't started any IO yet. Hence in
  * this case all we need to do is iop_committed processing, followed by an
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
  2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:04   ` Brian Foster
                     ` (2 more replies)
  2019-05-17  7:31 ` [PATCH 03/20] xfs: don't require log items to implement optional methods Christoph Hellwig
                   ` (17 subsequent siblings)
  19 siblings, 3 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
flag in function parameters.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_log.c     | 25 +++++++++++--------------
 fs/xfs/xfs_log.h     |  2 +-
 fs/xfs/xfs_log_cil.c |  4 ++--
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 457ced3ee3e1..1eb0938165fc 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -54,12 +54,9 @@ xlog_dealloc_log(
 	struct xlog		*log);
 
 /* local state machine functions */
-STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int);
-STATIC void
-xlog_state_do_callback(
-	struct xlog		*log,
-	int			aborted,
-	struct xlog_in_core	*iclog);
+STATIC void xlog_state_done_syncing(
+	struct xlog_in_core	*iclog,
+	bool			aborted);
 STATIC int
 xlog_state_get_iclog_space(
 	struct xlog		*log,
@@ -1255,7 +1252,7 @@ xlog_iodone(xfs_buf_t *bp)
 {
 	struct xlog_in_core	*iclog = bp->b_log_item;
 	struct xlog		*l = iclog->ic_log;
-	int			aborted = 0;
+	bool			aborted = false;
 
 	/*
 	 * Race to shutdown the filesystem if we see an error or the iclog is in
@@ -1275,9 +1272,9 @@ xlog_iodone(xfs_buf_t *bp)
 		 * callback routines to let them know that the log-commit
 		 * didn't succeed.
 		 */
-		aborted = XFS_LI_ABORTED;
+		aborted = true;
 	} else if (iclog->ic_state & XLOG_STATE_IOERROR) {
-		aborted = XFS_LI_ABORTED;
+		aborted = true;
 	}
 
 	/* log I/O is always issued ASYNC */
@@ -2697,7 +2694,7 @@ xlog_get_lowest_lsn(
 STATIC void
 xlog_state_do_callback(
 	struct xlog		*log,
-	int			aborted,
+	bool			aborted,
 	struct xlog_in_core	*ciclog)
 {
 	xlog_in_core_t	   *iclog;
@@ -2936,10 +2933,10 @@ xlog_state_do_callback(
  */
 STATIC void
 xlog_state_done_syncing(
-	xlog_in_core_t	*iclog,
-	int		aborted)
+	struct xlog_in_core	*iclog,
+	bool			aborted)
 {
-	struct xlog	   *log = iclog->ic_log;
+	struct xlog		*log = iclog->ic_log;
 
 	spin_lock(&log->l_icloglock);
 
@@ -4026,7 +4023,7 @@ xfs_log_force_umount(
 	 * avoid races.
 	 */
 	wake_up_all(&log->l_cilp->xc_commit_wait);
-	xlog_state_do_callback(log, XFS_LI_ABORTED, NULL);
+	xlog_state_do_callback(log, true, NULL);
 
 #ifdef XFSERRORDEBUG
 	{
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 73a64bf32f6f..4450a2a26a1a 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -77,7 +77,7 @@ xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
  */
 typedef struct xfs_log_callback {
 	struct xfs_log_callback	*cb_next;
-	void			(*cb_func)(void *, int);
+	void			(*cb_func)(void *, bool);
 	void			*cb_arg;
 } xfs_log_callback_t;
 
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 5e595948bc5a..1b54002d3874 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -577,7 +577,7 @@ xlog_discard_busy_extents(
 static void
 xlog_cil_committed(
 	void	*args,
-	int	abort)
+	bool	abort)
 {
 	struct xfs_cil_ctx	*ctx = args;
 	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
@@ -864,7 +864,7 @@ xlog_cil_push(
 out_abort_free_ticket:
 	xfs_log_ticket_put(tic);
 out_abort:
-	xlog_cil_committed(ctx, XFS_LI_ABORTED);
+	xlog_cil_committed(ctx, true);
 	return -EIO;
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 03/20] xfs: don't require log items to implement optional methods
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
  2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
  2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:06   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items Christoph Hellwig
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Just check if they are present first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_bmap_item.c     | 104 -------------------------------------
 fs/xfs/xfs_buf_item.c      |   8 ---
 fs/xfs/xfs_dquot_item.c    |  98 ----------------------------------
 fs/xfs/xfs_extfree_item.c  | 104 -------------------------------------
 fs/xfs/xfs_icreate_item.c  |  28 ----------
 fs/xfs/xfs_log_cil.c       |   3 +-
 fs/xfs/xfs_refcount_item.c | 104 -------------------------------------
 fs/xfs/xfs_rmap_item.c     | 104 -------------------------------------
 fs/xfs/xfs_trans.c         |  21 +++++---
 fs/xfs/xfs_trans_ail.c     |   2 +
 10 files changed, 19 insertions(+), 557 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index ce45f066995e..8e57df6d5581 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -95,15 +95,6 @@ xfs_bui_item_format(
 			xfs_bui_log_format_sizeof(buip->bui_format.bui_nextents));
 }
 
-/*
- * Pinning has no meaning for an bui item, so just return.
- */
-STATIC void
-xfs_bui_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
 /*
  * The unpin operation is the last place an BUI is manipulated in the log. It is
  * either inserted in the AIL or aborted in the event of a log I/O error. In
@@ -122,21 +113,6 @@ xfs_bui_item_unpin(
 	xfs_bui_release(buip);
 }
 
-/*
- * BUI items have no locking or pushing.  However, since BUIs are pulled from
- * the AIL when their corresponding BUDs are committed to disk, their situation
- * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
- * will eventually flush the log.  This should help in getting the BUI out of
- * the AIL.
- */
-STATIC uint
-xfs_bui_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The BUI has been either committed or aborted if the transaction has been
  * cancelled. If the transaction was cancelled, an BUD isn't going to be
@@ -150,44 +126,14 @@ xfs_bui_item_unlock(
 		xfs_bui_release(BUI_ITEM(lip));
 }
 
-/*
- * The BUI is logged only once and cannot be moved in the log, so simply return
- * the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_bui_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	return lsn;
-}
-
-/*
- * The BUI dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_bui_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all bui log items.
  */
 static const struct xfs_item_ops xfs_bui_item_ops = {
 	.iop_size	= xfs_bui_item_size,
 	.iop_format	= xfs_bui_item_format,
-	.iop_pin	= xfs_bui_item_pin,
 	.iop_unpin	= xfs_bui_item_unpin,
 	.iop_unlock	= xfs_bui_item_unlock,
-	.iop_committed	= xfs_bui_item_committed,
-	.iop_push	= xfs_bui_item_push,
-	.iop_committing = xfs_bui_item_committing,
 };
 
 /*
@@ -248,38 +194,6 @@ xfs_bud_item_format(
 			sizeof(struct xfs_bud_log_format));
 }
 
-/*
- * Pinning has no meaning for an bud item, so just return.
- */
-STATIC void
-xfs_bud_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an bud item, unpinning does
- * not either.
- */
-STATIC void
-xfs_bud_item_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
-/*
- * There isn't much you can do to push on an bud item.  It is simply stuck
- * waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_bud_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The BUD is either committed or aborted if the transaction is cancelled. If
  * the transaction is cancelled, drop our reference to the BUI and free the
@@ -322,32 +236,14 @@ xfs_bud_item_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/*
- * The BUD dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_bud_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all bud log items.
  */
 static const struct xfs_item_ops xfs_bud_item_ops = {
 	.iop_size	= xfs_bud_item_size,
 	.iop_format	= xfs_bud_item_format,
-	.iop_pin	= xfs_bud_item_pin,
-	.iop_unpin	= xfs_bud_item_unpin,
 	.iop_unlock	= xfs_bud_item_unlock,
 	.iop_committed	= xfs_bud_item_committed,
-	.iop_push	= xfs_bud_item_push,
-	.iop_committing = xfs_bud_item_committing,
 };
 
 /*
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 65b32acfa0f6..3e0d5845e47b 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -671,13 +671,6 @@ xfs_buf_item_committed(
 	return lsn;
 }
 
-STATIC void
-xfs_buf_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		commit_lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all buf log items.
  */
@@ -689,7 +682,6 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
 	.iop_unlock	= xfs_buf_item_unlock,
 	.iop_committed	= xfs_buf_item_committed,
 	.iop_push	= xfs_buf_item_push,
-	.iop_committing = xfs_buf_item_committing
 };
 
 STATIC int
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 87b23ae44397..486eea151fdb 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -94,18 +94,6 @@ xfs_qm_dquot_logitem_unpin(
 		wake_up(&dqp->q_pinwait);
 }
 
-STATIC xfs_lsn_t
-xfs_qm_dquot_logitem_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	/*
-	 * We always re-log the entire dquot when it becomes dirty,
-	 * so, the latest copy _is_ the only one that matters.
-	 */
-	return lsn;
-}
-
 /*
  * This is called to wait for the given dquot to be unpinned.
  * Most of these pin/unpin routines are plagiarized from inode code.
@@ -232,18 +220,6 @@ xfs_qm_dquot_logitem_unlock(
 	xfs_dqunlock(dqp);
 }
 
-/*
- * this needs to stamp an lsn into the dquot, I think.
- * rpc's that look at user dquot's would then have to
- * push on the dependency recorded in the dquot
- */
-STATIC void
-xfs_qm_dquot_logitem_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector for dquots
  */
@@ -253,9 +229,7 @@ static const struct xfs_item_ops xfs_dquot_item_ops = {
 	.iop_pin	= xfs_qm_dquot_logitem_pin,
 	.iop_unpin	= xfs_qm_dquot_logitem_unpin,
 	.iop_unlock	= xfs_qm_dquot_logitem_unlock,
-	.iop_committed	= xfs_qm_dquot_logitem_committed,
 	.iop_push	= xfs_qm_dquot_logitem_push,
-	.iop_committing = xfs_qm_dquot_logitem_committing,
 	.iop_error	= xfs_dquot_item_error
 };
 
@@ -314,26 +288,6 @@ xfs_qm_qoff_logitem_format(
 	xlog_finish_iovec(lv, vecp, sizeof(struct xfs_qoff_logitem));
 }
 
-/*
- * Pinning has no meaning for an quotaoff item, so just return.
- */
-STATIC void
-xfs_qm_qoff_logitem_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an quotaoff item, unpinning does
- * not either.
- */
-STATIC void
-xfs_qm_qoff_logitem_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
 /*
  * There isn't much you can do to push a quotaoff item.  It is simply
  * stuck waiting for the log to be flushed to disk.
@@ -346,28 +300,6 @@ xfs_qm_qoff_logitem_push(
 	return XFS_ITEM_LOCKED;
 }
 
-/*
- * Quotaoff items have no locking or pushing, so return failure
- * so that the caller doesn't bother with us.
- */
-STATIC void
-xfs_qm_qoff_logitem_unlock(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * The quotaoff-start-item is logged only once and cannot be moved in the log,
- * so simply return the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_qm_qoff_logitem_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	return lsn;
-}
-
 STATIC xfs_lsn_t
 xfs_qm_qoffend_logitem_committed(
 	struct xfs_log_item	*lip,
@@ -391,36 +323,11 @@ xfs_qm_qoffend_logitem_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/*
- * XXX rcc - don't know quite what to do with this.  I think we can
- * just ignore it.  The only time that isn't the case is if we allow
- * the client to somehow see that quotas have been turned off in which
- * we can't allow that to get back until the quotaoff hits the disk.
- * So how would that happen?  Also, do we need different routines for
- * quotaoff start and quotaoff end?  I suspect the answer is yes but
- * to be sure, I need to look at the recovery code and see how quota off
- * recovery is handled (do we roll forward or back or do something else).
- * If we roll forwards or backwards, then we need two separate routines,
- * one that does nothing and one that stamps in the lsn that matters
- * (truly makes the quotaoff irrevocable).  If we do something else,
- * then maybe we don't need two.
- */
-STATIC void
-xfs_qm_qoff_logitem_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		commit_lsn)
-{
-}
-
 static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 	.iop_size	= xfs_qm_qoff_logitem_size,
 	.iop_format	= xfs_qm_qoff_logitem_format,
-	.iop_pin	= xfs_qm_qoff_logitem_pin,
-	.iop_unpin	= xfs_qm_qoff_logitem_unpin,
-	.iop_unlock	= xfs_qm_qoff_logitem_unlock,
 	.iop_committed	= xfs_qm_qoffend_logitem_committed,
 	.iop_push	= xfs_qm_qoff_logitem_push,
-	.iop_committing = xfs_qm_qoff_logitem_committing
 };
 
 /*
@@ -429,12 +336,7 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
 	.iop_size	= xfs_qm_qoff_logitem_size,
 	.iop_format	= xfs_qm_qoff_logitem_format,
-	.iop_pin	= xfs_qm_qoff_logitem_pin,
-	.iop_unpin	= xfs_qm_qoff_logitem_unpin,
-	.iop_unlock	= xfs_qm_qoff_logitem_unlock,
-	.iop_committed	= xfs_qm_qoff_logitem_committed,
 	.iop_push	= xfs_qm_qoff_logitem_push,
-	.iop_committing = xfs_qm_qoff_logitem_committing
 };
 
 /*
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 74ddf66f4cfe..655ed0445750 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -106,15 +106,6 @@ xfs_efi_item_format(
 }
 
 
-/*
- * Pinning has no meaning for an efi item, so just return.
- */
-STATIC void
-xfs_efi_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
 /*
  * The unpin operation is the last place an EFI is manipulated in the log. It is
  * either inserted in the AIL or aborted in the event of a log I/O error. In
@@ -132,21 +123,6 @@ xfs_efi_item_unpin(
 	xfs_efi_release(efip);
 }
 
-/*
- * Efi items have no locking or pushing.  However, since EFIs are pulled from
- * the AIL when their corresponding EFDs are committed to disk, their situation
- * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
- * will eventually flush the log.  This should help in getting the EFI out of
- * the AIL.
- */
-STATIC uint
-xfs_efi_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The EFI has been either committed or aborted if the transaction has been
  * cancelled. If the transaction was cancelled, an EFD isn't going to be
@@ -160,44 +136,14 @@ xfs_efi_item_unlock(
 		xfs_efi_release(EFI_ITEM(lip));
 }
 
-/*
- * The EFI is logged only once and cannot be moved in the log, so simply return
- * the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_efi_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	return lsn;
-}
-
-/*
- * The EFI dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_efi_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all efi log items.
  */
 static const struct xfs_item_ops xfs_efi_item_ops = {
 	.iop_size	= xfs_efi_item_size,
 	.iop_format	= xfs_efi_item_format,
-	.iop_pin	= xfs_efi_item_pin,
 	.iop_unpin	= xfs_efi_item_unpin,
 	.iop_unlock	= xfs_efi_item_unlock,
-	.iop_committed	= xfs_efi_item_committed,
-	.iop_push	= xfs_efi_item_push,
-	.iop_committing = xfs_efi_item_committing
 };
 
 
@@ -348,38 +294,6 @@ xfs_efd_item_format(
 			xfs_efd_item_sizeof(efdp));
 }
 
-/*
- * Pinning has no meaning for an efd item, so just return.
- */
-STATIC void
-xfs_efd_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an efd item, unpinning does
- * not either.
- */
-STATIC void
-xfs_efd_item_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
-/*
- * There isn't much you can do to push on an efd item.  It is simply stuck
- * waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_efd_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The EFD is either committed or aborted if the transaction is cancelled. If
  * the transaction is cancelled, drop our reference to the EFI and free the EFD.
@@ -421,32 +335,14 @@ xfs_efd_item_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/*
- * The EFD dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_efd_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all efd log items.
  */
 static const struct xfs_item_ops xfs_efd_item_ops = {
 	.iop_size	= xfs_efd_item_size,
 	.iop_format	= xfs_efd_item_format,
-	.iop_pin	= xfs_efd_item_pin,
-	.iop_unpin	= xfs_efd_item_unpin,
 	.iop_unlock	= xfs_efd_item_unlock,
 	.iop_committed	= xfs_efd_item_committed,
-	.iop_push	= xfs_efd_item_push,
-	.iop_committing = xfs_efd_item_committing
 };
 
 /*
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index 8381d34cb102..03c174ff1ab3 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -56,23 +56,6 @@ xfs_icreate_item_format(
 			sizeof(struct xfs_icreate_log));
 }
 
-
-/* Pinning has no meaning for the create item, so just return. */
-STATIC void
-xfs_icreate_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-
-/* pinning has no meaning for the create item, so just return. */
-STATIC void
-xfs_icreate_item_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
 STATIC void
 xfs_icreate_item_unlock(
 	struct xfs_log_item	*lip)
@@ -110,26 +93,15 @@ xfs_icreate_item_push(
 	return XFS_ITEM_SUCCESS;
 }
 
-/* Ordered buffers do the dependency tracking here, so this does nothing. */
-STATIC void
-xfs_icreate_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all buf log items.
  */
 static const struct xfs_item_ops xfs_icreate_item_ops = {
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
-	.iop_pin	= xfs_icreate_item_pin,
-	.iop_unpin	= xfs_icreate_item_unpin,
 	.iop_push	= xfs_icreate_item_push,
 	.iop_unlock	= xfs_icreate_item_unlock,
 	.iop_committed	= xfs_icreate_item_committed,
-	.iop_committing = xfs_icreate_item_committing,
 };
 
 
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 1b54002d3874..49f37905c7a7 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -246,7 +246,8 @@ xfs_cil_prepare_item(
 	 * shadow buffer, so update the the pointer to it appropriately.
 	 */
 	if (!old_lv) {
-		lv->lv_item->li_ops->iop_pin(lv->lv_item);
+		if (lv->lv_item->li_ops->iop_pin)
+			lv->lv_item->li_ops->iop_pin(lv->lv_item);
 		lv->lv_item->li_lv_shadow = NULL;
 	} else if (old_lv != lv) {
 		ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index fce38b56b962..03a61886fe2a 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -94,15 +94,6 @@ xfs_cui_item_format(
 			xfs_cui_log_format_sizeof(cuip->cui_format.cui_nextents));
 }
 
-/*
- * Pinning has no meaning for an cui item, so just return.
- */
-STATIC void
-xfs_cui_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
 /*
  * The unpin operation is the last place an CUI is manipulated in the log. It is
  * either inserted in the AIL or aborted in the event of a log I/O error. In
@@ -121,21 +112,6 @@ xfs_cui_item_unpin(
 	xfs_cui_release(cuip);
 }
 
-/*
- * CUI items have no locking or pushing.  However, since CUIs are pulled from
- * the AIL when their corresponding CUDs are committed to disk, their situation
- * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
- * will eventually flush the log.  This should help in getting the CUI out of
- * the AIL.
- */
-STATIC uint
-xfs_cui_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The CUI has been either committed or aborted if the transaction has been
  * cancelled. If the transaction was cancelled, an CUD isn't going to be
@@ -149,44 +125,14 @@ xfs_cui_item_unlock(
 		xfs_cui_release(CUI_ITEM(lip));
 }
 
-/*
- * The CUI is logged only once and cannot be moved in the log, so simply return
- * the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_cui_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	return lsn;
-}
-
-/*
- * The CUI dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_cui_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all cui log items.
  */
 static const struct xfs_item_ops xfs_cui_item_ops = {
 	.iop_size	= xfs_cui_item_size,
 	.iop_format	= xfs_cui_item_format,
-	.iop_pin	= xfs_cui_item_pin,
 	.iop_unpin	= xfs_cui_item_unpin,
 	.iop_unlock	= xfs_cui_item_unlock,
-	.iop_committed	= xfs_cui_item_committed,
-	.iop_push	= xfs_cui_item_push,
-	.iop_committing = xfs_cui_item_committing,
 };
 
 /*
@@ -253,38 +199,6 @@ xfs_cud_item_format(
 			sizeof(struct xfs_cud_log_format));
 }
 
-/*
- * Pinning has no meaning for an cud item, so just return.
- */
-STATIC void
-xfs_cud_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an cud item, unpinning does
- * not either.
- */
-STATIC void
-xfs_cud_item_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
-/*
- * There isn't much you can do to push on an cud item.  It is simply stuck
- * waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_cud_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The CUD is either committed or aborted if the transaction is cancelled. If
  * the transaction is cancelled, drop our reference to the CUI and free the
@@ -327,32 +241,14 @@ xfs_cud_item_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/*
- * The CUD dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_cud_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all cud log items.
  */
 static const struct xfs_item_ops xfs_cud_item_ops = {
 	.iop_size	= xfs_cud_item_size,
 	.iop_format	= xfs_cud_item_format,
-	.iop_pin	= xfs_cud_item_pin,
-	.iop_unpin	= xfs_cud_item_unpin,
 	.iop_unlock	= xfs_cud_item_unlock,
 	.iop_committed	= xfs_cud_item_committed,
-	.iop_push	= xfs_cud_item_push,
-	.iop_committing = xfs_cud_item_committing,
 };
 
 /*
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 127dc9c32a54..df9f2505c5f3 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -93,15 +93,6 @@ xfs_rui_item_format(
 			xfs_rui_log_format_sizeof(ruip->rui_format.rui_nextents));
 }
 
-/*
- * Pinning has no meaning for an rui item, so just return.
- */
-STATIC void
-xfs_rui_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
 /*
  * The unpin operation is the last place an RUI is manipulated in the log. It is
  * either inserted in the AIL or aborted in the event of a log I/O error. In
@@ -120,21 +111,6 @@ xfs_rui_item_unpin(
 	xfs_rui_release(ruip);
 }
 
-/*
- * RUI items have no locking or pushing.  However, since RUIs are pulled from
- * the AIL when their corresponding RUDs are committed to disk, their situation
- * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
- * will eventually flush the log.  This should help in getting the RUI out of
- * the AIL.
- */
-STATIC uint
-xfs_rui_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The RUI has been either committed or aborted if the transaction has been
  * cancelled. If the transaction was cancelled, an RUD isn't going to be
@@ -148,44 +124,14 @@ xfs_rui_item_unlock(
 		xfs_rui_release(RUI_ITEM(lip));
 }
 
-/*
- * The RUI is logged only once and cannot be moved in the log, so simply return
- * the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_rui_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	return lsn;
-}
-
-/*
- * The RUI dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_rui_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all rui log items.
  */
 static const struct xfs_item_ops xfs_rui_item_ops = {
 	.iop_size	= xfs_rui_item_size,
 	.iop_format	= xfs_rui_item_format,
-	.iop_pin	= xfs_rui_item_pin,
 	.iop_unpin	= xfs_rui_item_unpin,
 	.iop_unlock	= xfs_rui_item_unlock,
-	.iop_committed	= xfs_rui_item_committed,
-	.iop_push	= xfs_rui_item_push,
-	.iop_committing = xfs_rui_item_committing,
 };
 
 /*
@@ -274,38 +220,6 @@ xfs_rud_item_format(
 			sizeof(struct xfs_rud_log_format));
 }
 
-/*
- * Pinning has no meaning for an rud item, so just return.
- */
-STATIC void
-xfs_rud_item_pin(
-	struct xfs_log_item	*lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an rud item, unpinning does
- * not either.
- */
-STATIC void
-xfs_rud_item_unpin(
-	struct xfs_log_item	*lip,
-	int			remove)
-{
-}
-
-/*
- * There isn't much you can do to push on an rud item.  It is simply stuck
- * waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_rud_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_PINNED;
-}
-
 /*
  * The RUD is either committed or aborted if the transaction is cancelled. If
  * the transaction is cancelled, drop our reference to the RUI and free the
@@ -348,32 +262,14 @@ xfs_rud_item_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/*
- * The RUD dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_rud_item_committing(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-}
-
 /*
  * This is the ops vector shared by all rud log items.
  */
 static const struct xfs_item_ops xfs_rud_item_ops = {
 	.iop_size	= xfs_rud_item_size,
 	.iop_format	= xfs_rud_item_format,
-	.iop_pin	= xfs_rud_item_pin,
-	.iop_unpin	= xfs_rud_item_unpin,
 	.iop_unlock	= xfs_rud_item_unlock,
 	.iop_committed	= xfs_rud_item_committed,
-	.iop_push	= xfs_rud_item_push,
-	.iop_committing = xfs_rud_item_committing,
 };
 
 /*
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 19f91312561a..ed7547b9f66b 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -779,11 +779,14 @@ xfs_trans_free_items(
 
 	list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
 		xfs_trans_del_item(lip);
-		if (commit_lsn != NULLCOMMITLSN)
+		if (commit_lsn != NULLCOMMITLSN &&
+		    lip->li_ops->iop_committing)
 			lip->li_ops->iop_committing(lip, commit_lsn);
 		if (abort)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
-		lip->li_ops->iop_unlock(lip);
+
+		if (lip->li_ops->iop_unlock)
+			lip->li_ops->iop_unlock(lip);
 	}
 }
 
@@ -804,7 +807,8 @@ xfs_log_item_batch_insert(
 	for (i = 0; i < nr_items; i++) {
 		struct xfs_log_item *lip = log_items[i];
 
-		lip->li_ops->iop_unpin(lip, 0);
+		if (lip->li_ops->iop_unpin)
+			lip->li_ops->iop_unpin(lip, 0);
 	}
 }
 
@@ -852,7 +856,10 @@ xfs_trans_committed_bulk(
 
 		if (aborted)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
-		item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
+		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)
@@ -864,7 +871,8 @@ xfs_trans_committed_bulk(
 		 */
 		if (aborted) {
 			ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount));
-			lip->li_ops->iop_unpin(lip, 1);
+			if (lip->li_ops->iop_unpin)
+				lip->li_ops->iop_unpin(lip, 1);
 			continue;
 		}
 
@@ -882,7 +890,8 @@ xfs_trans_committed_bulk(
 				xfs_trans_ail_update(ailp, lip, item_lsn);
 			else
 				spin_unlock(&ailp->ail_lock);
-			lip->li_ops->iop_unpin(lip, 0);
+			if (lip->li_ops->iop_unpin)
+				lip->li_ops->iop_unpin(lip, 0);
 			continue;
 		}
 
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index d3a4e89bf4a0..8509c4b59760 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -347,6 +347,8 @@ xfsaild_push_item(
 	if (XFS_TEST_ERROR(false, ailp->ail_mount, XFS_ERRTAG_LOG_ITEM_PIN))
 		return XFS_ITEM_PINNED;
 
+	if (!lip->li_ops->iop_push)
+		return XFS_ITEM_PINNED;
 	return lip->li_ops->iop_push(lip, &ailp->ail_buf_list);
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 03/20] xfs: don't require log items to implement optional methods Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:07   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 05/20] xfs: remove the iop_push implementation for quota off items Christoph Hellwig
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

This method should never be called, so don't waste code on it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_icreate_item.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index 03c174ff1ab3..cbaabc55f0c9 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -83,23 +83,12 @@ xfs_icreate_item_committed(
 	return (xfs_lsn_t)-1;
 }
 
-/* item can never get into the AIL */
-STATIC uint
-xfs_icreate_item_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	ASSERT(0);
-	return XFS_ITEM_SUCCESS;
-}
-
 /*
  * This is the ops vector shared by all buf log items.
  */
 static const struct xfs_item_ops xfs_icreate_item_ops = {
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
-	.iop_push	= xfs_icreate_item_push,
 	.iop_unlock	= xfs_icreate_item_unlock,
 	.iop_committed	= xfs_icreate_item_committed,
 };
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 05/20] xfs: remove the iop_push implementation for quota off items
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (3 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:08   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path Christoph Hellwig
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

If we want to push the log to make progress on the items we'd need to
return XFS_ITEM_PINNED instead of XFS_ITEM_LOCKED.  Removing the
method will do exactly that.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_dquot_item.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 486eea151fdb..a61a8a770d7f 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -288,18 +288,6 @@ xfs_qm_qoff_logitem_format(
 	xlog_finish_iovec(lv, vecp, sizeof(struct xfs_qoff_logitem));
 }
 
-/*
- * There isn't much you can do to push a quotaoff item.  It is simply
- * stuck waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_qm_qoff_logitem_push(
-	struct xfs_log_item	*lip,
-	struct list_head	*buffer_list)
-{
-	return XFS_ITEM_LOCKED;
-}
-
 STATIC xfs_lsn_t
 xfs_qm_qoffend_logitem_committed(
 	struct xfs_log_item	*lip,
@@ -327,7 +315,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 	.iop_size	= xfs_qm_qoff_logitem_size,
 	.iop_format	= xfs_qm_qoff_logitem_format,
 	.iop_committed	= xfs_qm_qoffend_logitem_committed,
-	.iop_push	= xfs_qm_qoff_logitem_push,
 };
 
 /*
@@ -336,7 +323,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
 	.iop_size	= xfs_qm_qoff_logitem_size,
 	.iop_format	= xfs_qm_qoff_logitem_format,
-	.iop_push	= xfs_qm_qoff_logitem_push,
 };
 
 /*
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (4 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 05/20] xfs: remove the iop_push implementation for quota off items Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 14:08   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

While commiting items looks very similar to freeing them on error it is
a different operation, and they will diverge a bit soon.

Split out the commit case from xfs_trans_free_items, inline it into
xfs_log_commit_cil and give it a separate trace point.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_log_cil.c    | 13 ++++++++++---
 fs/xfs/xfs_trace.h      |  1 +
 fs/xfs/xfs_trans.c      | 10 +++-------
 fs/xfs/xfs_trans_priv.h |  2 --
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 49f37905c7a7..c856bfce5bf2 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -985,6 +985,7 @@ xfs_log_commit_cil(
 {
 	struct xlog		*log = mp->m_log;
 	struct xfs_cil		*cil = log->l_cilp;
+	struct xfs_log_item	*lip, *next;
 	xfs_lsn_t		xc_commit_lsn;
 
 	/*
@@ -1009,7 +1010,7 @@ xfs_log_commit_cil(
 
 	/*
 	 * Once all the items of the transaction have been copied to the CIL,
-	 * the items can be unlocked and freed.
+	 * the items can be unlocked and possibly freed.
 	 *
 	 * This needs to be done before we drop the CIL context lock because we
 	 * have to update state in the log items and unlock them before they go
@@ -1018,8 +1019,14 @@ xfs_log_commit_cil(
 	 * the log items. This affects (at least) processing of stale buffers,
 	 * inodes and EFIs.
 	 */
-	xfs_trans_free_items(tp, xc_commit_lsn, false);
-
+	trace_xfs_trans_commit_items(tp, _RET_IP_);
+	list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
+		xfs_trans_del_item(lip);
+		if (lip->li_ops->iop_committing)
+			lip->li_ops->iop_committing(lip, xc_commit_lsn);
+		if (lip->li_ops->iop_unlock)
+			lip->li_ops->iop_unlock(lip);
+	}
 	xlog_cil_push_background(log);
 
 	up_read(&cil->xc_ctx_lock);
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 2464ea351f83..195a9cdb954e 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -3360,6 +3360,7 @@ DEFINE_TRANS_EVENT(xfs_trans_dup);
 DEFINE_TRANS_EVENT(xfs_trans_free);
 DEFINE_TRANS_EVENT(xfs_trans_roll);
 DEFINE_TRANS_EVENT(xfs_trans_add_item);
+DEFINE_TRANS_EVENT(xfs_trans_commit_items);
 DEFINE_TRANS_EVENT(xfs_trans_free_items);
 
 TRACE_EVENT(xfs_iunlink_update_bucket,
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index ed7547b9f66b..4ed5d032b26f 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -767,10 +767,9 @@ xfs_trans_del_item(
 }
 
 /* Detach and unlock all of the items in a transaction */
-void
+static void
 xfs_trans_free_items(
 	struct xfs_trans	*tp,
-	xfs_lsn_t		commit_lsn,
 	bool			abort)
 {
 	struct xfs_log_item	*lip, *next;
@@ -779,9 +778,6 @@ xfs_trans_free_items(
 
 	list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
 		xfs_trans_del_item(lip);
-		if (commit_lsn != NULLCOMMITLSN &&
-		    lip->li_ops->iop_committing)
-			lip->li_ops->iop_committing(lip, commit_lsn);
 		if (abort)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
 
@@ -1007,7 +1003,7 @@ __xfs_trans_commit(
 		tp->t_ticket = NULL;
 	}
 	current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
-	xfs_trans_free_items(tp, NULLCOMMITLSN, !!error);
+	xfs_trans_free_items(tp, !!error);
 	xfs_trans_free(tp);
 
 	XFS_STATS_INC(mp, xs_trans_empty);
@@ -1069,7 +1065,7 @@ xfs_trans_cancel(
 	/* mark this thread as no longer being in a transaction */
 	current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
 
-	xfs_trans_free_items(tp, NULLCOMMITLSN, dirty);
+	xfs_trans_free_items(tp, dirty);
 	xfs_trans_free(tp);
 }
 
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index 091eae9f4e74..bef1ebf933ed 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -16,8 +16,6 @@ struct xfs_log_vec;
 void	xfs_trans_init(struct xfs_mount *);
 void	xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
 void	xfs_trans_del_item(struct xfs_log_item *);
-void	xfs_trans_free_items(struct xfs_trans *tp, xfs_lsn_t commit_lsn,
-				bool abort);
 void	xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp);
 
 void	xfs_trans_committed_bulk(struct xfs_ail *ailp, struct xfs_log_vec *lv,
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 07/20] xfs: split iop_unlock
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (5 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 17:49   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 08/20] xfs: add a flag to release log items on commit Christoph Hellwig
                   ` (12 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

The iop_unlock is not only misnamed, but also causes deeper problems.
We call the method when either comitting a transaction, or when freeing
items on a cancelled transaction.  Various item implementations try
to distinguish the cases by checking the XFS_LI_ABORTED flag, but that
is only set if the cancelled transaction was dirty.  That leads to
possible leaks of items when cancelling a clean transaction.  The only
thing saving us there is that cancelling clean transactions with
attached items is incredibly rare, if we do it at all.

This patch replaces iop_unlock with a new iop_release method just for
releasing items on a transaction cancellation, and overloads the
existing iop_committing method with the commit path behavior that only
a few item implementations need to start with.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_bmap_item.c     | 17 +++++++----------
 fs/xfs/xfs_buf_item.c      | 15 ++++++++++++---
 fs/xfs/xfs_dquot_item.c    | 19 +++++++++++--------
 fs/xfs/xfs_extfree_item.c  | 17 +++++++----------
 fs/xfs/xfs_icreate_item.c  | 10 +++-------
 fs/xfs/xfs_inode_item.c    | 11 ++++++-----
 fs/xfs/xfs_log_cil.c       |  2 --
 fs/xfs/xfs_refcount_item.c | 17 +++++++----------
 fs/xfs/xfs_rmap_item.c     | 17 +++++++----------
 fs/xfs/xfs_trace.h         |  2 +-
 fs/xfs/xfs_trans.c         |  7 +++----
 fs/xfs/xfs_trans.h         |  4 ++--
 fs/xfs/xfs_trans_buf.c     |  2 +-
 13 files changed, 67 insertions(+), 73 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 8e57df6d5581..56c1ab161f3b 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -119,11 +119,10 @@ xfs_bui_item_unpin(
  * constructed and thus we free the BUI here directly.
  */
 STATIC void
-xfs_bui_item_unlock(
+xfs_bui_item_release(
 	struct xfs_log_item	*lip)
 {
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-		xfs_bui_release(BUI_ITEM(lip));
+	xfs_bui_release(BUI_ITEM(lip));
 }
 
 /*
@@ -133,7 +132,7 @@ static const struct xfs_item_ops xfs_bui_item_ops = {
 	.iop_size	= xfs_bui_item_size,
 	.iop_format	= xfs_bui_item_format,
 	.iop_unpin	= xfs_bui_item_unpin,
-	.iop_unlock	= xfs_bui_item_unlock,
+	.iop_release	= xfs_bui_item_release,
 };
 
 /*
@@ -200,15 +199,13 @@ xfs_bud_item_format(
  * BUD.
  */
 STATIC void
-xfs_bud_item_unlock(
+xfs_bud_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_bud_log_item	*budp = BUD_ITEM(lip);
 
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
-		xfs_bui_release(budp->bud_buip);
-		kmem_zone_free(xfs_bud_zone, budp);
-	}
+	xfs_bui_release(budp->bud_buip);
+	kmem_zone_free(xfs_bud_zone, budp);
 }
 
 /*
@@ -242,7 +239,7 @@ xfs_bud_item_committed(
 static const struct xfs_item_ops xfs_bud_item_ops = {
 	.iop_size	= xfs_bud_item_size,
 	.iop_format	= xfs_bud_item_format,
-	.iop_unlock	= xfs_bud_item_unlock,
+	.iop_release	= xfs_bud_item_release,
 	.iop_committed	= xfs_bud_item_committed,
 };
 
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 3e0d5845e47b..7193ee9ca5b8 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -594,7 +594,7 @@ xfs_buf_item_put(
  * free the item.
  */
 STATIC void
-xfs_buf_item_unlock(
+xfs_buf_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
@@ -609,7 +609,7 @@ xfs_buf_item_unlock(
 						   &lip->li_flags);
 #endif
 
-	trace_xfs_buf_item_unlock(bip);
+	trace_xfs_buf_item_release(bip);
 
 	/*
 	 * The bli dirty state should match whether the blf has logged segments
@@ -639,6 +639,14 @@ xfs_buf_item_unlock(
 	xfs_buf_relse(bp);
 }
 
+STATIC void
+xfs_buf_item_committing(
+	struct xfs_log_item	*lip,
+	xfs_lsn_t		commit_lsn)
+{
+	return xfs_buf_item_release(lip);
+}
+
 /*
  * This is called to find out where the oldest active copy of the
  * buf log item in the on disk log resides now that the last log
@@ -679,7 +687,8 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
 	.iop_format	= xfs_buf_item_format,
 	.iop_pin	= xfs_buf_item_pin,
 	.iop_unpin	= xfs_buf_item_unpin,
-	.iop_unlock	= xfs_buf_item_unlock,
+	.iop_release	= xfs_buf_item_release,
+	.iop_committing	= xfs_buf_item_committing,
 	.iop_committed	= xfs_buf_item_committed,
 	.iop_push	= xfs_buf_item_push,
 };
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index a61a8a770d7f..b8fd81641dfc 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -197,14 +197,8 @@ xfs_qm_dquot_logitem_push(
 	return rval;
 }
 
-/*
- * Unlock the dquot associated with the log item.
- * Clear the fields of the dquot and dquot log item that
- * are specific to the current transaction.  If the
- * hold flags is set, do not unlock the dquot.
- */
 STATIC void
-xfs_qm_dquot_logitem_unlock(
+xfs_qm_dquot_logitem_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_dquot	*dqp = DQUOT_ITEM(lip)->qli_dquot;
@@ -220,6 +214,14 @@ xfs_qm_dquot_logitem_unlock(
 	xfs_dqunlock(dqp);
 }
 
+STATIC void
+xfs_qm_dquot_logitem_committing(
+	struct xfs_log_item	*lip,
+	xfs_lsn_t		commit_lsn)
+{
+	return xfs_qm_dquot_logitem_release(lip);
+}
+
 /*
  * This is the ops vector for dquots
  */
@@ -228,7 +230,8 @@ static const struct xfs_item_ops xfs_dquot_item_ops = {
 	.iop_format	= xfs_qm_dquot_logitem_format,
 	.iop_pin	= xfs_qm_dquot_logitem_pin,
 	.iop_unpin	= xfs_qm_dquot_logitem_unpin,
-	.iop_unlock	= xfs_qm_dquot_logitem_unlock,
+	.iop_release	= xfs_qm_dquot_logitem_release,
+	.iop_committing	= xfs_qm_dquot_logitem_committing,
 	.iop_push	= xfs_qm_dquot_logitem_push,
 	.iop_error	= xfs_dquot_item_error
 };
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 655ed0445750..a73a3cff8502 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -129,11 +129,10 @@ xfs_efi_item_unpin(
  * constructed and thus we free the EFI here directly.
  */
 STATIC void
-xfs_efi_item_unlock(
+xfs_efi_item_release(
 	struct xfs_log_item	*lip)
 {
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-		xfs_efi_release(EFI_ITEM(lip));
+	xfs_efi_release(EFI_ITEM(lip));
 }
 
 /*
@@ -143,7 +142,7 @@ static const struct xfs_item_ops xfs_efi_item_ops = {
 	.iop_size	= xfs_efi_item_size,
 	.iop_format	= xfs_efi_item_format,
 	.iop_unpin	= xfs_efi_item_unpin,
-	.iop_unlock	= xfs_efi_item_unlock,
+	.iop_release	= xfs_efi_item_release,
 };
 
 
@@ -299,15 +298,13 @@ xfs_efd_item_format(
  * the transaction is cancelled, drop our reference to the EFI and free the EFD.
  */
 STATIC void
-xfs_efd_item_unlock(
+xfs_efd_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_efd_log_item	*efdp = EFD_ITEM(lip);
 
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
-		xfs_efi_release(efdp->efd_efip);
-		xfs_efd_item_free(efdp);
-	}
+	xfs_efi_release(efdp->efd_efip);
+	xfs_efd_item_free(efdp);
 }
 
 /*
@@ -341,7 +338,7 @@ xfs_efd_item_committed(
 static const struct xfs_item_ops xfs_efd_item_ops = {
 	.iop_size	= xfs_efd_item_size,
 	.iop_format	= xfs_efd_item_format,
-	.iop_unlock	= xfs_efd_item_unlock,
+	.iop_release	= xfs_efd_item_release,
 	.iop_committed	= xfs_efd_item_committed,
 };
 
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index cbaabc55f0c9..9aceb35dce24 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -57,14 +57,10 @@ xfs_icreate_item_format(
 }
 
 STATIC void
-xfs_icreate_item_unlock(
+xfs_icreate_item_release(
 	struct xfs_log_item	*lip)
 {
-	struct xfs_icreate_item	*icp = ICR_ITEM(lip);
-
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-		kmem_zone_free(xfs_icreate_zone, icp);
-	return;
+	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
 }
 
 /*
@@ -89,7 +85,7 @@ xfs_icreate_item_committed(
 static const struct xfs_item_ops xfs_icreate_item_ops = {
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
-	.iop_unlock	= xfs_icreate_item_unlock,
+	.iop_release	= xfs_icreate_item_release,
 	.iop_committed	= xfs_icreate_item_committed,
 };
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index fa1c4fe2ffbf..a00f0b6aecc7 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -565,7 +565,7 @@ xfs_inode_item_push(
  * Unlock the inode associated with the inode log item.
  */
 STATIC void
-xfs_inode_item_unlock(
+xfs_inode_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_inode_log_item *iip = INODE_ITEM(lip);
@@ -621,9 +621,10 @@ xfs_inode_item_committed(
 STATIC void
 xfs_inode_item_committing(
 	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
+	xfs_lsn_t		commit_lsn)
 {
-	INODE_ITEM(lip)->ili_last_lsn = lsn;
+	INODE_ITEM(lip)->ili_last_lsn = commit_lsn;
+	return xfs_inode_item_release(lip);
 }
 
 /*
@@ -634,10 +635,10 @@ static const struct xfs_item_ops xfs_inode_item_ops = {
 	.iop_format	= xfs_inode_item_format,
 	.iop_pin	= xfs_inode_item_pin,
 	.iop_unpin	= xfs_inode_item_unpin,
-	.iop_unlock	= xfs_inode_item_unlock,
+	.iop_release	= xfs_inode_item_release,
 	.iop_committed	= xfs_inode_item_committed,
 	.iop_push	= xfs_inode_item_push,
-	.iop_committing = xfs_inode_item_committing,
+	.iop_committing	= xfs_inode_item_committing,
 	.iop_error	= xfs_inode_item_error
 };
 
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index c856bfce5bf2..4cb459f21ad4 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -1024,8 +1024,6 @@ xfs_log_commit_cil(
 		xfs_trans_del_item(lip);
 		if (lip->li_ops->iop_committing)
 			lip->li_ops->iop_committing(lip, xc_commit_lsn);
-		if (lip->li_ops->iop_unlock)
-			lip->li_ops->iop_unlock(lip);
 	}
 	xlog_cil_push_background(log);
 
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 03a61886fe2a..9f8fb23dcc81 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -118,11 +118,10 @@ xfs_cui_item_unpin(
  * constructed and thus we free the CUI here directly.
  */
 STATIC void
-xfs_cui_item_unlock(
+xfs_cui_item_release(
 	struct xfs_log_item	*lip)
 {
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-		xfs_cui_release(CUI_ITEM(lip));
+	xfs_cui_release(CUI_ITEM(lip));
 }
 
 /*
@@ -132,7 +131,7 @@ static const struct xfs_item_ops xfs_cui_item_ops = {
 	.iop_size	= xfs_cui_item_size,
 	.iop_format	= xfs_cui_item_format,
 	.iop_unpin	= xfs_cui_item_unpin,
-	.iop_unlock	= xfs_cui_item_unlock,
+	.iop_release	= xfs_cui_item_release,
 };
 
 /*
@@ -205,15 +204,13 @@ xfs_cud_item_format(
  * CUD.
  */
 STATIC void
-xfs_cud_item_unlock(
+xfs_cud_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_cud_log_item	*cudp = CUD_ITEM(lip);
 
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
-		xfs_cui_release(cudp->cud_cuip);
-		kmem_zone_free(xfs_cud_zone, cudp);
-	}
+	xfs_cui_release(cudp->cud_cuip);
+	kmem_zone_free(xfs_cud_zone, cudp);
 }
 
 /*
@@ -247,7 +244,7 @@ xfs_cud_item_committed(
 static const struct xfs_item_ops xfs_cud_item_ops = {
 	.iop_size	= xfs_cud_item_size,
 	.iop_format	= xfs_cud_item_format,
-	.iop_unlock	= xfs_cud_item_unlock,
+	.iop_release	= xfs_cud_item_release,
 	.iop_committed	= xfs_cud_item_committed,
 };
 
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index df9f2505c5f3..e907bd169de5 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -117,11 +117,10 @@ xfs_rui_item_unpin(
  * constructed and thus we free the RUI here directly.
  */
 STATIC void
-xfs_rui_item_unlock(
+xfs_rui_item_release(
 	struct xfs_log_item	*lip)
 {
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-		xfs_rui_release(RUI_ITEM(lip));
+	xfs_rui_release(RUI_ITEM(lip));
 }
 
 /*
@@ -131,7 +130,7 @@ static const struct xfs_item_ops xfs_rui_item_ops = {
 	.iop_size	= xfs_rui_item_size,
 	.iop_format	= xfs_rui_item_format,
 	.iop_unpin	= xfs_rui_item_unpin,
-	.iop_unlock	= xfs_rui_item_unlock,
+	.iop_release	= xfs_rui_item_release,
 };
 
 /*
@@ -226,15 +225,13 @@ xfs_rud_item_format(
  * RUD.
  */
 STATIC void
-xfs_rud_item_unlock(
+xfs_rud_item_release(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_rud_log_item	*rudp = RUD_ITEM(lip);
 
-	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
-		xfs_rui_release(rudp->rud_ruip);
-		kmem_zone_free(xfs_rud_zone, rudp);
-	}
+	xfs_rui_release(rudp->rud_ruip);
+	kmem_zone_free(xfs_rud_zone, rudp);
 }
 
 /*
@@ -268,7 +265,7 @@ xfs_rud_item_committed(
 static const struct xfs_item_ops xfs_rud_item_ops = {
 	.iop_size	= xfs_rud_item_size,
 	.iop_format	= xfs_rud_item_format,
-	.iop_unlock	= xfs_rud_item_unlock,
+	.iop_release	= xfs_rud_item_release,
 	.iop_committed	= xfs_rud_item_committed,
 };
 
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 195a9cdb954e..65c920554b96 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -475,7 +475,7 @@ DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
-DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_release);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 4ed5d032b26f..45a39de65997 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -780,9 +780,8 @@ xfs_trans_free_items(
 		xfs_trans_del_item(lip);
 		if (abort)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
-
-		if (lip->li_ops->iop_unlock)
-			lip->li_ops->iop_unlock(lip);
+		if (lip->li_ops->iop_release)
+			lip->li_ops->iop_release(lip);
 	}
 }
 
@@ -815,7 +814,7 @@ xfs_log_item_batch_insert(
  *
  * If we are called with the aborted flag set, it is because a log write during
  * a CIL checkpoint commit has failed. In this case, all the items in the
- * checkpoint have already gone through iop_committed and iop_unlock, which
+ * checkpoint have already gone through iop_committed and iop_committing, which
  * means that checkpoint commit abort handling is treated exactly the same
  * as an iclog write error even though we haven't started any IO yet. Hence in
  * this case all we need to do is iop_committed processing, followed by an
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index c6e1c5704a8c..7bd1867613c2 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -72,9 +72,9 @@ struct xfs_item_ops {
 	void (*iop_pin)(xfs_log_item_t *);
 	void (*iop_unpin)(xfs_log_item_t *, int remove);
 	uint (*iop_push)(struct xfs_log_item *, struct list_head *);
-	void (*iop_unlock)(xfs_log_item_t *);
+	void (*iop_committing)(struct xfs_log_item *, xfs_lsn_t commit_lsn);
+	void (*iop_release)(struct xfs_log_item *);
 	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
-	void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
 	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
 };
 
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 7d65ebf1e847..3dca9cf40a9f 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -428,7 +428,7 @@ xfs_trans_brelse(
 
 /*
  * Mark the buffer as not needing to be unlocked when the buf item's
- * iop_unlock() routine is called.  The buffer must already be locked
+ * iop_committing() routine is called.  The buffer must already be locked
  * and associated with the given transaction.
  */
 /* ARGSUSED */
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 08/20] xfs: add a flag to release log items on commit
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (6 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 17:50   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item Christoph Hellwig
                   ` (11 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

We have various items that are released from ->iop_comitting.  Add a
flag to just call ->iop_release from the commit path to avoid tons
of boilerplate code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_bmap_item.c     | 27 +--------------------------
 fs/xfs/xfs_extfree_item.c  | 27 +--------------------------
 fs/xfs/xfs_icreate_item.c  | 18 +-----------------
 fs/xfs/xfs_refcount_item.c | 27 +--------------------------
 fs/xfs/xfs_rmap_item.c     | 27 +--------------------------
 fs/xfs/xfs_trans.c         |  5 +++++
 fs/xfs/xfs_trans.h         |  7 +++++++
 7 files changed, 17 insertions(+), 121 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 56c1ab161f3b..d7ceb2d1ae82 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -208,39 +208,14 @@ xfs_bud_item_release(
 	kmem_zone_free(xfs_bud_zone, budp);
 }
 
-/*
- * When the bud item is committed to disk, all we need to do is delete our
- * reference to our partner bui item and then free ourselves. Since we're
- * freeing ourselves we must return -1 to keep the transaction code from
- * further referencing this item.
- */
-STATIC xfs_lsn_t
-xfs_bud_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	struct xfs_bud_log_item	*budp = BUD_ITEM(lip);
-
-	/*
-	 * Drop the BUI reference regardless of whether the BUD has been
-	 * aborted. Once the BUD transaction is constructed, it is the sole
-	 * responsibility of the BUD to release the BUI (even if the BUI is
-	 * aborted due to log I/O error).
-	 */
-	xfs_bui_release(budp->bud_buip);
-	kmem_zone_free(xfs_bud_zone, budp);
-
-	return (xfs_lsn_t)-1;
-}
-
 /*
  * This is the ops vector shared by all bud log items.
  */
 static const struct xfs_item_ops xfs_bud_item_ops = {
+	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_bud_item_size,
 	.iop_format	= xfs_bud_item_format,
 	.iop_release	= xfs_bud_item_release,
-	.iop_committed	= xfs_bud_item_committed,
 };
 
 /*
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index a73a3cff8502..762eb288dfe8 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -307,39 +307,14 @@ xfs_efd_item_release(
 	xfs_efd_item_free(efdp);
 }
 
-/*
- * When the efd item is committed to disk, all we need to do is delete our
- * reference to our partner efi item and then free ourselves. Since we're
- * freeing ourselves we must return -1 to keep the transaction code from further
- * referencing this item.
- */
-STATIC xfs_lsn_t
-xfs_efd_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	struct xfs_efd_log_item	*efdp = EFD_ITEM(lip);
-
-	/*
-	 * Drop the EFI reference regardless of whether the EFD has been
-	 * aborted. Once the EFD transaction is constructed, it is the sole
-	 * responsibility of the EFD to release the EFI (even if the EFI is
-	 * aborted due to log I/O error).
-	 */
-	xfs_efi_release(efdp->efd_efip);
-	xfs_efd_item_free(efdp);
-
-	return (xfs_lsn_t)-1;
-}
-
 /*
  * This is the ops vector shared by all efd log items.
  */
 static const struct xfs_item_ops xfs_efd_item_ops = {
+	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_efd_item_size,
 	.iop_format	= xfs_efd_item_format,
 	.iop_release	= xfs_efd_item_release,
-	.iop_committed	= xfs_efd_item_committed,
 };
 
 /*
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index 9aceb35dce24..eb9cb04635be 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -63,30 +63,14 @@ xfs_icreate_item_release(
 	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
 }
 
-/*
- * Because we have ordered buffers being tracked in the AIL for the inode
- * creation, we don't need the create item after this. Hence we can free
- * the log item and return -1 to tell the caller we're done with the item.
- */
-STATIC xfs_lsn_t
-xfs_icreate_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	struct xfs_icreate_item	*icp = ICR_ITEM(lip);
-
-	kmem_zone_free(xfs_icreate_zone, icp);
-	return (xfs_lsn_t)-1;
-}
-
 /*
  * This is the ops vector shared by all buf log items.
  */
 static const struct xfs_item_ops xfs_icreate_item_ops = {
+	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
 	.iop_release	= xfs_icreate_item_release,
-	.iop_committed	= xfs_icreate_item_committed,
 };
 
 
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 9f8fb23dcc81..b4ab71ce39fc 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -213,39 +213,14 @@ xfs_cud_item_release(
 	kmem_zone_free(xfs_cud_zone, cudp);
 }
 
-/*
- * When the cud item is committed to disk, all we need to do is delete our
- * reference to our partner cui item and then free ourselves. Since we're
- * freeing ourselves we must return -1 to keep the transaction code from
- * further referencing this item.
- */
-STATIC xfs_lsn_t
-xfs_cud_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	struct xfs_cud_log_item	*cudp = CUD_ITEM(lip);
-
-	/*
-	 * Drop the CUI reference regardless of whether the CUD has been
-	 * aborted. Once the CUD transaction is constructed, it is the sole
-	 * responsibility of the CUD to release the CUI (even if the CUI is
-	 * aborted due to log I/O error).
-	 */
-	xfs_cui_release(cudp->cud_cuip);
-	kmem_zone_free(xfs_cud_zone, cudp);
-
-	return (xfs_lsn_t)-1;
-}
-
 /*
  * This is the ops vector shared by all cud log items.
  */
 static const struct xfs_item_ops xfs_cud_item_ops = {
+	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_cud_item_size,
 	.iop_format	= xfs_cud_item_format,
 	.iop_release	= xfs_cud_item_release,
-	.iop_committed	= xfs_cud_item_committed,
 };
 
 /*
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index e907bd169de5..1b35b3d38708 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -234,39 +234,14 @@ xfs_rud_item_release(
 	kmem_zone_free(xfs_rud_zone, rudp);
 }
 
-/*
- * When the rud item is committed to disk, all we need to do is delete our
- * reference to our partner rui item and then free ourselves. Since we're
- * freeing ourselves we must return -1 to keep the transaction code from
- * further referencing this item.
- */
-STATIC xfs_lsn_t
-xfs_rud_item_committed(
-	struct xfs_log_item	*lip,
-	xfs_lsn_t		lsn)
-{
-	struct xfs_rud_log_item	*rudp = RUD_ITEM(lip);
-
-	/*
-	 * Drop the RUI reference regardless of whether the RUD has been
-	 * aborted. Once the RUD transaction is constructed, it is the sole
-	 * responsibility of the RUD to release the RUI (even if the RUI is
-	 * aborted due to log I/O error).
-	 */
-	xfs_rui_release(rudp->rud_ruip);
-	kmem_zone_free(xfs_rud_zone, rudp);
-
-	return (xfs_lsn_t)-1;
-}
-
 /*
  * This is the ops vector shared by all rud log items.
  */
 static const struct xfs_item_ops xfs_rud_item_ops = {
+	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_rud_item_size,
 	.iop_format	= xfs_rud_item_format,
 	.iop_release	= xfs_rud_item_release,
-	.iop_committed	= xfs_rud_item_committed,
 };
 
 /*
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 45a39de65997..52a8a8ff2ae9 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -849,6 +849,11 @@ xfs_trans_committed_bulk(
 		struct xfs_log_item	*lip = lv->lv_item;
 		xfs_lsn_t		item_lsn;
 
+		if (lip->li_ops->flags & XFS_ITEM_RELEASE_ON_COMMIT) {
+			lip->li_ops->iop_release(lip);
+			continue;
+		}
+
 		if (aborted)
 			set_bit(XFS_LI_ABORTED, &lip->li_flags);
 		if (lip->li_ops->iop_committed)
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 7bd1867613c2..a38af44344bf 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -67,6 +67,7 @@ typedef struct xfs_log_item {
 	{ (1 << XFS_LI_DIRTY),		"DIRTY" }
 
 struct xfs_item_ops {
+	unsigned flags;
 	void (*iop_size)(xfs_log_item_t *, int *, int *);
 	void (*iop_format)(xfs_log_item_t *, struct xfs_log_vec *);
 	void (*iop_pin)(xfs_log_item_t *);
@@ -78,6 +79,12 @@ struct xfs_item_ops {
 	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
 };
 
+/*
+ * 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_ON_COMMIT	(1 << 0)
+
 void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
 			  int type, const struct xfs_item_ops *ops);
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (7 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 08/20] xfs: add a flag to release log items on commit Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 17:50   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 10/20] xfs: remove the xfs_log_item_t typedef Christoph Hellwig
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

The cast is not type safe, and we can just dereference the first
member instead to start with.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 71d216cf6f87..419eae485ff3 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -485,7 +485,7 @@ xfs_lock_inodes(
 		 */
 		if (!try_lock) {
 			for (j = (i - 1); j >= 0 && !try_lock; j--) {
-				lp = (xfs_log_item_t *)ips[j]->i_itemp;
+				lp = &ips[j]->i_itemp->ili_item;
 				if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags))
 					try_lock++;
 			}
@@ -585,7 +585,7 @@ xfs_lock_two_inodes(
 	 * the second lock. If we can't get it, we must release the first one
 	 * and try again.
 	 */
-	lp = (xfs_log_item_t *)ip0->i_itemp;
+	lp = &ip0->i_itemp->ili_item;
 	if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags)) {
 		if (!xfs_ilock_nowait(ip1, xfs_lock_inumorder(ip1_mode, 1))) {
 			xfs_iunlock(ip0, ip0_mode);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 10/20] xfs: remove the xfs_log_item_t typedef
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (8 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17 17:50   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 11/20] xfs: use a list_head for iclog callbacks Christoph Hellwig
                   ` (9 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_buf_item.c     |  6 +++---
 fs/xfs/xfs_buf_item.h     |  6 +++---
 fs/xfs/xfs_dquot_item.h   |  4 ++--
 fs/xfs/xfs_extfree_item.h |  4 ++--
 fs/xfs/xfs_inode.c        | 12 +++++------
 fs/xfs/xfs_inode_item.h   |  2 +-
 fs/xfs/xfs_log_recover.c  |  2 +-
 fs/xfs/xfs_trans.h        | 16 +++++++-------
 fs/xfs/xfs_trans_ail.c    | 44 +++++++++++++++++++--------------------
 9 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 7193ee9ca5b8..05eefc677cd8 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -981,9 +981,9 @@ xfs_buf_item_relse(
  */
 void
 xfs_buf_attach_iodone(
-	xfs_buf_t	*bp,
-	void		(*cb)(xfs_buf_t *, xfs_log_item_t *),
-	xfs_log_item_t	*lip)
+	struct xfs_buf		*bp,
+	void			(*cb)(struct xfs_buf *, struct xfs_log_item *),
+	struct xfs_log_item	*lip)
 {
 	ASSERT(xfs_buf_islocked(bp));
 
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 90f65f891fab..4a054b11011a 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -39,7 +39,7 @@ struct xfs_buf_log_item;
  * locked, and which 128 byte chunks of the buffer are dirty.
  */
 struct xfs_buf_log_item {
-	xfs_log_item_t		bli_item;	/* common item structure */
+	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 */
@@ -55,8 +55,8 @@ bool	xfs_buf_item_put(struct xfs_buf_log_item *);
 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_attach_iodone(struct xfs_buf *,
-			      void(*)(struct xfs_buf *, xfs_log_item_t *),
-			      xfs_log_item_t *);
+			      void(*)(struct xfs_buf *, struct xfs_log_item *),
+			      struct xfs_log_item *);
 void	xfs_buf_iodone_callbacks(struct xfs_buf *);
 void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
 bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h
index db9df710a308..1aed34ccdabc 100644
--- a/fs/xfs/xfs_dquot_item.h
+++ b/fs/xfs/xfs_dquot_item.h
@@ -12,13 +12,13 @@ struct xfs_mount;
 struct xfs_qoff_logitem;
 
 typedef struct xfs_dq_logitem {
-	xfs_log_item_t		 qli_item;	   /* common portion */
+	struct xfs_log_item	 qli_item;	   /* common portion */
 	struct xfs_dquot	*qli_dquot;	   /* dquot ptr */
 	xfs_lsn_t		 qli_flush_lsn;	   /* lsn at last flush */
 } xfs_dq_logitem_t;
 
 typedef struct xfs_qoff_logitem {
-	xfs_log_item_t		 qql_item;	/* common portion */
+	struct xfs_log_item	 qql_item;	/* common portion */
 	struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
 	unsigned int		qql_flags;
 } xfs_qoff_logitem_t;
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
index 2a6a895ca73e..b0dc4ebe8892 100644
--- a/fs/xfs/xfs_extfree_item.h
+++ b/fs/xfs/xfs_extfree_item.h
@@ -51,7 +51,7 @@ struct kmem_zone;
  * AIL, so at this point both the EFI and EFD are freed.
  */
 typedef struct xfs_efi_log_item {
-	xfs_log_item_t		efi_item;
+	struct xfs_log_item	efi_item;
 	atomic_t		efi_refcount;
 	atomic_t		efi_next_extent;
 	unsigned long		efi_flags;	/* misc flags */
@@ -64,7 +64,7 @@ typedef struct xfs_efi_log_item {
  * have been freed.
  */
 typedef struct xfs_efd_log_item {
-	xfs_log_item_t		efd_item;
+	struct xfs_log_item	efd_item;
 	xfs_efi_log_item_t	*efd_efip;
 	uint			efd_next_extent;
 	xfs_efd_log_format_t	efd_format;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 419eae485ff3..6076bae6eb21 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -441,12 +441,12 @@ xfs_lock_inumorder(int lock_mode, int subclass)
  */
 static void
 xfs_lock_inodes(
-	xfs_inode_t	**ips,
-	int		inodes,
-	uint		lock_mode)
+	struct xfs_inode	**ips,
+	int			inodes,
+	uint			lock_mode)
 {
-	int		attempts = 0, i, j, try_lock;
-	xfs_log_item_t	*lp;
+	int			attempts = 0, i, j, try_lock;
+	struct xfs_log_item	*lp;
 
 	/*
 	 * Currently supports between 2 and 5 inodes with exclusive locking.  We
@@ -551,7 +551,7 @@ xfs_lock_two_inodes(
 	struct xfs_inode	*temp;
 	uint			mode_temp;
 	int			attempts = 0;
-	xfs_log_item_t		*lp;
+	struct xfs_log_item	*lp;
 
 	ASSERT(hweight32(ip0_mode) == 1);
 	ASSERT(hweight32(ip1_mode) == 1);
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
index 27081eba220c..07a60e74c39c 100644
--- a/fs/xfs/xfs_inode_item.h
+++ b/fs/xfs/xfs_inode_item.h
@@ -14,7 +14,7 @@ struct xfs_inode;
 struct xfs_mount;
 
 typedef 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 ptr */
 	xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */
 	xfs_lsn_t		ili_last_lsn;	   /* lsn at last transaction */
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9329f5adbfbe..76023ea49356 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3463,7 +3463,7 @@ xlog_recover_efd_pass2(
 {
 	xfs_efd_log_format_t	*efd_formatp;
 	xfs_efi_log_item_t	*efip = NULL;
-	xfs_log_item_t		*lip;
+	struct xfs_log_item	*lip;
 	uint64_t		efi_id;
 	struct xfs_ail_cursor	cur;
 	struct xfs_ail		*ailp = log->l_ailp;
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index a38af44344bf..7a6ee0c2ce20 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -27,7 +27,7 @@ struct xfs_cud_log_item;
 struct xfs_bui_log_item;
 struct xfs_bud_log_item;
 
-typedef struct xfs_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 */
@@ -48,7 +48,7 @@ typedef struct xfs_log_item {
 	struct xfs_log_vec		*li_lv;		/* active log vector */
 	struct xfs_log_vec		*li_lv_shadow;	/* standby vector */
 	xfs_lsn_t			li_seq;		/* CIL commit seq */
-} xfs_log_item_t;
+};
 
 /*
  * li_flags use the (set/test/clear)_bit atomic interfaces because updates can
@@ -68,15 +68,15 @@ typedef struct xfs_log_item {
 
 struct xfs_item_ops {
 	unsigned flags;
-	void (*iop_size)(xfs_log_item_t *, int *, int *);
-	void (*iop_format)(xfs_log_item_t *, struct xfs_log_vec *);
-	void (*iop_pin)(xfs_log_item_t *);
-	void (*iop_unpin)(xfs_log_item_t *, int remove);
+	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 *);
+	void (*iop_unpin)(struct xfs_log_item *, int remove);
 	uint (*iop_push)(struct xfs_log_item *, struct list_head *);
 	void (*iop_committing)(struct xfs_log_item *, xfs_lsn_t commit_lsn);
 	void (*iop_release)(struct xfs_log_item *);
-	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
-	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
+	xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
+	void (*iop_error)(struct xfs_log_item *, xfs_buf_t *);
 };
 
 /*
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 8509c4b59760..f239344fda1a 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -74,29 +74,29 @@ xfs_ail_check(
  * Return a pointer to the last item in the AIL.  If the AIL is empty, then
  * return NULL.
  */
-static xfs_log_item_t *
+static struct xfs_log_item *
 xfs_ail_max(
 	struct xfs_ail  *ailp)
 {
 	if (list_empty(&ailp->ail_head))
 		return NULL;
 
-	return list_entry(ailp->ail_head.prev, xfs_log_item_t, li_ail);
+	return list_entry(ailp->ail_head.prev, struct xfs_log_item, li_ail);
 }
 
 /*
  * Return a pointer to the item which follows the given item in the AIL.  If
  * the given item is the last item in the list, then return NULL.
  */
-static xfs_log_item_t *
+static struct xfs_log_item *
 xfs_ail_next(
-	struct xfs_ail  *ailp,
-	xfs_log_item_t  *lip)
+	struct xfs_ail		*ailp,
+	struct xfs_log_item	*lip)
 {
 	if (lip->li_ail.next == &ailp->ail_head)
 		return NULL;
 
-	return list_first_entry(&lip->li_ail, xfs_log_item_t, li_ail);
+	return list_first_entry(&lip->li_ail, struct xfs_log_item, li_ail);
 }
 
 /*
@@ -109,10 +109,10 @@ xfs_ail_next(
  */
 xfs_lsn_t
 xfs_ail_min_lsn(
-	struct xfs_ail	*ailp)
+	struct xfs_ail		*ailp)
 {
-	xfs_lsn_t	lsn = 0;
-	xfs_log_item_t	*lip;
+	xfs_lsn_t		lsn = 0;
+	struct xfs_log_item	*lip;
 
 	spin_lock(&ailp->ail_lock);
 	lip = xfs_ail_min(ailp);
@@ -128,10 +128,10 @@ xfs_ail_min_lsn(
  */
 static xfs_lsn_t
 xfs_ail_max_lsn(
-	struct xfs_ail  *ailp)
+	struct xfs_ail		*ailp)
 {
-	xfs_lsn_t       lsn = 0;
-	xfs_log_item_t  *lip;
+	xfs_lsn_t       	lsn = 0;
+	struct xfs_log_item	*lip;
 
 	spin_lock(&ailp->ail_lock);
 	lip = xfs_ail_max(ailp);
@@ -216,13 +216,13 @@ xfs_trans_ail_cursor_clear(
  * ascending traversal.  Pass a @lsn of zero to initialise the cursor to the
  * first item in the AIL. Returns NULL if the list is empty.
  */
-xfs_log_item_t *
+struct xfs_log_item *
 xfs_trans_ail_cursor_first(
 	struct xfs_ail		*ailp,
 	struct xfs_ail_cursor	*cur,
 	xfs_lsn_t		lsn)
 {
-	xfs_log_item_t		*lip;
+	struct xfs_log_item	*lip;
 
 	xfs_trans_ail_cursor_init(ailp, cur);
 
@@ -248,7 +248,7 @@ __xfs_trans_ail_cursor_last(
 	struct xfs_ail		*ailp,
 	xfs_lsn_t		lsn)
 {
-	xfs_log_item_t		*lip;
+	struct xfs_log_item	*lip;
 
 	list_for_each_entry_reverse(lip, &ailp->ail_head, li_ail) {
 		if (XFS_LSN_CMP(lip->li_lsn, lsn) <= 0)
@@ -327,8 +327,8 @@ xfs_ail_splice(
  */
 static void
 xfs_ail_delete(
-	struct xfs_ail  *ailp,
-	xfs_log_item_t  *lip)
+	struct xfs_ail		*ailp,
+	struct xfs_log_item	*lip)
 {
 	xfs_ail_check(ailp, lip);
 	list_del(&lip->li_ail);
@@ -358,7 +358,7 @@ xfsaild_push(
 {
 	xfs_mount_t		*mp = ailp->ail_mount;
 	struct xfs_ail_cursor	cur;
-	xfs_log_item_t		*lip;
+	struct xfs_log_item	*lip;
 	xfs_lsn_t		lsn;
 	xfs_lsn_t		target;
 	long			tout;
@@ -613,10 +613,10 @@ xfsaild(
  */
 void
 xfs_ail_push(
-	struct xfs_ail	*ailp,
-	xfs_lsn_t	threshold_lsn)
+	struct xfs_ail		*ailp,
+	xfs_lsn_t		threshold_lsn)
 {
-	xfs_log_item_t	*lip;
+	struct xfs_log_item	*lip;
 
 	lip = xfs_ail_min(ailp);
 	if (!lip || XFS_FORCED_SHUTDOWN(ailp->ail_mount) ||
@@ -701,7 +701,7 @@ xfs_trans_ail_update_bulk(
 	int			nr_items,
 	xfs_lsn_t		lsn) __releases(ailp->ail_lock)
 {
-	xfs_log_item_t		*mlip;
+	struct xfs_log_item	*mlip;
 	int			mlip_changed = 0;
 	int			i;
 	LIST_HEAD(tmp);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (9 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 10/20] xfs: remove the xfs_log_item_t typedef Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:12   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances Christoph Hellwig
                   ` (8 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Replace the hand grown linked list handling and cil context attachment
with the standard list_head structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_log.c      | 51 ++++++++-----------------------------------
 fs/xfs/xfs_log.h      | 15 +++----------
 fs/xfs/xfs_log_cil.c  | 31 ++++++++++++++++++++------
 fs/xfs/xfs_log_priv.h | 10 +++------
 4 files changed, 39 insertions(+), 68 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 1eb0938165fc..0d6fb374dbe8 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -538,32 +538,6 @@ xfs_log_done(
 	return lsn;
 }
 
-/*
- * Attaches a new iclog I/O completion callback routine during
- * transaction commit.  If the log is in error state, a non-zero
- * return code is handed back and the caller is responsible for
- * executing the callback at an appropriate time.
- */
-int
-xfs_log_notify(
-	struct xlog_in_core	*iclog,
-	xfs_log_callback_t	*cb)
-{
-	int	abortflg;
-
-	spin_lock(&iclog->ic_callback_lock);
-	abortflg = (iclog->ic_state & XLOG_STATE_IOERROR);
-	if (!abortflg) {
-		ASSERT_ALWAYS((iclog->ic_state == XLOG_STATE_ACTIVE) ||
-			      (iclog->ic_state == XLOG_STATE_WANT_SYNC));
-		cb->cb_next = NULL;
-		*(iclog->ic_callback_tail) = cb;
-		iclog->ic_callback_tail = &(cb->cb_next);
-	}
-	spin_unlock(&iclog->ic_callback_lock);
-	return abortflg;
-}
-
 int
 xfs_log_release_iclog(
 	struct xfs_mount	*mp,
@@ -1554,7 +1528,7 @@ xlog_alloc_log(
 		iclog->ic_log = log;
 		atomic_set(&iclog->ic_refcnt, 0);
 		spin_lock_init(&iclog->ic_callback_lock);
-		iclog->ic_callback_tail = &(iclog->ic_callback);
+		INIT_LIST_HEAD(&iclog->ic_callbacks);
 		iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize;
 
 		init_waitqueue_head(&iclog->ic_force_wait);
@@ -2600,7 +2574,7 @@ xlog_state_clean_log(
 		if (iclog->ic_state == XLOG_STATE_DIRTY) {
 			iclog->ic_state	= XLOG_STATE_ACTIVE;
 			iclog->ic_offset       = 0;
-			ASSERT(iclog->ic_callback == NULL);
+			ASSERT(list_empty_careful(&iclog->ic_callbacks));
 			/*
 			 * If the number of ops in this iclog indicate it just
 			 * contains the dummy transaction, we can
@@ -2700,7 +2674,6 @@ xlog_state_do_callback(
 	xlog_in_core_t	   *iclog;
 	xlog_in_core_t	   *first_iclog;	/* used to know when we've
 						 * processed all iclogs once */
-	xfs_log_callback_t *cb, *cb_next;
 	int		   flushcnt = 0;
 	xfs_lsn_t	   lowest_lsn;
 	int		   ioerrors;	/* counter: iclogs with errors */
@@ -2811,7 +2784,7 @@ xlog_state_do_callback(
 				 */
 				ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn),
 					be64_to_cpu(iclog->ic_header.h_lsn)) <= 0);
-				if (iclog->ic_callback)
+				if (!list_empty_careful(&iclog->ic_callbacks))
 					atomic64_set(&log->l_last_sync_lsn,
 						be64_to_cpu(iclog->ic_header.h_lsn));
 
@@ -2828,26 +2801,20 @@ xlog_state_do_callback(
 			 * callbacks being added.
 			 */
 			spin_lock(&iclog->ic_callback_lock);
-			cb = iclog->ic_callback;
-			while (cb) {
-				iclog->ic_callback_tail = &(iclog->ic_callback);
-				iclog->ic_callback = NULL;
-				spin_unlock(&iclog->ic_callback_lock);
+			while (!list_empty(&iclog->ic_callbacks)) {
+				LIST_HEAD(tmp);
 
-				/* perform callbacks in the order given */
-				for (; cb; cb = cb_next) {
-					cb_next = cb->cb_next;
-					cb->cb_func(cb->cb_arg, aborted);
-				}
+				list_splice_init(&iclog->ic_callbacks, &tmp);
+
+				spin_unlock(&iclog->ic_callback_lock);
+				xlog_cil_process_commited(&tmp, aborted);
 				spin_lock(&iclog->ic_callback_lock);
-				cb = iclog->ic_callback;
 			}
 
 			loopdidcallbacks++;
 			funcdidcallbacks++;
 
 			spin_lock(&log->l_icloglock);
-			ASSERT(iclog->ic_callback == NULL);
 			spin_unlock(&iclog->ic_callback_lock);
 			if (!(iclog->ic_state & XLOG_STATE_IOERROR))
 				iclog->ic_state = XLOG_STATE_DIRTY;
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 4450a2a26a1a..fac46af28cf5 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -6,6 +6,8 @@
 #ifndef	__XFS_LOG_H__
 #define __XFS_LOG_H__
 
+struct xfs_cil_ctx;
+
 struct xfs_log_vec {
 	struct xfs_log_vec	*lv_next;	/* next lv in build list */
 	int			lv_niovecs;	/* number of iovecs in lv */
@@ -71,16 +73,6 @@ xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
 	return buf;
 }
 
-/*
- * Structure used to pass callback function and the function's argument
- * to the log manager.
- */
-typedef struct xfs_log_callback {
-	struct xfs_log_callback	*cb_next;
-	void			(*cb_func)(void *, bool);
-	void			*cb_arg;
-} xfs_log_callback_t;
-
 /*
  * By comparing each component, we don't have to worry about extra
  * endian issues in treating two 32 bit numbers as one 64 bit number
@@ -129,8 +121,6 @@ int	xfs_log_mount_cancel(struct xfs_mount *);
 xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
 xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp);
 void	  xfs_log_space_wake(struct xfs_mount *mp);
-int	  xfs_log_notify(struct xlog_in_core	*iclog,
-			 struct xfs_log_callback *callback_entry);
 int	  xfs_log_release_iclog(struct xfs_mount *mp,
 			 struct xlog_in_core	 *iclog);
 int	  xfs_log_reserve(struct xfs_mount *mp,
@@ -148,6 +138,7 @@ void	  xfs_log_ticket_put(struct xlog_ticket *ticket);
 
 void	xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
 				xfs_lsn_t *commit_lsn, bool regrant);
+void	xlog_cil_process_commited(struct list_head *list, bool aborted);
 bool	xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
 
 void	xfs_log_work_queue(struct xfs_mount *mp);
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 4cb459f21ad4..b6b30b8e22af 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -577,10 +577,9 @@ xlog_discard_busy_extents(
  */
 static void
 xlog_cil_committed(
-	void	*args,
-	bool	abort)
+	struct xfs_cil_ctx	*ctx,
+	bool			abort)
 {
-	struct xfs_cil_ctx	*ctx = args;
 	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
 
 	/*
@@ -615,6 +614,20 @@ xlog_cil_committed(
 		kmem_free(ctx);
 }
 
+void
+xlog_cil_process_commited(
+	struct list_head	*list,
+	bool			aborted)
+{
+	struct xfs_cil_ctx	*ctx;
+
+	while ((ctx = list_first_entry_or_null(list,
+			struct xfs_cil_ctx, iclog_entry))) {
+		list_del(&ctx->iclog_entry);
+		xlog_cil_committed(ctx, aborted);
+	}
+}
+
 /*
  * Push the Committed Item List to the log. If @push_seq flag is zero, then it
  * is a background flush and so we can chose to ignore it. Otherwise, if the
@@ -837,11 +850,15 @@ xlog_cil_push(
 		goto out_abort;
 
 	/* attach all the transactions w/ busy extents to iclog */
-	ctx->log_cb.cb_func = xlog_cil_committed;
-	ctx->log_cb.cb_arg = ctx;
-	error = xfs_log_notify(commit_iclog, &ctx->log_cb);
-	if (error)
+	spin_lock(&commit_iclog->ic_callback_lock);
+	if (commit_iclog->ic_state & XLOG_STATE_IOERROR) {
+		spin_unlock(&commit_iclog->ic_callback_lock);
 		goto out_abort;
+	}
+	ASSERT_ALWAYS(commit_iclog->ic_state == XLOG_STATE_ACTIVE ||
+		      commit_iclog->ic_state == XLOG_STATE_WANT_SYNC);
+	list_add_tail(&ctx->iclog_entry, &commit_iclog->ic_callbacks);
+	spin_unlock(&commit_iclog->ic_callback_lock);
 
 	/*
 	 * now the checkpoint commit is complete and we've attached the
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index b5f82cb36202..5c188ccb8568 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -10,7 +10,6 @@ struct xfs_buf;
 struct xlog;
 struct xlog_ticket;
 struct xfs_mount;
-struct xfs_log_callback;
 
 /*
  * Flags for log structure
@@ -181,8 +180,6 @@ typedef struct xlog_ticket {
  * - ic_next is the pointer to the next iclog in the ring.
  * - ic_bp is a pointer to the buffer used to write this incore log to disk.
  * - ic_log is a pointer back to the global log structure.
- * - ic_callback is a linked list of callback function/argument pairs to be
- *	called after an iclog finishes writing.
  * - ic_size is the full size of the header plus data.
  * - ic_offset is the current number of bytes written to in this iclog.
  * - ic_refcnt is bumped when someone is writing to the log.
@@ -193,7 +190,7 @@ typedef struct xlog_ticket {
  * structure cacheline aligned. The following fields can be contended on
  * by independent processes:
  *
- *	- ic_callback_*
+ *	- ic_callbacks
  *	- ic_refcnt
  *	- fields protected by the global l_icloglock
  *
@@ -216,8 +213,7 @@ typedef struct xlog_in_core {
 
 	/* Callback structures need their own cacheline */
 	spinlock_t		ic_callback_lock ____cacheline_aligned_in_smp;
-	struct xfs_log_callback	*ic_callback;
-	struct xfs_log_callback	**ic_callback_tail;
+	struct list_head	ic_callbacks;
 
 	/* reference counts need their own cacheline */
 	atomic_t		ic_refcnt ____cacheline_aligned_in_smp;
@@ -243,7 +239,7 @@ struct xfs_cil_ctx {
 	int			space_used;	/* aggregate size of regions */
 	struct list_head	busy_extents;	/* busy extents in chkpt */
 	struct xfs_log_vec	*lv_chain;	/* logvecs being pushed */
-	struct xfs_log_callback	log_cb;		/* completion callback hook. */
+	struct list_head	iclog_entry;
 	struct list_head	committing;	/* ctx committing list */
 	struct work_struct	discard_endio_work;
 };
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (10 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 11/20] xfs: use a list_head for iclog callbacks Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:12   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_bmap_item.c     | 6 ------
 fs/xfs/xfs_buf_item.c      | 3 ---
 fs/xfs/xfs_dquot_item.c    | 6 ------
 fs/xfs/xfs_extfree_item.c  | 6 ------
 fs/xfs/xfs_icreate_item.c  | 3 ---
 fs/xfs/xfs_inode_item.c    | 3 ---
 fs/xfs/xfs_refcount_item.c | 6 ------
 fs/xfs/xfs_rmap_item.c     | 6 ------
 8 files changed, 39 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index d7ceb2d1ae82..46dcadf790c2 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -125,9 +125,6 @@ xfs_bui_item_release(
 	xfs_bui_release(BUI_ITEM(lip));
 }
 
-/*
- * This is the ops vector shared by all bui log items.
- */
 static const struct xfs_item_ops xfs_bui_item_ops = {
 	.iop_size	= xfs_bui_item_size,
 	.iop_format	= xfs_bui_item_format,
@@ -208,9 +205,6 @@ xfs_bud_item_release(
 	kmem_zone_free(xfs_bud_zone, budp);
 }
 
-/*
- * This is the ops vector shared by all bud log items.
- */
 static const struct xfs_item_ops xfs_bud_item_ops = {
 	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_bud_item_size,
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 05eefc677cd8..2c7aef61ea92 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -679,9 +679,6 @@ xfs_buf_item_committed(
 	return lsn;
 }
 
-/*
- * This is the ops vector shared by all buf log items.
- */
 static const struct xfs_item_ops xfs_buf_item_ops = {
 	.iop_size	= xfs_buf_item_size,
 	.iop_format	= xfs_buf_item_format,
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index b8fd81641dfc..ade4520d3fdf 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -222,9 +222,6 @@ xfs_qm_dquot_logitem_committing(
 	return xfs_qm_dquot_logitem_release(lip);
 }
 
-/*
- * This is the ops vector for dquots
- */
 static const struct xfs_item_ops xfs_dquot_item_ops = {
 	.iop_size	= xfs_qm_dquot_logitem_size,
 	.iop_format	= xfs_qm_dquot_logitem_format,
@@ -320,9 +317,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 	.iop_committed	= xfs_qm_qoffend_logitem_committed,
 };
 
-/*
- * This is the ops vector shared by all quotaoff-start log items.
- */
 static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
 	.iop_size	= xfs_qm_qoff_logitem_size,
 	.iop_format	= xfs_qm_qoff_logitem_format,
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 762eb288dfe8..bb0b1e942d00 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -135,9 +135,6 @@ xfs_efi_item_release(
 	xfs_efi_release(EFI_ITEM(lip));
 }
 
-/*
- * This is the ops vector shared by all efi log items.
- */
 static const struct xfs_item_ops xfs_efi_item_ops = {
 	.iop_size	= xfs_efi_item_size,
 	.iop_format	= xfs_efi_item_format,
@@ -307,9 +304,6 @@ xfs_efd_item_release(
 	xfs_efd_item_free(efdp);
 }
 
-/*
- * This is the ops vector shared by all efd log items.
- */
 static const struct xfs_item_ops xfs_efd_item_ops = {
 	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_efd_item_size,
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index eb9cb04635be..4f1ce50ce323 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -63,9 +63,6 @@ xfs_icreate_item_release(
 	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
 }
 
-/*
- * This is the ops vector shared by all buf log items.
- */
 static const struct xfs_item_ops xfs_icreate_item_ops = {
 	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_icreate_item_size,
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a00f0b6aecc7..62847e95b399 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -627,9 +627,6 @@ xfs_inode_item_committing(
 	return xfs_inode_item_release(lip);
 }
 
-/*
- * This is the ops vector shared by all buf log items.
- */
 static const struct xfs_item_ops xfs_inode_item_ops = {
 	.iop_size	= xfs_inode_item_size,
 	.iop_format	= xfs_inode_item_format,
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index b4ab71ce39fc..2b2f6e7ad867 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -124,9 +124,6 @@ xfs_cui_item_release(
 	xfs_cui_release(CUI_ITEM(lip));
 }
 
-/*
- * This is the ops vector shared by all cui log items.
- */
 static const struct xfs_item_ops xfs_cui_item_ops = {
 	.iop_size	= xfs_cui_item_size,
 	.iop_format	= xfs_cui_item_format,
@@ -213,9 +210,6 @@ xfs_cud_item_release(
 	kmem_zone_free(xfs_cud_zone, cudp);
 }
 
-/*
- * This is the ops vector shared by all cud log items.
- */
 static const struct xfs_item_ops xfs_cud_item_ops = {
 	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_cud_item_size,
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 1b35b3d38708..dce1357aef88 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -123,9 +123,6 @@ xfs_rui_item_release(
 	xfs_rui_release(RUI_ITEM(lip));
 }
 
-/*
- * This is the ops vector shared by all rui log items.
- */
 static const struct xfs_item_ops xfs_rui_item_ops = {
 	.iop_size	= xfs_rui_item_size,
 	.iop_format	= xfs_rui_item_format,
@@ -234,9 +231,6 @@ xfs_rud_item_release(
 	kmem_zone_free(xfs_rud_zone, rudp);
 }
 
-/*
- * This is the ops vector shared by all rud log items.
- */
 static const struct xfs_item_ops xfs_rud_item_ops = {
 	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
 	.iop_size	= xfs_rud_item_size,
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (11 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-17  8:16   ` Nikolay Borisov
                     ` (2 more replies)
  2019-05-17  7:31 ` [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud Christoph Hellwig
                   ` (6 subsequent siblings)
  19 siblings, 3 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_extfree_item.c  | 27 +++++++++++++++------------
 fs/xfs/xfs_extfree_item.h  |  2 --
 fs/xfs/xfs_trans_extfree.c | 26 --------------------------
 3 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index bb0b1e942d00..ccf95cb8234c 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -312,32 +312,35 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
 };
 
 /*
- * Allocate and initialize an efd item with the given number of extents.
+ * Allocate an "extent free done" log item that will hold nextents worth of
+ * extents.  The caller must use all nextents extents, because we are not
+ * flexible about this at all.
  */
 struct xfs_efd_log_item *
-xfs_efd_init(
-	struct xfs_mount	*mp,
-	struct xfs_efi_log_item	*efip,
-	uint			nextents)
-
+xfs_trans_get_efd(
+	struct xfs_trans		*tp,
+	struct xfs_efi_log_item		*efip,
+	unsigned int			nextents)
 {
-	struct xfs_efd_log_item	*efdp;
-	uint			size;
+	struct xfs_efd_log_item		*efdp;
 
 	ASSERT(nextents > 0);
+
 	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
-		size = (uint)(sizeof(xfs_efd_log_item_t) +
-			((nextents - 1) * sizeof(xfs_extent_t)));
-		efdp = kmem_zalloc(size, KM_SLEEP);
+		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
+				(nextents - 1) * sizeof(struct xfs_extent),
+				KM_SLEEP);
 	} else {
 		efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP);
 	}
 
-	xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops);
+	xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
+			  &xfs_efd_item_ops);
 	efdp->efd_efip = efip;
 	efdp->efd_format.efd_nextents = nextents;
 	efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
 
+	xfs_trans_add_item(tp, &efdp->efd_item);
 	return efdp;
 }
 
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
index b0dc4ebe8892..16aaab06d4ec 100644
--- a/fs/xfs/xfs_extfree_item.h
+++ b/fs/xfs/xfs_extfree_item.h
@@ -79,8 +79,6 @@ extern struct kmem_zone	*xfs_efi_zone;
 extern struct kmem_zone	*xfs_efd_zone;
 
 xfs_efi_log_item_t	*xfs_efi_init(struct xfs_mount *, uint);
-xfs_efd_log_item_t	*xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
-				      uint);
 int			xfs_efi_copy_format(xfs_log_iovec_t *buf,
 					    xfs_efi_log_format_t *dst_efi_fmt);
 void			xfs_efi_item_free(xfs_efi_log_item_t *);
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
index 8ee7a3f8bb20..20ab1c9d758f 100644
--- a/fs/xfs/xfs_trans_extfree.c
+++ b/fs/xfs/xfs_trans_extfree.c
@@ -19,32 +19,6 @@
 #include "xfs_bmap.h"
 #include "xfs_trace.h"
 
-/*
- * This routine is called to allocate an "extent free done"
- * log item that will hold nextents worth of extents.  The
- * caller must use all nextents extents, because we are not
- * flexible about this at all.
- */
-struct xfs_efd_log_item *
-xfs_trans_get_efd(struct xfs_trans		*tp,
-		  struct xfs_efi_log_item	*efip,
-		  uint				nextents)
-{
-	struct xfs_efd_log_item			*efdp;
-
-	ASSERT(tp != NULL);
-	ASSERT(nextents > 0);
-
-	efdp = xfs_efd_init(tp->t_mountp, efip, nextents);
-	ASSERT(efdp != NULL);
-
-	/*
-	 * Get a log_item_desc to point at the new item.
-	 */
-	xfs_trans_add_item(tp, &efdp->efd_item);
-	return efdp;
-}
-
 /*
  * Free an extent and log it to the EFD. Note that the transaction is marked
  * dirty regardless of whether the extent free succeeds or fails to support the
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (12 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:13   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud Christoph Hellwig
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_refcount_item.c  | 14 ++++++--------
 fs/xfs/xfs_refcount_item.h  |  2 --
 fs/xfs/xfs_trans_refcount.c | 16 ----------------
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 2b2f6e7ad867..70dcdf40ac92 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -217,22 +217,20 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
 	.iop_release	= xfs_cud_item_release,
 };
 
-/*
- * Allocate and initialize an cud item with the given number of extents.
- */
 struct xfs_cud_log_item *
-xfs_cud_init(
-	struct xfs_mount		*mp,
+xfs_trans_get_cud(
+	struct xfs_trans		*tp,
 	struct xfs_cui_log_item		*cuip)
-
 {
-	struct xfs_cud_log_item	*cudp;
+	struct xfs_cud_log_item		*cudp;
 
 	cudp = kmem_zone_zalloc(xfs_cud_zone, KM_SLEEP);
-	xfs_log_item_init(mp, &cudp->cud_item, XFS_LI_CUD, &xfs_cud_item_ops);
+	xfs_log_item_init(tp->t_mountp, &cudp->cud_item, XFS_LI_CUD,
+			  &xfs_cud_item_ops);
 	cudp->cud_cuip = cuip;
 	cudp->cud_format.cud_cui_id = cuip->cui_format.cui_id;
 
+	xfs_trans_add_item(tp, &cudp->cud_item);
 	return cudp;
 }
 
diff --git a/fs/xfs/xfs_refcount_item.h b/fs/xfs/xfs_refcount_item.h
index 3896dcc2368f..e47530f30489 100644
--- a/fs/xfs/xfs_refcount_item.h
+++ b/fs/xfs/xfs_refcount_item.h
@@ -78,8 +78,6 @@ extern struct kmem_zone	*xfs_cui_zone;
 extern struct kmem_zone	*xfs_cud_zone;
 
 struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint);
-struct xfs_cud_log_item *xfs_cud_init(struct xfs_mount *,
-		struct xfs_cui_log_item *);
 void xfs_cui_item_free(struct xfs_cui_log_item *);
 void xfs_cui_release(struct xfs_cui_log_item *);
 int xfs_cui_recover(struct xfs_trans *parent_tp, struct xfs_cui_log_item *cuip);
diff --git a/fs/xfs/xfs_trans_refcount.c b/fs/xfs/xfs_trans_refcount.c
index 8d734728dd1b..d793fb500378 100644
--- a/fs/xfs/xfs_trans_refcount.c
+++ b/fs/xfs/xfs_trans_refcount.c
@@ -17,22 +17,6 @@
 #include "xfs_alloc.h"
 #include "xfs_refcount.h"
 
-/*
- * This routine is called to allocate a "refcount update done"
- * log item.
- */
-struct xfs_cud_log_item *
-xfs_trans_get_cud(
-	struct xfs_trans		*tp,
-	struct xfs_cui_log_item		*cuip)
-{
-	struct xfs_cud_log_item		*cudp;
-
-	cudp = xfs_cud_init(tp->t_mountp, cuip);
-	xfs_trans_add_item(tp, &cudp->cud_item);
-	return cudp;
-}
-
 /*
  * Finish an refcount update and log it to the CUD. Note that the
  * transaction is marked dirty regardless of whether the refcount
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (13 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:13   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud Christoph Hellwig
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_rmap_item.c  | 14 ++++++--------
 fs/xfs/xfs_rmap_item.h  |  2 --
 fs/xfs/xfs_trans_rmap.c | 12 ------------
 3 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index dce1357aef88..5f11e6d43484 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -238,22 +238,20 @@ static const struct xfs_item_ops xfs_rud_item_ops = {
 	.iop_release	= xfs_rud_item_release,
 };
 
-/*
- * Allocate and initialize an rud item with the given number of extents.
- */
 struct xfs_rud_log_item *
-xfs_rud_init(
-	struct xfs_mount		*mp,
+xfs_trans_get_rud(
+	struct xfs_trans		*tp,
 	struct xfs_rui_log_item		*ruip)
-
 {
-	struct xfs_rud_log_item	*rudp;
+	struct xfs_rud_log_item		*rudp;
 
 	rudp = kmem_zone_zalloc(xfs_rud_zone, KM_SLEEP);
-	xfs_log_item_init(mp, &rudp->rud_item, XFS_LI_RUD, &xfs_rud_item_ops);
+	xfs_log_item_init(tp->t_mountp, &rudp->rud_item, XFS_LI_RUD,
+			  &xfs_rud_item_ops);
 	rudp->rud_ruip = ruip;
 	rudp->rud_format.rud_rui_id = ruip->rui_format.rui_id;
 
+	xfs_trans_add_item(tp, &rudp->rud_item);
 	return rudp;
 }
 
diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h
index 7e482baa27f5..8708e4a5aa5c 100644
--- a/fs/xfs/xfs_rmap_item.h
+++ b/fs/xfs/xfs_rmap_item.h
@@ -78,8 +78,6 @@ extern struct kmem_zone	*xfs_rui_zone;
 extern struct kmem_zone	*xfs_rud_zone;
 
 struct xfs_rui_log_item *xfs_rui_init(struct xfs_mount *, uint);
-struct xfs_rud_log_item *xfs_rud_init(struct xfs_mount *,
-		struct xfs_rui_log_item *);
 int xfs_rui_copy_format(struct xfs_log_iovec *buf,
 		struct xfs_rui_log_format *dst_rui_fmt);
 void xfs_rui_item_free(struct xfs_rui_log_item *);
diff --git a/fs/xfs/xfs_trans_rmap.c b/fs/xfs/xfs_trans_rmap.c
index 5c7936b1be13..863e3281daaa 100644
--- a/fs/xfs/xfs_trans_rmap.c
+++ b/fs/xfs/xfs_trans_rmap.c
@@ -60,18 +60,6 @@ xfs_trans_set_rmap_flags(
 	}
 }
 
-struct xfs_rud_log_item *
-xfs_trans_get_rud(
-	struct xfs_trans		*tp,
-	struct xfs_rui_log_item		*ruip)
-{
-	struct xfs_rud_log_item		*rudp;
-
-	rudp = xfs_rud_init(tp->t_mountp, ruip);
-	xfs_trans_add_item(tp, &rudp->rud_item);
-	return rudp;
-}
-
 /*
  * Finish an rmap update and log it to the RUD. Note that the transaction is
  * marked dirty regardless of whether the rmap update succeeds or fails to
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (14 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:13   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c Christoph Hellwig
                   ` (3 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_bmap_item.c  | 14 ++++++--------
 fs/xfs/xfs_bmap_item.h  |  2 --
 fs/xfs/xfs_trans_bmap.c | 16 ----------------
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 46dcadf790c2..40385c8b752a 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -212,22 +212,20 @@ static const struct xfs_item_ops xfs_bud_item_ops = {
 	.iop_release	= xfs_bud_item_release,
 };
 
-/*
- * Allocate and initialize an bud item with the given number of extents.
- */
 struct xfs_bud_log_item *
-xfs_bud_init(
-	struct xfs_mount		*mp,
+xfs_trans_get_bud(
+	struct xfs_trans		*tp,
 	struct xfs_bui_log_item		*buip)
-
 {
-	struct xfs_bud_log_item	*budp;
+	struct xfs_bud_log_item		*budp;
 
 	budp = kmem_zone_zalloc(xfs_bud_zone, KM_SLEEP);
-	xfs_log_item_init(mp, &budp->bud_item, XFS_LI_BUD, &xfs_bud_item_ops);
+	xfs_log_item_init(tp->t_mountp, &budp->bud_item, XFS_LI_BUD,
+			  &xfs_bud_item_ops);
 	budp->bud_buip = buip;
 	budp->bud_format.bud_bui_id = buip->bui_format.bui_id;
 
+	xfs_trans_add_item(tp, &budp->bud_item);
 	return budp;
 }
 
diff --git a/fs/xfs/xfs_bmap_item.h b/fs/xfs/xfs_bmap_item.h
index 89e043a88bb8..ad479cc73de8 100644
--- a/fs/xfs/xfs_bmap_item.h
+++ b/fs/xfs/xfs_bmap_item.h
@@ -75,8 +75,6 @@ extern struct kmem_zone	*xfs_bui_zone;
 extern struct kmem_zone	*xfs_bud_zone;
 
 struct xfs_bui_log_item *xfs_bui_init(struct xfs_mount *);
-struct xfs_bud_log_item *xfs_bud_init(struct xfs_mount *,
-		struct xfs_bui_log_item *);
 void xfs_bui_item_free(struct xfs_bui_log_item *);
 void xfs_bui_release(struct xfs_bui_log_item *);
 int xfs_bui_recover(struct xfs_trans *parent_tp, struct xfs_bui_log_item *buip);
diff --git a/fs/xfs/xfs_trans_bmap.c b/fs/xfs/xfs_trans_bmap.c
index e1c7d55b32c3..c6f5b217d17c 100644
--- a/fs/xfs/xfs_trans_bmap.c
+++ b/fs/xfs/xfs_trans_bmap.c
@@ -18,22 +18,6 @@
 #include "xfs_bmap.h"
 #include "xfs_inode.h"
 
-/*
- * This routine is called to allocate a "bmap update done"
- * log item.
- */
-struct xfs_bud_log_item *
-xfs_trans_get_bud(
-	struct xfs_trans		*tp,
-	struct xfs_bui_log_item		*buip)
-{
-	struct xfs_bud_log_item		*budp;
-
-	budp = xfs_bud_init(tp->t_mountp, buip);
-	xfs_trans_add_item(tp, &budp->bud_item);
-	return budp;
-}
-
 /*
  * Finish an bmap update and log it to the BUD. Note that the
  * transaction is marked dirty regardless of whether the bmap update
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (15 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:13   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c Christoph Hellwig
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Keep all the extree item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/Makefile            |   1 -
 fs/xfs/xfs_extfree_item.c  | 247 ++++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_trans.h         |   8 --
 fs/xfs/xfs_trans_extfree.c | 260 -------------------------------------
 4 files changed, 246 insertions(+), 270 deletions(-)
 delete mode 100644 fs/xfs/xfs_trans_extfree.c

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 1dfc6df2e2bd..771a4738abd2 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -106,7 +106,6 @@ xfs-y				+= xfs_log.o \
 				   xfs_trans_ail.o \
 				   xfs_trans_bmap.o \
 				   xfs_trans_buf.o \
-				   xfs_trans_extfree.o \
 				   xfs_trans_inode.o \
 				   xfs_trans_refcount.o \
 				   xfs_trans_rmap.o \
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index ccf95cb8234c..219dbaf9d65b 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -5,11 +5,14 @@
  */
 #include "xfs.h"
 #include "xfs_fs.h"
+#include "xfs_shared.h"
 #include "xfs_format.h"
 #include "xfs_log_format.h"
 #include "xfs_trans_resv.h"
 #include "xfs_bit.h"
 #include "xfs_mount.h"
+#include "xfs_defer.h"
+#include "xfs_trans.h"
 #include "xfs_trans.h"
 #include "xfs_trans_priv.h"
 #include "xfs_buf_item.h"
@@ -17,6 +20,9 @@
 #include "xfs_log.h"
 #include "xfs_btree.h"
 #include "xfs_rmap.h"
+#include "xfs_alloc.h"
+#include "xfs_bmap.h"
+#include "xfs_trace.h"
 
 
 kmem_zone_t	*xfs_efi_zone;
@@ -316,7 +322,7 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
  * extents.  The caller must use all nextents extents, because we are not
  * flexible about this at all.
  */
-struct xfs_efd_log_item *
+static struct xfs_efd_log_item *
 xfs_trans_get_efd(
 	struct xfs_trans		*tp,
 	struct xfs_efi_log_item		*efip,
@@ -344,6 +350,245 @@ xfs_trans_get_efd(
 	return efdp;
 }
 
+/*
+ * Free an extent and log it to the EFD. Note that the transaction is marked
+ * dirty regardless of whether the extent free succeeds or fails to support the
+ * EFI/EFD lifecycle rules.
+ */
+static int
+xfs_trans_free_extent(
+	struct xfs_trans		*tp,
+	struct xfs_efd_log_item		*efdp,
+	xfs_fsblock_t			start_block,
+	xfs_extlen_t			ext_len,
+	const struct xfs_owner_info	*oinfo,
+	bool				skip_discard)
+{
+	struct xfs_mount		*mp = tp->t_mountp;
+	struct xfs_extent		*extp;
+	uint				next_extent;
+	xfs_agnumber_t			agno = XFS_FSB_TO_AGNO(mp, start_block);
+	xfs_agblock_t			agbno = XFS_FSB_TO_AGBNO(mp,
+								start_block);
+	int				error;
+
+	trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
+
+	error = __xfs_free_extent(tp, start_block, ext_len,
+				  oinfo, XFS_AG_RESV_NONE, skip_discard);
+	/*
+	 * Mark the transaction dirty, even on error. This ensures the
+	 * transaction is aborted, which:
+	 *
+	 * 1.) releases the EFI and frees the EFD
+	 * 2.) shuts down the filesystem
+	 */
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
+
+	next_extent = efdp->efd_next_extent;
+	ASSERT(next_extent < efdp->efd_format.efd_nextents);
+	extp = &(efdp->efd_format.efd_extents[next_extent]);
+	extp->ext_start = start_block;
+	extp->ext_len = ext_len;
+	efdp->efd_next_extent++;
+
+	return error;
+}
+
+/* Sort bmap items by AG. */
+static int
+xfs_extent_free_diff_items(
+	void				*priv,
+	struct list_head		*a,
+	struct list_head		*b)
+{
+	struct xfs_mount		*mp = priv;
+	struct xfs_extent_free_item	*ra;
+	struct xfs_extent_free_item	*rb;
+
+	ra = container_of(a, struct xfs_extent_free_item, xefi_list);
+	rb = container_of(b, struct xfs_extent_free_item, xefi_list);
+	return  XFS_FSB_TO_AGNO(mp, ra->xefi_startblock) -
+		XFS_FSB_TO_AGNO(mp, rb->xefi_startblock);
+}
+
+/* Get an EFI. */
+STATIC void *
+xfs_extent_free_create_intent(
+	struct xfs_trans		*tp,
+	unsigned int			count)
+{
+	struct xfs_efi_log_item		*efip;
+
+	ASSERT(tp != NULL);
+	ASSERT(count > 0);
+
+	efip = xfs_efi_init(tp->t_mountp, count);
+	ASSERT(efip != NULL);
+
+	/*
+	 * Get a log_item_desc to point at the new item.
+	 */
+	xfs_trans_add_item(tp, &efip->efi_item);
+	return efip;
+}
+
+/* Log a free extent to the intent item. */
+STATIC void
+xfs_extent_free_log_item(
+	struct xfs_trans		*tp,
+	void				*intent,
+	struct list_head		*item)
+{
+	struct xfs_efi_log_item		*efip = intent;
+	struct xfs_extent_free_item	*free;
+	uint				next_extent;
+	struct xfs_extent		*extp;
+
+	free = container_of(item, struct xfs_extent_free_item, xefi_list);
+
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
+
+	/*
+	 * atomic_inc_return gives us the value after the increment;
+	 * we want to use it as an array index so we need to subtract 1 from
+	 * it.
+	 */
+	next_extent = atomic_inc_return(&efip->efi_next_extent) - 1;
+	ASSERT(next_extent < efip->efi_format.efi_nextents);
+	extp = &efip->efi_format.efi_extents[next_extent];
+	extp->ext_start = free->xefi_startblock;
+	extp->ext_len = free->xefi_blockcount;
+}
+
+/* Get an EFD so we can process all the free extents. */
+STATIC void *
+xfs_extent_free_create_done(
+	struct xfs_trans		*tp,
+	void				*intent,
+	unsigned int			count)
+{
+	return xfs_trans_get_efd(tp, intent, count);
+}
+
+/* Process a free extent. */
+STATIC int
+xfs_extent_free_finish_item(
+	struct xfs_trans		*tp,
+	struct list_head		*item,
+	void				*done_item,
+	void				**state)
+{
+	struct xfs_extent_free_item	*free;
+	int				error;
+
+	free = container_of(item, struct xfs_extent_free_item, xefi_list);
+	error = xfs_trans_free_extent(tp, done_item,
+			free->xefi_startblock,
+			free->xefi_blockcount,
+			&free->xefi_oinfo, free->xefi_skip_discard);
+	kmem_free(free);
+	return error;
+}
+
+/* Abort all pending EFIs. */
+STATIC void
+xfs_extent_free_abort_intent(
+	void				*intent)
+{
+	xfs_efi_release(intent);
+}
+
+/* Cancel a free extent. */
+STATIC void
+xfs_extent_free_cancel_item(
+	struct list_head		*item)
+{
+	struct xfs_extent_free_item	*free;
+
+	free = container_of(item, struct xfs_extent_free_item, xefi_list);
+	kmem_free(free);
+}
+
+const struct xfs_defer_op_type xfs_extent_free_defer_type = {
+	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
+	.diff_items	= xfs_extent_free_diff_items,
+	.create_intent	= xfs_extent_free_create_intent,
+	.abort_intent	= xfs_extent_free_abort_intent,
+	.log_item	= xfs_extent_free_log_item,
+	.create_done	= xfs_extent_free_create_done,
+	.finish_item	= xfs_extent_free_finish_item,
+	.cancel_item	= xfs_extent_free_cancel_item,
+};
+
+/*
+ * AGFL blocks are accounted differently in the reserve pools and are not
+ * inserted into the busy extent list.
+ */
+STATIC int
+xfs_agfl_free_finish_item(
+	struct xfs_trans		*tp,
+	struct list_head		*item,
+	void				*done_item,
+	void				**state)
+{
+	struct xfs_mount		*mp = tp->t_mountp;
+	struct xfs_efd_log_item		*efdp = done_item;
+	struct xfs_extent_free_item	*free;
+	struct xfs_extent		*extp;
+	struct xfs_buf			*agbp;
+	int				error;
+	xfs_agnumber_t			agno;
+	xfs_agblock_t			agbno;
+	uint				next_extent;
+
+	free = container_of(item, struct xfs_extent_free_item, xefi_list);
+	ASSERT(free->xefi_blockcount == 1);
+	agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
+	agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
+
+	trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
+
+	error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
+	if (!error)
+		error = xfs_free_agfl_block(tp, agno, agbno, agbp,
+					    &free->xefi_oinfo);
+
+	/*
+	 * Mark the transaction dirty, even on error. This ensures the
+	 * transaction is aborted, which:
+	 *
+	 * 1.) releases the EFI and frees the EFD
+	 * 2.) shuts down the filesystem
+	 */
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
+
+	next_extent = efdp->efd_next_extent;
+	ASSERT(next_extent < efdp->efd_format.efd_nextents);
+	extp = &(efdp->efd_format.efd_extents[next_extent]);
+	extp->ext_start = free->xefi_startblock;
+	extp->ext_len = free->xefi_blockcount;
+	efdp->efd_next_extent++;
+
+	kmem_free(free);
+	return error;
+}
+
+/* sub-type with special handling for AGFL deferred frees */
+const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
+	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
+	.diff_items	= xfs_extent_free_diff_items,
+	.create_intent	= xfs_extent_free_create_intent,
+	.abort_intent	= xfs_extent_free_abort_intent,
+	.log_item	= xfs_extent_free_log_item,
+	.create_done	= xfs_extent_free_create_done,
+	.finish_item	= xfs_agfl_free_finish_item,
+	.cancel_item	= xfs_extent_free_cancel_item,
+};
+
 /*
  * Process an extent free intent item that was recovered from
  * the log.  We need to free the extents that it describes.
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 7a6ee0c2ce20..cc6549100176 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -230,14 +230,6 @@ 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);
 
-struct xfs_efd_log_item	*xfs_trans_get_efd(struct xfs_trans *,
-				  struct xfs_efi_log_item *,
-				  uint);
-int		xfs_trans_free_extent(struct xfs_trans *,
-				      struct xfs_efd_log_item *, xfs_fsblock_t,
-				      xfs_extlen_t,
-				      const struct xfs_owner_info *,
-				      bool);
 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 *);
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
deleted file mode 100644
index 20ab1c9d758f..000000000000
--- a/fs/xfs/xfs_trans_extfree.c
+++ /dev/null
@@ -1,260 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_shared.h"
-#include "xfs_format.h"
-#include "xfs_log_format.h"
-#include "xfs_trans_resv.h"
-#include "xfs_bit.h"
-#include "xfs_mount.h"
-#include "xfs_defer.h"
-#include "xfs_trans.h"
-#include "xfs_trans_priv.h"
-#include "xfs_extfree_item.h"
-#include "xfs_alloc.h"
-#include "xfs_bmap.h"
-#include "xfs_trace.h"
-
-/*
- * Free an extent and log it to the EFD. Note that the transaction is marked
- * dirty regardless of whether the extent free succeeds or fails to support the
- * EFI/EFD lifecycle rules.
- */
-int
-xfs_trans_free_extent(
-	struct xfs_trans		*tp,
-	struct xfs_efd_log_item		*efdp,
-	xfs_fsblock_t			start_block,
-	xfs_extlen_t			ext_len,
-	const struct xfs_owner_info	*oinfo,
-	bool				skip_discard)
-{
-	struct xfs_mount		*mp = tp->t_mountp;
-	struct xfs_extent		*extp;
-	uint				next_extent;
-	xfs_agnumber_t			agno = XFS_FSB_TO_AGNO(mp, start_block);
-	xfs_agblock_t			agbno = XFS_FSB_TO_AGBNO(mp,
-								start_block);
-	int				error;
-
-	trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
-
-	error = __xfs_free_extent(tp, start_block, ext_len,
-				  oinfo, XFS_AG_RESV_NONE, skip_discard);
-	/*
-	 * Mark the transaction dirty, even on error. This ensures the
-	 * transaction is aborted, which:
-	 *
-	 * 1.) releases the EFI and frees the EFD
-	 * 2.) shuts down the filesystem
-	 */
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
-
-	next_extent = efdp->efd_next_extent;
-	ASSERT(next_extent < efdp->efd_format.efd_nextents);
-	extp = &(efdp->efd_format.efd_extents[next_extent]);
-	extp->ext_start = start_block;
-	extp->ext_len = ext_len;
-	efdp->efd_next_extent++;
-
-	return error;
-}
-
-/* Sort bmap items by AG. */
-static int
-xfs_extent_free_diff_items(
-	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
-{
-	struct xfs_mount		*mp = priv;
-	struct xfs_extent_free_item	*ra;
-	struct xfs_extent_free_item	*rb;
-
-	ra = container_of(a, struct xfs_extent_free_item, xefi_list);
-	rb = container_of(b, struct xfs_extent_free_item, xefi_list);
-	return  XFS_FSB_TO_AGNO(mp, ra->xefi_startblock) -
-		XFS_FSB_TO_AGNO(mp, rb->xefi_startblock);
-}
-
-/* Get an EFI. */
-STATIC void *
-xfs_extent_free_create_intent(
-	struct xfs_trans		*tp,
-	unsigned int			count)
-{
-	struct xfs_efi_log_item		*efip;
-
-	ASSERT(tp != NULL);
-	ASSERT(count > 0);
-
-	efip = xfs_efi_init(tp->t_mountp, count);
-	ASSERT(efip != NULL);
-
-	/*
-	 * Get a log_item_desc to point at the new item.
-	 */
-	xfs_trans_add_item(tp, &efip->efi_item);
-	return efip;
-}
-
-/* Log a free extent to the intent item. */
-STATIC void
-xfs_extent_free_log_item(
-	struct xfs_trans		*tp,
-	void				*intent,
-	struct list_head		*item)
-{
-	struct xfs_efi_log_item		*efip = intent;
-	struct xfs_extent_free_item	*free;
-	uint				next_extent;
-	struct xfs_extent		*extp;
-
-	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
-
-	/*
-	 * atomic_inc_return gives us the value after the increment;
-	 * we want to use it as an array index so we need to subtract 1 from
-	 * it.
-	 */
-	next_extent = atomic_inc_return(&efip->efi_next_extent) - 1;
-	ASSERT(next_extent < efip->efi_format.efi_nextents);
-	extp = &efip->efi_format.efi_extents[next_extent];
-	extp->ext_start = free->xefi_startblock;
-	extp->ext_len = free->xefi_blockcount;
-}
-
-/* Get an EFD so we can process all the free extents. */
-STATIC void *
-xfs_extent_free_create_done(
-	struct xfs_trans		*tp,
-	void				*intent,
-	unsigned int			count)
-{
-	return xfs_trans_get_efd(tp, intent, count);
-}
-
-/* Process a free extent. */
-STATIC int
-xfs_extent_free_finish_item(
-	struct xfs_trans		*tp,
-	struct list_head		*item,
-	void				*done_item,
-	void				**state)
-{
-	struct xfs_extent_free_item	*free;
-	int				error;
-
-	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-	error = xfs_trans_free_extent(tp, done_item,
-			free->xefi_startblock,
-			free->xefi_blockcount,
-			&free->xefi_oinfo, free->xefi_skip_discard);
-	kmem_free(free);
-	return error;
-}
-
-/* Abort all pending EFIs. */
-STATIC void
-xfs_extent_free_abort_intent(
-	void				*intent)
-{
-	xfs_efi_release(intent);
-}
-
-/* Cancel a free extent. */
-STATIC void
-xfs_extent_free_cancel_item(
-	struct list_head		*item)
-{
-	struct xfs_extent_free_item	*free;
-
-	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-	kmem_free(free);
-}
-
-const struct xfs_defer_op_type xfs_extent_free_defer_type = {
-	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
-	.diff_items	= xfs_extent_free_diff_items,
-	.create_intent	= xfs_extent_free_create_intent,
-	.abort_intent	= xfs_extent_free_abort_intent,
-	.log_item	= xfs_extent_free_log_item,
-	.create_done	= xfs_extent_free_create_done,
-	.finish_item	= xfs_extent_free_finish_item,
-	.cancel_item	= xfs_extent_free_cancel_item,
-};
-
-/*
- * AGFL blocks are accounted differently in the reserve pools and are not
- * inserted into the busy extent list.
- */
-STATIC int
-xfs_agfl_free_finish_item(
-	struct xfs_trans		*tp,
-	struct list_head		*item,
-	void				*done_item,
-	void				**state)
-{
-	struct xfs_mount		*mp = tp->t_mountp;
-	struct xfs_efd_log_item		*efdp = done_item;
-	struct xfs_extent_free_item	*free;
-	struct xfs_extent		*extp;
-	struct xfs_buf			*agbp;
-	int				error;
-	xfs_agnumber_t			agno;
-	xfs_agblock_t			agbno;
-	uint				next_extent;
-
-	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-	ASSERT(free->xefi_blockcount == 1);
-	agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
-	agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
-
-	trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
-
-	error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
-	if (!error)
-		error = xfs_free_agfl_block(tp, agno, agbno, agbp,
-					    &free->xefi_oinfo);
-
-	/*
-	 * Mark the transaction dirty, even on error. This ensures the
-	 * transaction is aborted, which:
-	 *
-	 * 1.) releases the EFI and frees the EFD
-	 * 2.) shuts down the filesystem
-	 */
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
-
-	next_extent = efdp->efd_next_extent;
-	ASSERT(next_extent < efdp->efd_format.efd_nextents);
-	extp = &(efdp->efd_format.efd_extents[next_extent]);
-	extp->ext_start = free->xefi_startblock;
-	extp->ext_len = free->xefi_blockcount;
-	efdp->efd_next_extent++;
-
-	kmem_free(free);
-	return error;
-}
-
-
-/* sub-type with special handling for AGFL deferred frees */
-const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
-	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
-	.diff_items	= xfs_extent_free_diff_items,
-	.create_intent	= xfs_extent_free_create_intent,
-	.abort_intent	= xfs_extent_free_abort_intent,
-	.log_item	= xfs_extent_free_log_item,
-	.create_done	= xfs_extent_free_create_done,
-	.finish_item	= xfs_agfl_free_finish_item,
-	.cancel_item	= xfs_extent_free_cancel_item,
-};
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (16 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:14   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c Christoph Hellwig
  2019-05-17  7:31 ` [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c Christoph Hellwig
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Keep all the refcount item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/Makefile             |   1 -
 fs/xfs/xfs_refcount_item.c  | 208 ++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_trans.h          |  11 --
 fs/xfs/xfs_trans_refcount.c | 224 ------------------------------------
 4 files changed, 207 insertions(+), 237 deletions(-)
 delete mode 100644 fs/xfs/xfs_trans_refcount.c

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 771a4738abd2..26f8c51d8803 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -107,7 +107,6 @@ xfs-y				+= xfs_log.o \
 				   xfs_trans_bmap.o \
 				   xfs_trans_buf.o \
 				   xfs_trans_inode.o \
-				   xfs_trans_refcount.o \
 				   xfs_trans_rmap.o \
 
 # optional features
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 70dcdf40ac92..7bcc49ee5885 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -217,7 +217,7 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
 	.iop_release	= xfs_cud_item_release,
 };
 
-struct xfs_cud_log_item *
+static struct xfs_cud_log_item *
 xfs_trans_get_cud(
 	struct xfs_trans		*tp,
 	struct xfs_cui_log_item		*cuip)
@@ -234,6 +234,212 @@ xfs_trans_get_cud(
 	return cudp;
 }
 
+/*
+ * Finish an refcount update and log it to the CUD. Note that the
+ * transaction is marked dirty regardless of whether the refcount
+ * update succeeds or fails to support the CUI/CUD lifecycle rules.
+ */
+static int
+xfs_trans_log_finish_refcount_update(
+	struct xfs_trans		*tp,
+	struct xfs_cud_log_item		*cudp,
+	enum xfs_refcount_intent_type	type,
+	xfs_fsblock_t			startblock,
+	xfs_extlen_t			blockcount,
+	xfs_fsblock_t			*new_fsb,
+	xfs_extlen_t			*new_len,
+	struct xfs_btree_cur		**pcur)
+{
+	int				error;
+
+	error = xfs_refcount_finish_one(tp, type, startblock,
+			blockcount, new_fsb, new_len, pcur);
+
+	/*
+	 * Mark the transaction dirty, even on error. This ensures the
+	 * transaction is aborted, which:
+	 *
+	 * 1.) releases the CUI and frees the CUD
+	 * 2.) shuts down the filesystem
+	 */
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &cudp->cud_item.li_flags);
+
+	return error;
+}
+
+/* Sort refcount intents by AG. */
+static int
+xfs_refcount_update_diff_items(
+	void				*priv,
+	struct list_head		*a,
+	struct list_head		*b)
+{
+	struct xfs_mount		*mp = priv;
+	struct xfs_refcount_intent	*ra;
+	struct xfs_refcount_intent	*rb;
+
+	ra = container_of(a, struct xfs_refcount_intent, ri_list);
+	rb = container_of(b, struct xfs_refcount_intent, ri_list);
+	return  XFS_FSB_TO_AGNO(mp, ra->ri_startblock) -
+		XFS_FSB_TO_AGNO(mp, rb->ri_startblock);
+}
+
+/* Get an CUI. */
+STATIC void *
+xfs_refcount_update_create_intent(
+	struct xfs_trans		*tp,
+	unsigned int			count)
+{
+	struct xfs_cui_log_item		*cuip;
+
+	ASSERT(tp != NULL);
+	ASSERT(count > 0);
+
+	cuip = xfs_cui_init(tp->t_mountp, count);
+	ASSERT(cuip != NULL);
+
+	/*
+	 * Get a log_item_desc to point at the new item.
+	 */
+	xfs_trans_add_item(tp, &cuip->cui_item);
+	return cuip;
+}
+
+/* Set the phys extent flags for this reverse mapping. */
+static void
+xfs_trans_set_refcount_flags(
+	struct xfs_phys_extent		*refc,
+	enum xfs_refcount_intent_type	type)
+{
+	refc->pe_flags = 0;
+	switch (type) {
+	case XFS_REFCOUNT_INCREASE:
+	case XFS_REFCOUNT_DECREASE:
+	case XFS_REFCOUNT_ALLOC_COW:
+	case XFS_REFCOUNT_FREE_COW:
+		refc->pe_flags |= type;
+		break;
+	default:
+		ASSERT(0);
+	}
+}
+
+/* Log refcount updates in the intent item. */
+STATIC void
+xfs_refcount_update_log_item(
+	struct xfs_trans		*tp,
+	void				*intent,
+	struct list_head		*item)
+{
+	struct xfs_cui_log_item		*cuip = intent;
+	struct xfs_refcount_intent	*refc;
+	uint				next_extent;
+	struct xfs_phys_extent		*ext;
+
+	refc = container_of(item, struct xfs_refcount_intent, ri_list);
+
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags);
+
+	/*
+	 * atomic_inc_return gives us the value after the increment;
+	 * we want to use it as an array index so we need to subtract 1 from
+	 * it.
+	 */
+	next_extent = atomic_inc_return(&cuip->cui_next_extent) - 1;
+	ASSERT(next_extent < cuip->cui_format.cui_nextents);
+	ext = &cuip->cui_format.cui_extents[next_extent];
+	ext->pe_startblock = refc->ri_startblock;
+	ext->pe_len = refc->ri_blockcount;
+	xfs_trans_set_refcount_flags(ext, refc->ri_type);
+}
+
+/* Get an CUD so we can process all the deferred refcount updates. */
+STATIC void *
+xfs_refcount_update_create_done(
+	struct xfs_trans		*tp,
+	void				*intent,
+	unsigned int			count)
+{
+	return xfs_trans_get_cud(tp, intent);
+}
+
+/* Process a deferred refcount update. */
+STATIC int
+xfs_refcount_update_finish_item(
+	struct xfs_trans		*tp,
+	struct list_head		*item,
+	void				*done_item,
+	void				**state)
+{
+	struct xfs_refcount_intent	*refc;
+	xfs_fsblock_t			new_fsb;
+	xfs_extlen_t			new_aglen;
+	int				error;
+
+	refc = container_of(item, struct xfs_refcount_intent, ri_list);
+	error = xfs_trans_log_finish_refcount_update(tp, done_item,
+			refc->ri_type,
+			refc->ri_startblock,
+			refc->ri_blockcount,
+			&new_fsb, &new_aglen,
+			(struct xfs_btree_cur **)state);
+	/* Did we run out of reservation?  Requeue what we didn't finish. */
+	if (!error && new_aglen > 0) {
+		ASSERT(refc->ri_type == XFS_REFCOUNT_INCREASE ||
+		       refc->ri_type == XFS_REFCOUNT_DECREASE);
+		refc->ri_startblock = new_fsb;
+		refc->ri_blockcount = new_aglen;
+		return -EAGAIN;
+	}
+	kmem_free(refc);
+	return error;
+}
+
+/* Clean up after processing deferred refcounts. */
+STATIC void
+xfs_refcount_update_finish_cleanup(
+	struct xfs_trans	*tp,
+	void			*state,
+	int			error)
+{
+	struct xfs_btree_cur	*rcur = state;
+
+	xfs_refcount_finish_one_cleanup(tp, rcur, error);
+}
+
+/* Abort all pending CUIs. */
+STATIC void
+xfs_refcount_update_abort_intent(
+	void				*intent)
+{
+	xfs_cui_release(intent);
+}
+
+/* Cancel a deferred refcount update. */
+STATIC void
+xfs_refcount_update_cancel_item(
+	struct list_head		*item)
+{
+	struct xfs_refcount_intent	*refc;
+
+	refc = container_of(item, struct xfs_refcount_intent, ri_list);
+	kmem_free(refc);
+}
+
+const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
+	.max_items	= XFS_CUI_MAX_FAST_EXTENTS,
+	.diff_items	= xfs_refcount_update_diff_items,
+	.create_intent	= xfs_refcount_update_create_intent,
+	.abort_intent	= xfs_refcount_update_abort_intent,
+	.log_item	= xfs_refcount_update_log_item,
+	.create_done	= xfs_refcount_update_create_done,
+	.finish_item	= xfs_refcount_update_finish_item,
+	.finish_cleanup = xfs_refcount_update_finish_cleanup,
+	.cancel_item	= xfs_refcount_update_cancel_item,
+};
+
 /*
  * Process a refcount update intent item that was recovered from the log.
  * We need to update the refcountbt.
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index cc6549100176..1fe910d6da82 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -255,17 +255,6 @@ int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
 		xfs_fsblock_t startblock, xfs_filblks_t blockcount,
 		xfs_exntst_t state, struct xfs_btree_cur **pcur);
 
-/* refcount updates */
-enum xfs_refcount_intent_type;
-
-struct xfs_cud_log_item *xfs_trans_get_cud(struct xfs_trans *tp,
-		struct xfs_cui_log_item *cuip);
-int xfs_trans_log_finish_refcount_update(struct xfs_trans *tp,
-		struct xfs_cud_log_item *cudp,
-		enum xfs_refcount_intent_type type, xfs_fsblock_t startblock,
-		xfs_extlen_t blockcount, xfs_fsblock_t *new_fsb,
-		xfs_extlen_t *new_len, struct xfs_btree_cur **pcur);
-
 /* mapping updates */
 enum xfs_bmap_intent_type;
 
diff --git a/fs/xfs/xfs_trans_refcount.c b/fs/xfs/xfs_trans_refcount.c
deleted file mode 100644
index d793fb500378..000000000000
--- a/fs/xfs/xfs_trans_refcount.c
+++ /dev/null
@@ -1,224 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Oracle.  All Rights Reserved.
- * Author: Darrick J. Wong <darrick.wong@oracle.com>
- */
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_shared.h"
-#include "xfs_format.h"
-#include "xfs_log_format.h"
-#include "xfs_trans_resv.h"
-#include "xfs_mount.h"
-#include "xfs_defer.h"
-#include "xfs_trans.h"
-#include "xfs_trans_priv.h"
-#include "xfs_refcount_item.h"
-#include "xfs_alloc.h"
-#include "xfs_refcount.h"
-
-/*
- * Finish an refcount update and log it to the CUD. Note that the
- * transaction is marked dirty regardless of whether the refcount
- * update succeeds or fails to support the CUI/CUD lifecycle rules.
- */
-int
-xfs_trans_log_finish_refcount_update(
-	struct xfs_trans		*tp,
-	struct xfs_cud_log_item		*cudp,
-	enum xfs_refcount_intent_type	type,
-	xfs_fsblock_t			startblock,
-	xfs_extlen_t			blockcount,
-	xfs_fsblock_t			*new_fsb,
-	xfs_extlen_t			*new_len,
-	struct xfs_btree_cur		**pcur)
-{
-	int				error;
-
-	error = xfs_refcount_finish_one(tp, type, startblock,
-			blockcount, new_fsb, new_len, pcur);
-
-	/*
-	 * Mark the transaction dirty, even on error. This ensures the
-	 * transaction is aborted, which:
-	 *
-	 * 1.) releases the CUI and frees the CUD
-	 * 2.) shuts down the filesystem
-	 */
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &cudp->cud_item.li_flags);
-
-	return error;
-}
-
-/* Sort refcount intents by AG. */
-static int
-xfs_refcount_update_diff_items(
-	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
-{
-	struct xfs_mount		*mp = priv;
-	struct xfs_refcount_intent	*ra;
-	struct xfs_refcount_intent	*rb;
-
-	ra = container_of(a, struct xfs_refcount_intent, ri_list);
-	rb = container_of(b, struct xfs_refcount_intent, ri_list);
-	return  XFS_FSB_TO_AGNO(mp, ra->ri_startblock) -
-		XFS_FSB_TO_AGNO(mp, rb->ri_startblock);
-}
-
-/* Get an CUI. */
-STATIC void *
-xfs_refcount_update_create_intent(
-	struct xfs_trans		*tp,
-	unsigned int			count)
-{
-	struct xfs_cui_log_item		*cuip;
-
-	ASSERT(tp != NULL);
-	ASSERT(count > 0);
-
-	cuip = xfs_cui_init(tp->t_mountp, count);
-	ASSERT(cuip != NULL);
-
-	/*
-	 * Get a log_item_desc to point at the new item.
-	 */
-	xfs_trans_add_item(tp, &cuip->cui_item);
-	return cuip;
-}
-
-/* Set the phys extent flags for this reverse mapping. */
-static void
-xfs_trans_set_refcount_flags(
-	struct xfs_phys_extent		*refc,
-	enum xfs_refcount_intent_type	type)
-{
-	refc->pe_flags = 0;
-	switch (type) {
-	case XFS_REFCOUNT_INCREASE:
-	case XFS_REFCOUNT_DECREASE:
-	case XFS_REFCOUNT_ALLOC_COW:
-	case XFS_REFCOUNT_FREE_COW:
-		refc->pe_flags |= type;
-		break;
-	default:
-		ASSERT(0);
-	}
-}
-
-/* Log refcount updates in the intent item. */
-STATIC void
-xfs_refcount_update_log_item(
-	struct xfs_trans		*tp,
-	void				*intent,
-	struct list_head		*item)
-{
-	struct xfs_cui_log_item		*cuip = intent;
-	struct xfs_refcount_intent	*refc;
-	uint				next_extent;
-	struct xfs_phys_extent		*ext;
-
-	refc = container_of(item, struct xfs_refcount_intent, ri_list);
-
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags);
-
-	/*
-	 * atomic_inc_return gives us the value after the increment;
-	 * we want to use it as an array index so we need to subtract 1 from
-	 * it.
-	 */
-	next_extent = atomic_inc_return(&cuip->cui_next_extent) - 1;
-	ASSERT(next_extent < cuip->cui_format.cui_nextents);
-	ext = &cuip->cui_format.cui_extents[next_extent];
-	ext->pe_startblock = refc->ri_startblock;
-	ext->pe_len = refc->ri_blockcount;
-	xfs_trans_set_refcount_flags(ext, refc->ri_type);
-}
-
-/* Get an CUD so we can process all the deferred refcount updates. */
-STATIC void *
-xfs_refcount_update_create_done(
-	struct xfs_trans		*tp,
-	void				*intent,
-	unsigned int			count)
-{
-	return xfs_trans_get_cud(tp, intent);
-}
-
-/* Process a deferred refcount update. */
-STATIC int
-xfs_refcount_update_finish_item(
-	struct xfs_trans		*tp,
-	struct list_head		*item,
-	void				*done_item,
-	void				**state)
-{
-	struct xfs_refcount_intent	*refc;
-	xfs_fsblock_t			new_fsb;
-	xfs_extlen_t			new_aglen;
-	int				error;
-
-	refc = container_of(item, struct xfs_refcount_intent, ri_list);
-	error = xfs_trans_log_finish_refcount_update(tp, done_item,
-			refc->ri_type,
-			refc->ri_startblock,
-			refc->ri_blockcount,
-			&new_fsb, &new_aglen,
-			(struct xfs_btree_cur **)state);
-	/* Did we run out of reservation?  Requeue what we didn't finish. */
-	if (!error && new_aglen > 0) {
-		ASSERT(refc->ri_type == XFS_REFCOUNT_INCREASE ||
-		       refc->ri_type == XFS_REFCOUNT_DECREASE);
-		refc->ri_startblock = new_fsb;
-		refc->ri_blockcount = new_aglen;
-		return -EAGAIN;
-	}
-	kmem_free(refc);
-	return error;
-}
-
-/* Clean up after processing deferred refcounts. */
-STATIC void
-xfs_refcount_update_finish_cleanup(
-	struct xfs_trans	*tp,
-	void			*state,
-	int			error)
-{
-	struct xfs_btree_cur	*rcur = state;
-
-	xfs_refcount_finish_one_cleanup(tp, rcur, error);
-}
-
-/* Abort all pending CUIs. */
-STATIC void
-xfs_refcount_update_abort_intent(
-	void				*intent)
-{
-	xfs_cui_release(intent);
-}
-
-/* Cancel a deferred refcount update. */
-STATIC void
-xfs_refcount_update_cancel_item(
-	struct list_head		*item)
-{
-	struct xfs_refcount_intent	*refc;
-
-	refc = container_of(item, struct xfs_refcount_intent, ri_list);
-	kmem_free(refc);
-}
-
-const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
-	.max_items	= XFS_CUI_MAX_FAST_EXTENTS,
-	.diff_items	= xfs_refcount_update_diff_items,
-	.create_intent	= xfs_refcount_update_create_intent,
-	.abort_intent	= xfs_refcount_update_abort_intent,
-	.log_item	= xfs_refcount_update_log_item,
-	.create_done	= xfs_refcount_update_create_done,
-	.finish_item	= xfs_refcount_update_finish_item,
-	.finish_cleanup = xfs_refcount_update_finish_cleanup,
-	.cancel_item	= xfs_refcount_update_cancel_item,
-};
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (17 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:14   ` Brian Foster
  2019-05-17  7:31 ` [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c Christoph Hellwig
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Keep all rmap item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/Makefile         |   3 +-
 fs/xfs/xfs_rmap_item.c  | 229 ++++++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_trans.h      |  11 --
 fs/xfs/xfs_trans_rmap.c | 245 ----------------------------------------
 4 files changed, 229 insertions(+), 259 deletions(-)
 delete mode 100644 fs/xfs/xfs_trans_rmap.c

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 26f8c51d8803..1730664770c5 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -106,8 +106,7 @@ xfs-y				+= xfs_log.o \
 				   xfs_trans_ail.o \
 				   xfs_trans_bmap.o \
 				   xfs_trans_buf.o \
-				   xfs_trans_inode.o \
-				   xfs_trans_rmap.o \
+				   xfs_trans_inode.o
 
 # optional features
 xfs-$(CONFIG_XFS_QUOTA)		+= xfs_dquot.o \
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 5f11e6d43484..6da664ae97e2 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -238,7 +238,7 @@ static const struct xfs_item_ops xfs_rud_item_ops = {
 	.iop_release	= xfs_rud_item_release,
 };
 
-struct xfs_rud_log_item *
+static struct xfs_rud_log_item *
 xfs_trans_get_rud(
 	struct xfs_trans		*tp,
 	struct xfs_rui_log_item		*ruip)
@@ -255,6 +255,233 @@ xfs_trans_get_rud(
 	return rudp;
 }
 
+/* Set the map extent flags for this reverse mapping. */
+static void
+xfs_trans_set_rmap_flags(
+	struct xfs_map_extent		*rmap,
+	enum xfs_rmap_intent_type	type,
+	int				whichfork,
+	xfs_exntst_t			state)
+{
+	rmap->me_flags = 0;
+	if (state == XFS_EXT_UNWRITTEN)
+		rmap->me_flags |= XFS_RMAP_EXTENT_UNWRITTEN;
+	if (whichfork == XFS_ATTR_FORK)
+		rmap->me_flags |= XFS_RMAP_EXTENT_ATTR_FORK;
+	switch (type) {
+	case XFS_RMAP_MAP:
+		rmap->me_flags |= XFS_RMAP_EXTENT_MAP;
+		break;
+	case XFS_RMAP_MAP_SHARED:
+		rmap->me_flags |= XFS_RMAP_EXTENT_MAP_SHARED;
+		break;
+	case XFS_RMAP_UNMAP:
+		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP;
+		break;
+	case XFS_RMAP_UNMAP_SHARED:
+		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP_SHARED;
+		break;
+	case XFS_RMAP_CONVERT:
+		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT;
+		break;
+	case XFS_RMAP_CONVERT_SHARED:
+		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT_SHARED;
+		break;
+	case XFS_RMAP_ALLOC:
+		rmap->me_flags |= XFS_RMAP_EXTENT_ALLOC;
+		break;
+	case XFS_RMAP_FREE:
+		rmap->me_flags |= XFS_RMAP_EXTENT_FREE;
+		break;
+	default:
+		ASSERT(0);
+	}
+}
+
+/*
+ * Finish an rmap update and log it to the RUD. Note that the transaction is
+ * marked dirty regardless of whether the rmap update succeeds or fails to
+ * support the RUI/RUD lifecycle rules.
+ */
+static int
+xfs_trans_log_finish_rmap_update(
+	struct xfs_trans		*tp,
+	struct xfs_rud_log_item		*rudp,
+	enum xfs_rmap_intent_type	type,
+	uint64_t			owner,
+	int				whichfork,
+	xfs_fileoff_t			startoff,
+	xfs_fsblock_t			startblock,
+	xfs_filblks_t			blockcount,
+	xfs_exntst_t			state,
+	struct xfs_btree_cur		**pcur)
+{
+	int				error;
+
+	error = xfs_rmap_finish_one(tp, type, owner, whichfork, startoff,
+			startblock, blockcount, state, pcur);
+
+	/*
+	 * Mark the transaction dirty, even on error. This ensures the
+	 * transaction is aborted, which:
+	 *
+	 * 1.) releases the RUI and frees the RUD
+	 * 2.) shuts down the filesystem
+	 */
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &rudp->rud_item.li_flags);
+
+	return error;
+}
+
+/* Sort rmap intents by AG. */
+static int
+xfs_rmap_update_diff_items(
+	void				*priv,
+	struct list_head		*a,
+	struct list_head		*b)
+{
+	struct xfs_mount		*mp = priv;
+	struct xfs_rmap_intent		*ra;
+	struct xfs_rmap_intent		*rb;
+
+	ra = container_of(a, struct xfs_rmap_intent, ri_list);
+	rb = container_of(b, struct xfs_rmap_intent, ri_list);
+	return  XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
+		XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
+}
+
+/* Get an RUI. */
+STATIC void *
+xfs_rmap_update_create_intent(
+	struct xfs_trans		*tp,
+	unsigned int			count)
+{
+	struct xfs_rui_log_item		*ruip;
+
+	ASSERT(tp != NULL);
+	ASSERT(count > 0);
+
+	ruip = xfs_rui_init(tp->t_mountp, count);
+	ASSERT(ruip != NULL);
+
+	/*
+	 * Get a log_item_desc to point at the new item.
+	 */
+	xfs_trans_add_item(tp, &ruip->rui_item);
+	return ruip;
+}
+
+/* Log rmap updates in the intent item. */
+STATIC void
+xfs_rmap_update_log_item(
+	struct xfs_trans		*tp,
+	void				*intent,
+	struct list_head		*item)
+{
+	struct xfs_rui_log_item		*ruip = intent;
+	struct xfs_rmap_intent		*rmap;
+	uint				next_extent;
+	struct xfs_map_extent		*map;
+
+	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags);
+
+	/*
+	 * atomic_inc_return gives us the value after the increment;
+	 * we want to use it as an array index so we need to subtract 1 from
+	 * it.
+	 */
+	next_extent = atomic_inc_return(&ruip->rui_next_extent) - 1;
+	ASSERT(next_extent < ruip->rui_format.rui_nextents);
+	map = &ruip->rui_format.rui_extents[next_extent];
+	map->me_owner = rmap->ri_owner;
+	map->me_startblock = rmap->ri_bmap.br_startblock;
+	map->me_startoff = rmap->ri_bmap.br_startoff;
+	map->me_len = rmap->ri_bmap.br_blockcount;
+	xfs_trans_set_rmap_flags(map, rmap->ri_type, rmap->ri_whichfork,
+			rmap->ri_bmap.br_state);
+}
+
+/* Get an RUD so we can process all the deferred rmap updates. */
+STATIC void *
+xfs_rmap_update_create_done(
+	struct xfs_trans		*tp,
+	void				*intent,
+	unsigned int			count)
+{
+	return xfs_trans_get_rud(tp, intent);
+}
+
+/* Process a deferred rmap update. */
+STATIC int
+xfs_rmap_update_finish_item(
+	struct xfs_trans		*tp,
+	struct list_head		*item,
+	void				*done_item,
+	void				**state)
+{
+	struct xfs_rmap_intent		*rmap;
+	int				error;
+
+	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+	error = xfs_trans_log_finish_rmap_update(tp, done_item,
+			rmap->ri_type,
+			rmap->ri_owner, rmap->ri_whichfork,
+			rmap->ri_bmap.br_startoff,
+			rmap->ri_bmap.br_startblock,
+			rmap->ri_bmap.br_blockcount,
+			rmap->ri_bmap.br_state,
+			(struct xfs_btree_cur **)state);
+	kmem_free(rmap);
+	return error;
+}
+
+/* Clean up after processing deferred rmaps. */
+STATIC void
+xfs_rmap_update_finish_cleanup(
+	struct xfs_trans	*tp,
+	void			*state,
+	int			error)
+{
+	struct xfs_btree_cur	*rcur = state;
+
+	xfs_rmap_finish_one_cleanup(tp, rcur, error);
+}
+
+/* Abort all pending RUIs. */
+STATIC void
+xfs_rmap_update_abort_intent(
+	void				*intent)
+{
+	xfs_rui_release(intent);
+}
+
+/* Cancel a deferred rmap update. */
+STATIC void
+xfs_rmap_update_cancel_item(
+	struct list_head		*item)
+{
+	struct xfs_rmap_intent		*rmap;
+
+	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
+	kmem_free(rmap);
+}
+
+const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
+	.max_items	= XFS_RUI_MAX_FAST_EXTENTS,
+	.diff_items	= xfs_rmap_update_diff_items,
+	.create_intent	= xfs_rmap_update_create_intent,
+	.abort_intent	= xfs_rmap_update_abort_intent,
+	.log_item	= xfs_rmap_update_log_item,
+	.create_done	= xfs_rmap_update_create_done,
+	.finish_item	= xfs_rmap_update_finish_item,
+	.finish_cleanup = xfs_rmap_update_finish_cleanup,
+	.cancel_item	= xfs_rmap_update_cancel_item,
+};
+
 /*
  * Process an rmap update intent item that was recovered from the log.
  * We need to update the rmapbt.
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 1fe910d6da82..bb411d8c41cf 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -244,17 +244,6 @@ void		xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
 
 extern kmem_zone_t	*xfs_trans_zone;
 
-/* rmap updates */
-enum xfs_rmap_intent_type;
-
-struct xfs_rud_log_item *xfs_trans_get_rud(struct xfs_trans *tp,
-		struct xfs_rui_log_item *ruip);
-int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
-		struct xfs_rud_log_item *rudp, enum xfs_rmap_intent_type type,
-		uint64_t owner, int whichfork, xfs_fileoff_t startoff,
-		xfs_fsblock_t startblock, xfs_filblks_t blockcount,
-		xfs_exntst_t state, struct xfs_btree_cur **pcur);
-
 /* mapping updates */
 enum xfs_bmap_intent_type;
 
diff --git a/fs/xfs/xfs_trans_rmap.c b/fs/xfs/xfs_trans_rmap.c
deleted file mode 100644
index 863e3281daaa..000000000000
--- a/fs/xfs/xfs_trans_rmap.c
+++ /dev/null
@@ -1,245 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Oracle.  All Rights Reserved.
- * Author: Darrick J. Wong <darrick.wong@oracle.com>
- */
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_shared.h"
-#include "xfs_format.h"
-#include "xfs_log_format.h"
-#include "xfs_trans_resv.h"
-#include "xfs_mount.h"
-#include "xfs_defer.h"
-#include "xfs_trans.h"
-#include "xfs_trans_priv.h"
-#include "xfs_rmap_item.h"
-#include "xfs_alloc.h"
-#include "xfs_rmap.h"
-
-/* Set the map extent flags for this reverse mapping. */
-static void
-xfs_trans_set_rmap_flags(
-	struct xfs_map_extent		*rmap,
-	enum xfs_rmap_intent_type	type,
-	int				whichfork,
-	xfs_exntst_t			state)
-{
-	rmap->me_flags = 0;
-	if (state == XFS_EXT_UNWRITTEN)
-		rmap->me_flags |= XFS_RMAP_EXTENT_UNWRITTEN;
-	if (whichfork == XFS_ATTR_FORK)
-		rmap->me_flags |= XFS_RMAP_EXTENT_ATTR_FORK;
-	switch (type) {
-	case XFS_RMAP_MAP:
-		rmap->me_flags |= XFS_RMAP_EXTENT_MAP;
-		break;
-	case XFS_RMAP_MAP_SHARED:
-		rmap->me_flags |= XFS_RMAP_EXTENT_MAP_SHARED;
-		break;
-	case XFS_RMAP_UNMAP:
-		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP;
-		break;
-	case XFS_RMAP_UNMAP_SHARED:
-		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP_SHARED;
-		break;
-	case XFS_RMAP_CONVERT:
-		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT;
-		break;
-	case XFS_RMAP_CONVERT_SHARED:
-		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT_SHARED;
-		break;
-	case XFS_RMAP_ALLOC:
-		rmap->me_flags |= XFS_RMAP_EXTENT_ALLOC;
-		break;
-	case XFS_RMAP_FREE:
-		rmap->me_flags |= XFS_RMAP_EXTENT_FREE;
-		break;
-	default:
-		ASSERT(0);
-	}
-}
-
-/*
- * Finish an rmap update and log it to the RUD. Note that the transaction is
- * marked dirty regardless of whether the rmap update succeeds or fails to
- * support the RUI/RUD lifecycle rules.
- */
-int
-xfs_trans_log_finish_rmap_update(
-	struct xfs_trans		*tp,
-	struct xfs_rud_log_item		*rudp,
-	enum xfs_rmap_intent_type	type,
-	uint64_t			owner,
-	int				whichfork,
-	xfs_fileoff_t			startoff,
-	xfs_fsblock_t			startblock,
-	xfs_filblks_t			blockcount,
-	xfs_exntst_t			state,
-	struct xfs_btree_cur		**pcur)
-{
-	int				error;
-
-	error = xfs_rmap_finish_one(tp, type, owner, whichfork, startoff,
-			startblock, blockcount, state, pcur);
-
-	/*
-	 * Mark the transaction dirty, even on error. This ensures the
-	 * transaction is aborted, which:
-	 *
-	 * 1.) releases the RUI and frees the RUD
-	 * 2.) shuts down the filesystem
-	 */
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &rudp->rud_item.li_flags);
-
-	return error;
-}
-
-/* Sort rmap intents by AG. */
-static int
-xfs_rmap_update_diff_items(
-	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
-{
-	struct xfs_mount		*mp = priv;
-	struct xfs_rmap_intent		*ra;
-	struct xfs_rmap_intent		*rb;
-
-	ra = container_of(a, struct xfs_rmap_intent, ri_list);
-	rb = container_of(b, struct xfs_rmap_intent, ri_list);
-	return  XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
-		XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
-}
-
-/* Get an RUI. */
-STATIC void *
-xfs_rmap_update_create_intent(
-	struct xfs_trans		*tp,
-	unsigned int			count)
-{
-	struct xfs_rui_log_item		*ruip;
-
-	ASSERT(tp != NULL);
-	ASSERT(count > 0);
-
-	ruip = xfs_rui_init(tp->t_mountp, count);
-	ASSERT(ruip != NULL);
-
-	/*
-	 * Get a log_item_desc to point at the new item.
-	 */
-	xfs_trans_add_item(tp, &ruip->rui_item);
-	return ruip;
-}
-
-/* Log rmap updates in the intent item. */
-STATIC void
-xfs_rmap_update_log_item(
-	struct xfs_trans		*tp,
-	void				*intent,
-	struct list_head		*item)
-{
-	struct xfs_rui_log_item		*ruip = intent;
-	struct xfs_rmap_intent		*rmap;
-	uint				next_extent;
-	struct xfs_map_extent		*map;
-
-	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
-
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags);
-
-	/*
-	 * atomic_inc_return gives us the value after the increment;
-	 * we want to use it as an array index so we need to subtract 1 from
-	 * it.
-	 */
-	next_extent = atomic_inc_return(&ruip->rui_next_extent) - 1;
-	ASSERT(next_extent < ruip->rui_format.rui_nextents);
-	map = &ruip->rui_format.rui_extents[next_extent];
-	map->me_owner = rmap->ri_owner;
-	map->me_startblock = rmap->ri_bmap.br_startblock;
-	map->me_startoff = rmap->ri_bmap.br_startoff;
-	map->me_len = rmap->ri_bmap.br_blockcount;
-	xfs_trans_set_rmap_flags(map, rmap->ri_type, rmap->ri_whichfork,
-			rmap->ri_bmap.br_state);
-}
-
-/* Get an RUD so we can process all the deferred rmap updates. */
-STATIC void *
-xfs_rmap_update_create_done(
-	struct xfs_trans		*tp,
-	void				*intent,
-	unsigned int			count)
-{
-	return xfs_trans_get_rud(tp, intent);
-}
-
-/* Process a deferred rmap update. */
-STATIC int
-xfs_rmap_update_finish_item(
-	struct xfs_trans		*tp,
-	struct list_head		*item,
-	void				*done_item,
-	void				**state)
-{
-	struct xfs_rmap_intent		*rmap;
-	int				error;
-
-	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
-	error = xfs_trans_log_finish_rmap_update(tp, done_item,
-			rmap->ri_type,
-			rmap->ri_owner, rmap->ri_whichfork,
-			rmap->ri_bmap.br_startoff,
-			rmap->ri_bmap.br_startblock,
-			rmap->ri_bmap.br_blockcount,
-			rmap->ri_bmap.br_state,
-			(struct xfs_btree_cur **)state);
-	kmem_free(rmap);
-	return error;
-}
-
-/* Clean up after processing deferred rmaps. */
-STATIC void
-xfs_rmap_update_finish_cleanup(
-	struct xfs_trans	*tp,
-	void			*state,
-	int			error)
-{
-	struct xfs_btree_cur	*rcur = state;
-
-	xfs_rmap_finish_one_cleanup(tp, rcur, error);
-}
-
-/* Abort all pending RUIs. */
-STATIC void
-xfs_rmap_update_abort_intent(
-	void				*intent)
-{
-	xfs_rui_release(intent);
-}
-
-/* Cancel a deferred rmap update. */
-STATIC void
-xfs_rmap_update_cancel_item(
-	struct list_head		*item)
-{
-	struct xfs_rmap_intent		*rmap;
-
-	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
-	kmem_free(rmap);
-}
-
-const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
-	.max_items	= XFS_RUI_MAX_FAST_EXTENTS,
-	.diff_items	= xfs_rmap_update_diff_items,
-	.create_intent	= xfs_rmap_update_create_intent,
-	.abort_intent	= xfs_rmap_update_abort_intent,
-	.log_item	= xfs_rmap_update_log_item,
-	.create_done	= xfs_rmap_update_create_done,
-	.finish_item	= xfs_rmap_update_finish_item,
-	.finish_cleanup = xfs_rmap_update_finish_cleanup,
-	.cancel_item	= xfs_rmap_update_cancel_item,
-};
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c
  2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
                   ` (18 preceding siblings ...)
  2019-05-17  7:31 ` [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c Christoph Hellwig
@ 2019-05-17  7:31 ` Christoph Hellwig
  2019-05-20 13:14   ` Brian Foster
  19 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  7:31 UTC (permalink / raw)
  To: linux-xfs

Keep all bmap item related code together.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/Makefile         |   1 -
 fs/xfs/xfs_bmap_item.c  | 200 ++++++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_trans.h      |  11 --
 fs/xfs/xfs_trans_bmap.c | 216 ----------------------------------------
 4 files changed, 199 insertions(+), 229 deletions(-)
 delete mode 100644 fs/xfs/xfs_trans_bmap.c

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 1730664770c5..9161af54a87c 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -104,7 +104,6 @@ xfs-y				+= xfs_log.o \
 				   xfs_rmap_item.o \
 				   xfs_log_recover.o \
 				   xfs_trans_ail.o \
-				   xfs_trans_bmap.o \
 				   xfs_trans_buf.o \
 				   xfs_trans_inode.o
 
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 40385c8b752a..ce5cf8aea3a4 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -6,6 +6,7 @@
 #include "xfs.h"
 #include "xfs_fs.h"
 #include "xfs_format.h"
+#include "xfs_shared.h"
 #include "xfs_log_format.h"
 #include "xfs_trans_resv.h"
 #include "xfs_bit.h"
@@ -212,7 +213,7 @@ static const struct xfs_item_ops xfs_bud_item_ops = {
 	.iop_release	= xfs_bud_item_release,
 };
 
-struct xfs_bud_log_item *
+static struct xfs_bud_log_item *
 xfs_trans_get_bud(
 	struct xfs_trans		*tp,
 	struct xfs_bui_log_item		*buip)
@@ -229,6 +230,203 @@ xfs_trans_get_bud(
 	return budp;
 }
 
+/*
+ * Finish an bmap update and log it to the BUD. Note that the
+ * transaction is marked dirty regardless of whether the bmap update
+ * succeeds or fails to support the BUI/BUD lifecycle rules.
+ */
+static int
+xfs_trans_log_finish_bmap_update(
+	struct xfs_trans		*tp,
+	struct xfs_bud_log_item		*budp,
+	enum xfs_bmap_intent_type	type,
+	struct xfs_inode		*ip,
+	int				whichfork,
+	xfs_fileoff_t			startoff,
+	xfs_fsblock_t			startblock,
+	xfs_filblks_t			*blockcount,
+	xfs_exntst_t			state)
+{
+	int				error;
+
+	error = xfs_bmap_finish_one(tp, ip, type, whichfork, startoff,
+			startblock, blockcount, state);
+
+	/*
+	 * Mark the transaction dirty, even on error. This ensures the
+	 * transaction is aborted, which:
+	 *
+	 * 1.) releases the BUI and frees the BUD
+	 * 2.) shuts down the filesystem
+	 */
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &budp->bud_item.li_flags);
+
+	return error;
+}
+
+/* Sort bmap intents by inode. */
+static int
+xfs_bmap_update_diff_items(
+	void				*priv,
+	struct list_head		*a,
+	struct list_head		*b)
+{
+	struct xfs_bmap_intent		*ba;
+	struct xfs_bmap_intent		*bb;
+
+	ba = container_of(a, struct xfs_bmap_intent, bi_list);
+	bb = container_of(b, struct xfs_bmap_intent, bi_list);
+	return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
+}
+
+/* Get an BUI. */
+STATIC void *
+xfs_bmap_update_create_intent(
+	struct xfs_trans		*tp,
+	unsigned int			count)
+{
+	struct xfs_bui_log_item		*buip;
+
+	ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS);
+	ASSERT(tp != NULL);
+
+	buip = xfs_bui_init(tp->t_mountp);
+	ASSERT(buip != NULL);
+
+	/*
+	 * Get a log_item_desc to point at the new item.
+	 */
+	xfs_trans_add_item(tp, &buip->bui_item);
+	return buip;
+}
+
+/* Set the map extent flags for this mapping. */
+static void
+xfs_trans_set_bmap_flags(
+	struct xfs_map_extent		*bmap,
+	enum xfs_bmap_intent_type	type,
+	int				whichfork,
+	xfs_exntst_t			state)
+{
+	bmap->me_flags = 0;
+	switch (type) {
+	case XFS_BMAP_MAP:
+	case XFS_BMAP_UNMAP:
+		bmap->me_flags = type;
+		break;
+	default:
+		ASSERT(0);
+	}
+	if (state == XFS_EXT_UNWRITTEN)
+		bmap->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
+	if (whichfork == XFS_ATTR_FORK)
+		bmap->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
+}
+
+/* Log bmap updates in the intent item. */
+STATIC void
+xfs_bmap_update_log_item(
+	struct xfs_trans		*tp,
+	void				*intent,
+	struct list_head		*item)
+{
+	struct xfs_bui_log_item		*buip = intent;
+	struct xfs_bmap_intent		*bmap;
+	uint				next_extent;
+	struct xfs_map_extent		*map;
+
+	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+
+	tp->t_flags |= XFS_TRANS_DIRTY;
+	set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags);
+
+	/*
+	 * atomic_inc_return gives us the value after the increment;
+	 * we want to use it as an array index so we need to subtract 1 from
+	 * it.
+	 */
+	next_extent = atomic_inc_return(&buip->bui_next_extent) - 1;
+	ASSERT(next_extent < buip->bui_format.bui_nextents);
+	map = &buip->bui_format.bui_extents[next_extent];
+	map->me_owner = bmap->bi_owner->i_ino;
+	map->me_startblock = bmap->bi_bmap.br_startblock;
+	map->me_startoff = bmap->bi_bmap.br_startoff;
+	map->me_len = bmap->bi_bmap.br_blockcount;
+	xfs_trans_set_bmap_flags(map, bmap->bi_type, bmap->bi_whichfork,
+			bmap->bi_bmap.br_state);
+}
+
+/* Get an BUD so we can process all the deferred rmap updates. */
+STATIC void *
+xfs_bmap_update_create_done(
+	struct xfs_trans		*tp,
+	void				*intent,
+	unsigned int			count)
+{
+	return xfs_trans_get_bud(tp, intent);
+}
+
+/* Process a deferred rmap update. */
+STATIC int
+xfs_bmap_update_finish_item(
+	struct xfs_trans		*tp,
+	struct list_head		*item,
+	void				*done_item,
+	void				**state)
+{
+	struct xfs_bmap_intent		*bmap;
+	xfs_filblks_t			count;
+	int				error;
+
+	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+	count = bmap->bi_bmap.br_blockcount;
+	error = xfs_trans_log_finish_bmap_update(tp, done_item,
+			bmap->bi_type,
+			bmap->bi_owner, bmap->bi_whichfork,
+			bmap->bi_bmap.br_startoff,
+			bmap->bi_bmap.br_startblock,
+			&count,
+			bmap->bi_bmap.br_state);
+	if (!error && count > 0) {
+		ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
+		bmap->bi_bmap.br_blockcount = count;
+		return -EAGAIN;
+	}
+	kmem_free(bmap);
+	return error;
+}
+
+/* Abort all pending BUIs. */
+STATIC void
+xfs_bmap_update_abort_intent(
+	void				*intent)
+{
+	xfs_bui_release(intent);
+}
+
+/* Cancel a deferred rmap update. */
+STATIC void
+xfs_bmap_update_cancel_item(
+	struct list_head		*item)
+{
+	struct xfs_bmap_intent		*bmap;
+
+	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
+	kmem_free(bmap);
+}
+
+const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
+	.max_items	= XFS_BUI_MAX_FAST_EXTENTS,
+	.diff_items	= xfs_bmap_update_diff_items,
+	.create_intent	= xfs_bmap_update_create_intent,
+	.abort_intent	= xfs_bmap_update_abort_intent,
+	.log_item	= xfs_bmap_update_log_item,
+	.create_done	= xfs_bmap_update_create_done,
+	.finish_item	= xfs_bmap_update_finish_item,
+	.cancel_item	= xfs_bmap_update_cancel_item,
+};
+
 /*
  * Process a bmap update intent item that was recovered from the log.
  * We need to update some inode's bmbt.
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index bb411d8c41cf..d3dcabc27b97 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -244,15 +244,4 @@ void		xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
 
 extern kmem_zone_t	*xfs_trans_zone;
 
-/* mapping updates */
-enum xfs_bmap_intent_type;
-
-struct xfs_bud_log_item *xfs_trans_get_bud(struct xfs_trans *tp,
-		struct xfs_bui_log_item *buip);
-int xfs_trans_log_finish_bmap_update(struct xfs_trans *tp,
-		struct xfs_bud_log_item *rudp, enum xfs_bmap_intent_type type,
-		struct xfs_inode *ip, int whichfork, xfs_fileoff_t startoff,
-		xfs_fsblock_t startblock, xfs_filblks_t *blockcount,
-		xfs_exntst_t state);
-
 #endif	/* __XFS_TRANS_H__ */
diff --git a/fs/xfs/xfs_trans_bmap.c b/fs/xfs/xfs_trans_bmap.c
deleted file mode 100644
index c6f5b217d17c..000000000000
--- a/fs/xfs/xfs_trans_bmap.c
+++ /dev/null
@@ -1,216 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Oracle.  All Rights Reserved.
- * Author: Darrick J. Wong <darrick.wong@oracle.com>
- */
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_shared.h"
-#include "xfs_format.h"
-#include "xfs_log_format.h"
-#include "xfs_trans_resv.h"
-#include "xfs_mount.h"
-#include "xfs_defer.h"
-#include "xfs_trans.h"
-#include "xfs_trans_priv.h"
-#include "xfs_bmap_item.h"
-#include "xfs_alloc.h"
-#include "xfs_bmap.h"
-#include "xfs_inode.h"
-
-/*
- * Finish an bmap update and log it to the BUD. Note that the
- * transaction is marked dirty regardless of whether the bmap update
- * succeeds or fails to support the BUI/BUD lifecycle rules.
- */
-int
-xfs_trans_log_finish_bmap_update(
-	struct xfs_trans		*tp,
-	struct xfs_bud_log_item		*budp,
-	enum xfs_bmap_intent_type	type,
-	struct xfs_inode		*ip,
-	int				whichfork,
-	xfs_fileoff_t			startoff,
-	xfs_fsblock_t			startblock,
-	xfs_filblks_t			*blockcount,
-	xfs_exntst_t			state)
-{
-	int				error;
-
-	error = xfs_bmap_finish_one(tp, ip, type, whichfork, startoff,
-			startblock, blockcount, state);
-
-	/*
-	 * Mark the transaction dirty, even on error. This ensures the
-	 * transaction is aborted, which:
-	 *
-	 * 1.) releases the BUI and frees the BUD
-	 * 2.) shuts down the filesystem
-	 */
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &budp->bud_item.li_flags);
-
-	return error;
-}
-
-/* Sort bmap intents by inode. */
-static int
-xfs_bmap_update_diff_items(
-	void				*priv,
-	struct list_head		*a,
-	struct list_head		*b)
-{
-	struct xfs_bmap_intent		*ba;
-	struct xfs_bmap_intent		*bb;
-
-	ba = container_of(a, struct xfs_bmap_intent, bi_list);
-	bb = container_of(b, struct xfs_bmap_intent, bi_list);
-	return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
-}
-
-/* Get an BUI. */
-STATIC void *
-xfs_bmap_update_create_intent(
-	struct xfs_trans		*tp,
-	unsigned int			count)
-{
-	struct xfs_bui_log_item		*buip;
-
-	ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS);
-	ASSERT(tp != NULL);
-
-	buip = xfs_bui_init(tp->t_mountp);
-	ASSERT(buip != NULL);
-
-	/*
-	 * Get a log_item_desc to point at the new item.
-	 */
-	xfs_trans_add_item(tp, &buip->bui_item);
-	return buip;
-}
-
-/* Set the map extent flags for this mapping. */
-static void
-xfs_trans_set_bmap_flags(
-	struct xfs_map_extent		*bmap,
-	enum xfs_bmap_intent_type	type,
-	int				whichfork,
-	xfs_exntst_t			state)
-{
-	bmap->me_flags = 0;
-	switch (type) {
-	case XFS_BMAP_MAP:
-	case XFS_BMAP_UNMAP:
-		bmap->me_flags = type;
-		break;
-	default:
-		ASSERT(0);
-	}
-	if (state == XFS_EXT_UNWRITTEN)
-		bmap->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
-	if (whichfork == XFS_ATTR_FORK)
-		bmap->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
-}
-
-/* Log bmap updates in the intent item. */
-STATIC void
-xfs_bmap_update_log_item(
-	struct xfs_trans		*tp,
-	void				*intent,
-	struct list_head		*item)
-{
-	struct xfs_bui_log_item		*buip = intent;
-	struct xfs_bmap_intent		*bmap;
-	uint				next_extent;
-	struct xfs_map_extent		*map;
-
-	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-
-	tp->t_flags |= XFS_TRANS_DIRTY;
-	set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags);
-
-	/*
-	 * atomic_inc_return gives us the value after the increment;
-	 * we want to use it as an array index so we need to subtract 1 from
-	 * it.
-	 */
-	next_extent = atomic_inc_return(&buip->bui_next_extent) - 1;
-	ASSERT(next_extent < buip->bui_format.bui_nextents);
-	map = &buip->bui_format.bui_extents[next_extent];
-	map->me_owner = bmap->bi_owner->i_ino;
-	map->me_startblock = bmap->bi_bmap.br_startblock;
-	map->me_startoff = bmap->bi_bmap.br_startoff;
-	map->me_len = bmap->bi_bmap.br_blockcount;
-	xfs_trans_set_bmap_flags(map, bmap->bi_type, bmap->bi_whichfork,
-			bmap->bi_bmap.br_state);
-}
-
-/* Get an BUD so we can process all the deferred rmap updates. */
-STATIC void *
-xfs_bmap_update_create_done(
-	struct xfs_trans		*tp,
-	void				*intent,
-	unsigned int			count)
-{
-	return xfs_trans_get_bud(tp, intent);
-}
-
-/* Process a deferred rmap update. */
-STATIC int
-xfs_bmap_update_finish_item(
-	struct xfs_trans		*tp,
-	struct list_head		*item,
-	void				*done_item,
-	void				**state)
-{
-	struct xfs_bmap_intent		*bmap;
-	xfs_filblks_t			count;
-	int				error;
-
-	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-	count = bmap->bi_bmap.br_blockcount;
-	error = xfs_trans_log_finish_bmap_update(tp, done_item,
-			bmap->bi_type,
-			bmap->bi_owner, bmap->bi_whichfork,
-			bmap->bi_bmap.br_startoff,
-			bmap->bi_bmap.br_startblock,
-			&count,
-			bmap->bi_bmap.br_state);
-	if (!error && count > 0) {
-		ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
-		bmap->bi_bmap.br_blockcount = count;
-		return -EAGAIN;
-	}
-	kmem_free(bmap);
-	return error;
-}
-
-/* Abort all pending BUIs. */
-STATIC void
-xfs_bmap_update_abort_intent(
-	void				*intent)
-{
-	xfs_bui_release(intent);
-}
-
-/* Cancel a deferred rmap update. */
-STATIC void
-xfs_bmap_update_cancel_item(
-	struct list_head		*item)
-{
-	struct xfs_bmap_intent		*bmap;
-
-	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-	kmem_free(bmap);
-}
-
-const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
-	.max_items	= XFS_BUI_MAX_FAST_EXTENTS,
-	.diff_items	= xfs_bmap_update_diff_items,
-	.create_intent	= xfs_bmap_update_create_intent,
-	.abort_intent	= xfs_bmap_update_abort_intent,
-	.log_item	= xfs_bmap_update_log_item,
-	.create_done	= xfs_bmap_update_create_done,
-	.finish_item	= xfs_bmap_update_finish_item,
-	.cancel_item	= xfs_bmap_update_cancel_item,
-};
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
@ 2019-05-17  8:16   ` Nikolay Borisov
  2019-05-17  8:27     ` Christoph Hellwig
  2019-05-17 18:26   ` Eric Sandeen
  2019-05-20 13:12   ` Brian Foster
  2 siblings, 1 reply; 60+ messages in thread
From: Nikolay Borisov @ 2019-05-17  8:16 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs



On 17.05.19 г. 10:31 ч., Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_extfree_item.c  | 27 +++++++++++++++------------
>  fs/xfs/xfs_extfree_item.h  |  2 --
>  fs/xfs/xfs_trans_extfree.c | 26 --------------------------
>  3 files changed, 15 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index bb0b1e942d00..ccf95cb8234c 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -312,32 +312,35 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
>  };
>  
>  /*
> - * Allocate and initialize an efd item with the given number of extents.
> + * Allocate an "extent free done" log item that will hold nextents worth of
> + * extents.  The caller must use all nextents extents, because we are not
> + * flexible about this at all.
>   */
>  struct xfs_efd_log_item *
> -xfs_efd_init(
> -	struct xfs_mount	*mp,
> -	struct xfs_efi_log_item	*efip,
> -	uint			nextents)
> -
> +xfs_trans_get_efd(
> +	struct xfs_trans		*tp,
> +	struct xfs_efi_log_item		*efip,
> +	unsigned int			nextents)
>  {
> -	struct xfs_efd_log_item	*efdp;
> -	uint			size;
> +	struct xfs_efd_log_item		*efdp;
>  
>  	ASSERT(nextents > 0);
> +
>  	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> -		size = (uint)(sizeof(xfs_efd_log_item_t) +
> -			((nextents - 1) * sizeof(xfs_extent_t)));
> -		efdp = kmem_zalloc(size, KM_SLEEP);
> +		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> +				(nextents - 1) * sizeof(struct xfs_extent),
> +				KM_SLEEP);

xfs_efd_log is really a struct which ends with an array. I think it will
make it slightly more obvious if you use the newly introduced
struct_size like so:

kmem_zalloc(struct_size(efdp, efd_format.efd_extents, nextents -1),
KM_SLEEP)


<snip>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17  8:16   ` Nikolay Borisov
@ 2019-05-17  8:27     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-17  8:27 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 11:16:52AM +0300, Nikolay Borisov wrote:
> xfs_efd_log is really a struct which ends with an array. I think it will
> make it slightly more obvious if you use the newly introduced
> struct_size like so:
> 
> kmem_zalloc(struct_size(efdp, efd_format.efd_extents, nextents -1),
> KM_SLEEP)

If we do that we should also kill the fake first entry in the array
and make it a C99 flexible array.  But that should be done in a separate
patch.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
  2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
@ 2019-05-17 14:04   ` Brian Foster
  2019-05-20 22:08   ` Darrick J. Wong
  1 sibling, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:00AM +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_trans.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 912b42f5fe4a..19f91312561a 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -815,7 +815,7 @@ xfs_log_item_batch_insert(
>   *
>   * If we are called with the aborted flag set, it is because a log write during
>   * a CIL checkpoint commit has failed. In this case, all the items in the
> - * checkpoint have already gone through iop_commited and iop_unlock, which
> + * checkpoint have already gone through iop_committed and iop_unlock, which
>   * means that checkpoint commit abort handling is treated exactly the same
>   * as an iclog write error even though we haven't started any IO yet. Hence in
>   * this case all we need to do is iop_committed processing, followed by an
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
@ 2019-05-17 14:04   ` Brian Foster
  2019-05-20  6:03     ` Christoph Hellwig
  2019-05-17 14:10   ` Eric Sandeen
  2019-05-20 22:08   ` Darrick J. Wong
  2 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:01AM +0200, Christoph Hellwig wrote:
> Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
> flag in function parameters.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_log.c     | 25 +++++++++++--------------
>  fs/xfs/xfs_log.h     |  2 +-
>  fs/xfs/xfs_log_cil.c |  4 ++--
>  3 files changed, 14 insertions(+), 17 deletions(-)
> 
...
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index 5e595948bc5a..1b54002d3874 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -577,7 +577,7 @@ xlog_discard_busy_extents(
>  static void
>  xlog_cil_committed(
>  	void	*args,
> -	int	abort)
> +	bool	abort)
>  {

Just FYI.. this function passes abort to xfs_trans_committed_bulk(),
which also looks like it could be changed from int to bool. That aside:

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  	struct xfs_cil_ctx	*ctx = args;
>  	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
> @@ -864,7 +864,7 @@ xlog_cil_push(
>  out_abort_free_ticket:
>  	xfs_log_ticket_put(tic);
>  out_abort:
> -	xlog_cil_committed(ctx, XFS_LI_ABORTED);
> +	xlog_cil_committed(ctx, true);
>  	return -EIO;
>  }
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 03/20] xfs: don't require log items to implement optional methods
  2019-05-17  7:31 ` [PATCH 03/20] xfs: don't require log items to implement optional methods Christoph Hellwig
@ 2019-05-17 14:06   ` Brian Foster
  2019-05-20  6:06     ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:02AM +0200, Christoph Hellwig wrote:
> Just check if they are present first.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_bmap_item.c     | 104 -------------------------------------
>  fs/xfs/xfs_buf_item.c      |   8 ---
>  fs/xfs/xfs_dquot_item.c    |  98 ----------------------------------
>  fs/xfs/xfs_extfree_item.c  | 104 -------------------------------------
>  fs/xfs/xfs_icreate_item.c  |  28 ----------
>  fs/xfs/xfs_log_cil.c       |   3 +-
>  fs/xfs/xfs_refcount_item.c | 104 -------------------------------------
>  fs/xfs/xfs_rmap_item.c     | 104 -------------------------------------
>  fs/xfs/xfs_trans.c         |  21 +++++---
>  fs/xfs/xfs_trans_ail.c     |   2 +
>  10 files changed, 19 insertions(+), 557 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index ce45f066995e..8e57df6d5581 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
...
> @@ -122,21 +113,6 @@ xfs_bui_item_unpin(
>  	xfs_bui_release(buip);
>  }
>  
> -/*
> - * BUI items have no locking or pushing.  However, since BUIs are pulled from
> - * the AIL when their corresponding BUDs are committed to disk, their situation
> - * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
> - * will eventually flush the log.  This should help in getting the BUI out of
> - * the AIL.
> - */
> -STATIC uint
> -xfs_bui_item_push(
> -	struct xfs_log_item	*lip,
> -	struct list_head	*buffer_list)
> -{
> -	return XFS_ITEM_PINNED;
> -}
> -

Nice cleanup overall. This removes a ton of duplicated and boilerplate
code. One thing I don't like is the loss of information around the use
of XFS_ITEM_PINNED in all these ->iop_push() calls associated with
intents. I'd almost rather see a generic xfs_intent_item_push() defined
somewhere and wire that up to these various calls. Short of that, could
we at least move some of the information from these comments to the push
call in xfsaild_push_item()? For example....

>  /*
>   * The BUI has been either committed or aborted if the transaction has been
>   * cancelled. If the transaction was cancelled, an BUD isn't going to be
...
> diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> index d3a4e89bf4a0..8509c4b59760 100644
> --- a/fs/xfs/xfs_trans_ail.c
> +++ b/fs/xfs/xfs_trans_ail.c
> @@ -347,6 +347,8 @@ xfsaild_push_item(
>  	if (XFS_TEST_ERROR(false, ailp->ail_mount, XFS_ERRTAG_LOG_ITEM_PIN))
>  		return XFS_ITEM_PINNED;
>  

/*
 * Consider the item pinned if a push callback is not defined so the
 * caller will force the log. This should only happen for intent items
 * as they are unpinned once the associated done item is committed to
 * the on-disk log.
 */

Otherwise this looks fine.

Brian

> +	if (!lip->li_ops->iop_push)
> +		return XFS_ITEM_PINNED;
>  	return lip->li_ops->iop_push(lip, &ailp->ail_buf_list);
>  }
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items
  2019-05-17  7:31 ` [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items Christoph Hellwig
@ 2019-05-17 14:07   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:03AM +0200, Christoph Hellwig wrote:
> This method should never be called, so don't waste code on it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_icreate_item.c | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
> index 03c174ff1ab3..cbaabc55f0c9 100644
> --- a/fs/xfs/xfs_icreate_item.c
> +++ b/fs/xfs/xfs_icreate_item.c
> @@ -83,23 +83,12 @@ xfs_icreate_item_committed(
>  	return (xfs_lsn_t)-1;
>  }
>  
> -/* item can never get into the AIL */
> -STATIC uint
> -xfs_icreate_item_push(
> -	struct xfs_log_item	*lip,
> -	struct list_head	*buffer_list)
> -{
> -	ASSERT(0);
> -	return XFS_ITEM_SUCCESS;
> -}
> -
>  /*
>   * This is the ops vector shared by all buf log items.
>   */
>  static const struct xfs_item_ops xfs_icreate_item_ops = {
>  	.iop_size	= xfs_icreate_item_size,
>  	.iop_format	= xfs_icreate_item_format,
> -	.iop_push	= xfs_icreate_item_push,
>  	.iop_unlock	= xfs_icreate_item_unlock,
>  	.iop_committed	= xfs_icreate_item_committed,
>  };
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/20] xfs: remove the iop_push implementation for quota off items
  2019-05-17  7:31 ` [PATCH 05/20] xfs: remove the iop_push implementation for quota off items Christoph Hellwig
@ 2019-05-17 14:08   ` Brian Foster
  2019-05-20  6:09     ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:04AM +0200, Christoph Hellwig wrote:
> If we want to push the log to make progress on the items we'd need to
> return XFS_ITEM_PINNED instead of XFS_ITEM_LOCKED.  Removing the
> method will do exactly that.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_dquot_item.c | 14 --------------
>  1 file changed, 14 deletions(-)
> 
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index 486eea151fdb..a61a8a770d7f 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -288,18 +288,6 @@ xfs_qm_qoff_logitem_format(
>  	xlog_finish_iovec(lv, vecp, sizeof(struct xfs_qoff_logitem));
>  }
>  
> -/*
> - * There isn't much you can do to push a quotaoff item.  It is simply
> - * stuck waiting for the log to be flushed to disk.
> - */
> -STATIC uint
> -xfs_qm_qoff_logitem_push(
> -	struct xfs_log_item	*lip,
> -	struct list_head	*buffer_list)
> -{
> -	return XFS_ITEM_LOCKED;
> -}
> -

Hmm, this one is a bit interesting because it's a potential change in
behavior and I'm not sure the comment above accurately reflects the
situation. In xfs_qm_scall_quotaoff(), we log the first quotaoff item
and commit it synchronously. I believe this means it immediately goes
into the AIL. Then we have to iterate inodes to drop all dquot
references and purge the dquot cache, which can do I/O by writing back
dquot bufs before we eventually log the quotaoff_end item. All in all
this can take a bit of time (and we have test scenarios that reproduce
quotaoff log deadlocks already).

I think this change can cause AIL processing concurrent to a quotaoff in
progress to potentially force the log on every pass. I would not expect
that to have a positive effect because a log force doesn't actually help
the quotaoff progress until the quotaoff_end is committed, and that
already occurs synchronously as well. I don't think it's wise to change
behavior here, at least not without some testing and analysis around how
this impacts those already somewhat flakey quota off operations.

Brian

>  STATIC xfs_lsn_t
>  xfs_qm_qoffend_logitem_committed(
>  	struct xfs_log_item	*lip,
> @@ -327,7 +315,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
>  	.iop_size	= xfs_qm_qoff_logitem_size,
>  	.iop_format	= xfs_qm_qoff_logitem_format,
>  	.iop_committed	= xfs_qm_qoffend_logitem_committed,
> -	.iop_push	= xfs_qm_qoff_logitem_push,
>  };
>  
>  /*
> @@ -336,7 +323,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
>  static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
>  	.iop_size	= xfs_qm_qoff_logitem_size,
>  	.iop_format	= xfs_qm_qoff_logitem_format,
> -	.iop_push	= xfs_qm_qoff_logitem_push,
>  };
>  
>  /*
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path
  2019-05-17  7:31 ` [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path Christoph Hellwig
@ 2019-05-17 14:08   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-17 14:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:05AM +0200, Christoph Hellwig wrote:
> While commiting items looks very similar to freeing them on error it is
> a different operation, and they will diverge a bit soon.
> 
> Split out the commit case from xfs_trans_free_items, inline it into
> xfs_log_commit_cil and give it a separate trace point.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_log_cil.c    | 13 ++++++++++---
>  fs/xfs/xfs_trace.h      |  1 +
>  fs/xfs/xfs_trans.c      | 10 +++-------
>  fs/xfs/xfs_trans_priv.h |  2 --
>  4 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index 49f37905c7a7..c856bfce5bf2 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -985,6 +985,7 @@ xfs_log_commit_cil(
>  {
>  	struct xlog		*log = mp->m_log;
>  	struct xfs_cil		*cil = log->l_cilp;
> +	struct xfs_log_item	*lip, *next;
>  	xfs_lsn_t		xc_commit_lsn;
>  
>  	/*
> @@ -1009,7 +1010,7 @@ xfs_log_commit_cil(
>  
>  	/*
>  	 * Once all the items of the transaction have been copied to the CIL,
> -	 * the items can be unlocked and freed.
> +	 * the items can be unlocked and possibly freed.
>  	 *
>  	 * This needs to be done before we drop the CIL context lock because we
>  	 * have to update state in the log items and unlock them before they go
> @@ -1018,8 +1019,14 @@ xfs_log_commit_cil(
>  	 * the log items. This affects (at least) processing of stale buffers,
>  	 * inodes and EFIs.
>  	 */
> -	xfs_trans_free_items(tp, xc_commit_lsn, false);
> -
> +	trace_xfs_trans_commit_items(tp, _RET_IP_);
> +	list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
> +		xfs_trans_del_item(lip);
> +		if (lip->li_ops->iop_committing)
> +			lip->li_ops->iop_committing(lip, xc_commit_lsn);
> +		if (lip->li_ops->iop_unlock)
> +			lip->li_ops->iop_unlock(lip);
> +	}
>  	xlog_cil_push_background(log);
>  
>  	up_read(&cil->xc_ctx_lock);
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 2464ea351f83..195a9cdb954e 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -3360,6 +3360,7 @@ DEFINE_TRANS_EVENT(xfs_trans_dup);
>  DEFINE_TRANS_EVENT(xfs_trans_free);
>  DEFINE_TRANS_EVENT(xfs_trans_roll);
>  DEFINE_TRANS_EVENT(xfs_trans_add_item);
> +DEFINE_TRANS_EVENT(xfs_trans_commit_items);
>  DEFINE_TRANS_EVENT(xfs_trans_free_items);
>  
>  TRACE_EVENT(xfs_iunlink_update_bucket,
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index ed7547b9f66b..4ed5d032b26f 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -767,10 +767,9 @@ xfs_trans_del_item(
>  }
>  
>  /* Detach and unlock all of the items in a transaction */
> -void
> +static void
>  xfs_trans_free_items(
>  	struct xfs_trans	*tp,
> -	xfs_lsn_t		commit_lsn,
>  	bool			abort)
>  {
>  	struct xfs_log_item	*lip, *next;
> @@ -779,9 +778,6 @@ xfs_trans_free_items(
>  
>  	list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
>  		xfs_trans_del_item(lip);
> -		if (commit_lsn != NULLCOMMITLSN &&
> -		    lip->li_ops->iop_committing)
> -			lip->li_ops->iop_committing(lip, commit_lsn);
>  		if (abort)
>  			set_bit(XFS_LI_ABORTED, &lip->li_flags);
>  
> @@ -1007,7 +1003,7 @@ __xfs_trans_commit(
>  		tp->t_ticket = NULL;
>  	}
>  	current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
> -	xfs_trans_free_items(tp, NULLCOMMITLSN, !!error);
> +	xfs_trans_free_items(tp, !!error);
>  	xfs_trans_free(tp);
>  
>  	XFS_STATS_INC(mp, xs_trans_empty);
> @@ -1069,7 +1065,7 @@ xfs_trans_cancel(
>  	/* mark this thread as no longer being in a transaction */
>  	current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
>  
> -	xfs_trans_free_items(tp, NULLCOMMITLSN, dirty);
> +	xfs_trans_free_items(tp, dirty);
>  	xfs_trans_free(tp);
>  }
>  
> diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
> index 091eae9f4e74..bef1ebf933ed 100644
> --- a/fs/xfs/xfs_trans_priv.h
> +++ b/fs/xfs/xfs_trans_priv.h
> @@ -16,8 +16,6 @@ struct xfs_log_vec;
>  void	xfs_trans_init(struct xfs_mount *);
>  void	xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
>  void	xfs_trans_del_item(struct xfs_log_item *);
> -void	xfs_trans_free_items(struct xfs_trans *tp, xfs_lsn_t commit_lsn,
> -				bool abort);
>  void	xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp);
>  
>  void	xfs_trans_committed_bulk(struct xfs_ail *ailp, struct xfs_log_vec *lv,
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
  2019-05-17 14:04   ` Brian Foster
@ 2019-05-17 14:10   ` Eric Sandeen
  2019-05-20  6:05     ` Christoph Hellwig
  2019-05-20 22:08   ` Darrick J. Wong
  2 siblings, 1 reply; 60+ messages in thread
From: Eric Sandeen @ 2019-05-17 14:10 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs

On 5/17/19 2:31 AM, Christoph Hellwig wrote:
> Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
> flag in function parameters.

...

>  out_abort:
> -	xlog_cil_committed(ctx, XFS_LI_ABORTED);
> +	xlog_cil_committed(ctx, true);
>  	return -EIO;

Technically fine but I'm kind of on the fence about changes like this;
doesn't it make the code less readable?  Passing a self-documenting
flag makes code reading a lot easier than seeing "true" and having
to cross-reference what the bool means.  What's your thought on how this
helps?  Is it worth keeping things like this more self-documenting?

Thanks,
-Eric

> Signed-off-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/20] xfs: split iop_unlock
  2019-05-17  7:31 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
@ 2019-05-17 17:49   ` Brian Foster
  2019-05-20  6:10     ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-17 17:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:06AM +0200, Christoph Hellwig wrote:
> The iop_unlock is not only misnamed, but also causes deeper problems.
> We call the method when either comitting a transaction, or when freeing
> items on a cancelled transaction.  Various item implementations try
> to distinguish the cases by checking the XFS_LI_ABORTED flag, but that
> is only set if the cancelled transaction was dirty.  That leads to
> possible leaks of items when cancelling a clean transaction.  The only
> thing saving us there is that cancelling clean transactions with
> attached items is incredibly rare, if we do it at all.
> 

Refactoring aside, I see that the majority of this patch is focused on
intent log item implementations. I don't think an item leak is possible
here because we intentionally dirty transactions when either an intent
or done item is logged. See xfs_extent_free_log_item() and
xfs_trans_free_extent() for examples associated with the EFI/EFD items.

On one hand this logic supports the current item reference counting
logic (for example, so we know whether to drop the log's reference to an
EFI on transaction abort or wait until physical log commit time). On the
other hand, the items themselves must be logged to disk so we have to
mark them dirty (along with the transaction on behalf of the item) for
that reason as well. FWIW, I do think the current approach of adding the
intent item and dirtying it separately is slightly confusing,
particularly since I'm not sure we have any valid use case to have a
clean intent/done item in a transaction.

I suppose this kind of refactoring might still make sense on its own if
the resulting code is more clear or streamlined. I.e., perhaps there's
no need for the separate ->iop_committing() and ->iop_unlock() callbacks
invoked one after the other. That said, I think the commit log should
probably be updated to focus on that (unless I'm missing something about
the potential leak). Hm?

Brian

> This patch replaces iop_unlock with a new iop_release method just for
> releasing items on a transaction cancellation, and overloads the
> existing iop_committing method with the commit path behavior that only
> a few item implementations need to start with.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_bmap_item.c     | 17 +++++++----------
>  fs/xfs/xfs_buf_item.c      | 15 ++++++++++++---
>  fs/xfs/xfs_dquot_item.c    | 19 +++++++++++--------
>  fs/xfs/xfs_extfree_item.c  | 17 +++++++----------
>  fs/xfs/xfs_icreate_item.c  | 10 +++-------
>  fs/xfs/xfs_inode_item.c    | 11 ++++++-----
>  fs/xfs/xfs_log_cil.c       |  2 --
>  fs/xfs/xfs_refcount_item.c | 17 +++++++----------
>  fs/xfs/xfs_rmap_item.c     | 17 +++++++----------
>  fs/xfs/xfs_trace.h         |  2 +-
>  fs/xfs/xfs_trans.c         |  7 +++----
>  fs/xfs/xfs_trans.h         |  4 ++--
>  fs/xfs/xfs_trans_buf.c     |  2 +-
>  13 files changed, 67 insertions(+), 73 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index 8e57df6d5581..56c1ab161f3b 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -119,11 +119,10 @@ xfs_bui_item_unpin(
>   * constructed and thus we free the BUI here directly.
>   */
>  STATIC void
> -xfs_bui_item_unlock(
> +xfs_bui_item_release(
>  	struct xfs_log_item	*lip)
>  {
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
> -		xfs_bui_release(BUI_ITEM(lip));
> +	xfs_bui_release(BUI_ITEM(lip));
>  }
>  
>  /*
> @@ -133,7 +132,7 @@ static const struct xfs_item_ops xfs_bui_item_ops = {
>  	.iop_size	= xfs_bui_item_size,
>  	.iop_format	= xfs_bui_item_format,
>  	.iop_unpin	= xfs_bui_item_unpin,
> -	.iop_unlock	= xfs_bui_item_unlock,
> +	.iop_release	= xfs_bui_item_release,
>  };
>  
>  /*
> @@ -200,15 +199,13 @@ xfs_bud_item_format(
>   * BUD.
>   */
>  STATIC void
> -xfs_bud_item_unlock(
> +xfs_bud_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_bud_log_item	*budp = BUD_ITEM(lip);
>  
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
> -		xfs_bui_release(budp->bud_buip);
> -		kmem_zone_free(xfs_bud_zone, budp);
> -	}
> +	xfs_bui_release(budp->bud_buip);
> +	kmem_zone_free(xfs_bud_zone, budp);
>  }
>  
>  /*
> @@ -242,7 +239,7 @@ xfs_bud_item_committed(
>  static const struct xfs_item_ops xfs_bud_item_ops = {
>  	.iop_size	= xfs_bud_item_size,
>  	.iop_format	= xfs_bud_item_format,
> -	.iop_unlock	= xfs_bud_item_unlock,
> +	.iop_release	= xfs_bud_item_release,
>  	.iop_committed	= xfs_bud_item_committed,
>  };
>  
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 3e0d5845e47b..7193ee9ca5b8 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -594,7 +594,7 @@ xfs_buf_item_put(
>   * free the item.
>   */
>  STATIC void
> -xfs_buf_item_unlock(
> +xfs_buf_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
> @@ -609,7 +609,7 @@ xfs_buf_item_unlock(
>  						   &lip->li_flags);
>  #endif
>  
> -	trace_xfs_buf_item_unlock(bip);
> +	trace_xfs_buf_item_release(bip);
>  
>  	/*
>  	 * The bli dirty state should match whether the blf has logged segments
> @@ -639,6 +639,14 @@ xfs_buf_item_unlock(
>  	xfs_buf_relse(bp);
>  }
>  
> +STATIC void
> +xfs_buf_item_committing(
> +	struct xfs_log_item	*lip,
> +	xfs_lsn_t		commit_lsn)
> +{
> +	return xfs_buf_item_release(lip);
> +}
> +
>  /*
>   * This is called to find out where the oldest active copy of the
>   * buf log item in the on disk log resides now that the last log
> @@ -679,7 +687,8 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
>  	.iop_format	= xfs_buf_item_format,
>  	.iop_pin	= xfs_buf_item_pin,
>  	.iop_unpin	= xfs_buf_item_unpin,
> -	.iop_unlock	= xfs_buf_item_unlock,
> +	.iop_release	= xfs_buf_item_release,
> +	.iop_committing	= xfs_buf_item_committing,
>  	.iop_committed	= xfs_buf_item_committed,
>  	.iop_push	= xfs_buf_item_push,
>  };
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index a61a8a770d7f..b8fd81641dfc 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -197,14 +197,8 @@ xfs_qm_dquot_logitem_push(
>  	return rval;
>  }
>  
> -/*
> - * Unlock the dquot associated with the log item.
> - * Clear the fields of the dquot and dquot log item that
> - * are specific to the current transaction.  If the
> - * hold flags is set, do not unlock the dquot.
> - */
>  STATIC void
> -xfs_qm_dquot_logitem_unlock(
> +xfs_qm_dquot_logitem_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_dquot	*dqp = DQUOT_ITEM(lip)->qli_dquot;
> @@ -220,6 +214,14 @@ xfs_qm_dquot_logitem_unlock(
>  	xfs_dqunlock(dqp);
>  }
>  
> +STATIC void
> +xfs_qm_dquot_logitem_committing(
> +	struct xfs_log_item	*lip,
> +	xfs_lsn_t		commit_lsn)
> +{
> +	return xfs_qm_dquot_logitem_release(lip);
> +}
> +
>  /*
>   * This is the ops vector for dquots
>   */
> @@ -228,7 +230,8 @@ static const struct xfs_item_ops xfs_dquot_item_ops = {
>  	.iop_format	= xfs_qm_dquot_logitem_format,
>  	.iop_pin	= xfs_qm_dquot_logitem_pin,
>  	.iop_unpin	= xfs_qm_dquot_logitem_unpin,
> -	.iop_unlock	= xfs_qm_dquot_logitem_unlock,
> +	.iop_release	= xfs_qm_dquot_logitem_release,
> +	.iop_committing	= xfs_qm_dquot_logitem_committing,
>  	.iop_push	= xfs_qm_dquot_logitem_push,
>  	.iop_error	= xfs_dquot_item_error
>  };
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index 655ed0445750..a73a3cff8502 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -129,11 +129,10 @@ xfs_efi_item_unpin(
>   * constructed and thus we free the EFI here directly.
>   */
>  STATIC void
> -xfs_efi_item_unlock(
> +xfs_efi_item_release(
>  	struct xfs_log_item	*lip)
>  {
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
> -		xfs_efi_release(EFI_ITEM(lip));
> +	xfs_efi_release(EFI_ITEM(lip));
>  }
>  
>  /*
> @@ -143,7 +142,7 @@ static const struct xfs_item_ops xfs_efi_item_ops = {
>  	.iop_size	= xfs_efi_item_size,
>  	.iop_format	= xfs_efi_item_format,
>  	.iop_unpin	= xfs_efi_item_unpin,
> -	.iop_unlock	= xfs_efi_item_unlock,
> +	.iop_release	= xfs_efi_item_release,
>  };
>  
>  
> @@ -299,15 +298,13 @@ xfs_efd_item_format(
>   * the transaction is cancelled, drop our reference to the EFI and free the EFD.
>   */
>  STATIC void
> -xfs_efd_item_unlock(
> +xfs_efd_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_efd_log_item	*efdp = EFD_ITEM(lip);
>  
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
> -		xfs_efi_release(efdp->efd_efip);
> -		xfs_efd_item_free(efdp);
> -	}
> +	xfs_efi_release(efdp->efd_efip);
> +	xfs_efd_item_free(efdp);
>  }
>  
>  /*
> @@ -341,7 +338,7 @@ xfs_efd_item_committed(
>  static const struct xfs_item_ops xfs_efd_item_ops = {
>  	.iop_size	= xfs_efd_item_size,
>  	.iop_format	= xfs_efd_item_format,
> -	.iop_unlock	= xfs_efd_item_unlock,
> +	.iop_release	= xfs_efd_item_release,
>  	.iop_committed	= xfs_efd_item_committed,
>  };
>  
> diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
> index cbaabc55f0c9..9aceb35dce24 100644
> --- a/fs/xfs/xfs_icreate_item.c
> +++ b/fs/xfs/xfs_icreate_item.c
> @@ -57,14 +57,10 @@ xfs_icreate_item_format(
>  }
>  
>  STATIC void
> -xfs_icreate_item_unlock(
> +xfs_icreate_item_release(
>  	struct xfs_log_item	*lip)
>  {
> -	struct xfs_icreate_item	*icp = ICR_ITEM(lip);
> -
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
> -		kmem_zone_free(xfs_icreate_zone, icp);
> -	return;
> +	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
>  }
>  
>  /*
> @@ -89,7 +85,7 @@ xfs_icreate_item_committed(
>  static const struct xfs_item_ops xfs_icreate_item_ops = {
>  	.iop_size	= xfs_icreate_item_size,
>  	.iop_format	= xfs_icreate_item_format,
> -	.iop_unlock	= xfs_icreate_item_unlock,
> +	.iop_release	= xfs_icreate_item_release,
>  	.iop_committed	= xfs_icreate_item_committed,
>  };
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index fa1c4fe2ffbf..a00f0b6aecc7 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -565,7 +565,7 @@ xfs_inode_item_push(
>   * Unlock the inode associated with the inode log item.
>   */
>  STATIC void
> -xfs_inode_item_unlock(
> +xfs_inode_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_inode_log_item *iip = INODE_ITEM(lip);
> @@ -621,9 +621,10 @@ xfs_inode_item_committed(
>  STATIC void
>  xfs_inode_item_committing(
>  	struct xfs_log_item	*lip,
> -	xfs_lsn_t		lsn)
> +	xfs_lsn_t		commit_lsn)
>  {
> -	INODE_ITEM(lip)->ili_last_lsn = lsn;
> +	INODE_ITEM(lip)->ili_last_lsn = commit_lsn;
> +	return xfs_inode_item_release(lip);
>  }
>  
>  /*
> @@ -634,10 +635,10 @@ static const struct xfs_item_ops xfs_inode_item_ops = {
>  	.iop_format	= xfs_inode_item_format,
>  	.iop_pin	= xfs_inode_item_pin,
>  	.iop_unpin	= xfs_inode_item_unpin,
> -	.iop_unlock	= xfs_inode_item_unlock,
> +	.iop_release	= xfs_inode_item_release,
>  	.iop_committed	= xfs_inode_item_committed,
>  	.iop_push	= xfs_inode_item_push,
> -	.iop_committing = xfs_inode_item_committing,
> +	.iop_committing	= xfs_inode_item_committing,
>  	.iop_error	= xfs_inode_item_error
>  };
>  
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index c856bfce5bf2..4cb459f21ad4 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -1024,8 +1024,6 @@ xfs_log_commit_cil(
>  		xfs_trans_del_item(lip);
>  		if (lip->li_ops->iop_committing)
>  			lip->li_ops->iop_committing(lip, xc_commit_lsn);
> -		if (lip->li_ops->iop_unlock)
> -			lip->li_ops->iop_unlock(lip);
>  	}
>  	xlog_cil_push_background(log);
>  
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index 03a61886fe2a..9f8fb23dcc81 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -118,11 +118,10 @@ xfs_cui_item_unpin(
>   * constructed and thus we free the CUI here directly.
>   */
>  STATIC void
> -xfs_cui_item_unlock(
> +xfs_cui_item_release(
>  	struct xfs_log_item	*lip)
>  {
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
> -		xfs_cui_release(CUI_ITEM(lip));
> +	xfs_cui_release(CUI_ITEM(lip));
>  }
>  
>  /*
> @@ -132,7 +131,7 @@ static const struct xfs_item_ops xfs_cui_item_ops = {
>  	.iop_size	= xfs_cui_item_size,
>  	.iop_format	= xfs_cui_item_format,
>  	.iop_unpin	= xfs_cui_item_unpin,
> -	.iop_unlock	= xfs_cui_item_unlock,
> +	.iop_release	= xfs_cui_item_release,
>  };
>  
>  /*
> @@ -205,15 +204,13 @@ xfs_cud_item_format(
>   * CUD.
>   */
>  STATIC void
> -xfs_cud_item_unlock(
> +xfs_cud_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_cud_log_item	*cudp = CUD_ITEM(lip);
>  
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
> -		xfs_cui_release(cudp->cud_cuip);
> -		kmem_zone_free(xfs_cud_zone, cudp);
> -	}
> +	xfs_cui_release(cudp->cud_cuip);
> +	kmem_zone_free(xfs_cud_zone, cudp);
>  }
>  
>  /*
> @@ -247,7 +244,7 @@ xfs_cud_item_committed(
>  static const struct xfs_item_ops xfs_cud_item_ops = {
>  	.iop_size	= xfs_cud_item_size,
>  	.iop_format	= xfs_cud_item_format,
> -	.iop_unlock	= xfs_cud_item_unlock,
> +	.iop_release	= xfs_cud_item_release,
>  	.iop_committed	= xfs_cud_item_committed,
>  };
>  
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index df9f2505c5f3..e907bd169de5 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -117,11 +117,10 @@ xfs_rui_item_unpin(
>   * constructed and thus we free the RUI here directly.
>   */
>  STATIC void
> -xfs_rui_item_unlock(
> +xfs_rui_item_release(
>  	struct xfs_log_item	*lip)
>  {
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
> -		xfs_rui_release(RUI_ITEM(lip));
> +	xfs_rui_release(RUI_ITEM(lip));
>  }
>  
>  /*
> @@ -131,7 +130,7 @@ static const struct xfs_item_ops xfs_rui_item_ops = {
>  	.iop_size	= xfs_rui_item_size,
>  	.iop_format	= xfs_rui_item_format,
>  	.iop_unpin	= xfs_rui_item_unpin,
> -	.iop_unlock	= xfs_rui_item_unlock,
> +	.iop_release	= xfs_rui_item_release,
>  };
>  
>  /*
> @@ -226,15 +225,13 @@ xfs_rud_item_format(
>   * RUD.
>   */
>  STATIC void
> -xfs_rud_item_unlock(
> +xfs_rud_item_release(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_rud_log_item	*rudp = RUD_ITEM(lip);
>  
> -	if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
> -		xfs_rui_release(rudp->rud_ruip);
> -		kmem_zone_free(xfs_rud_zone, rudp);
> -	}
> +	xfs_rui_release(rudp->rud_ruip);
> +	kmem_zone_free(xfs_rud_zone, rudp);
>  }
>  
>  /*
> @@ -268,7 +265,7 @@ xfs_rud_item_committed(
>  static const struct xfs_item_ops xfs_rud_item_ops = {
>  	.iop_size	= xfs_rud_item_size,
>  	.iop_format	= xfs_rud_item_format,
> -	.iop_unlock	= xfs_rud_item_unlock,
> +	.iop_release	= xfs_rud_item_release,
>  	.iop_committed	= xfs_rud_item_committed,
>  };
>  
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 195a9cdb954e..65c920554b96 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -475,7 +475,7 @@ DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
>  DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
>  DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
>  DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
> -DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock);
> +DEFINE_BUF_ITEM_EVENT(xfs_buf_item_release);
>  DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
>  DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
>  DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 4ed5d032b26f..45a39de65997 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -780,9 +780,8 @@ xfs_trans_free_items(
>  		xfs_trans_del_item(lip);
>  		if (abort)
>  			set_bit(XFS_LI_ABORTED, &lip->li_flags);
> -
> -		if (lip->li_ops->iop_unlock)
> -			lip->li_ops->iop_unlock(lip);
> +		if (lip->li_ops->iop_release)
> +			lip->li_ops->iop_release(lip);
>  	}
>  }
>  
> @@ -815,7 +814,7 @@ xfs_log_item_batch_insert(
>   *
>   * If we are called with the aborted flag set, it is because a log write during
>   * a CIL checkpoint commit has failed. In this case, all the items in the
> - * checkpoint have already gone through iop_committed and iop_unlock, which
> + * checkpoint have already gone through iop_committed and iop_committing, which
>   * means that checkpoint commit abort handling is treated exactly the same
>   * as an iclog write error even though we haven't started any IO yet. Hence in
>   * this case all we need to do is iop_committed processing, followed by an
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index c6e1c5704a8c..7bd1867613c2 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -72,9 +72,9 @@ struct xfs_item_ops {
>  	void (*iop_pin)(xfs_log_item_t *);
>  	void (*iop_unpin)(xfs_log_item_t *, int remove);
>  	uint (*iop_push)(struct xfs_log_item *, struct list_head *);
> -	void (*iop_unlock)(xfs_log_item_t *);
> +	void (*iop_committing)(struct xfs_log_item *, xfs_lsn_t commit_lsn);
> +	void (*iop_release)(struct xfs_log_item *);
>  	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
> -	void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
>  	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
>  };
>  
> diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
> index 7d65ebf1e847..3dca9cf40a9f 100644
> --- a/fs/xfs/xfs_trans_buf.c
> +++ b/fs/xfs/xfs_trans_buf.c
> @@ -428,7 +428,7 @@ xfs_trans_brelse(
>  
>  /*
>   * Mark the buffer as not needing to be unlocked when the buf item's
> - * iop_unlock() routine is called.  The buffer must already be locked
> + * iop_committing() routine is called.  The buffer must already be locked
>   * and associated with the given transaction.
>   */
>  /* ARGSUSED */
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 08/20] xfs: add a flag to release log items on commit
  2019-05-17  7:31 ` [PATCH 08/20] xfs: add a flag to release log items on commit Christoph Hellwig
@ 2019-05-17 17:50   ` Brian Foster
  2019-05-20  6:11     ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-17 17:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:07AM +0200, Christoph Hellwig wrote:
> We have various items that are released from ->iop_comitting.  Add a
> flag to just call ->iop_release from the commit path to avoid tons
> of boilerplate code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Seems reasonable, but the naming is getting a little confusing. Your
commit log refers to ->iop_committing() and the patch modifies
->iop_committed(). Both the committing and committed callbacks still
exist, while the flag is called *_RELEASE_ON_COMMIT and thus doesn't
indicate which event it actually refers to. Can we fix this up? Maybe
just call it *_RELEASE_ON_COMMITTED?

>  fs/xfs/xfs_bmap_item.c     | 27 +--------------------------
>  fs/xfs/xfs_extfree_item.c  | 27 +--------------------------
>  fs/xfs/xfs_icreate_item.c  | 18 +-----------------
>  fs/xfs/xfs_refcount_item.c | 27 +--------------------------
>  fs/xfs/xfs_rmap_item.c     | 27 +--------------------------
>  fs/xfs/xfs_trans.c         |  5 +++++
>  fs/xfs/xfs_trans.h         |  7 +++++++
>  7 files changed, 17 insertions(+), 121 deletions(-)
> 
...
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 45a39de65997..52a8a8ff2ae9 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -849,6 +849,11 @@ xfs_trans_committed_bulk(
>  		struct xfs_log_item	*lip = lv->lv_item;
>  		xfs_lsn_t		item_lsn;
>  
> +		if (lip->li_ops->flags & XFS_ITEM_RELEASE_ON_COMMIT) {
> +			lip->li_ops->iop_release(lip);
> +			continue;
> +		}

It might be appropriate to set the aborted flag before the callback.
Even though none of the current users happen to care, it's a more
consistent semantic with the other direct caller of ->iop_release().

Brian

> +
>  		if (aborted)
>  			set_bit(XFS_LI_ABORTED, &lip->li_flags);
>  		if (lip->li_ops->iop_committed)
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 7bd1867613c2..a38af44344bf 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -67,6 +67,7 @@ typedef struct xfs_log_item {
>  	{ (1 << XFS_LI_DIRTY),		"DIRTY" }
>  
>  struct xfs_item_ops {
> +	unsigned flags;
>  	void (*iop_size)(xfs_log_item_t *, int *, int *);
>  	void (*iop_format)(xfs_log_item_t *, struct xfs_log_vec *);
>  	void (*iop_pin)(xfs_log_item_t *);
> @@ -78,6 +79,12 @@ struct xfs_item_ops {
>  	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
>  };
>  
> +/*
> + * 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_ON_COMMIT	(1 << 0)
> +
>  void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
>  			  int type, const struct xfs_item_ops *ops);
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item
  2019-05-17  7:31 ` [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item Christoph Hellwig
@ 2019-05-17 17:50   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-17 17:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:08AM +0200, Christoph Hellwig wrote:
> The cast is not type safe, and we can just dereference the first
> member instead to start with.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 71d216cf6f87..419eae485ff3 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -485,7 +485,7 @@ xfs_lock_inodes(
>  		 */
>  		if (!try_lock) {
>  			for (j = (i - 1); j >= 0 && !try_lock; j--) {
> -				lp = (xfs_log_item_t *)ips[j]->i_itemp;
> +				lp = &ips[j]->i_itemp->ili_item;
>  				if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags))
>  					try_lock++;
>  			}
> @@ -585,7 +585,7 @@ xfs_lock_two_inodes(
>  	 * the second lock. If we can't get it, we must release the first one
>  	 * and try again.
>  	 */
> -	lp = (xfs_log_item_t *)ip0->i_itemp;
> +	lp = &ip0->i_itemp->ili_item;
>  	if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags)) {
>  		if (!xfs_ilock_nowait(ip1, xfs_lock_inumorder(ip1_mode, 1))) {
>  			xfs_iunlock(ip0, ip0_mode);
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 10/20] xfs: remove the xfs_log_item_t typedef
  2019-05-17  7:31 ` [PATCH 10/20] xfs: remove the xfs_log_item_t typedef Christoph Hellwig
@ 2019-05-17 17:50   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-17 17:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:09AM +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_buf_item.c     |  6 +++---
>  fs/xfs/xfs_buf_item.h     |  6 +++---
>  fs/xfs/xfs_dquot_item.h   |  4 ++--
>  fs/xfs/xfs_extfree_item.h |  4 ++--
>  fs/xfs/xfs_inode.c        | 12 +++++------
>  fs/xfs/xfs_inode_item.h   |  2 +-
>  fs/xfs/xfs_log_recover.c  |  2 +-
>  fs/xfs/xfs_trans.h        | 16 +++++++-------
>  fs/xfs/xfs_trans_ail.c    | 44 +++++++++++++++++++--------------------
>  9 files changed, 48 insertions(+), 48 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 7193ee9ca5b8..05eefc677cd8 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -981,9 +981,9 @@ xfs_buf_item_relse(
>   */
>  void
>  xfs_buf_attach_iodone(
> -	xfs_buf_t	*bp,
> -	void		(*cb)(xfs_buf_t *, xfs_log_item_t *),
> -	xfs_log_item_t	*lip)
> +	struct xfs_buf		*bp,
> +	void			(*cb)(struct xfs_buf *, struct xfs_log_item *),
> +	struct xfs_log_item	*lip)
>  {
>  	ASSERT(xfs_buf_islocked(bp));
>  
> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> index 90f65f891fab..4a054b11011a 100644
> --- a/fs/xfs/xfs_buf_item.h
> +++ b/fs/xfs/xfs_buf_item.h
> @@ -39,7 +39,7 @@ struct xfs_buf_log_item;
>   * locked, and which 128 byte chunks of the buffer are dirty.
>   */
>  struct xfs_buf_log_item {
> -	xfs_log_item_t		bli_item;	/* common item structure */
> +	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 */
> @@ -55,8 +55,8 @@ bool	xfs_buf_item_put(struct xfs_buf_log_item *);
>  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_attach_iodone(struct xfs_buf *,
> -			      void(*)(struct xfs_buf *, xfs_log_item_t *),
> -			      xfs_log_item_t *);
> +			      void(*)(struct xfs_buf *, struct xfs_log_item *),
> +			      struct xfs_log_item *);
>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h
> index db9df710a308..1aed34ccdabc 100644
> --- a/fs/xfs/xfs_dquot_item.h
> +++ b/fs/xfs/xfs_dquot_item.h
> @@ -12,13 +12,13 @@ struct xfs_mount;
>  struct xfs_qoff_logitem;
>  
>  typedef struct xfs_dq_logitem {
> -	xfs_log_item_t		 qli_item;	   /* common portion */
> +	struct xfs_log_item	 qli_item;	   /* common portion */
>  	struct xfs_dquot	*qli_dquot;	   /* dquot ptr */
>  	xfs_lsn_t		 qli_flush_lsn;	   /* lsn at last flush */
>  } xfs_dq_logitem_t;
>  
>  typedef struct xfs_qoff_logitem {
> -	xfs_log_item_t		 qql_item;	/* common portion */
> +	struct xfs_log_item	 qql_item;	/* common portion */
>  	struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
>  	unsigned int		qql_flags;
>  } xfs_qoff_logitem_t;
> diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
> index 2a6a895ca73e..b0dc4ebe8892 100644
> --- a/fs/xfs/xfs_extfree_item.h
> +++ b/fs/xfs/xfs_extfree_item.h
> @@ -51,7 +51,7 @@ struct kmem_zone;
>   * AIL, so at this point both the EFI and EFD are freed.
>   */
>  typedef struct xfs_efi_log_item {
> -	xfs_log_item_t		efi_item;
> +	struct xfs_log_item	efi_item;
>  	atomic_t		efi_refcount;
>  	atomic_t		efi_next_extent;
>  	unsigned long		efi_flags;	/* misc flags */
> @@ -64,7 +64,7 @@ typedef struct xfs_efi_log_item {
>   * have been freed.
>   */
>  typedef struct xfs_efd_log_item {
> -	xfs_log_item_t		efd_item;
> +	struct xfs_log_item	efd_item;
>  	xfs_efi_log_item_t	*efd_efip;
>  	uint			efd_next_extent;
>  	xfs_efd_log_format_t	efd_format;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 419eae485ff3..6076bae6eb21 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -441,12 +441,12 @@ xfs_lock_inumorder(int lock_mode, int subclass)
>   */
>  static void
>  xfs_lock_inodes(
> -	xfs_inode_t	**ips,
> -	int		inodes,
> -	uint		lock_mode)
> +	struct xfs_inode	**ips,
> +	int			inodes,
> +	uint			lock_mode)
>  {
> -	int		attempts = 0, i, j, try_lock;
> -	xfs_log_item_t	*lp;
> +	int			attempts = 0, i, j, try_lock;
> +	struct xfs_log_item	*lp;
>  
>  	/*
>  	 * Currently supports between 2 and 5 inodes with exclusive locking.  We
> @@ -551,7 +551,7 @@ xfs_lock_two_inodes(
>  	struct xfs_inode	*temp;
>  	uint			mode_temp;
>  	int			attempts = 0;
> -	xfs_log_item_t		*lp;
> +	struct xfs_log_item	*lp;
>  
>  	ASSERT(hweight32(ip0_mode) == 1);
>  	ASSERT(hweight32(ip1_mode) == 1);
> diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
> index 27081eba220c..07a60e74c39c 100644
> --- a/fs/xfs/xfs_inode_item.h
> +++ b/fs/xfs/xfs_inode_item.h
> @@ -14,7 +14,7 @@ struct xfs_inode;
>  struct xfs_mount;
>  
>  typedef 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 ptr */
>  	xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */
>  	xfs_lsn_t		ili_last_lsn;	   /* lsn at last transaction */
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 9329f5adbfbe..76023ea49356 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -3463,7 +3463,7 @@ xlog_recover_efd_pass2(
>  {
>  	xfs_efd_log_format_t	*efd_formatp;
>  	xfs_efi_log_item_t	*efip = NULL;
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  	uint64_t		efi_id;
>  	struct xfs_ail_cursor	cur;
>  	struct xfs_ail		*ailp = log->l_ailp;
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index a38af44344bf..7a6ee0c2ce20 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -27,7 +27,7 @@ struct xfs_cud_log_item;
>  struct xfs_bui_log_item;
>  struct xfs_bud_log_item;
>  
> -typedef struct xfs_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 */
> @@ -48,7 +48,7 @@ typedef struct xfs_log_item {
>  	struct xfs_log_vec		*li_lv;		/* active log vector */
>  	struct xfs_log_vec		*li_lv_shadow;	/* standby vector */
>  	xfs_lsn_t			li_seq;		/* CIL commit seq */
> -} xfs_log_item_t;
> +};
>  
>  /*
>   * li_flags use the (set/test/clear)_bit atomic interfaces because updates can
> @@ -68,15 +68,15 @@ typedef struct xfs_log_item {
>  
>  struct xfs_item_ops {
>  	unsigned flags;
> -	void (*iop_size)(xfs_log_item_t *, int *, int *);
> -	void (*iop_format)(xfs_log_item_t *, struct xfs_log_vec *);
> -	void (*iop_pin)(xfs_log_item_t *);
> -	void (*iop_unpin)(xfs_log_item_t *, int remove);
> +	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 *);
> +	void (*iop_unpin)(struct xfs_log_item *, int remove);
>  	uint (*iop_push)(struct xfs_log_item *, struct list_head *);
>  	void (*iop_committing)(struct xfs_log_item *, xfs_lsn_t commit_lsn);
>  	void (*iop_release)(struct xfs_log_item *);
> -	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
> -	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
> +	xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
> +	void (*iop_error)(struct xfs_log_item *, xfs_buf_t *);
>  };
>  
>  /*
> diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> index 8509c4b59760..f239344fda1a 100644
> --- a/fs/xfs/xfs_trans_ail.c
> +++ b/fs/xfs/xfs_trans_ail.c
> @@ -74,29 +74,29 @@ xfs_ail_check(
>   * Return a pointer to the last item in the AIL.  If the AIL is empty, then
>   * return NULL.
>   */
> -static xfs_log_item_t *
> +static struct xfs_log_item *
>  xfs_ail_max(
>  	struct xfs_ail  *ailp)
>  {
>  	if (list_empty(&ailp->ail_head))
>  		return NULL;
>  
> -	return list_entry(ailp->ail_head.prev, xfs_log_item_t, li_ail);
> +	return list_entry(ailp->ail_head.prev, struct xfs_log_item, li_ail);
>  }
>  
>  /*
>   * Return a pointer to the item which follows the given item in the AIL.  If
>   * the given item is the last item in the list, then return NULL.
>   */
> -static xfs_log_item_t *
> +static struct xfs_log_item *
>  xfs_ail_next(
> -	struct xfs_ail  *ailp,
> -	xfs_log_item_t  *lip)
> +	struct xfs_ail		*ailp,
> +	struct xfs_log_item	*lip)
>  {
>  	if (lip->li_ail.next == &ailp->ail_head)
>  		return NULL;
>  
> -	return list_first_entry(&lip->li_ail, xfs_log_item_t, li_ail);
> +	return list_first_entry(&lip->li_ail, struct xfs_log_item, li_ail);
>  }
>  
>  /*
> @@ -109,10 +109,10 @@ xfs_ail_next(
>   */
>  xfs_lsn_t
>  xfs_ail_min_lsn(
> -	struct xfs_ail	*ailp)
> +	struct xfs_ail		*ailp)
>  {
> -	xfs_lsn_t	lsn = 0;
> -	xfs_log_item_t	*lip;
> +	xfs_lsn_t		lsn = 0;
> +	struct xfs_log_item	*lip;
>  
>  	spin_lock(&ailp->ail_lock);
>  	lip = xfs_ail_min(ailp);
> @@ -128,10 +128,10 @@ xfs_ail_min_lsn(
>   */
>  static xfs_lsn_t
>  xfs_ail_max_lsn(
> -	struct xfs_ail  *ailp)
> +	struct xfs_ail		*ailp)
>  {
> -	xfs_lsn_t       lsn = 0;
> -	xfs_log_item_t  *lip;
> +	xfs_lsn_t       	lsn = 0;
> +	struct xfs_log_item	*lip;
>  
>  	spin_lock(&ailp->ail_lock);
>  	lip = xfs_ail_max(ailp);
> @@ -216,13 +216,13 @@ xfs_trans_ail_cursor_clear(
>   * ascending traversal.  Pass a @lsn of zero to initialise the cursor to the
>   * first item in the AIL. Returns NULL if the list is empty.
>   */
> -xfs_log_item_t *
> +struct xfs_log_item *
>  xfs_trans_ail_cursor_first(
>  	struct xfs_ail		*ailp,
>  	struct xfs_ail_cursor	*cur,
>  	xfs_lsn_t		lsn)
>  {
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  
>  	xfs_trans_ail_cursor_init(ailp, cur);
>  
> @@ -248,7 +248,7 @@ __xfs_trans_ail_cursor_last(
>  	struct xfs_ail		*ailp,
>  	xfs_lsn_t		lsn)
>  {
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  
>  	list_for_each_entry_reverse(lip, &ailp->ail_head, li_ail) {
>  		if (XFS_LSN_CMP(lip->li_lsn, lsn) <= 0)
> @@ -327,8 +327,8 @@ xfs_ail_splice(
>   */
>  static void
>  xfs_ail_delete(
> -	struct xfs_ail  *ailp,
> -	xfs_log_item_t  *lip)
> +	struct xfs_ail		*ailp,
> +	struct xfs_log_item	*lip)
>  {
>  	xfs_ail_check(ailp, lip);
>  	list_del(&lip->li_ail);
> @@ -358,7 +358,7 @@ xfsaild_push(
>  {
>  	xfs_mount_t		*mp = ailp->ail_mount;
>  	struct xfs_ail_cursor	cur;
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  	xfs_lsn_t		lsn;
>  	xfs_lsn_t		target;
>  	long			tout;
> @@ -613,10 +613,10 @@ xfsaild(
>   */
>  void
>  xfs_ail_push(
> -	struct xfs_ail	*ailp,
> -	xfs_lsn_t	threshold_lsn)
> +	struct xfs_ail		*ailp,
> +	xfs_lsn_t		threshold_lsn)
>  {
> -	xfs_log_item_t	*lip;
> +	struct xfs_log_item	*lip;
>  
>  	lip = xfs_ail_min(ailp);
>  	if (!lip || XFS_FORCED_SHUTDOWN(ailp->ail_mount) ||
> @@ -701,7 +701,7 @@ xfs_trans_ail_update_bulk(
>  	int			nr_items,
>  	xfs_lsn_t		lsn) __releases(ailp->ail_lock)
>  {
> -	xfs_log_item_t		*mlip;
> +	struct xfs_log_item	*mlip;
>  	int			mlip_changed = 0;
>  	int			i;
>  	LIST_HEAD(tmp);
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
  2019-05-17  8:16   ` Nikolay Borisov
@ 2019-05-17 18:26   ` Eric Sandeen
  2019-05-20  6:03     ` Christoph Hellwig
  2019-05-20 13:12   ` Brian Foster
  2 siblings, 1 reply; 60+ messages in thread
From: Eric Sandeen @ 2019-05-17 18:26 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs


On 5/17/19 2:31 AM, Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.

hm, do the thin ->create_done() wrappers make sense either?

/* Get an EFD so we can process all the free extents. */
STATIC void *
xfs_extent_free_create_done(
        struct xfs_trans                *tp,
        void                            *intent,
        unsigned int                    count)
{
        return xfs_trans_get_efd(tp, intent, count);
}

should we just hook xfs_trans_get_FOO() directly to ->create_done?

 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_extfree_item.c  | 27 +++++++++++++++------------
>  fs/xfs/xfs_extfree_item.h  |  2 --
>  fs/xfs/xfs_trans_extfree.c | 26 --------------------------
>  3 files changed, 15 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index bb0b1e942d00..ccf95cb8234c 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -312,32 +312,35 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
>  };
>  
>  /*
> - * Allocate and initialize an efd item with the given number of extents.
> + * Allocate an "extent free done" log item that will hold nextents worth of
> + * extents.  The caller must use all nextents extents, because we are not
> + * flexible about this at all.
>   */
>  struct xfs_efd_log_item *
> -xfs_efd_init(
> -	struct xfs_mount	*mp,
> -	struct xfs_efi_log_item	*efip,
> -	uint			nextents)
> -
> +xfs_trans_get_efd(
> +	struct xfs_trans		*tp,
> +	struct xfs_efi_log_item		*efip,
> +	unsigned int			nextents)
>  {
> -	struct xfs_efd_log_item	*efdp;
> -	uint			size;
> +	struct xfs_efd_log_item		*efdp;
>  
>  	ASSERT(nextents > 0);
> +
>  	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> -		size = (uint)(sizeof(xfs_efd_log_item_t) +
> -			((nextents - 1) * sizeof(xfs_extent_t)));
> -		efdp = kmem_zalloc(size, KM_SLEEP);
> +		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> +				(nextents - 1) * sizeof(struct xfs_extent),
> +				KM_SLEEP);
>  	} else {
>  		efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP);
>  	}
>  
> -	xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops);
> +	xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
> +			  &xfs_efd_item_ops);
>  	efdp->efd_efip = efip;
>  	efdp->efd_format.efd_nextents = nextents;
>  	efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
>  
> +	xfs_trans_add_item(tp, &efdp->efd_item);
>  	return efdp;
>  }
>  
> diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
> index b0dc4ebe8892..16aaab06d4ec 100644
> --- a/fs/xfs/xfs_extfree_item.h
> +++ b/fs/xfs/xfs_extfree_item.h
> @@ -79,8 +79,6 @@ extern struct kmem_zone	*xfs_efi_zone;
>  extern struct kmem_zone	*xfs_efd_zone;
>  
>  xfs_efi_log_item_t	*xfs_efi_init(struct xfs_mount *, uint);
> -xfs_efd_log_item_t	*xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
> -				      uint);
>  int			xfs_efi_copy_format(xfs_log_iovec_t *buf,
>  					    xfs_efi_log_format_t *dst_efi_fmt);
>  void			xfs_efi_item_free(xfs_efi_log_item_t *);
> diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
> index 8ee7a3f8bb20..20ab1c9d758f 100644
> --- a/fs/xfs/xfs_trans_extfree.c
> +++ b/fs/xfs/xfs_trans_extfree.c
> @@ -19,32 +19,6 @@
>  #include "xfs_bmap.h"
>  #include "xfs_trace.h"
>  
> -/*
> - * This routine is called to allocate an "extent free done"
> - * log item that will hold nextents worth of extents.  The
> - * caller must use all nextents extents, because we are not
> - * flexible about this at all.
> - */
> -struct xfs_efd_log_item *
> -xfs_trans_get_efd(struct xfs_trans		*tp,
> -		  struct xfs_efi_log_item	*efip,
> -		  uint				nextents)
> -{
> -	struct xfs_efd_log_item			*efdp;
> -
> -	ASSERT(tp != NULL);
> -	ASSERT(nextents > 0);
> -
> -	efdp = xfs_efd_init(tp->t_mountp, efip, nextents);
> -	ASSERT(efdp != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &efdp->efd_item);
> -	return efdp;
> -}
> -
>  /*
>   * Free an extent and log it to the EFD. Note that the transaction is marked
>   * dirty regardless of whether the extent free succeeds or fails to support the
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17 18:26   ` Eric Sandeen
@ 2019-05-20  6:03     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:03 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 01:26:59PM -0500, Eric Sandeen wrote:
> 
> On 5/17/19 2:31 AM, Christoph Hellwig wrote:
> > There is no good reason to keep these two functions separate.
> 
> hm, do the thin ->create_done() wrappers make sense either?
> 
> /* Get an EFD so we can process all the free extents. */
> STATIC void *
> xfs_extent_free_create_done(
>         struct xfs_trans                *tp,
>         void                            *intent,
>         unsigned int                    count)
> {
>         return xfs_trans_get_efd(tp, intent, count);
> }
> 
> should we just hook xfs_trans_get_FOO() directly to ->create_done?

Well, we have another callers of those in the log recovery code.

I have some ideas how to clean some of this up, but that is too much
for this series.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17 14:04   ` Brian Foster
@ 2019-05-20  6:03     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:03 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 10:04:48AM -0400, Brian Foster wrote:
> Just FYI.. this function passes abort to xfs_trans_committed_bulk(),
> which also looks like it could be changed from int to bool. That aside:

True.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17 14:10   ` Eric Sandeen
@ 2019-05-20  6:05     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:05 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 09:10:49AM -0500, Eric Sandeen wrote:
> On 5/17/19 2:31 AM, Christoph Hellwig wrote:
> > Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
> > flag in function parameters.
> 
> ...
> 
> >  out_abort:
> > -	xlog_cil_committed(ctx, XFS_LI_ABORTED);
> > +	xlog_cil_committed(ctx, true);
> >  	return -EIO;
> 
> Technically fine but I'm kind of on the fence about changes like this;
> doesn't it make the code less readable?  Passing a self-documenting
> flag makes code reading a lot easier than seeing "true" and having
> to cross-reference what the bool means.  What's your thought on how this
> helps?  Is it worth keeping things like this more self-documenting?

I hate this one because it passes a flag that is used for something
entirely different and then actually interpreted as an int in boolean
context later on.  Switching to a proper bool seems like the simplest
cleanup, but we could also add a different self describing flag if
it bothers you.  But it doesn't really seem like we'd ever grow another
flag here.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 03/20] xfs: don't require log items to implement optional methods
  2019-05-17 14:06   ` Brian Foster
@ 2019-05-20  6:06     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:06 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 10:06:54AM -0400, Brian Foster wrote:
> Nice cleanup overall. This removes a ton of duplicated and boilerplate
> code. One thing I don't like is the loss of information around the use
> of XFS_ITEM_PINNED in all these ->iop_push() calls associated with
> intents. I'd almost rather see a generic xfs_intent_item_push() defined
> somewhere and wire that up to these various calls.

I don't particularly like that idea, for one because it adds so much
boilerplate code to the intents, but also because if you logically thing
about it - if an item can't be pushed it kinda is per defintion pinned,
so I think this default makes sense.

> Short of that, could
> we at least move some of the information from these comments to the push
> call in xfsaild_push_item()? For example....

Sure, I can do that.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 05/20] xfs: remove the iop_push implementation for quota off items
  2019-05-17 14:08   ` Brian Foster
@ 2019-05-20  6:09     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:09 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 10:08:42AM -0400, Brian Foster wrote:
> Hmm, this one is a bit interesting because it's a potential change in
> behavior and I'm not sure the comment above accurately reflects the
> situation. In xfs_qm_scall_quotaoff(), we log the first quotaoff item
> and commit it synchronously. I believe this means it immediately goes
> into the AIL. Then we have to iterate inodes to drop all dquot
> references and purge the dquot cache, which can do I/O by writing back
> dquot bufs before we eventually log the quotaoff_end item. All in all
> this can take a bit of time (and we have test scenarios that reproduce
> quotaoff log deadlocks already).
> 
> I think this change can cause AIL processing concurrent to a quotaoff in
> progress to potentially force the log on every pass. I would not expect
> that to have a positive effect because a log force doesn't actually help
> the quotaoff progress until the quotaoff_end is committed, and that
> already occurs synchronously as well. I don't think it's wise to change
> behavior here, at least not without some testing and analysis around how
> this impacts those already somewhat flakey quota off operations.

True, the log force probably doesn't help.  I'll drop this for now,
the whole quotaoff logging scheme looks pretty dodgy to me to start
with, so it will need some more attention in the future.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/20] xfs: split iop_unlock
  2019-05-17 17:49   ` Brian Foster
@ 2019-05-20  6:10     ` Christoph Hellwig
  2019-05-20 11:38       ` Brian Foster
  0 siblings, 1 reply; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:10 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 01:49:16PM -0400, Brian Foster wrote:
> Refactoring aside, I see that the majority of this patch is focused on
> intent log item implementations. I don't think an item leak is possible
> here because we intentionally dirty transactions when either an intent
> or done item is logged. See xfs_extent_free_log_item() and
> xfs_trans_free_extent() for examples associated with the EFI/EFD items.

That's why I said theoretical.

> On one hand this logic supports the current item reference counting
> logic (for example, so we know whether to drop the log's reference to an
> EFI on transaction abort or wait until physical log commit time). On the
> other hand, the items themselves must be logged to disk so we have to
> mark them dirty (along with the transaction on behalf of the item) for
> that reason as well. FWIW, I do think the current approach of adding the
> intent item and dirtying it separately is slightly confusing,
> particularly since I'm not sure we have any valid use case to have a
> clean intent/done item in a transaction.

Indeed.  I think there is plenty of opportunity for futher wok here.

> I suppose this kind of refactoring might still make sense on its own if
> the resulting code is more clear or streamlined. I.e., perhaps there's
> no need for the separate ->iop_committing() and ->iop_unlock() callbacks
> invoked one after the other. That said, I think the commit log should
> probably be updated to focus on that (unless I'm missing something about
> the potential leak). Hm?

The streamlining was the the point.  I just noticed that if we were
every to about a clean intent item we'd leak it while doing that.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 08/20] xfs: add a flag to release log items on commit
  2019-05-17 17:50   ` Brian Foster
@ 2019-05-20  6:11     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20  6:11 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Fri, May 17, 2019 at 01:50:25PM -0400, Brian Foster wrote:
> On Fri, May 17, 2019 at 09:31:07AM +0200, Christoph Hellwig wrote:
> > We have various items that are released from ->iop_comitting.  Add a
> > flag to just call ->iop_release from the commit path to avoid tons
> > of boilerplate code.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> 
> Seems reasonable, but the naming is getting a little confusing. Your
> commit log refers to ->iop_committing() and the patch modifies
> ->iop_committed(). Both the committing and committed callbacks still
> exist, while the flag is called *_RELEASE_ON_COMMIT and thus doesn't
> indicate which event it actually refers to. Can we fix this up? Maybe
> just call it *_RELEASE_ON_COMMITTED?

Sounds fine. 

> 
> >  fs/xfs/xfs_bmap_item.c     | 27 +--------------------------
> >  fs/xfs/xfs_extfree_item.c  | 27 +--------------------------
> >  fs/xfs/xfs_icreate_item.c  | 18 +-----------------
> >  fs/xfs/xfs_refcount_item.c | 27 +--------------------------
> >  fs/xfs/xfs_rmap_item.c     | 27 +--------------------------
> >  fs/xfs/xfs_trans.c         |  5 +++++
> >  fs/xfs/xfs_trans.h         |  7 +++++++
> >  7 files changed, 17 insertions(+), 121 deletions(-)
> > 
> ...
> > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> > index 45a39de65997..52a8a8ff2ae9 100644
> > --- a/fs/xfs/xfs_trans.c
> > +++ b/fs/xfs/xfs_trans.c
> > @@ -849,6 +849,11 @@ xfs_trans_committed_bulk(
> >  		struct xfs_log_item	*lip = lv->lv_item;
> >  		xfs_lsn_t		item_lsn;
> >  
> > +		if (lip->li_ops->flags & XFS_ITEM_RELEASE_ON_COMMIT) {
> > +			lip->li_ops->iop_release(lip);
> > +			continue;
> > +		}
> 
> It might be appropriate to set the aborted flag before the callback.
> Even though none of the current users happen to care, it's a more
> consistent semantic with the other direct caller of ->iop_release().

Ok.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 07/20] xfs: split iop_unlock
  2019-05-20  6:10     ` Christoph Hellwig
@ 2019-05-20 11:38       ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 11:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Mon, May 20, 2019 at 08:10:43AM +0200, Christoph Hellwig wrote:
> On Fri, May 17, 2019 at 01:49:16PM -0400, Brian Foster wrote:
> > Refactoring aside, I see that the majority of this patch is focused on
> > intent log item implementations. I don't think an item leak is possible
> > here because we intentionally dirty transactions when either an intent
> > or done item is logged. See xfs_extent_free_log_item() and
> > xfs_trans_free_extent() for examples associated with the EFI/EFD items.
> 
> That's why I said theoretical.
> 

The current commit log says it's either rare or doesn't occur in
practice, which leaves the question open. I'm pointing out that for the
codepaths affected by this patch, I don't think it can occur.

I agree that it's still a theoretical possibility based on the current
log item interface and intent item implementations...

> > On one hand this logic supports the current item reference counting
> > logic (for example, so we know whether to drop the log's reference to an
> > EFI on transaction abort or wait until physical log commit time). On the
> > other hand, the items themselves must be logged to disk so we have to
> > mark them dirty (along with the transaction on behalf of the item) for
> > that reason as well. FWIW, I do think the current approach of adding the
> > intent item and dirtying it separately is slightly confusing,
> > particularly since I'm not sure we have any valid use case to have a
> > clean intent/done item in a transaction.
> 
> Indeed.  I think there is plenty of opportunity for futher wok here.
> 
> > I suppose this kind of refactoring might still make sense on its own if
> > the resulting code is more clear or streamlined. I.e., perhaps there's
> > no need for the separate ->iop_committing() and ->iop_unlock() callbacks
> > invoked one after the other. That said, I think the commit log should
> > probably be updated to focus on that (unless I'm missing something about
> > the potential leak). Hm?
> 
> The streamlining was the the point.  I just noticed that if we were
> every to about a clean intent item we'd leak it while doing that.

Ok, then I'd just suggest to update the commit log. I guess it's easier
for me to just suggest one, so for example (feel free to use, modify or
replace):

---

iop_unlock() is called when comitting or cancelling a transaction. In
the latter case, the transaction may or may not be aborted. While there
is no known problem with the current code in practice, this
implementation is limited in that any log item implementation that might
want to differentiate between a commit and a cancel must rely on the
aborted state. The aborted bit is only set when the cancelled
transaction is dirty, however. This means that there is no way to
distinguish between a commit and a clean transaction cancel.

For example, intent log items currently rely on this distinction. The
log item is either transferred to the CIL on commit or released on
transaction cancel. There is currently no possibility for a clean intent
log item in a transaction, but if that state is ever introduced a cancel
of such a transaction will immediately result in memory leaks of the
associated log item(s). This is an interface deficiency and landmine.

To clean this up, replace ->iop_unlock() with an ->iop_release()
callback that is specific to transaction cancel. The existing
->iop_committing() callback occurs at the same time as ->iop_unlock() in
the commit path and there is no need for two separate callbacks here.
Overload ->iop_committing() with the current commit time ->iop_unlock()
implementations to eliminate the need for the latter and further
simplify the interface.

---

I'll try to get through the rest of this series today..

Brian

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-17  7:31 ` [PATCH 11/20] xfs: use a list_head for iclog callbacks Christoph Hellwig
@ 2019-05-20 13:12   ` Brian Foster
  2019-05-20 13:19     ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:10AM +0200, Christoph Hellwig wrote:
> Replace the hand grown linked list handling and cil context attachment
> with the standard list_head structure.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_log.c      | 51 ++++++++-----------------------------------
>  fs/xfs/xfs_log.h      | 15 +++----------
>  fs/xfs/xfs_log_cil.c  | 31 ++++++++++++++++++++------
>  fs/xfs/xfs_log_priv.h | 10 +++------
>  4 files changed, 39 insertions(+), 68 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 1eb0938165fc..0d6fb374dbe8 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
...
> @@ -2828,26 +2801,20 @@ xlog_state_do_callback(
>  			 * callbacks being added.
>  			 */
>  			spin_lock(&iclog->ic_callback_lock);
> -			cb = iclog->ic_callback;
> -			while (cb) {
> -				iclog->ic_callback_tail = &(iclog->ic_callback);
> -				iclog->ic_callback = NULL;
> -				spin_unlock(&iclog->ic_callback_lock);
> +			while (!list_empty(&iclog->ic_callbacks)) {
> +				LIST_HEAD(tmp);
>  
> -				/* perform callbacks in the order given */
> -				for (; cb; cb = cb_next) {
> -					cb_next = cb->cb_next;
> -					cb->cb_func(cb->cb_arg, aborted);
> -				}
> +				list_splice_init(&iclog->ic_callbacks, &tmp);
> +
> +				spin_unlock(&iclog->ic_callback_lock);
> +				xlog_cil_process_commited(&tmp, aborted);

s/commited/committed/ please.

>  				spin_lock(&iclog->ic_callback_lock);
> -				cb = iclog->ic_callback;
>  			}
>  
...
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index 4cb459f21ad4..b6b30b8e22af 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
...
> @@ -615,6 +614,20 @@ xlog_cil_committed(
>  		kmem_free(ctx);
>  }
>  
> +void
> +xlog_cil_process_commited(
> +	struct list_head	*list,
> +	bool			aborted)
> +{
> +	struct xfs_cil_ctx	*ctx;
> +
> +	while ((ctx = list_first_entry_or_null(list,

Are double braces necessary here?

> +			struct xfs_cil_ctx, iclog_entry))) {
> +		list_del(&ctx->iclog_entry);
> +		xlog_cil_committed(ctx, aborted);
> +	}
> +}
...
> @@ -837,11 +850,15 @@ xlog_cil_push(
>  		goto out_abort;
>  
>  	/* attach all the transactions w/ busy extents to iclog */

Any idea what this ^ comment means? ISTM it's misplaced or stale. If so,
we might as well toss/replace it.

With those nits fixed:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> -	ctx->log_cb.cb_func = xlog_cil_committed;
> -	ctx->log_cb.cb_arg = ctx;
> -	error = xfs_log_notify(commit_iclog, &ctx->log_cb);
> -	if (error)
> +	spin_lock(&commit_iclog->ic_callback_lock);
> +	if (commit_iclog->ic_state & XLOG_STATE_IOERROR) {
> +		spin_unlock(&commit_iclog->ic_callback_lock);
>  		goto out_abort;
> +	}
> +	ASSERT_ALWAYS(commit_iclog->ic_state == XLOG_STATE_ACTIVE ||
> +		      commit_iclog->ic_state == XLOG_STATE_WANT_SYNC);
> +	list_add_tail(&ctx->iclog_entry, &commit_iclog->ic_callbacks);
> +	spin_unlock(&commit_iclog->ic_callback_lock);
>  
>  	/*
>  	 * now the checkpoint commit is complete and we've attached the
> diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
> index b5f82cb36202..5c188ccb8568 100644
> --- a/fs/xfs/xfs_log_priv.h
> +++ b/fs/xfs/xfs_log_priv.h
> @@ -10,7 +10,6 @@ struct xfs_buf;
>  struct xlog;
>  struct xlog_ticket;
>  struct xfs_mount;
> -struct xfs_log_callback;
>  
>  /*
>   * Flags for log structure
> @@ -181,8 +180,6 @@ typedef struct xlog_ticket {
>   * - ic_next is the pointer to the next iclog in the ring.
>   * - ic_bp is a pointer to the buffer used to write this incore log to disk.
>   * - ic_log is a pointer back to the global log structure.
> - * - ic_callback is a linked list of callback function/argument pairs to be
> - *	called after an iclog finishes writing.
>   * - ic_size is the full size of the header plus data.
>   * - ic_offset is the current number of bytes written to in this iclog.
>   * - ic_refcnt is bumped when someone is writing to the log.
> @@ -193,7 +190,7 @@ typedef struct xlog_ticket {
>   * structure cacheline aligned. The following fields can be contended on
>   * by independent processes:
>   *
> - *	- ic_callback_*
> + *	- ic_callbacks
>   *	- ic_refcnt
>   *	- fields protected by the global l_icloglock
>   *
> @@ -216,8 +213,7 @@ typedef struct xlog_in_core {
>  
>  	/* Callback structures need their own cacheline */
>  	spinlock_t		ic_callback_lock ____cacheline_aligned_in_smp;
> -	struct xfs_log_callback	*ic_callback;
> -	struct xfs_log_callback	**ic_callback_tail;
> +	struct list_head	ic_callbacks;
>  
>  	/* reference counts need their own cacheline */
>  	atomic_t		ic_refcnt ____cacheline_aligned_in_smp;
> @@ -243,7 +239,7 @@ struct xfs_cil_ctx {
>  	int			space_used;	/* aggregate size of regions */
>  	struct list_head	busy_extents;	/* busy extents in chkpt */
>  	struct xfs_log_vec	*lv_chain;	/* logvecs being pushed */
> -	struct xfs_log_callback	log_cb;		/* completion callback hook. */
> +	struct list_head	iclog_entry;
>  	struct list_head	committing;	/* ctx committing list */
>  	struct work_struct	discard_endio_work;
>  };
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances
  2019-05-17  7:31 ` [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances Christoph Hellwig
@ 2019-05-20 13:12   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:11AM +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_bmap_item.c     | 6 ------
>  fs/xfs/xfs_buf_item.c      | 3 ---
>  fs/xfs/xfs_dquot_item.c    | 6 ------
>  fs/xfs/xfs_extfree_item.c  | 6 ------
>  fs/xfs/xfs_icreate_item.c  | 3 ---
>  fs/xfs/xfs_inode_item.c    | 3 ---
>  fs/xfs/xfs_refcount_item.c | 6 ------
>  fs/xfs/xfs_rmap_item.c     | 6 ------
>  8 files changed, 39 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index d7ceb2d1ae82..46dcadf790c2 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -125,9 +125,6 @@ xfs_bui_item_release(
>  	xfs_bui_release(BUI_ITEM(lip));
>  }
>  
> -/*
> - * This is the ops vector shared by all bui log items.
> - */
>  static const struct xfs_item_ops xfs_bui_item_ops = {
>  	.iop_size	= xfs_bui_item_size,
>  	.iop_format	= xfs_bui_item_format,
> @@ -208,9 +205,6 @@ xfs_bud_item_release(
>  	kmem_zone_free(xfs_bud_zone, budp);
>  }
>  
> -/*
> - * This is the ops vector shared by all bud log items.
> - */
>  static const struct xfs_item_ops xfs_bud_item_ops = {
>  	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
>  	.iop_size	= xfs_bud_item_size,
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 05eefc677cd8..2c7aef61ea92 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -679,9 +679,6 @@ xfs_buf_item_committed(
>  	return lsn;
>  }
>  
> -/*
> - * This is the ops vector shared by all buf log items.
> - */
>  static const struct xfs_item_ops xfs_buf_item_ops = {
>  	.iop_size	= xfs_buf_item_size,
>  	.iop_format	= xfs_buf_item_format,
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index b8fd81641dfc..ade4520d3fdf 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -222,9 +222,6 @@ xfs_qm_dquot_logitem_committing(
>  	return xfs_qm_dquot_logitem_release(lip);
>  }
>  
> -/*
> - * This is the ops vector for dquots
> - */
>  static const struct xfs_item_ops xfs_dquot_item_ops = {
>  	.iop_size	= xfs_qm_dquot_logitem_size,
>  	.iop_format	= xfs_qm_dquot_logitem_format,
> @@ -320,9 +317,6 @@ static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
>  	.iop_committed	= xfs_qm_qoffend_logitem_committed,
>  };
>  
> -/*
> - * This is the ops vector shared by all quotaoff-start log items.
> - */
>  static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
>  	.iop_size	= xfs_qm_qoff_logitem_size,
>  	.iop_format	= xfs_qm_qoff_logitem_format,
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index 762eb288dfe8..bb0b1e942d00 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -135,9 +135,6 @@ xfs_efi_item_release(
>  	xfs_efi_release(EFI_ITEM(lip));
>  }
>  
> -/*
> - * This is the ops vector shared by all efi log items.
> - */
>  static const struct xfs_item_ops xfs_efi_item_ops = {
>  	.iop_size	= xfs_efi_item_size,
>  	.iop_format	= xfs_efi_item_format,
> @@ -307,9 +304,6 @@ xfs_efd_item_release(
>  	xfs_efd_item_free(efdp);
>  }
>  
> -/*
> - * This is the ops vector shared by all efd log items.
> - */
>  static const struct xfs_item_ops xfs_efd_item_ops = {
>  	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
>  	.iop_size	= xfs_efd_item_size,
> diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
> index eb9cb04635be..4f1ce50ce323 100644
> --- a/fs/xfs/xfs_icreate_item.c
> +++ b/fs/xfs/xfs_icreate_item.c
> @@ -63,9 +63,6 @@ xfs_icreate_item_release(
>  	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
>  }
>  
> -/*
> - * This is the ops vector shared by all buf log items.
> - */
>  static const struct xfs_item_ops xfs_icreate_item_ops = {
>  	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
>  	.iop_size	= xfs_icreate_item_size,
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index a00f0b6aecc7..62847e95b399 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -627,9 +627,6 @@ xfs_inode_item_committing(
>  	return xfs_inode_item_release(lip);
>  }
>  
> -/*
> - * This is the ops vector shared by all buf log items.
> - */
>  static const struct xfs_item_ops xfs_inode_item_ops = {
>  	.iop_size	= xfs_inode_item_size,
>  	.iop_format	= xfs_inode_item_format,
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index b4ab71ce39fc..2b2f6e7ad867 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -124,9 +124,6 @@ xfs_cui_item_release(
>  	xfs_cui_release(CUI_ITEM(lip));
>  }
>  
> -/*
> - * This is the ops vector shared by all cui log items.
> - */
>  static const struct xfs_item_ops xfs_cui_item_ops = {
>  	.iop_size	= xfs_cui_item_size,
>  	.iop_format	= xfs_cui_item_format,
> @@ -213,9 +210,6 @@ xfs_cud_item_release(
>  	kmem_zone_free(xfs_cud_zone, cudp);
>  }
>  
> -/*
> - * This is the ops vector shared by all cud log items.
> - */
>  static const struct xfs_item_ops xfs_cud_item_ops = {
>  	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
>  	.iop_size	= xfs_cud_item_size,
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index 1b35b3d38708..dce1357aef88 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -123,9 +123,6 @@ xfs_rui_item_release(
>  	xfs_rui_release(RUI_ITEM(lip));
>  }
>  
> -/*
> - * This is the ops vector shared by all rui log items.
> - */
>  static const struct xfs_item_ops xfs_rui_item_ops = {
>  	.iop_size	= xfs_rui_item_size,
>  	.iop_format	= xfs_rui_item_format,
> @@ -234,9 +231,6 @@ xfs_rud_item_release(
>  	kmem_zone_free(xfs_rud_zone, rudp);
>  }
>  
> -/*
> - * This is the ops vector shared by all rud log items.
> - */
>  static const struct xfs_item_ops xfs_rud_item_ops = {
>  	.flags		= XFS_ITEM_RELEASE_ON_COMMIT,
>  	.iop_size	= xfs_rud_item_size,
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
  2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
  2019-05-17  8:16   ` Nikolay Borisov
  2019-05-17 18:26   ` Eric Sandeen
@ 2019-05-20 13:12   ` Brian Foster
  2 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:12AM +0200, Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Looks good, and there's only one more user of the xfs_efd_log_item_t
typedef. ;)

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_extfree_item.c  | 27 +++++++++++++++------------
>  fs/xfs/xfs_extfree_item.h  |  2 --
>  fs/xfs/xfs_trans_extfree.c | 26 --------------------------
>  3 files changed, 15 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index bb0b1e942d00..ccf95cb8234c 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -312,32 +312,35 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
>  };
>  
>  /*
> - * Allocate and initialize an efd item with the given number of extents.
> + * Allocate an "extent free done" log item that will hold nextents worth of
> + * extents.  The caller must use all nextents extents, because we are not
> + * flexible about this at all.
>   */
>  struct xfs_efd_log_item *
> -xfs_efd_init(
> -	struct xfs_mount	*mp,
> -	struct xfs_efi_log_item	*efip,
> -	uint			nextents)
> -
> +xfs_trans_get_efd(
> +	struct xfs_trans		*tp,
> +	struct xfs_efi_log_item		*efip,
> +	unsigned int			nextents)
>  {
> -	struct xfs_efd_log_item	*efdp;
> -	uint			size;
> +	struct xfs_efd_log_item		*efdp;
>  
>  	ASSERT(nextents > 0);
> +
>  	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> -		size = (uint)(sizeof(xfs_efd_log_item_t) +
> -			((nextents - 1) * sizeof(xfs_extent_t)));
> -		efdp = kmem_zalloc(size, KM_SLEEP);
> +		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> +				(nextents - 1) * sizeof(struct xfs_extent),
> +				KM_SLEEP);
>  	} else {
>  		efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP);
>  	}
>  
> -	xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops);
> +	xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
> +			  &xfs_efd_item_ops);
>  	efdp->efd_efip = efip;
>  	efdp->efd_format.efd_nextents = nextents;
>  	efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
>  
> +	xfs_trans_add_item(tp, &efdp->efd_item);
>  	return efdp;
>  }
>  
> diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
> index b0dc4ebe8892..16aaab06d4ec 100644
> --- a/fs/xfs/xfs_extfree_item.h
> +++ b/fs/xfs/xfs_extfree_item.h
> @@ -79,8 +79,6 @@ extern struct kmem_zone	*xfs_efi_zone;
>  extern struct kmem_zone	*xfs_efd_zone;
>  
>  xfs_efi_log_item_t	*xfs_efi_init(struct xfs_mount *, uint);
> -xfs_efd_log_item_t	*xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
> -				      uint);
>  int			xfs_efi_copy_format(xfs_log_iovec_t *buf,
>  					    xfs_efi_log_format_t *dst_efi_fmt);
>  void			xfs_efi_item_free(xfs_efi_log_item_t *);
> diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
> index 8ee7a3f8bb20..20ab1c9d758f 100644
> --- a/fs/xfs/xfs_trans_extfree.c
> +++ b/fs/xfs/xfs_trans_extfree.c
> @@ -19,32 +19,6 @@
>  #include "xfs_bmap.h"
>  #include "xfs_trace.h"
>  
> -/*
> - * This routine is called to allocate an "extent free done"
> - * log item that will hold nextents worth of extents.  The
> - * caller must use all nextents extents, because we are not
> - * flexible about this at all.
> - */
> -struct xfs_efd_log_item *
> -xfs_trans_get_efd(struct xfs_trans		*tp,
> -		  struct xfs_efi_log_item	*efip,
> -		  uint				nextents)
> -{
> -	struct xfs_efd_log_item			*efdp;
> -
> -	ASSERT(tp != NULL);
> -	ASSERT(nextents > 0);
> -
> -	efdp = xfs_efd_init(tp->t_mountp, efip, nextents);
> -	ASSERT(efdp != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &efdp->efd_item);
> -	return efdp;
> -}
> -
>  /*
>   * Free an extent and log it to the EFD. Note that the transaction is marked
>   * dirty regardless of whether the extent free succeeds or fails to support the
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud
  2019-05-17  7:31 ` [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud Christoph Hellwig
@ 2019-05-20 13:13   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:13AM +0200, Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_refcount_item.c  | 14 ++++++--------
>  fs/xfs/xfs_refcount_item.h  |  2 --
>  fs/xfs/xfs_trans_refcount.c | 16 ----------------
>  3 files changed, 6 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index 2b2f6e7ad867..70dcdf40ac92 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -217,22 +217,20 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
>  	.iop_release	= xfs_cud_item_release,
>  };
>  
> -/*
> - * Allocate and initialize an cud item with the given number of extents.
> - */
>  struct xfs_cud_log_item *
> -xfs_cud_init(
> -	struct xfs_mount		*mp,
> +xfs_trans_get_cud(
> +	struct xfs_trans		*tp,
>  	struct xfs_cui_log_item		*cuip)
> -
>  {
> -	struct xfs_cud_log_item	*cudp;
> +	struct xfs_cud_log_item		*cudp;
>  
>  	cudp = kmem_zone_zalloc(xfs_cud_zone, KM_SLEEP);
> -	xfs_log_item_init(mp, &cudp->cud_item, XFS_LI_CUD, &xfs_cud_item_ops);
> +	xfs_log_item_init(tp->t_mountp, &cudp->cud_item, XFS_LI_CUD,
> +			  &xfs_cud_item_ops);
>  	cudp->cud_cuip = cuip;
>  	cudp->cud_format.cud_cui_id = cuip->cui_format.cui_id;
>  
> +	xfs_trans_add_item(tp, &cudp->cud_item);
>  	return cudp;
>  }
>  
> diff --git a/fs/xfs/xfs_refcount_item.h b/fs/xfs/xfs_refcount_item.h
> index 3896dcc2368f..e47530f30489 100644
> --- a/fs/xfs/xfs_refcount_item.h
> +++ b/fs/xfs/xfs_refcount_item.h
> @@ -78,8 +78,6 @@ extern struct kmem_zone	*xfs_cui_zone;
>  extern struct kmem_zone	*xfs_cud_zone;
>  
>  struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint);
> -struct xfs_cud_log_item *xfs_cud_init(struct xfs_mount *,
> -		struct xfs_cui_log_item *);
>  void xfs_cui_item_free(struct xfs_cui_log_item *);
>  void xfs_cui_release(struct xfs_cui_log_item *);
>  int xfs_cui_recover(struct xfs_trans *parent_tp, struct xfs_cui_log_item *cuip);
> diff --git a/fs/xfs/xfs_trans_refcount.c b/fs/xfs/xfs_trans_refcount.c
> index 8d734728dd1b..d793fb500378 100644
> --- a/fs/xfs/xfs_trans_refcount.c
> +++ b/fs/xfs/xfs_trans_refcount.c
> @@ -17,22 +17,6 @@
>  #include "xfs_alloc.h"
>  #include "xfs_refcount.h"
>  
> -/*
> - * This routine is called to allocate a "refcount update done"
> - * log item.
> - */
> -struct xfs_cud_log_item *
> -xfs_trans_get_cud(
> -	struct xfs_trans		*tp,
> -	struct xfs_cui_log_item		*cuip)
> -{
> -	struct xfs_cud_log_item		*cudp;
> -
> -	cudp = xfs_cud_init(tp->t_mountp, cuip);
> -	xfs_trans_add_item(tp, &cudp->cud_item);
> -	return cudp;
> -}
> -
>  /*
>   * Finish an refcount update and log it to the CUD. Note that the
>   * transaction is marked dirty regardless of whether the refcount
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud
  2019-05-17  7:31 ` [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud Christoph Hellwig
@ 2019-05-20 13:13   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:14AM +0200, Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_rmap_item.c  | 14 ++++++--------
>  fs/xfs/xfs_rmap_item.h  |  2 --
>  fs/xfs/xfs_trans_rmap.c | 12 ------------
>  3 files changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index dce1357aef88..5f11e6d43484 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -238,22 +238,20 @@ static const struct xfs_item_ops xfs_rud_item_ops = {
>  	.iop_release	= xfs_rud_item_release,
>  };
>  
> -/*
> - * Allocate and initialize an rud item with the given number of extents.
> - */
>  struct xfs_rud_log_item *
> -xfs_rud_init(
> -	struct xfs_mount		*mp,
> +xfs_trans_get_rud(
> +	struct xfs_trans		*tp,
>  	struct xfs_rui_log_item		*ruip)
> -
>  {
> -	struct xfs_rud_log_item	*rudp;
> +	struct xfs_rud_log_item		*rudp;
>  
>  	rudp = kmem_zone_zalloc(xfs_rud_zone, KM_SLEEP);
> -	xfs_log_item_init(mp, &rudp->rud_item, XFS_LI_RUD, &xfs_rud_item_ops);
> +	xfs_log_item_init(tp->t_mountp, &rudp->rud_item, XFS_LI_RUD,
> +			  &xfs_rud_item_ops);
>  	rudp->rud_ruip = ruip;
>  	rudp->rud_format.rud_rui_id = ruip->rui_format.rui_id;
>  
> +	xfs_trans_add_item(tp, &rudp->rud_item);
>  	return rudp;
>  }
>  
> diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h
> index 7e482baa27f5..8708e4a5aa5c 100644
> --- a/fs/xfs/xfs_rmap_item.h
> +++ b/fs/xfs/xfs_rmap_item.h
> @@ -78,8 +78,6 @@ extern struct kmem_zone	*xfs_rui_zone;
>  extern struct kmem_zone	*xfs_rud_zone;
>  
>  struct xfs_rui_log_item *xfs_rui_init(struct xfs_mount *, uint);
> -struct xfs_rud_log_item *xfs_rud_init(struct xfs_mount *,
> -		struct xfs_rui_log_item *);
>  int xfs_rui_copy_format(struct xfs_log_iovec *buf,
>  		struct xfs_rui_log_format *dst_rui_fmt);
>  void xfs_rui_item_free(struct xfs_rui_log_item *);
> diff --git a/fs/xfs/xfs_trans_rmap.c b/fs/xfs/xfs_trans_rmap.c
> index 5c7936b1be13..863e3281daaa 100644
> --- a/fs/xfs/xfs_trans_rmap.c
> +++ b/fs/xfs/xfs_trans_rmap.c
> @@ -60,18 +60,6 @@ xfs_trans_set_rmap_flags(
>  	}
>  }
>  
> -struct xfs_rud_log_item *
> -xfs_trans_get_rud(
> -	struct xfs_trans		*tp,
> -	struct xfs_rui_log_item		*ruip)
> -{
> -	struct xfs_rud_log_item		*rudp;
> -
> -	rudp = xfs_rud_init(tp->t_mountp, ruip);
> -	xfs_trans_add_item(tp, &rudp->rud_item);
> -	return rudp;
> -}
> -
>  /*
>   * Finish an rmap update and log it to the RUD. Note that the transaction is
>   * marked dirty regardless of whether the rmap update succeeds or fails to
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud
  2019-05-17  7:31 ` [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud Christoph Hellwig
@ 2019-05-20 13:13   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:15AM +0200, Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_bmap_item.c  | 14 ++++++--------
>  fs/xfs/xfs_bmap_item.h  |  2 --
>  fs/xfs/xfs_trans_bmap.c | 16 ----------------
>  3 files changed, 6 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index 46dcadf790c2..40385c8b752a 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -212,22 +212,20 @@ static const struct xfs_item_ops xfs_bud_item_ops = {
>  	.iop_release	= xfs_bud_item_release,
>  };
>  
> -/*
> - * Allocate and initialize an bud item with the given number of extents.
> - */
>  struct xfs_bud_log_item *
> -xfs_bud_init(
> -	struct xfs_mount		*mp,
> +xfs_trans_get_bud(
> +	struct xfs_trans		*tp,
>  	struct xfs_bui_log_item		*buip)
> -
>  {
> -	struct xfs_bud_log_item	*budp;
> +	struct xfs_bud_log_item		*budp;
>  
>  	budp = kmem_zone_zalloc(xfs_bud_zone, KM_SLEEP);
> -	xfs_log_item_init(mp, &budp->bud_item, XFS_LI_BUD, &xfs_bud_item_ops);
> +	xfs_log_item_init(tp->t_mountp, &budp->bud_item, XFS_LI_BUD,
> +			  &xfs_bud_item_ops);
>  	budp->bud_buip = buip;
>  	budp->bud_format.bud_bui_id = buip->bui_format.bui_id;
>  
> +	xfs_trans_add_item(tp, &budp->bud_item);
>  	return budp;
>  }
>  
> diff --git a/fs/xfs/xfs_bmap_item.h b/fs/xfs/xfs_bmap_item.h
> index 89e043a88bb8..ad479cc73de8 100644
> --- a/fs/xfs/xfs_bmap_item.h
> +++ b/fs/xfs/xfs_bmap_item.h
> @@ -75,8 +75,6 @@ extern struct kmem_zone	*xfs_bui_zone;
>  extern struct kmem_zone	*xfs_bud_zone;
>  
>  struct xfs_bui_log_item *xfs_bui_init(struct xfs_mount *);
> -struct xfs_bud_log_item *xfs_bud_init(struct xfs_mount *,
> -		struct xfs_bui_log_item *);
>  void xfs_bui_item_free(struct xfs_bui_log_item *);
>  void xfs_bui_release(struct xfs_bui_log_item *);
>  int xfs_bui_recover(struct xfs_trans *parent_tp, struct xfs_bui_log_item *buip);
> diff --git a/fs/xfs/xfs_trans_bmap.c b/fs/xfs/xfs_trans_bmap.c
> index e1c7d55b32c3..c6f5b217d17c 100644
> --- a/fs/xfs/xfs_trans_bmap.c
> +++ b/fs/xfs/xfs_trans_bmap.c
> @@ -18,22 +18,6 @@
>  #include "xfs_bmap.h"
>  #include "xfs_inode.h"
>  
> -/*
> - * This routine is called to allocate a "bmap update done"
> - * log item.
> - */
> -struct xfs_bud_log_item *
> -xfs_trans_get_bud(
> -	struct xfs_trans		*tp,
> -	struct xfs_bui_log_item		*buip)
> -{
> -	struct xfs_bud_log_item		*budp;
> -
> -	budp = xfs_bud_init(tp->t_mountp, buip);
> -	xfs_trans_add_item(tp, &budp->bud_item);
> -	return budp;
> -}
> -
>  /*
>   * Finish an bmap update and log it to the BUD. Note that the
>   * transaction is marked dirty regardless of whether the bmap update
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c
  2019-05-17  7:31 ` [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c Christoph Hellwig
@ 2019-05-20 13:13   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:16AM +0200, Christoph Hellwig wrote:
> Keep all the extree item related code together in one file.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/Makefile            |   1 -
>  fs/xfs/xfs_extfree_item.c  | 247 ++++++++++++++++++++++++++++++++++-
>  fs/xfs/xfs_trans.h         |   8 --
>  fs/xfs/xfs_trans_extfree.c | 260 -------------------------------------
>  4 files changed, 246 insertions(+), 270 deletions(-)
>  delete mode 100644 fs/xfs/xfs_trans_extfree.c
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 1dfc6df2e2bd..771a4738abd2 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -106,7 +106,6 @@ xfs-y				+= xfs_log.o \
>  				   xfs_trans_ail.o \
>  				   xfs_trans_bmap.o \
>  				   xfs_trans_buf.o \
> -				   xfs_trans_extfree.o \
>  				   xfs_trans_inode.o \
>  				   xfs_trans_refcount.o \
>  				   xfs_trans_rmap.o \
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index ccf95cb8234c..219dbaf9d65b 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -5,11 +5,14 @@
>   */
>  #include "xfs.h"
>  #include "xfs_fs.h"
> +#include "xfs_shared.h"
>  #include "xfs_format.h"
>  #include "xfs_log_format.h"
>  #include "xfs_trans_resv.h"
>  #include "xfs_bit.h"
>  #include "xfs_mount.h"
> +#include "xfs_defer.h"
> +#include "xfs_trans.h"
>  #include "xfs_trans.h"
>  #include "xfs_trans_priv.h"
>  #include "xfs_buf_item.h"
> @@ -17,6 +20,9 @@
>  #include "xfs_log.h"
>  #include "xfs_btree.h"
>  #include "xfs_rmap.h"
> +#include "xfs_alloc.h"
> +#include "xfs_bmap.h"
> +#include "xfs_trace.h"
>  
>  
>  kmem_zone_t	*xfs_efi_zone;
> @@ -316,7 +322,7 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
>   * extents.  The caller must use all nextents extents, because we are not
>   * flexible about this at all.
>   */
> -struct xfs_efd_log_item *
> +static struct xfs_efd_log_item *
>  xfs_trans_get_efd(
>  	struct xfs_trans		*tp,
>  	struct xfs_efi_log_item		*efip,
> @@ -344,6 +350,245 @@ xfs_trans_get_efd(
>  	return efdp;
>  }
>  
> +/*
> + * Free an extent and log it to the EFD. Note that the transaction is marked
> + * dirty regardless of whether the extent free succeeds or fails to support the
> + * EFI/EFD lifecycle rules.
> + */
> +static int
> +xfs_trans_free_extent(
> +	struct xfs_trans		*tp,
> +	struct xfs_efd_log_item		*efdp,
> +	xfs_fsblock_t			start_block,
> +	xfs_extlen_t			ext_len,
> +	const struct xfs_owner_info	*oinfo,
> +	bool				skip_discard)
> +{
> +	struct xfs_mount		*mp = tp->t_mountp;
> +	struct xfs_extent		*extp;
> +	uint				next_extent;
> +	xfs_agnumber_t			agno = XFS_FSB_TO_AGNO(mp, start_block);
> +	xfs_agblock_t			agbno = XFS_FSB_TO_AGBNO(mp,
> +								start_block);
> +	int				error;
> +
> +	trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
> +
> +	error = __xfs_free_extent(tp, start_block, ext_len,
> +				  oinfo, XFS_AG_RESV_NONE, skip_discard);
> +	/*
> +	 * Mark the transaction dirty, even on error. This ensures the
> +	 * transaction is aborted, which:
> +	 *
> +	 * 1.) releases the EFI and frees the EFD
> +	 * 2.) shuts down the filesystem
> +	 */
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
> +
> +	next_extent = efdp->efd_next_extent;
> +	ASSERT(next_extent < efdp->efd_format.efd_nextents);
> +	extp = &(efdp->efd_format.efd_extents[next_extent]);
> +	extp->ext_start = start_block;
> +	extp->ext_len = ext_len;
> +	efdp->efd_next_extent++;
> +
> +	return error;
> +}
> +
> +/* Sort bmap items by AG. */
> +static int
> +xfs_extent_free_diff_items(
> +	void				*priv,
> +	struct list_head		*a,
> +	struct list_head		*b)
> +{
> +	struct xfs_mount		*mp = priv;
> +	struct xfs_extent_free_item	*ra;
> +	struct xfs_extent_free_item	*rb;
> +
> +	ra = container_of(a, struct xfs_extent_free_item, xefi_list);
> +	rb = container_of(b, struct xfs_extent_free_item, xefi_list);
> +	return  XFS_FSB_TO_AGNO(mp, ra->xefi_startblock) -
> +		XFS_FSB_TO_AGNO(mp, rb->xefi_startblock);
> +}
> +
> +/* Get an EFI. */
> +STATIC void *
> +xfs_extent_free_create_intent(
> +	struct xfs_trans		*tp,
> +	unsigned int			count)
> +{
> +	struct xfs_efi_log_item		*efip;
> +
> +	ASSERT(tp != NULL);
> +	ASSERT(count > 0);
> +
> +	efip = xfs_efi_init(tp->t_mountp, count);
> +	ASSERT(efip != NULL);
> +
> +	/*
> +	 * Get a log_item_desc to point at the new item.
> +	 */
> +	xfs_trans_add_item(tp, &efip->efi_item);
> +	return efip;
> +}
> +
> +/* Log a free extent to the intent item. */
> +STATIC void
> +xfs_extent_free_log_item(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	struct list_head		*item)
> +{
> +	struct xfs_efi_log_item		*efip = intent;
> +	struct xfs_extent_free_item	*free;
> +	uint				next_extent;
> +	struct xfs_extent		*extp;
> +
> +	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> +
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
> +
> +	/*
> +	 * atomic_inc_return gives us the value after the increment;
> +	 * we want to use it as an array index so we need to subtract 1 from
> +	 * it.
> +	 */
> +	next_extent = atomic_inc_return(&efip->efi_next_extent) - 1;
> +	ASSERT(next_extent < efip->efi_format.efi_nextents);
> +	extp = &efip->efi_format.efi_extents[next_extent];
> +	extp->ext_start = free->xefi_startblock;
> +	extp->ext_len = free->xefi_blockcount;
> +}
> +
> +/* Get an EFD so we can process all the free extents. */
> +STATIC void *
> +xfs_extent_free_create_done(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	unsigned int			count)
> +{
> +	return xfs_trans_get_efd(tp, intent, count);
> +}
> +
> +/* Process a free extent. */
> +STATIC int
> +xfs_extent_free_finish_item(
> +	struct xfs_trans		*tp,
> +	struct list_head		*item,
> +	void				*done_item,
> +	void				**state)
> +{
> +	struct xfs_extent_free_item	*free;
> +	int				error;
> +
> +	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> +	error = xfs_trans_free_extent(tp, done_item,
> +			free->xefi_startblock,
> +			free->xefi_blockcount,
> +			&free->xefi_oinfo, free->xefi_skip_discard);
> +	kmem_free(free);
> +	return error;
> +}
> +
> +/* Abort all pending EFIs. */
> +STATIC void
> +xfs_extent_free_abort_intent(
> +	void				*intent)
> +{
> +	xfs_efi_release(intent);
> +}
> +
> +/* Cancel a free extent. */
> +STATIC void
> +xfs_extent_free_cancel_item(
> +	struct list_head		*item)
> +{
> +	struct xfs_extent_free_item	*free;
> +
> +	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> +	kmem_free(free);
> +}
> +
> +const struct xfs_defer_op_type xfs_extent_free_defer_type = {
> +	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
> +	.diff_items	= xfs_extent_free_diff_items,
> +	.create_intent	= xfs_extent_free_create_intent,
> +	.abort_intent	= xfs_extent_free_abort_intent,
> +	.log_item	= xfs_extent_free_log_item,
> +	.create_done	= xfs_extent_free_create_done,
> +	.finish_item	= xfs_extent_free_finish_item,
> +	.cancel_item	= xfs_extent_free_cancel_item,
> +};
> +
> +/*
> + * AGFL blocks are accounted differently in the reserve pools and are not
> + * inserted into the busy extent list.
> + */
> +STATIC int
> +xfs_agfl_free_finish_item(
> +	struct xfs_trans		*tp,
> +	struct list_head		*item,
> +	void				*done_item,
> +	void				**state)
> +{
> +	struct xfs_mount		*mp = tp->t_mountp;
> +	struct xfs_efd_log_item		*efdp = done_item;
> +	struct xfs_extent_free_item	*free;
> +	struct xfs_extent		*extp;
> +	struct xfs_buf			*agbp;
> +	int				error;
> +	xfs_agnumber_t			agno;
> +	xfs_agblock_t			agbno;
> +	uint				next_extent;
> +
> +	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> +	ASSERT(free->xefi_blockcount == 1);
> +	agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
> +	agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
> +
> +	trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
> +
> +	error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
> +	if (!error)
> +		error = xfs_free_agfl_block(tp, agno, agbno, agbp,
> +					    &free->xefi_oinfo);
> +
> +	/*
> +	 * Mark the transaction dirty, even on error. This ensures the
> +	 * transaction is aborted, which:
> +	 *
> +	 * 1.) releases the EFI and frees the EFD
> +	 * 2.) shuts down the filesystem
> +	 */
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
> +
> +	next_extent = efdp->efd_next_extent;
> +	ASSERT(next_extent < efdp->efd_format.efd_nextents);
> +	extp = &(efdp->efd_format.efd_extents[next_extent]);
> +	extp->ext_start = free->xefi_startblock;
> +	extp->ext_len = free->xefi_blockcount;
> +	efdp->efd_next_extent++;
> +
> +	kmem_free(free);
> +	return error;
> +}
> +
> +/* sub-type with special handling for AGFL deferred frees */
> +const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
> +	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
> +	.diff_items	= xfs_extent_free_diff_items,
> +	.create_intent	= xfs_extent_free_create_intent,
> +	.abort_intent	= xfs_extent_free_abort_intent,
> +	.log_item	= xfs_extent_free_log_item,
> +	.create_done	= xfs_extent_free_create_done,
> +	.finish_item	= xfs_agfl_free_finish_item,
> +	.cancel_item	= xfs_extent_free_cancel_item,
> +};
> +
>  /*
>   * Process an extent free intent item that was recovered from
>   * the log.  We need to free the extents that it describes.
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 7a6ee0c2ce20..cc6549100176 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -230,14 +230,6 @@ 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);
>  
> -struct xfs_efd_log_item	*xfs_trans_get_efd(struct xfs_trans *,
> -				  struct xfs_efi_log_item *,
> -				  uint);
> -int		xfs_trans_free_extent(struct xfs_trans *,
> -				      struct xfs_efd_log_item *, xfs_fsblock_t,
> -				      xfs_extlen_t,
> -				      const struct xfs_owner_info *,
> -				      bool);
>  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 *);
> diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
> deleted file mode 100644
> index 20ab1c9d758f..000000000000
> --- a/fs/xfs/xfs_trans_extfree.c
> +++ /dev/null
> @@ -1,260 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Copyright (c) 2000,2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - */
> -#include "xfs.h"
> -#include "xfs_fs.h"
> -#include "xfs_shared.h"
> -#include "xfs_format.h"
> -#include "xfs_log_format.h"
> -#include "xfs_trans_resv.h"
> -#include "xfs_bit.h"
> -#include "xfs_mount.h"
> -#include "xfs_defer.h"
> -#include "xfs_trans.h"
> -#include "xfs_trans_priv.h"
> -#include "xfs_extfree_item.h"
> -#include "xfs_alloc.h"
> -#include "xfs_bmap.h"
> -#include "xfs_trace.h"
> -
> -/*
> - * Free an extent and log it to the EFD. Note that the transaction is marked
> - * dirty regardless of whether the extent free succeeds or fails to support the
> - * EFI/EFD lifecycle rules.
> - */
> -int
> -xfs_trans_free_extent(
> -	struct xfs_trans		*tp,
> -	struct xfs_efd_log_item		*efdp,
> -	xfs_fsblock_t			start_block,
> -	xfs_extlen_t			ext_len,
> -	const struct xfs_owner_info	*oinfo,
> -	bool				skip_discard)
> -{
> -	struct xfs_mount		*mp = tp->t_mountp;
> -	struct xfs_extent		*extp;
> -	uint				next_extent;
> -	xfs_agnumber_t			agno = XFS_FSB_TO_AGNO(mp, start_block);
> -	xfs_agblock_t			agbno = XFS_FSB_TO_AGBNO(mp,
> -								start_block);
> -	int				error;
> -
> -	trace_xfs_bmap_free_deferred(tp->t_mountp, agno, 0, agbno, ext_len);
> -
> -	error = __xfs_free_extent(tp, start_block, ext_len,
> -				  oinfo, XFS_AG_RESV_NONE, skip_discard);
> -	/*
> -	 * Mark the transaction dirty, even on error. This ensures the
> -	 * transaction is aborted, which:
> -	 *
> -	 * 1.) releases the EFI and frees the EFD
> -	 * 2.) shuts down the filesystem
> -	 */
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
> -
> -	next_extent = efdp->efd_next_extent;
> -	ASSERT(next_extent < efdp->efd_format.efd_nextents);
> -	extp = &(efdp->efd_format.efd_extents[next_extent]);
> -	extp->ext_start = start_block;
> -	extp->ext_len = ext_len;
> -	efdp->efd_next_extent++;
> -
> -	return error;
> -}
> -
> -/* Sort bmap items by AG. */
> -static int
> -xfs_extent_free_diff_items(
> -	void				*priv,
> -	struct list_head		*a,
> -	struct list_head		*b)
> -{
> -	struct xfs_mount		*mp = priv;
> -	struct xfs_extent_free_item	*ra;
> -	struct xfs_extent_free_item	*rb;
> -
> -	ra = container_of(a, struct xfs_extent_free_item, xefi_list);
> -	rb = container_of(b, struct xfs_extent_free_item, xefi_list);
> -	return  XFS_FSB_TO_AGNO(mp, ra->xefi_startblock) -
> -		XFS_FSB_TO_AGNO(mp, rb->xefi_startblock);
> -}
> -
> -/* Get an EFI. */
> -STATIC void *
> -xfs_extent_free_create_intent(
> -	struct xfs_trans		*tp,
> -	unsigned int			count)
> -{
> -	struct xfs_efi_log_item		*efip;
> -
> -	ASSERT(tp != NULL);
> -	ASSERT(count > 0);
> -
> -	efip = xfs_efi_init(tp->t_mountp, count);
> -	ASSERT(efip != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &efip->efi_item);
> -	return efip;
> -}
> -
> -/* Log a free extent to the intent item. */
> -STATIC void
> -xfs_extent_free_log_item(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	struct list_head		*item)
> -{
> -	struct xfs_efi_log_item		*efip = intent;
> -	struct xfs_extent_free_item	*free;
> -	uint				next_extent;
> -	struct xfs_extent		*extp;
> -
> -	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> -
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags);
> -
> -	/*
> -	 * atomic_inc_return gives us the value after the increment;
> -	 * we want to use it as an array index so we need to subtract 1 from
> -	 * it.
> -	 */
> -	next_extent = atomic_inc_return(&efip->efi_next_extent) - 1;
> -	ASSERT(next_extent < efip->efi_format.efi_nextents);
> -	extp = &efip->efi_format.efi_extents[next_extent];
> -	extp->ext_start = free->xefi_startblock;
> -	extp->ext_len = free->xefi_blockcount;
> -}
> -
> -/* Get an EFD so we can process all the free extents. */
> -STATIC void *
> -xfs_extent_free_create_done(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	unsigned int			count)
> -{
> -	return xfs_trans_get_efd(tp, intent, count);
> -}
> -
> -/* Process a free extent. */
> -STATIC int
> -xfs_extent_free_finish_item(
> -	struct xfs_trans		*tp,
> -	struct list_head		*item,
> -	void				*done_item,
> -	void				**state)
> -{
> -	struct xfs_extent_free_item	*free;
> -	int				error;
> -
> -	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> -	error = xfs_trans_free_extent(tp, done_item,
> -			free->xefi_startblock,
> -			free->xefi_blockcount,
> -			&free->xefi_oinfo, free->xefi_skip_discard);
> -	kmem_free(free);
> -	return error;
> -}
> -
> -/* Abort all pending EFIs. */
> -STATIC void
> -xfs_extent_free_abort_intent(
> -	void				*intent)
> -{
> -	xfs_efi_release(intent);
> -}
> -
> -/* Cancel a free extent. */
> -STATIC void
> -xfs_extent_free_cancel_item(
> -	struct list_head		*item)
> -{
> -	struct xfs_extent_free_item	*free;
> -
> -	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> -	kmem_free(free);
> -}
> -
> -const struct xfs_defer_op_type xfs_extent_free_defer_type = {
> -	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
> -	.diff_items	= xfs_extent_free_diff_items,
> -	.create_intent	= xfs_extent_free_create_intent,
> -	.abort_intent	= xfs_extent_free_abort_intent,
> -	.log_item	= xfs_extent_free_log_item,
> -	.create_done	= xfs_extent_free_create_done,
> -	.finish_item	= xfs_extent_free_finish_item,
> -	.cancel_item	= xfs_extent_free_cancel_item,
> -};
> -
> -/*
> - * AGFL blocks are accounted differently in the reserve pools and are not
> - * inserted into the busy extent list.
> - */
> -STATIC int
> -xfs_agfl_free_finish_item(
> -	struct xfs_trans		*tp,
> -	struct list_head		*item,
> -	void				*done_item,
> -	void				**state)
> -{
> -	struct xfs_mount		*mp = tp->t_mountp;
> -	struct xfs_efd_log_item		*efdp = done_item;
> -	struct xfs_extent_free_item	*free;
> -	struct xfs_extent		*extp;
> -	struct xfs_buf			*agbp;
> -	int				error;
> -	xfs_agnumber_t			agno;
> -	xfs_agblock_t			agbno;
> -	uint				next_extent;
> -
> -	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> -	ASSERT(free->xefi_blockcount == 1);
> -	agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
> -	agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
> -
> -	trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
> -
> -	error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
> -	if (!error)
> -		error = xfs_free_agfl_block(tp, agno, agbno, agbp,
> -					    &free->xefi_oinfo);
> -
> -	/*
> -	 * Mark the transaction dirty, even on error. This ensures the
> -	 * transaction is aborted, which:
> -	 *
> -	 * 1.) releases the EFI and frees the EFD
> -	 * 2.) shuts down the filesystem
> -	 */
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags);
> -
> -	next_extent = efdp->efd_next_extent;
> -	ASSERT(next_extent < efdp->efd_format.efd_nextents);
> -	extp = &(efdp->efd_format.efd_extents[next_extent]);
> -	extp->ext_start = free->xefi_startblock;
> -	extp->ext_len = free->xefi_blockcount;
> -	efdp->efd_next_extent++;
> -
> -	kmem_free(free);
> -	return error;
> -}
> -
> -
> -/* sub-type with special handling for AGFL deferred frees */
> -const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
> -	.max_items	= XFS_EFI_MAX_FAST_EXTENTS,
> -	.diff_items	= xfs_extent_free_diff_items,
> -	.create_intent	= xfs_extent_free_create_intent,
> -	.abort_intent	= xfs_extent_free_abort_intent,
> -	.log_item	= xfs_extent_free_log_item,
> -	.create_done	= xfs_extent_free_create_done,
> -	.finish_item	= xfs_agfl_free_finish_item,
> -	.cancel_item	= xfs_extent_free_cancel_item,
> -};
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c
  2019-05-17  7:31 ` [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c Christoph Hellwig
@ 2019-05-20 13:14   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:14 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:17AM +0200, Christoph Hellwig wrote:
> Keep all the refcount item related code together in one file.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/Makefile             |   1 -
>  fs/xfs/xfs_refcount_item.c  | 208 ++++++++++++++++++++++++++++++++-
>  fs/xfs/xfs_trans.h          |  11 --
>  fs/xfs/xfs_trans_refcount.c | 224 ------------------------------------
>  4 files changed, 207 insertions(+), 237 deletions(-)
>  delete mode 100644 fs/xfs/xfs_trans_refcount.c
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 771a4738abd2..26f8c51d8803 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -107,7 +107,6 @@ xfs-y				+= xfs_log.o \
>  				   xfs_trans_bmap.o \
>  				   xfs_trans_buf.o \
>  				   xfs_trans_inode.o \
> -				   xfs_trans_refcount.o \
>  				   xfs_trans_rmap.o \
>  
>  # optional features
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index 70dcdf40ac92..7bcc49ee5885 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -217,7 +217,7 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
>  	.iop_release	= xfs_cud_item_release,
>  };
>  
> -struct xfs_cud_log_item *
> +static struct xfs_cud_log_item *
>  xfs_trans_get_cud(
>  	struct xfs_trans		*tp,
>  	struct xfs_cui_log_item		*cuip)
> @@ -234,6 +234,212 @@ xfs_trans_get_cud(
>  	return cudp;
>  }
>  
> +/*
> + * Finish an refcount update and log it to the CUD. Note that the
> + * transaction is marked dirty regardless of whether the refcount
> + * update succeeds or fails to support the CUI/CUD lifecycle rules.
> + */
> +static int
> +xfs_trans_log_finish_refcount_update(
> +	struct xfs_trans		*tp,
> +	struct xfs_cud_log_item		*cudp,
> +	enum xfs_refcount_intent_type	type,
> +	xfs_fsblock_t			startblock,
> +	xfs_extlen_t			blockcount,
> +	xfs_fsblock_t			*new_fsb,
> +	xfs_extlen_t			*new_len,
> +	struct xfs_btree_cur		**pcur)
> +{
> +	int				error;
> +
> +	error = xfs_refcount_finish_one(tp, type, startblock,
> +			blockcount, new_fsb, new_len, pcur);
> +
> +	/*
> +	 * Mark the transaction dirty, even on error. This ensures the
> +	 * transaction is aborted, which:
> +	 *
> +	 * 1.) releases the CUI and frees the CUD
> +	 * 2.) shuts down the filesystem
> +	 */
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &cudp->cud_item.li_flags);
> +
> +	return error;
> +}
> +
> +/* Sort refcount intents by AG. */
> +static int
> +xfs_refcount_update_diff_items(
> +	void				*priv,
> +	struct list_head		*a,
> +	struct list_head		*b)
> +{
> +	struct xfs_mount		*mp = priv;
> +	struct xfs_refcount_intent	*ra;
> +	struct xfs_refcount_intent	*rb;
> +
> +	ra = container_of(a, struct xfs_refcount_intent, ri_list);
> +	rb = container_of(b, struct xfs_refcount_intent, ri_list);
> +	return  XFS_FSB_TO_AGNO(mp, ra->ri_startblock) -
> +		XFS_FSB_TO_AGNO(mp, rb->ri_startblock);
> +}
> +
> +/* Get an CUI. */
> +STATIC void *
> +xfs_refcount_update_create_intent(
> +	struct xfs_trans		*tp,
> +	unsigned int			count)
> +{
> +	struct xfs_cui_log_item		*cuip;
> +
> +	ASSERT(tp != NULL);
> +	ASSERT(count > 0);
> +
> +	cuip = xfs_cui_init(tp->t_mountp, count);
> +	ASSERT(cuip != NULL);
> +
> +	/*
> +	 * Get a log_item_desc to point at the new item.
> +	 */
> +	xfs_trans_add_item(tp, &cuip->cui_item);
> +	return cuip;
> +}
> +
> +/* Set the phys extent flags for this reverse mapping. */
> +static void
> +xfs_trans_set_refcount_flags(
> +	struct xfs_phys_extent		*refc,
> +	enum xfs_refcount_intent_type	type)
> +{
> +	refc->pe_flags = 0;
> +	switch (type) {
> +	case XFS_REFCOUNT_INCREASE:
> +	case XFS_REFCOUNT_DECREASE:
> +	case XFS_REFCOUNT_ALLOC_COW:
> +	case XFS_REFCOUNT_FREE_COW:
> +		refc->pe_flags |= type;
> +		break;
> +	default:
> +		ASSERT(0);
> +	}
> +}
> +
> +/* Log refcount updates in the intent item. */
> +STATIC void
> +xfs_refcount_update_log_item(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	struct list_head		*item)
> +{
> +	struct xfs_cui_log_item		*cuip = intent;
> +	struct xfs_refcount_intent	*refc;
> +	uint				next_extent;
> +	struct xfs_phys_extent		*ext;
> +
> +	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> +
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags);
> +
> +	/*
> +	 * atomic_inc_return gives us the value after the increment;
> +	 * we want to use it as an array index so we need to subtract 1 from
> +	 * it.
> +	 */
> +	next_extent = atomic_inc_return(&cuip->cui_next_extent) - 1;
> +	ASSERT(next_extent < cuip->cui_format.cui_nextents);
> +	ext = &cuip->cui_format.cui_extents[next_extent];
> +	ext->pe_startblock = refc->ri_startblock;
> +	ext->pe_len = refc->ri_blockcount;
> +	xfs_trans_set_refcount_flags(ext, refc->ri_type);
> +}
> +
> +/* Get an CUD so we can process all the deferred refcount updates. */
> +STATIC void *
> +xfs_refcount_update_create_done(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	unsigned int			count)
> +{
> +	return xfs_trans_get_cud(tp, intent);
> +}
> +
> +/* Process a deferred refcount update. */
> +STATIC int
> +xfs_refcount_update_finish_item(
> +	struct xfs_trans		*tp,
> +	struct list_head		*item,
> +	void				*done_item,
> +	void				**state)
> +{
> +	struct xfs_refcount_intent	*refc;
> +	xfs_fsblock_t			new_fsb;
> +	xfs_extlen_t			new_aglen;
> +	int				error;
> +
> +	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> +	error = xfs_trans_log_finish_refcount_update(tp, done_item,
> +			refc->ri_type,
> +			refc->ri_startblock,
> +			refc->ri_blockcount,
> +			&new_fsb, &new_aglen,
> +			(struct xfs_btree_cur **)state);
> +	/* Did we run out of reservation?  Requeue what we didn't finish. */
> +	if (!error && new_aglen > 0) {
> +		ASSERT(refc->ri_type == XFS_REFCOUNT_INCREASE ||
> +		       refc->ri_type == XFS_REFCOUNT_DECREASE);
> +		refc->ri_startblock = new_fsb;
> +		refc->ri_blockcount = new_aglen;
> +		return -EAGAIN;
> +	}
> +	kmem_free(refc);
> +	return error;
> +}
> +
> +/* Clean up after processing deferred refcounts. */
> +STATIC void
> +xfs_refcount_update_finish_cleanup(
> +	struct xfs_trans	*tp,
> +	void			*state,
> +	int			error)
> +{
> +	struct xfs_btree_cur	*rcur = state;
> +
> +	xfs_refcount_finish_one_cleanup(tp, rcur, error);
> +}
> +
> +/* Abort all pending CUIs. */
> +STATIC void
> +xfs_refcount_update_abort_intent(
> +	void				*intent)
> +{
> +	xfs_cui_release(intent);
> +}
> +
> +/* Cancel a deferred refcount update. */
> +STATIC void
> +xfs_refcount_update_cancel_item(
> +	struct list_head		*item)
> +{
> +	struct xfs_refcount_intent	*refc;
> +
> +	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> +	kmem_free(refc);
> +}
> +
> +const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
> +	.max_items	= XFS_CUI_MAX_FAST_EXTENTS,
> +	.diff_items	= xfs_refcount_update_diff_items,
> +	.create_intent	= xfs_refcount_update_create_intent,
> +	.abort_intent	= xfs_refcount_update_abort_intent,
> +	.log_item	= xfs_refcount_update_log_item,
> +	.create_done	= xfs_refcount_update_create_done,
> +	.finish_item	= xfs_refcount_update_finish_item,
> +	.finish_cleanup = xfs_refcount_update_finish_cleanup,
> +	.cancel_item	= xfs_refcount_update_cancel_item,
> +};
> +
>  /*
>   * Process a refcount update intent item that was recovered from the log.
>   * We need to update the refcountbt.
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index cc6549100176..1fe910d6da82 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -255,17 +255,6 @@ int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
>  		xfs_fsblock_t startblock, xfs_filblks_t blockcount,
>  		xfs_exntst_t state, struct xfs_btree_cur **pcur);
>  
> -/* refcount updates */
> -enum xfs_refcount_intent_type;
> -
> -struct xfs_cud_log_item *xfs_trans_get_cud(struct xfs_trans *tp,
> -		struct xfs_cui_log_item *cuip);
> -int xfs_trans_log_finish_refcount_update(struct xfs_trans *tp,
> -		struct xfs_cud_log_item *cudp,
> -		enum xfs_refcount_intent_type type, xfs_fsblock_t startblock,
> -		xfs_extlen_t blockcount, xfs_fsblock_t *new_fsb,
> -		xfs_extlen_t *new_len, struct xfs_btree_cur **pcur);
> -
>  /* mapping updates */
>  enum xfs_bmap_intent_type;
>  
> diff --git a/fs/xfs/xfs_trans_refcount.c b/fs/xfs/xfs_trans_refcount.c
> deleted file mode 100644
> index d793fb500378..000000000000
> --- a/fs/xfs/xfs_trans_refcount.c
> +++ /dev/null
> @@ -1,224 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * Copyright (C) 2016 Oracle.  All Rights Reserved.
> - * Author: Darrick J. Wong <darrick.wong@oracle.com>
> - */
> -#include "xfs.h"
> -#include "xfs_fs.h"
> -#include "xfs_shared.h"
> -#include "xfs_format.h"
> -#include "xfs_log_format.h"
> -#include "xfs_trans_resv.h"
> -#include "xfs_mount.h"
> -#include "xfs_defer.h"
> -#include "xfs_trans.h"
> -#include "xfs_trans_priv.h"
> -#include "xfs_refcount_item.h"
> -#include "xfs_alloc.h"
> -#include "xfs_refcount.h"
> -
> -/*
> - * Finish an refcount update and log it to the CUD. Note that the
> - * transaction is marked dirty regardless of whether the refcount
> - * update succeeds or fails to support the CUI/CUD lifecycle rules.
> - */
> -int
> -xfs_trans_log_finish_refcount_update(
> -	struct xfs_trans		*tp,
> -	struct xfs_cud_log_item		*cudp,
> -	enum xfs_refcount_intent_type	type,
> -	xfs_fsblock_t			startblock,
> -	xfs_extlen_t			blockcount,
> -	xfs_fsblock_t			*new_fsb,
> -	xfs_extlen_t			*new_len,
> -	struct xfs_btree_cur		**pcur)
> -{
> -	int				error;
> -
> -	error = xfs_refcount_finish_one(tp, type, startblock,
> -			blockcount, new_fsb, new_len, pcur);
> -
> -	/*
> -	 * Mark the transaction dirty, even on error. This ensures the
> -	 * transaction is aborted, which:
> -	 *
> -	 * 1.) releases the CUI and frees the CUD
> -	 * 2.) shuts down the filesystem
> -	 */
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &cudp->cud_item.li_flags);
> -
> -	return error;
> -}
> -
> -/* Sort refcount intents by AG. */
> -static int
> -xfs_refcount_update_diff_items(
> -	void				*priv,
> -	struct list_head		*a,
> -	struct list_head		*b)
> -{
> -	struct xfs_mount		*mp = priv;
> -	struct xfs_refcount_intent	*ra;
> -	struct xfs_refcount_intent	*rb;
> -
> -	ra = container_of(a, struct xfs_refcount_intent, ri_list);
> -	rb = container_of(b, struct xfs_refcount_intent, ri_list);
> -	return  XFS_FSB_TO_AGNO(mp, ra->ri_startblock) -
> -		XFS_FSB_TO_AGNO(mp, rb->ri_startblock);
> -}
> -
> -/* Get an CUI. */
> -STATIC void *
> -xfs_refcount_update_create_intent(
> -	struct xfs_trans		*tp,
> -	unsigned int			count)
> -{
> -	struct xfs_cui_log_item		*cuip;
> -
> -	ASSERT(tp != NULL);
> -	ASSERT(count > 0);
> -
> -	cuip = xfs_cui_init(tp->t_mountp, count);
> -	ASSERT(cuip != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &cuip->cui_item);
> -	return cuip;
> -}
> -
> -/* Set the phys extent flags for this reverse mapping. */
> -static void
> -xfs_trans_set_refcount_flags(
> -	struct xfs_phys_extent		*refc,
> -	enum xfs_refcount_intent_type	type)
> -{
> -	refc->pe_flags = 0;
> -	switch (type) {
> -	case XFS_REFCOUNT_INCREASE:
> -	case XFS_REFCOUNT_DECREASE:
> -	case XFS_REFCOUNT_ALLOC_COW:
> -	case XFS_REFCOUNT_FREE_COW:
> -		refc->pe_flags |= type;
> -		break;
> -	default:
> -		ASSERT(0);
> -	}
> -}
> -
> -/* Log refcount updates in the intent item. */
> -STATIC void
> -xfs_refcount_update_log_item(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	struct list_head		*item)
> -{
> -	struct xfs_cui_log_item		*cuip = intent;
> -	struct xfs_refcount_intent	*refc;
> -	uint				next_extent;
> -	struct xfs_phys_extent		*ext;
> -
> -	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> -
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags);
> -
> -	/*
> -	 * atomic_inc_return gives us the value after the increment;
> -	 * we want to use it as an array index so we need to subtract 1 from
> -	 * it.
> -	 */
> -	next_extent = atomic_inc_return(&cuip->cui_next_extent) - 1;
> -	ASSERT(next_extent < cuip->cui_format.cui_nextents);
> -	ext = &cuip->cui_format.cui_extents[next_extent];
> -	ext->pe_startblock = refc->ri_startblock;
> -	ext->pe_len = refc->ri_blockcount;
> -	xfs_trans_set_refcount_flags(ext, refc->ri_type);
> -}
> -
> -/* Get an CUD so we can process all the deferred refcount updates. */
> -STATIC void *
> -xfs_refcount_update_create_done(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	unsigned int			count)
> -{
> -	return xfs_trans_get_cud(tp, intent);
> -}
> -
> -/* Process a deferred refcount update. */
> -STATIC int
> -xfs_refcount_update_finish_item(
> -	struct xfs_trans		*tp,
> -	struct list_head		*item,
> -	void				*done_item,
> -	void				**state)
> -{
> -	struct xfs_refcount_intent	*refc;
> -	xfs_fsblock_t			new_fsb;
> -	xfs_extlen_t			new_aglen;
> -	int				error;
> -
> -	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> -	error = xfs_trans_log_finish_refcount_update(tp, done_item,
> -			refc->ri_type,
> -			refc->ri_startblock,
> -			refc->ri_blockcount,
> -			&new_fsb, &new_aglen,
> -			(struct xfs_btree_cur **)state);
> -	/* Did we run out of reservation?  Requeue what we didn't finish. */
> -	if (!error && new_aglen > 0) {
> -		ASSERT(refc->ri_type == XFS_REFCOUNT_INCREASE ||
> -		       refc->ri_type == XFS_REFCOUNT_DECREASE);
> -		refc->ri_startblock = new_fsb;
> -		refc->ri_blockcount = new_aglen;
> -		return -EAGAIN;
> -	}
> -	kmem_free(refc);
> -	return error;
> -}
> -
> -/* Clean up after processing deferred refcounts. */
> -STATIC void
> -xfs_refcount_update_finish_cleanup(
> -	struct xfs_trans	*tp,
> -	void			*state,
> -	int			error)
> -{
> -	struct xfs_btree_cur	*rcur = state;
> -
> -	xfs_refcount_finish_one_cleanup(tp, rcur, error);
> -}
> -
> -/* Abort all pending CUIs. */
> -STATIC void
> -xfs_refcount_update_abort_intent(
> -	void				*intent)
> -{
> -	xfs_cui_release(intent);
> -}
> -
> -/* Cancel a deferred refcount update. */
> -STATIC void
> -xfs_refcount_update_cancel_item(
> -	struct list_head		*item)
> -{
> -	struct xfs_refcount_intent	*refc;
> -
> -	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> -	kmem_free(refc);
> -}
> -
> -const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
> -	.max_items	= XFS_CUI_MAX_FAST_EXTENTS,
> -	.diff_items	= xfs_refcount_update_diff_items,
> -	.create_intent	= xfs_refcount_update_create_intent,
> -	.abort_intent	= xfs_refcount_update_abort_intent,
> -	.log_item	= xfs_refcount_update_log_item,
> -	.create_done	= xfs_refcount_update_create_done,
> -	.finish_item	= xfs_refcount_update_finish_item,
> -	.finish_cleanup = xfs_refcount_update_finish_cleanup,
> -	.cancel_item	= xfs_refcount_update_cancel_item,
> -};
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c
  2019-05-17  7:31 ` [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c Christoph Hellwig
@ 2019-05-20 13:14   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:14 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:18AM +0200, Christoph Hellwig wrote:
> Keep all rmap item related code together in one file.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/Makefile         |   3 +-
>  fs/xfs/xfs_rmap_item.c  | 229 ++++++++++++++++++++++++++++++++++++-
>  fs/xfs/xfs_trans.h      |  11 --
>  fs/xfs/xfs_trans_rmap.c | 245 ----------------------------------------
>  4 files changed, 229 insertions(+), 259 deletions(-)
>  delete mode 100644 fs/xfs/xfs_trans_rmap.c
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 26f8c51d8803..1730664770c5 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -106,8 +106,7 @@ xfs-y				+= xfs_log.o \
>  				   xfs_trans_ail.o \
>  				   xfs_trans_bmap.o \
>  				   xfs_trans_buf.o \
> -				   xfs_trans_inode.o \
> -				   xfs_trans_rmap.o \
> +				   xfs_trans_inode.o
>  
>  # optional features
>  xfs-$(CONFIG_XFS_QUOTA)		+= xfs_dquot.o \
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index 5f11e6d43484..6da664ae97e2 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -238,7 +238,7 @@ static const struct xfs_item_ops xfs_rud_item_ops = {
>  	.iop_release	= xfs_rud_item_release,
>  };
>  
> -struct xfs_rud_log_item *
> +static struct xfs_rud_log_item *
>  xfs_trans_get_rud(
>  	struct xfs_trans		*tp,
>  	struct xfs_rui_log_item		*ruip)
> @@ -255,6 +255,233 @@ xfs_trans_get_rud(
>  	return rudp;
>  }
>  
> +/* Set the map extent flags for this reverse mapping. */
> +static void
> +xfs_trans_set_rmap_flags(
> +	struct xfs_map_extent		*rmap,
> +	enum xfs_rmap_intent_type	type,
> +	int				whichfork,
> +	xfs_exntst_t			state)
> +{
> +	rmap->me_flags = 0;
> +	if (state == XFS_EXT_UNWRITTEN)
> +		rmap->me_flags |= XFS_RMAP_EXTENT_UNWRITTEN;
> +	if (whichfork == XFS_ATTR_FORK)
> +		rmap->me_flags |= XFS_RMAP_EXTENT_ATTR_FORK;
> +	switch (type) {
> +	case XFS_RMAP_MAP:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_MAP;
> +		break;
> +	case XFS_RMAP_MAP_SHARED:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_MAP_SHARED;
> +		break;
> +	case XFS_RMAP_UNMAP:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP;
> +		break;
> +	case XFS_RMAP_UNMAP_SHARED:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP_SHARED;
> +		break;
> +	case XFS_RMAP_CONVERT:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT;
> +		break;
> +	case XFS_RMAP_CONVERT_SHARED:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT_SHARED;
> +		break;
> +	case XFS_RMAP_ALLOC:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_ALLOC;
> +		break;
> +	case XFS_RMAP_FREE:
> +		rmap->me_flags |= XFS_RMAP_EXTENT_FREE;
> +		break;
> +	default:
> +		ASSERT(0);
> +	}
> +}
> +
> +/*
> + * Finish an rmap update and log it to the RUD. Note that the transaction is
> + * marked dirty regardless of whether the rmap update succeeds or fails to
> + * support the RUI/RUD lifecycle rules.
> + */
> +static int
> +xfs_trans_log_finish_rmap_update(
> +	struct xfs_trans		*tp,
> +	struct xfs_rud_log_item		*rudp,
> +	enum xfs_rmap_intent_type	type,
> +	uint64_t			owner,
> +	int				whichfork,
> +	xfs_fileoff_t			startoff,
> +	xfs_fsblock_t			startblock,
> +	xfs_filblks_t			blockcount,
> +	xfs_exntst_t			state,
> +	struct xfs_btree_cur		**pcur)
> +{
> +	int				error;
> +
> +	error = xfs_rmap_finish_one(tp, type, owner, whichfork, startoff,
> +			startblock, blockcount, state, pcur);
> +
> +	/*
> +	 * Mark the transaction dirty, even on error. This ensures the
> +	 * transaction is aborted, which:
> +	 *
> +	 * 1.) releases the RUI and frees the RUD
> +	 * 2.) shuts down the filesystem
> +	 */
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &rudp->rud_item.li_flags);
> +
> +	return error;
> +}
> +
> +/* Sort rmap intents by AG. */
> +static int
> +xfs_rmap_update_diff_items(
> +	void				*priv,
> +	struct list_head		*a,
> +	struct list_head		*b)
> +{
> +	struct xfs_mount		*mp = priv;
> +	struct xfs_rmap_intent		*ra;
> +	struct xfs_rmap_intent		*rb;
> +
> +	ra = container_of(a, struct xfs_rmap_intent, ri_list);
> +	rb = container_of(b, struct xfs_rmap_intent, ri_list);
> +	return  XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
> +		XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
> +}
> +
> +/* Get an RUI. */
> +STATIC void *
> +xfs_rmap_update_create_intent(
> +	struct xfs_trans		*tp,
> +	unsigned int			count)
> +{
> +	struct xfs_rui_log_item		*ruip;
> +
> +	ASSERT(tp != NULL);
> +	ASSERT(count > 0);
> +
> +	ruip = xfs_rui_init(tp->t_mountp, count);
> +	ASSERT(ruip != NULL);
> +
> +	/*
> +	 * Get a log_item_desc to point at the new item.
> +	 */
> +	xfs_trans_add_item(tp, &ruip->rui_item);
> +	return ruip;
> +}
> +
> +/* Log rmap updates in the intent item. */
> +STATIC void
> +xfs_rmap_update_log_item(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	struct list_head		*item)
> +{
> +	struct xfs_rui_log_item		*ruip = intent;
> +	struct xfs_rmap_intent		*rmap;
> +	uint				next_extent;
> +	struct xfs_map_extent		*map;
> +
> +	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> +
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags);
> +
> +	/*
> +	 * atomic_inc_return gives us the value after the increment;
> +	 * we want to use it as an array index so we need to subtract 1 from
> +	 * it.
> +	 */
> +	next_extent = atomic_inc_return(&ruip->rui_next_extent) - 1;
> +	ASSERT(next_extent < ruip->rui_format.rui_nextents);
> +	map = &ruip->rui_format.rui_extents[next_extent];
> +	map->me_owner = rmap->ri_owner;
> +	map->me_startblock = rmap->ri_bmap.br_startblock;
> +	map->me_startoff = rmap->ri_bmap.br_startoff;
> +	map->me_len = rmap->ri_bmap.br_blockcount;
> +	xfs_trans_set_rmap_flags(map, rmap->ri_type, rmap->ri_whichfork,
> +			rmap->ri_bmap.br_state);
> +}
> +
> +/* Get an RUD so we can process all the deferred rmap updates. */
> +STATIC void *
> +xfs_rmap_update_create_done(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	unsigned int			count)
> +{
> +	return xfs_trans_get_rud(tp, intent);
> +}
> +
> +/* Process a deferred rmap update. */
> +STATIC int
> +xfs_rmap_update_finish_item(
> +	struct xfs_trans		*tp,
> +	struct list_head		*item,
> +	void				*done_item,
> +	void				**state)
> +{
> +	struct xfs_rmap_intent		*rmap;
> +	int				error;
> +
> +	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> +	error = xfs_trans_log_finish_rmap_update(tp, done_item,
> +			rmap->ri_type,
> +			rmap->ri_owner, rmap->ri_whichfork,
> +			rmap->ri_bmap.br_startoff,
> +			rmap->ri_bmap.br_startblock,
> +			rmap->ri_bmap.br_blockcount,
> +			rmap->ri_bmap.br_state,
> +			(struct xfs_btree_cur **)state);
> +	kmem_free(rmap);
> +	return error;
> +}
> +
> +/* Clean up after processing deferred rmaps. */
> +STATIC void
> +xfs_rmap_update_finish_cleanup(
> +	struct xfs_trans	*tp,
> +	void			*state,
> +	int			error)
> +{
> +	struct xfs_btree_cur	*rcur = state;
> +
> +	xfs_rmap_finish_one_cleanup(tp, rcur, error);
> +}
> +
> +/* Abort all pending RUIs. */
> +STATIC void
> +xfs_rmap_update_abort_intent(
> +	void				*intent)
> +{
> +	xfs_rui_release(intent);
> +}
> +
> +/* Cancel a deferred rmap update. */
> +STATIC void
> +xfs_rmap_update_cancel_item(
> +	struct list_head		*item)
> +{
> +	struct xfs_rmap_intent		*rmap;
> +
> +	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> +	kmem_free(rmap);
> +}
> +
> +const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
> +	.max_items	= XFS_RUI_MAX_FAST_EXTENTS,
> +	.diff_items	= xfs_rmap_update_diff_items,
> +	.create_intent	= xfs_rmap_update_create_intent,
> +	.abort_intent	= xfs_rmap_update_abort_intent,
> +	.log_item	= xfs_rmap_update_log_item,
> +	.create_done	= xfs_rmap_update_create_done,
> +	.finish_item	= xfs_rmap_update_finish_item,
> +	.finish_cleanup = xfs_rmap_update_finish_cleanup,
> +	.cancel_item	= xfs_rmap_update_cancel_item,
> +};
> +
>  /*
>   * Process an rmap update intent item that was recovered from the log.
>   * We need to update the rmapbt.
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 1fe910d6da82..bb411d8c41cf 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -244,17 +244,6 @@ void		xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
>  
>  extern kmem_zone_t	*xfs_trans_zone;
>  
> -/* rmap updates */
> -enum xfs_rmap_intent_type;
> -
> -struct xfs_rud_log_item *xfs_trans_get_rud(struct xfs_trans *tp,
> -		struct xfs_rui_log_item *ruip);
> -int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
> -		struct xfs_rud_log_item *rudp, enum xfs_rmap_intent_type type,
> -		uint64_t owner, int whichfork, xfs_fileoff_t startoff,
> -		xfs_fsblock_t startblock, xfs_filblks_t blockcount,
> -		xfs_exntst_t state, struct xfs_btree_cur **pcur);
> -
>  /* mapping updates */
>  enum xfs_bmap_intent_type;
>  
> diff --git a/fs/xfs/xfs_trans_rmap.c b/fs/xfs/xfs_trans_rmap.c
> deleted file mode 100644
> index 863e3281daaa..000000000000
> --- a/fs/xfs/xfs_trans_rmap.c
> +++ /dev/null
> @@ -1,245 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * Copyright (C) 2016 Oracle.  All Rights Reserved.
> - * Author: Darrick J. Wong <darrick.wong@oracle.com>
> - */
> -#include "xfs.h"
> -#include "xfs_fs.h"
> -#include "xfs_shared.h"
> -#include "xfs_format.h"
> -#include "xfs_log_format.h"
> -#include "xfs_trans_resv.h"
> -#include "xfs_mount.h"
> -#include "xfs_defer.h"
> -#include "xfs_trans.h"
> -#include "xfs_trans_priv.h"
> -#include "xfs_rmap_item.h"
> -#include "xfs_alloc.h"
> -#include "xfs_rmap.h"
> -
> -/* Set the map extent flags for this reverse mapping. */
> -static void
> -xfs_trans_set_rmap_flags(
> -	struct xfs_map_extent		*rmap,
> -	enum xfs_rmap_intent_type	type,
> -	int				whichfork,
> -	xfs_exntst_t			state)
> -{
> -	rmap->me_flags = 0;
> -	if (state == XFS_EXT_UNWRITTEN)
> -		rmap->me_flags |= XFS_RMAP_EXTENT_UNWRITTEN;
> -	if (whichfork == XFS_ATTR_FORK)
> -		rmap->me_flags |= XFS_RMAP_EXTENT_ATTR_FORK;
> -	switch (type) {
> -	case XFS_RMAP_MAP:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_MAP;
> -		break;
> -	case XFS_RMAP_MAP_SHARED:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_MAP_SHARED;
> -		break;
> -	case XFS_RMAP_UNMAP:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP;
> -		break;
> -	case XFS_RMAP_UNMAP_SHARED:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_UNMAP_SHARED;
> -		break;
> -	case XFS_RMAP_CONVERT:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT;
> -		break;
> -	case XFS_RMAP_CONVERT_SHARED:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_CONVERT_SHARED;
> -		break;
> -	case XFS_RMAP_ALLOC:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_ALLOC;
> -		break;
> -	case XFS_RMAP_FREE:
> -		rmap->me_flags |= XFS_RMAP_EXTENT_FREE;
> -		break;
> -	default:
> -		ASSERT(0);
> -	}
> -}
> -
> -/*
> - * Finish an rmap update and log it to the RUD. Note that the transaction is
> - * marked dirty regardless of whether the rmap update succeeds or fails to
> - * support the RUI/RUD lifecycle rules.
> - */
> -int
> -xfs_trans_log_finish_rmap_update(
> -	struct xfs_trans		*tp,
> -	struct xfs_rud_log_item		*rudp,
> -	enum xfs_rmap_intent_type	type,
> -	uint64_t			owner,
> -	int				whichfork,
> -	xfs_fileoff_t			startoff,
> -	xfs_fsblock_t			startblock,
> -	xfs_filblks_t			blockcount,
> -	xfs_exntst_t			state,
> -	struct xfs_btree_cur		**pcur)
> -{
> -	int				error;
> -
> -	error = xfs_rmap_finish_one(tp, type, owner, whichfork, startoff,
> -			startblock, blockcount, state, pcur);
> -
> -	/*
> -	 * Mark the transaction dirty, even on error. This ensures the
> -	 * transaction is aborted, which:
> -	 *
> -	 * 1.) releases the RUI and frees the RUD
> -	 * 2.) shuts down the filesystem
> -	 */
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &rudp->rud_item.li_flags);
> -
> -	return error;
> -}
> -
> -/* Sort rmap intents by AG. */
> -static int
> -xfs_rmap_update_diff_items(
> -	void				*priv,
> -	struct list_head		*a,
> -	struct list_head		*b)
> -{
> -	struct xfs_mount		*mp = priv;
> -	struct xfs_rmap_intent		*ra;
> -	struct xfs_rmap_intent		*rb;
> -
> -	ra = container_of(a, struct xfs_rmap_intent, ri_list);
> -	rb = container_of(b, struct xfs_rmap_intent, ri_list);
> -	return  XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
> -		XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
> -}
> -
> -/* Get an RUI. */
> -STATIC void *
> -xfs_rmap_update_create_intent(
> -	struct xfs_trans		*tp,
> -	unsigned int			count)
> -{
> -	struct xfs_rui_log_item		*ruip;
> -
> -	ASSERT(tp != NULL);
> -	ASSERT(count > 0);
> -
> -	ruip = xfs_rui_init(tp->t_mountp, count);
> -	ASSERT(ruip != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &ruip->rui_item);
> -	return ruip;
> -}
> -
> -/* Log rmap updates in the intent item. */
> -STATIC void
> -xfs_rmap_update_log_item(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	struct list_head		*item)
> -{
> -	struct xfs_rui_log_item		*ruip = intent;
> -	struct xfs_rmap_intent		*rmap;
> -	uint				next_extent;
> -	struct xfs_map_extent		*map;
> -
> -	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> -
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags);
> -
> -	/*
> -	 * atomic_inc_return gives us the value after the increment;
> -	 * we want to use it as an array index so we need to subtract 1 from
> -	 * it.
> -	 */
> -	next_extent = atomic_inc_return(&ruip->rui_next_extent) - 1;
> -	ASSERT(next_extent < ruip->rui_format.rui_nextents);
> -	map = &ruip->rui_format.rui_extents[next_extent];
> -	map->me_owner = rmap->ri_owner;
> -	map->me_startblock = rmap->ri_bmap.br_startblock;
> -	map->me_startoff = rmap->ri_bmap.br_startoff;
> -	map->me_len = rmap->ri_bmap.br_blockcount;
> -	xfs_trans_set_rmap_flags(map, rmap->ri_type, rmap->ri_whichfork,
> -			rmap->ri_bmap.br_state);
> -}
> -
> -/* Get an RUD so we can process all the deferred rmap updates. */
> -STATIC void *
> -xfs_rmap_update_create_done(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	unsigned int			count)
> -{
> -	return xfs_trans_get_rud(tp, intent);
> -}
> -
> -/* Process a deferred rmap update. */
> -STATIC int
> -xfs_rmap_update_finish_item(
> -	struct xfs_trans		*tp,
> -	struct list_head		*item,
> -	void				*done_item,
> -	void				**state)
> -{
> -	struct xfs_rmap_intent		*rmap;
> -	int				error;
> -
> -	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> -	error = xfs_trans_log_finish_rmap_update(tp, done_item,
> -			rmap->ri_type,
> -			rmap->ri_owner, rmap->ri_whichfork,
> -			rmap->ri_bmap.br_startoff,
> -			rmap->ri_bmap.br_startblock,
> -			rmap->ri_bmap.br_blockcount,
> -			rmap->ri_bmap.br_state,
> -			(struct xfs_btree_cur **)state);
> -	kmem_free(rmap);
> -	return error;
> -}
> -
> -/* Clean up after processing deferred rmaps. */
> -STATIC void
> -xfs_rmap_update_finish_cleanup(
> -	struct xfs_trans	*tp,
> -	void			*state,
> -	int			error)
> -{
> -	struct xfs_btree_cur	*rcur = state;
> -
> -	xfs_rmap_finish_one_cleanup(tp, rcur, error);
> -}
> -
> -/* Abort all pending RUIs. */
> -STATIC void
> -xfs_rmap_update_abort_intent(
> -	void				*intent)
> -{
> -	xfs_rui_release(intent);
> -}
> -
> -/* Cancel a deferred rmap update. */
> -STATIC void
> -xfs_rmap_update_cancel_item(
> -	struct list_head		*item)
> -{
> -	struct xfs_rmap_intent		*rmap;
> -
> -	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> -	kmem_free(rmap);
> -}
> -
> -const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
> -	.max_items	= XFS_RUI_MAX_FAST_EXTENTS,
> -	.diff_items	= xfs_rmap_update_diff_items,
> -	.create_intent	= xfs_rmap_update_create_intent,
> -	.abort_intent	= xfs_rmap_update_abort_intent,
> -	.log_item	= xfs_rmap_update_log_item,
> -	.create_done	= xfs_rmap_update_create_done,
> -	.finish_item	= xfs_rmap_update_finish_item,
> -	.finish_cleanup = xfs_rmap_update_finish_cleanup,
> -	.cancel_item	= xfs_rmap_update_cancel_item,
> -};
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c
  2019-05-17  7:31 ` [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c Christoph Hellwig
@ 2019-05-20 13:14   ` Brian Foster
  0 siblings, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:14 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:19AM +0200, Christoph Hellwig wrote:
> Keep all bmap item related code together.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/Makefile         |   1 -
>  fs/xfs/xfs_bmap_item.c  | 200 ++++++++++++++++++++++++++++++++++++-
>  fs/xfs/xfs_trans.h      |  11 --
>  fs/xfs/xfs_trans_bmap.c | 216 ----------------------------------------
>  4 files changed, 199 insertions(+), 229 deletions(-)
>  delete mode 100644 fs/xfs/xfs_trans_bmap.c
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 1730664770c5..9161af54a87c 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -104,7 +104,6 @@ xfs-y				+= xfs_log.o \
>  				   xfs_rmap_item.o \
>  				   xfs_log_recover.o \
>  				   xfs_trans_ail.o \
> -				   xfs_trans_bmap.o \
>  				   xfs_trans_buf.o \
>  				   xfs_trans_inode.o
>  
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index 40385c8b752a..ce5cf8aea3a4 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -6,6 +6,7 @@
>  #include "xfs.h"
>  #include "xfs_fs.h"
>  #include "xfs_format.h"
> +#include "xfs_shared.h"
>  #include "xfs_log_format.h"
>  #include "xfs_trans_resv.h"
>  #include "xfs_bit.h"
> @@ -212,7 +213,7 @@ static const struct xfs_item_ops xfs_bud_item_ops = {
>  	.iop_release	= xfs_bud_item_release,
>  };
>  
> -struct xfs_bud_log_item *
> +static struct xfs_bud_log_item *
>  xfs_trans_get_bud(
>  	struct xfs_trans		*tp,
>  	struct xfs_bui_log_item		*buip)
> @@ -229,6 +230,203 @@ xfs_trans_get_bud(
>  	return budp;
>  }
>  
> +/*
> + * Finish an bmap update and log it to the BUD. Note that the
> + * transaction is marked dirty regardless of whether the bmap update
> + * succeeds or fails to support the BUI/BUD lifecycle rules.
> + */
> +static int
> +xfs_trans_log_finish_bmap_update(
> +	struct xfs_trans		*tp,
> +	struct xfs_bud_log_item		*budp,
> +	enum xfs_bmap_intent_type	type,
> +	struct xfs_inode		*ip,
> +	int				whichfork,
> +	xfs_fileoff_t			startoff,
> +	xfs_fsblock_t			startblock,
> +	xfs_filblks_t			*blockcount,
> +	xfs_exntst_t			state)
> +{
> +	int				error;
> +
> +	error = xfs_bmap_finish_one(tp, ip, type, whichfork, startoff,
> +			startblock, blockcount, state);
> +
> +	/*
> +	 * Mark the transaction dirty, even on error. This ensures the
> +	 * transaction is aborted, which:
> +	 *
> +	 * 1.) releases the BUI and frees the BUD
> +	 * 2.) shuts down the filesystem
> +	 */
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &budp->bud_item.li_flags);
> +
> +	return error;
> +}
> +
> +/* Sort bmap intents by inode. */
> +static int
> +xfs_bmap_update_diff_items(
> +	void				*priv,
> +	struct list_head		*a,
> +	struct list_head		*b)
> +{
> +	struct xfs_bmap_intent		*ba;
> +	struct xfs_bmap_intent		*bb;
> +
> +	ba = container_of(a, struct xfs_bmap_intent, bi_list);
> +	bb = container_of(b, struct xfs_bmap_intent, bi_list);
> +	return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
> +}
> +
> +/* Get an BUI. */
> +STATIC void *
> +xfs_bmap_update_create_intent(
> +	struct xfs_trans		*tp,
> +	unsigned int			count)
> +{
> +	struct xfs_bui_log_item		*buip;
> +
> +	ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS);
> +	ASSERT(tp != NULL);
> +
> +	buip = xfs_bui_init(tp->t_mountp);
> +	ASSERT(buip != NULL);
> +
> +	/*
> +	 * Get a log_item_desc to point at the new item.
> +	 */
> +	xfs_trans_add_item(tp, &buip->bui_item);
> +	return buip;
> +}
> +
> +/* Set the map extent flags for this mapping. */
> +static void
> +xfs_trans_set_bmap_flags(
> +	struct xfs_map_extent		*bmap,
> +	enum xfs_bmap_intent_type	type,
> +	int				whichfork,
> +	xfs_exntst_t			state)
> +{
> +	bmap->me_flags = 0;
> +	switch (type) {
> +	case XFS_BMAP_MAP:
> +	case XFS_BMAP_UNMAP:
> +		bmap->me_flags = type;
> +		break;
> +	default:
> +		ASSERT(0);
> +	}
> +	if (state == XFS_EXT_UNWRITTEN)
> +		bmap->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
> +	if (whichfork == XFS_ATTR_FORK)
> +		bmap->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
> +}
> +
> +/* Log bmap updates in the intent item. */
> +STATIC void
> +xfs_bmap_update_log_item(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	struct list_head		*item)
> +{
> +	struct xfs_bui_log_item		*buip = intent;
> +	struct xfs_bmap_intent		*bmap;
> +	uint				next_extent;
> +	struct xfs_map_extent		*map;
> +
> +	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> +
> +	tp->t_flags |= XFS_TRANS_DIRTY;
> +	set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags);
> +
> +	/*
> +	 * atomic_inc_return gives us the value after the increment;
> +	 * we want to use it as an array index so we need to subtract 1 from
> +	 * it.
> +	 */
> +	next_extent = atomic_inc_return(&buip->bui_next_extent) - 1;
> +	ASSERT(next_extent < buip->bui_format.bui_nextents);
> +	map = &buip->bui_format.bui_extents[next_extent];
> +	map->me_owner = bmap->bi_owner->i_ino;
> +	map->me_startblock = bmap->bi_bmap.br_startblock;
> +	map->me_startoff = bmap->bi_bmap.br_startoff;
> +	map->me_len = bmap->bi_bmap.br_blockcount;
> +	xfs_trans_set_bmap_flags(map, bmap->bi_type, bmap->bi_whichfork,
> +			bmap->bi_bmap.br_state);
> +}
> +
> +/* Get an BUD so we can process all the deferred rmap updates. */
> +STATIC void *
> +xfs_bmap_update_create_done(
> +	struct xfs_trans		*tp,
> +	void				*intent,
> +	unsigned int			count)
> +{
> +	return xfs_trans_get_bud(tp, intent);
> +}
> +
> +/* Process a deferred rmap update. */
> +STATIC int
> +xfs_bmap_update_finish_item(
> +	struct xfs_trans		*tp,
> +	struct list_head		*item,
> +	void				*done_item,
> +	void				**state)
> +{
> +	struct xfs_bmap_intent		*bmap;
> +	xfs_filblks_t			count;
> +	int				error;
> +
> +	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> +	count = bmap->bi_bmap.br_blockcount;
> +	error = xfs_trans_log_finish_bmap_update(tp, done_item,
> +			bmap->bi_type,
> +			bmap->bi_owner, bmap->bi_whichfork,
> +			bmap->bi_bmap.br_startoff,
> +			bmap->bi_bmap.br_startblock,
> +			&count,
> +			bmap->bi_bmap.br_state);
> +	if (!error && count > 0) {
> +		ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
> +		bmap->bi_bmap.br_blockcount = count;
> +		return -EAGAIN;
> +	}
> +	kmem_free(bmap);
> +	return error;
> +}
> +
> +/* Abort all pending BUIs. */
> +STATIC void
> +xfs_bmap_update_abort_intent(
> +	void				*intent)
> +{
> +	xfs_bui_release(intent);
> +}
> +
> +/* Cancel a deferred rmap update. */
> +STATIC void
> +xfs_bmap_update_cancel_item(
> +	struct list_head		*item)
> +{
> +	struct xfs_bmap_intent		*bmap;
> +
> +	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> +	kmem_free(bmap);
> +}
> +
> +const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
> +	.max_items	= XFS_BUI_MAX_FAST_EXTENTS,
> +	.diff_items	= xfs_bmap_update_diff_items,
> +	.create_intent	= xfs_bmap_update_create_intent,
> +	.abort_intent	= xfs_bmap_update_abort_intent,
> +	.log_item	= xfs_bmap_update_log_item,
> +	.create_done	= xfs_bmap_update_create_done,
> +	.finish_item	= xfs_bmap_update_finish_item,
> +	.cancel_item	= xfs_bmap_update_cancel_item,
> +};
> +
>  /*
>   * Process a bmap update intent item that was recovered from the log.
>   * We need to update some inode's bmbt.
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index bb411d8c41cf..d3dcabc27b97 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -244,15 +244,4 @@ void		xfs_trans_buf_copy_type(struct xfs_buf *dst_bp,
>  
>  extern kmem_zone_t	*xfs_trans_zone;
>  
> -/* mapping updates */
> -enum xfs_bmap_intent_type;
> -
> -struct xfs_bud_log_item *xfs_trans_get_bud(struct xfs_trans *tp,
> -		struct xfs_bui_log_item *buip);
> -int xfs_trans_log_finish_bmap_update(struct xfs_trans *tp,
> -		struct xfs_bud_log_item *rudp, enum xfs_bmap_intent_type type,
> -		struct xfs_inode *ip, int whichfork, xfs_fileoff_t startoff,
> -		xfs_fsblock_t startblock, xfs_filblks_t *blockcount,
> -		xfs_exntst_t state);
> -
>  #endif	/* __XFS_TRANS_H__ */
> diff --git a/fs/xfs/xfs_trans_bmap.c b/fs/xfs/xfs_trans_bmap.c
> deleted file mode 100644
> index c6f5b217d17c..000000000000
> --- a/fs/xfs/xfs_trans_bmap.c
> +++ /dev/null
> @@ -1,216 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * Copyright (C) 2016 Oracle.  All Rights Reserved.
> - * Author: Darrick J. Wong <darrick.wong@oracle.com>
> - */
> -#include "xfs.h"
> -#include "xfs_fs.h"
> -#include "xfs_shared.h"
> -#include "xfs_format.h"
> -#include "xfs_log_format.h"
> -#include "xfs_trans_resv.h"
> -#include "xfs_mount.h"
> -#include "xfs_defer.h"
> -#include "xfs_trans.h"
> -#include "xfs_trans_priv.h"
> -#include "xfs_bmap_item.h"
> -#include "xfs_alloc.h"
> -#include "xfs_bmap.h"
> -#include "xfs_inode.h"
> -
> -/*
> - * Finish an bmap update and log it to the BUD. Note that the
> - * transaction is marked dirty regardless of whether the bmap update
> - * succeeds or fails to support the BUI/BUD lifecycle rules.
> - */
> -int
> -xfs_trans_log_finish_bmap_update(
> -	struct xfs_trans		*tp,
> -	struct xfs_bud_log_item		*budp,
> -	enum xfs_bmap_intent_type	type,
> -	struct xfs_inode		*ip,
> -	int				whichfork,
> -	xfs_fileoff_t			startoff,
> -	xfs_fsblock_t			startblock,
> -	xfs_filblks_t			*blockcount,
> -	xfs_exntst_t			state)
> -{
> -	int				error;
> -
> -	error = xfs_bmap_finish_one(tp, ip, type, whichfork, startoff,
> -			startblock, blockcount, state);
> -
> -	/*
> -	 * Mark the transaction dirty, even on error. This ensures the
> -	 * transaction is aborted, which:
> -	 *
> -	 * 1.) releases the BUI and frees the BUD
> -	 * 2.) shuts down the filesystem
> -	 */
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &budp->bud_item.li_flags);
> -
> -	return error;
> -}
> -
> -/* Sort bmap intents by inode. */
> -static int
> -xfs_bmap_update_diff_items(
> -	void				*priv,
> -	struct list_head		*a,
> -	struct list_head		*b)
> -{
> -	struct xfs_bmap_intent		*ba;
> -	struct xfs_bmap_intent		*bb;
> -
> -	ba = container_of(a, struct xfs_bmap_intent, bi_list);
> -	bb = container_of(b, struct xfs_bmap_intent, bi_list);
> -	return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
> -}
> -
> -/* Get an BUI. */
> -STATIC void *
> -xfs_bmap_update_create_intent(
> -	struct xfs_trans		*tp,
> -	unsigned int			count)
> -{
> -	struct xfs_bui_log_item		*buip;
> -
> -	ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS);
> -	ASSERT(tp != NULL);
> -
> -	buip = xfs_bui_init(tp->t_mountp);
> -	ASSERT(buip != NULL);
> -
> -	/*
> -	 * Get a log_item_desc to point at the new item.
> -	 */
> -	xfs_trans_add_item(tp, &buip->bui_item);
> -	return buip;
> -}
> -
> -/* Set the map extent flags for this mapping. */
> -static void
> -xfs_trans_set_bmap_flags(
> -	struct xfs_map_extent		*bmap,
> -	enum xfs_bmap_intent_type	type,
> -	int				whichfork,
> -	xfs_exntst_t			state)
> -{
> -	bmap->me_flags = 0;
> -	switch (type) {
> -	case XFS_BMAP_MAP:
> -	case XFS_BMAP_UNMAP:
> -		bmap->me_flags = type;
> -		break;
> -	default:
> -		ASSERT(0);
> -	}
> -	if (state == XFS_EXT_UNWRITTEN)
> -		bmap->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
> -	if (whichfork == XFS_ATTR_FORK)
> -		bmap->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
> -}
> -
> -/* Log bmap updates in the intent item. */
> -STATIC void
> -xfs_bmap_update_log_item(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	struct list_head		*item)
> -{
> -	struct xfs_bui_log_item		*buip = intent;
> -	struct xfs_bmap_intent		*bmap;
> -	uint				next_extent;
> -	struct xfs_map_extent		*map;
> -
> -	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> -
> -	tp->t_flags |= XFS_TRANS_DIRTY;
> -	set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags);
> -
> -	/*
> -	 * atomic_inc_return gives us the value after the increment;
> -	 * we want to use it as an array index so we need to subtract 1 from
> -	 * it.
> -	 */
> -	next_extent = atomic_inc_return(&buip->bui_next_extent) - 1;
> -	ASSERT(next_extent < buip->bui_format.bui_nextents);
> -	map = &buip->bui_format.bui_extents[next_extent];
> -	map->me_owner = bmap->bi_owner->i_ino;
> -	map->me_startblock = bmap->bi_bmap.br_startblock;
> -	map->me_startoff = bmap->bi_bmap.br_startoff;
> -	map->me_len = bmap->bi_bmap.br_blockcount;
> -	xfs_trans_set_bmap_flags(map, bmap->bi_type, bmap->bi_whichfork,
> -			bmap->bi_bmap.br_state);
> -}
> -
> -/* Get an BUD so we can process all the deferred rmap updates. */
> -STATIC void *
> -xfs_bmap_update_create_done(
> -	struct xfs_trans		*tp,
> -	void				*intent,
> -	unsigned int			count)
> -{
> -	return xfs_trans_get_bud(tp, intent);
> -}
> -
> -/* Process a deferred rmap update. */
> -STATIC int
> -xfs_bmap_update_finish_item(
> -	struct xfs_trans		*tp,
> -	struct list_head		*item,
> -	void				*done_item,
> -	void				**state)
> -{
> -	struct xfs_bmap_intent		*bmap;
> -	xfs_filblks_t			count;
> -	int				error;
> -
> -	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> -	count = bmap->bi_bmap.br_blockcount;
> -	error = xfs_trans_log_finish_bmap_update(tp, done_item,
> -			bmap->bi_type,
> -			bmap->bi_owner, bmap->bi_whichfork,
> -			bmap->bi_bmap.br_startoff,
> -			bmap->bi_bmap.br_startblock,
> -			&count,
> -			bmap->bi_bmap.br_state);
> -	if (!error && count > 0) {
> -		ASSERT(bmap->bi_type == XFS_BMAP_UNMAP);
> -		bmap->bi_bmap.br_blockcount = count;
> -		return -EAGAIN;
> -	}
> -	kmem_free(bmap);
> -	return error;
> -}
> -
> -/* Abort all pending BUIs. */
> -STATIC void
> -xfs_bmap_update_abort_intent(
> -	void				*intent)
> -{
> -	xfs_bui_release(intent);
> -}
> -
> -/* Cancel a deferred rmap update. */
> -STATIC void
> -xfs_bmap_update_cancel_item(
> -	struct list_head		*item)
> -{
> -	struct xfs_bmap_intent		*bmap;
> -
> -	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> -	kmem_free(bmap);
> -}
> -
> -const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
> -	.max_items	= XFS_BUI_MAX_FAST_EXTENTS,
> -	.diff_items	= xfs_bmap_update_diff_items,
> -	.create_intent	= xfs_bmap_update_create_intent,
> -	.abort_intent	= xfs_bmap_update_abort_intent,
> -	.log_item	= xfs_bmap_update_log_item,
> -	.create_done	= xfs_bmap_update_create_done,
> -	.finish_item	= xfs_bmap_update_finish_item,
> -	.cancel_item	= xfs_bmap_update_cancel_item,
> -};
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-20 13:12   ` Brian Foster
@ 2019-05-20 13:19     ` Christoph Hellwig
  2019-05-20 13:25       ` Brian Foster
  2019-05-20 13:27       ` Bryan Gurney
  0 siblings, 2 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20 13:19 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Mon, May 20, 2019 at 09:12:33AM -0400, Brian Foster wrote:
> > +				spin_unlock(&iclog->ic_callback_lock);
> > +				xlog_cil_process_commited(&tmp, aborted);
> 
> s/commited/committed/ please.

Ok.

> > +	while ((ctx = list_first_entry_or_null(list,
> 
> Are double braces necessary here?

Without them gcc is unhappy:

fs/xfs/xfs_log_cil.c: In function ‘xlog_cil_process_commited’:
fs/xfs/xfs_log_cil.c:624:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  while (ctx = list_first_entry_or_null(list,

> >  	/* attach all the transactions w/ busy extents to iclog */
> 
> Any idea what this ^ comment means? ISTM it's misplaced or stale. If so,
> we might as well toss/replace it.

No idea.  We can probbaly remove it.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-20 13:19     ` Christoph Hellwig
@ 2019-05-20 13:25       ` Brian Foster
  2019-05-20 13:27       ` Bryan Gurney
  1 sibling, 0 replies; 60+ messages in thread
From: Brian Foster @ 2019-05-20 13:25 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Mon, May 20, 2019 at 03:19:46PM +0200, Christoph Hellwig wrote:
> On Mon, May 20, 2019 at 09:12:33AM -0400, Brian Foster wrote:
> > > +				spin_unlock(&iclog->ic_callback_lock);
> > > +				xlog_cil_process_commited(&tmp, aborted);
> > 
> > s/commited/committed/ please.
> 
> Ok.
> 
> > > +	while ((ctx = list_first_entry_or_null(list,
> > 
> > Are double braces necessary here?
> 
> Without them gcc is unhappy:
> 
> fs/xfs/xfs_log_cil.c: In function ‘xlog_cil_process_commited’:
> fs/xfs/xfs_log_cil.c:624:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
>   while (ctx = list_first_entry_or_null(list,
> 

Ok, wasn't quite sure if that mattered.

Brian

> > >  	/* attach all the transactions w/ busy extents to iclog */
> > 
> > Any idea what this ^ comment means? ISTM it's misplaced or stale. If so,
> > we might as well toss/replace it.
> 
> No idea.  We can probbaly remove it.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-20 13:19     ` Christoph Hellwig
  2019-05-20 13:25       ` Brian Foster
@ 2019-05-20 13:27       ` Bryan Gurney
  2019-05-20 13:31         ` Christoph Hellwig
  1 sibling, 1 reply; 60+ messages in thread
From: Bryan Gurney @ 2019-05-20 13:27 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Brian Foster, linux-xfs

On Mon, May 20, 2019 at 9:20 AM Christoph Hellwig <hch@lst.de> wrote:
>
> On Mon, May 20, 2019 at 09:12:33AM -0400, Brian Foster wrote:
> > > +                           spin_unlock(&iclog->ic_callback_lock);
> > > +                           xlog_cil_process_commited(&tmp, aborted);
> >
> > s/commited/committed/ please.
>
> Ok.
>
> > > +   while ((ctx = list_first_entry_or_null(list,
> >
> > Are double braces necessary here?
>
> Without them gcc is unhappy:
>
> fs/xfs/xfs_log_cil.c: In function ‘xlog_cil_process_commited’:
> fs/xfs/xfs_log_cil.c:624:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
>   while (ctx = list_first_entry_or_null(list,
>

It's probably to guard against an assignment in a while / if / etc. statement.

In other words: Are you sure you didn't intend the following?

     while (ctx == list_first_entry_or_null(list,
                     struct xfs_cil_ctx, iclog_entry)) {

(I've stumbled on a bug like this before, so I figured I'd ask, just
to be certain.)


Thanks,

Bryan

> > >     /* attach all the transactions w/ busy extents to iclog */
> >
> > Any idea what this ^ comment means? ISTM it's misplaced or stale. If so,
> > we might as well toss/replace it.
>
> No idea.  We can probbaly remove it.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
  2019-05-20 13:27       ` Bryan Gurney
@ 2019-05-20 13:31         ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-05-20 13:31 UTC (permalink / raw)
  To: Bryan Gurney; +Cc: Christoph Hellwig, Brian Foster, linux-xfs

On Mon, May 20, 2019 at 09:27:37AM -0400, Bryan Gurney wrote:
> It's probably to guard against an assignment in a while / if / etc. statement.
> 
> In other words: Are you sure you didn't intend the following?
> 
>      while (ctx == list_first_entry_or_null(list,
>                      struct xfs_cil_ctx, iclog_entry)) {
> 
> (I've stumbled on a bug like this before, so I figured I'd ask, just
> to be certain.)

Yes, I'm sure.  I'm iterating the list to remove each entry from it
from start to end.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
  2019-05-17 14:04   ` Brian Foster
  2019-05-17 14:10   ` Eric Sandeen
@ 2019-05-20 22:08   ` Darrick J. Wong
  2019-06-11  8:46     ` Christoph Hellwig
  2 siblings, 1 reply; 60+ messages in thread
From: Darrick J. Wong @ 2019-05-20 22:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:01AM +0200, Christoph Hellwig wrote:
> Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
> flag in function parameters.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_log.c     | 25 +++++++++++--------------
>  fs/xfs/xfs_log.h     |  2 +-
>  fs/xfs/xfs_log_cil.c |  4 ++--
>  3 files changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 457ced3ee3e1..1eb0938165fc 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -54,12 +54,9 @@ xlog_dealloc_log(
>  	struct xlog		*log);
>  
>  /* local state machine functions */
> -STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int);
> -STATIC void
> -xlog_state_do_callback(
> -	struct xlog		*log,
> -	int			aborted,
> -	struct xlog_in_core	*iclog);
> +STATIC void xlog_state_done_syncing(
> +	struct xlog_in_core	*iclog,
> +	bool			aborted);

I totally mistook this for a function definition. :/

STATIC void xlog_state_done_syncing(struct xlog_in_core *iclog, bool aborted);

...seems to fit on one line, right?

--D

>  STATIC int
>  xlog_state_get_iclog_space(
>  	struct xlog		*log,
> @@ -1255,7 +1252,7 @@ xlog_iodone(xfs_buf_t *bp)
>  {
>  	struct xlog_in_core	*iclog = bp->b_log_item;
>  	struct xlog		*l = iclog->ic_log;
> -	int			aborted = 0;
> +	bool			aborted = false;
>  
>  	/*
>  	 * Race to shutdown the filesystem if we see an error or the iclog is in
> @@ -1275,9 +1272,9 @@ xlog_iodone(xfs_buf_t *bp)
>  		 * callback routines to let them know that the log-commit
>  		 * didn't succeed.
>  		 */
> -		aborted = XFS_LI_ABORTED;
> +		aborted = true;
>  	} else if (iclog->ic_state & XLOG_STATE_IOERROR) {
> -		aborted = XFS_LI_ABORTED;
> +		aborted = true;
>  	}
>  
>  	/* log I/O is always issued ASYNC */
> @@ -2697,7 +2694,7 @@ xlog_get_lowest_lsn(
>  STATIC void
>  xlog_state_do_callback(
>  	struct xlog		*log,
> -	int			aborted,
> +	bool			aborted,
>  	struct xlog_in_core	*ciclog)
>  {
>  	xlog_in_core_t	   *iclog;
> @@ -2936,10 +2933,10 @@ xlog_state_do_callback(
>   */
>  STATIC void
>  xlog_state_done_syncing(
> -	xlog_in_core_t	*iclog,
> -	int		aborted)
> +	struct xlog_in_core	*iclog,
> +	bool			aborted)
>  {
> -	struct xlog	   *log = iclog->ic_log;
> +	struct xlog		*log = iclog->ic_log;
>  
>  	spin_lock(&log->l_icloglock);
>  
> @@ -4026,7 +4023,7 @@ xfs_log_force_umount(
>  	 * avoid races.
>  	 */
>  	wake_up_all(&log->l_cilp->xc_commit_wait);
> -	xlog_state_do_callback(log, XFS_LI_ABORTED, NULL);
> +	xlog_state_do_callback(log, true, NULL);
>  
>  #ifdef XFSERRORDEBUG
>  	{
> diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
> index 73a64bf32f6f..4450a2a26a1a 100644
> --- a/fs/xfs/xfs_log.h
> +++ b/fs/xfs/xfs_log.h
> @@ -77,7 +77,7 @@ xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
>   */
>  typedef struct xfs_log_callback {
>  	struct xfs_log_callback	*cb_next;
> -	void			(*cb_func)(void *, int);
> +	void			(*cb_func)(void *, bool);
>  	void			*cb_arg;
>  } xfs_log_callback_t;
>  
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index 5e595948bc5a..1b54002d3874 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -577,7 +577,7 @@ xlog_discard_busy_extents(
>  static void
>  xlog_cil_committed(
>  	void	*args,
> -	int	abort)
> +	bool	abort)
>  {
>  	struct xfs_cil_ctx	*ctx = args;
>  	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
> @@ -864,7 +864,7 @@ xlog_cil_push(
>  out_abort_free_ticket:
>  	xfs_log_ticket_put(tic);
>  out_abort:
> -	xlog_cil_committed(ctx, XFS_LI_ABORTED);
> +	xlog_cil_committed(ctx, true);
>  	return -EIO;
>  }
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
  2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
  2019-05-17 14:04   ` Brian Foster
@ 2019-05-20 22:08   ` Darrick J. Wong
  1 sibling, 0 replies; 60+ messages in thread
From: Darrick J. Wong @ 2019-05-20 22:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Fri, May 17, 2019 at 09:31:00AM +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_trans.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 912b42f5fe4a..19f91312561a 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -815,7 +815,7 @@ xfs_log_item_batch_insert(
>   *
>   * If we are called with the aborted flag set, it is because a log write during
>   * a CIL checkpoint commit has failed. In this case, all the items in the
> - * checkpoint have already gone through iop_commited and iop_unlock, which
> + * checkpoint have already gone through iop_committed and iop_unlock, which
>   * means that checkpoint commit abort handling is treated exactly the same
>   * as an iclog write error even though we haven't started any IO yet. Hence in
>   * this case all we need to do is iop_committed processing, followed by an
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
  2019-05-20 22:08   ` Darrick J. Wong
@ 2019-06-11  8:46     ` Christoph Hellwig
  0 siblings, 0 replies; 60+ messages in thread
From: Christoph Hellwig @ 2019-06-11  8:46 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, linux-xfs

On Mon, May 20, 2019 at 03:08:44PM -0700, Darrick J. Wong wrote:
> > -xlog_state_do_callback(
> > -	struct xlog		*log,
> > -	int			aborted,
> > -	struct xlog_in_core	*iclog);
> > +STATIC void xlog_state_done_syncing(
> > +	struct xlog_in_core	*iclog,
> > +	bool			aborted);
> 
> I totally mistook this for a function definition. :/
> 
> STATIC void xlog_state_done_syncing(struct xlog_in_core *iclog, bool aborted);
> 
> ...seems to fit on one line, right?

Yes, but this style is used by all the forward declarations in
xfs_log.c.  Eventually we should fix them all, or even better get rid
of most of them.

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2019-06-11  8:46 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17  7:30 misc log item related cleanups Christoph Hellwig
2019-05-17  7:31 ` [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk Christoph Hellwig
2019-05-17 14:04   ` Brian Foster
2019-05-20 22:08   ` Darrick J. Wong
2019-05-17  7:31 ` [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag Christoph Hellwig
2019-05-17 14:04   ` Brian Foster
2019-05-20  6:03     ` Christoph Hellwig
2019-05-17 14:10   ` Eric Sandeen
2019-05-20  6:05     ` Christoph Hellwig
2019-05-20 22:08   ` Darrick J. Wong
2019-06-11  8:46     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 03/20] xfs: don't require log items to implement optional methods Christoph Hellwig
2019-05-17 14:06   ` Brian Foster
2019-05-20  6:06     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items Christoph Hellwig
2019-05-17 14:07   ` Brian Foster
2019-05-17  7:31 ` [PATCH 05/20] xfs: remove the iop_push implementation for quota off items Christoph Hellwig
2019-05-17 14:08   ` Brian Foster
2019-05-20  6:09     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path Christoph Hellwig
2019-05-17 14:08   ` Brian Foster
2019-05-17  7:31 ` [PATCH 07/20] xfs: split iop_unlock Christoph Hellwig
2019-05-17 17:49   ` Brian Foster
2019-05-20  6:10     ` Christoph Hellwig
2019-05-20 11:38       ` Brian Foster
2019-05-17  7:31 ` [PATCH 08/20] xfs: add a flag to release log items on commit Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-20  6:11     ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-17  7:31 ` [PATCH 10/20] xfs: remove the xfs_log_item_t typedef Christoph Hellwig
2019-05-17 17:50   ` Brian Foster
2019-05-17  7:31 ` [PATCH 11/20] xfs: use a list_head for iclog callbacks Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-20 13:19     ` Christoph Hellwig
2019-05-20 13:25       ` Brian Foster
2019-05-20 13:27       ` Bryan Gurney
2019-05-20 13:31         ` Christoph Hellwig
2019-05-17  7:31 ` [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-17  7:31 ` [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd Christoph Hellwig
2019-05-17  8:16   ` Nikolay Borisov
2019-05-17  8:27     ` Christoph Hellwig
2019-05-17 18:26   ` Eric Sandeen
2019-05-20  6:03     ` Christoph Hellwig
2019-05-20 13:12   ` Brian Foster
2019-05-17  7:31 ` [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c Christoph Hellwig
2019-05-20 13:13   ` Brian Foster
2019-05-17  7:31 ` [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster
2019-05-17  7:31 ` [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster
2019-05-17  7:31 ` [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c Christoph Hellwig
2019-05-20 13:14   ` Brian Foster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.