misc log item related cleanups
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.
PATCH 1/20 xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
--- fs/xfs/xfs_trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_trans.c +1 -1
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 19 lines
fs/xfs/xfs_trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_trans.c +1
-1@@ -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 Signature · 1 line
2.20.1
Re: [PATCH 01/20] xfs: fix a trivial comment typo in the xfs_trans_committed_bulk
In reply to Christoph HellwigQuoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 20 lines
--- fs/xfs/xfs_trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_trans.c +1
-1@@ -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 Signature · 1 line
2.20.1
PATCH 2/20 xfs: stop using XFS_LI_ABORTED as a parameter flag
In reply to Christoph HellwigJust pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a flag in function parameters.
--- 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(-)
fs/xfs/xfs_log.c +11 -14
@@ -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 voidxlog_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 voidxlog_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 {
fs/xfs/xfs_log.h +1 -1
@@ -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 ;
fs/xfs/xfs_log_cil.c +2 -2
@@ -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 ; }
Signature · 1 line
2.20.1
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
Quoted 10 lines · Christoph Hellwig
Just pass a straight bool aborted instead of abusing
XFS_LI_ABORTEDas a flag in function parameters.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)
...
fs/xfs/xfs_log_cil.c xlog_discard_busy_extents( · line 581
Quoted 11 lines
fs/xfs/xfs_log_cil.c +1
-1@@ -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:
Quoted 14 lines
fs/xfs/xfs_log_cil.c +1
-1struct 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 ; }Signature · 1 line
2.20.1
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
Quoted 2 lines · Brian Foster
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.
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
Just pass a straight bool aborted instead of abusing
XFS_LI_ABORTEDas a flag in function parameters.
...
fs/xfs/xfs_log_cil.c xlog_cil_push( · line 868
Quoted 4 lines
out_abort:fs/xfs/xfs_log_cil.c +1
-1-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
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig
Just pass a straight bool aborted instead of abusing
XFS_LI_ABORTEDas a flag in function parameters....
Quoted 10 lines
fs/xfs/xfs_log_cil.c xlog_cil_push( · line 868
Quoted 4 lines
out_abort:fs/xfs/xfs_log_cil.c +1
-1-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.
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
In reply to Christoph HellwigQuoted 17 lines · Christoph Hellwig
Just pass a straight bool aborted instead of abusing
XFS_LI_ABORTEDas a flag in function parameters.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_log.c +0
-0@@ -54,12 +54,9 @@ xlog_dealloc_log( struct xlog *log);
fs/xfs/xfs_log.c xlog_dealloc_log( · line 59
Quoted 10 lines
fs/xfs/xfs_log.c +3
-6/* 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
Quoted 94 lines
fs/xfs/xfs_log.c +8
-8STATIC 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 voidxlog_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 voidxlog_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 {fs/xfs/xfs_log.h +1
-1@@ -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 ;fs/xfs/xfs_log_cil.c +2
-2@@ -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 ; }Signature · 1 line
2.20.1
Re: [PATCH 02/20] xfs: stop using XFS_LI_ABORTED as a parameter flag
Quoted 10 lines · Darrick J. Wong
fs/xfs/xfs_log.c xlog_dealloc_log( · line 59
Quoted 7 lines
fs/xfs/xfs_log.c +3
-4-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. :/
Quoted 3 lines
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.
PATCH 3/20 xfs: don't require log items to implement optional methods
In reply to Christoph HellwigJust check if they are present first.
--- 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(-)
fs/xfs/xfs_bmap_item.c +0 -104
@@ -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, };/*
fs/xfs/xfs_buf_item.c +0 -8
@@ -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
fs/xfs/xfs_dquot_item.c +0 -98
147 lines not on this page · raw message
fs/xfs/xfs_extfree_item.c +0 -104
150 lines not on this page · raw message
fs/xfs/xfs_icreate_item.c +0 -28
@@ -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 voidxfs_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, };
fs/xfs/xfs_log_cil.c +2 -1
@@ -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 );
fs/xfs/xfs_refcount_item.c +0 -104
150 lines not on this page · raw message
fs/xfs/xfs_rmap_item.c +0 -104
150 lines not on this page · raw message
fs/xfs/xfs_trans.c +15 -6
@@ -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 ; }
fs/xfs/xfs_trans_ail.c +2 -0
@@ -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); }
Signature · 1 line
2.20.1
Re: [PATCH 03/20] xfs: don't require log items to implement optional methods
Quoted 20 lines · Christoph Hellwig
Just check if they are present first.
Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_bmap_item.c +0
-0
...
Quoted 9 lines
fs/xfs/xfs_bmap_item.c +0
-5@@ -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
fs/xfs/xfs_bmap_item.c xfs_bui_item_unpin( · line 139
Quoted 10 lines
fs/xfs/xfs_bmap_item.c +0
-10-* 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....
Quoted 3 lines
fs/xfs/xfs_bmap_item.c +0
-0/* * 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
...
fs/xfs/xfs_trans_ail.c xfsaild_push_item( · line 349
Quoted 8 lines
fs/xfs/xfs_trans_ail.c +0
-0@@ -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
Quoted 8 lines
fs/xfs/xfs_trans_ail.c +2
-0+if (!lip->li_ops->iop_push) +return XFS_ITEM_PINNED ;return lip->li_ops->iop_push (lip, &ailp->ail_buf_list); }Signature · 1 line
2.20.1
Re: [PATCH 03/20] xfs: don't require log items to implement optional methods
Quoted 5 lines · Brian Foster
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_PINNEDin all these ->iop_push() calls associated with intents. I'd almost rather see a genericxfs_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.
Quoted 3 lines
Short of that, could
we at least move some of the information from these comments to the push call inxfsaild_push_item()? For example....
Sure, I can do that.
PATCH 4/20 xfs: remove the dummy iop_push implementation for inode creation items
In reply to Christoph HellwigThis method should never be called, so don't waste code on it.
--- fs/xfs/xfs_icreate_item.c | 11 ----------- 1 file changed, 11 deletions(-)
fs/xfs/xfs_icreate_item.c +0 -11
@@ -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, };
Signature · 1 line
2.20.1
Re: [PATCH 04/20] xfs: remove the dummy iop_push implementation for inode creation items
Quoted 4 lines · Christoph Hellwig
This method should never be called, so don't waste code on it.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 34 lines
fs/xfs/xfs_icreate_item.c | 11 ----------- 1 file changed, 11 deletions(-)fs/xfs/xfs_icreate_item.c +0
-11@@ -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, };Signature · 1 line
2.20.1
PATCH 5/20 xfs: remove the iop_push implementation for quota off items
In reply to Christoph HellwigIf 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.
--- fs/xfs/xfs_dquot_item.c | 14 -------------- 1 file changed, 14 deletions(-)
fs/xfs/xfs_dquot_item.c +0 -14
@@ -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, };/*
Signature · 1 line
2.20.1
Re: [PATCH 05/20] xfs: remove the iop_push implementation for quota off items
Quoted 19 lines · Christoph Hellwig
If we want to push the log to make progress on the items we'd need to return
XFS_ITEM_PINNEDinstead ofXFS_ITEM_LOCKED. Removing the method will do exactly that.Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_dquot_item.c | 14 -------------- 1 file changed, 14 deletions(-)fs/xfs/xfs_dquot_item.c +0
-2@@ -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
fs/xfs/xfs_dquot_item.c xfs_qm_qoff_logitem_format( · line 302
Quoted 10 lines
fs/xfs/xfs_dquot_item.c +0
-10-* 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
Quoted 22 lines
fs/xfs/xfs_dquot_item.c +0
-2STATIC 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, };/* Signature · 1 line
2.20.1
Re: [PATCH 05/20] xfs: remove the iop_push implementation for quota off items
Quoted 10 lines · Brian Foster
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 thequotaoff_enditem. All in all this can take a bit of time (and we have test scenarios that reproduce quotaoff log deadlocks already).
Quoted 7 lines
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_endis 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.
PATCH 6/20 xfs: don't use xfs_trans_free_items in the commit path
In reply to Christoph HellwigWhile 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.
--- 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(-)
fs/xfs/xfs_log_cil.c +10 -3
@@ -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);
fs/xfs/xfs_trace.h +1 -0
@@ -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,
fs/xfs/xfs_trans.c +3 -7
@@ -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); }
fs/xfs/xfs_trans_priv.h +0 -2
@@ -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,
Signature · 1 line
2.20.1
Re: [PATCH 06/20] xfs: don't use xfs_trans_free_items in the commit path
Quoted 8 lines · Christoph Hellwig
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 intoxfs_log_commit_ciland give it a separate trace point.Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 116 lines
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(-)fs/xfs/xfs_log_cil.c +10
-3@@ -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);fs/xfs/xfs_trace.h +1
-0@@ -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,fs/xfs/xfs_trans.c +3
-7@@ -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); }fs/xfs/xfs_trans_priv.h +0
-2@@ -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,Signature · 1 line
2.20.1
PATCH 7/20 xfs: split iop_unlock
In reply to Christoph HellwigThe 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.
--- 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(-)
fs/xfs/xfs_bmap_item.c +7 -10
@@ -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, };
fs/xfs/xfs_buf_item.c +12 -3
@@ -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, };
fs/xfs/xfs_dquot_item.c +11 -8
@@ -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 };
fs/xfs/xfs_extfree_item.c +7 -10
@@ -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, };
fs/xfs/xfs_icreate_item.c +3 -7
@@ -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, };
fs/xfs/xfs_inode_item.c +6 -5
@@ -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 voidxfs_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 };
fs/xfs/xfs_log_cil.c +0 -2
@@ -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);
fs/xfs/xfs_refcount_item.c +7 -10
@@ -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, };
fs/xfs/xfs_rmap_item.c +7 -10
@@ -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, };
fs/xfs/xfs_trace.h +1 -1
@@ -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);
fs/xfs/xfs_trans.c +3 -4
@@ -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
fs/xfs/xfs_trans.h +2 -2
@@ -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 *); };
fs/xfs/xfs_trans_buf.c +1 -1
@@ -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 */
Signature · 1 line
2.20.1
Re: [PATCH 07/20] xfs: split iop_unlock
Quoted 9 lines · Christoph Hellwig
The
iop_unlockis 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 theXFS_LI_ABORTEDflag, 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
Quoted 486 lines
This patch replaces
iop_unlockwith a newiop_releasemethod just for releasing items on a transaction cancellation, and overloads the existingiop_committingmethod with the commit path behavior that only a few item implementations need to start with.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_bmap_item.c +7
-10@@ -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, };fs/xfs/xfs_buf_item.c +12
-3@@ -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, };fs/xfs/xfs_dquot_item.c +11
-8@@ -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 };fs/xfs/xfs_extfree_item.c +7
-10@@ -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, };fs/xfs/xfs_icreate_item.c +3
-7@@ -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, };fs/xfs/xfs_inode_item.c +6
-5@@ -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 voidxfs_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 };fs/xfs/xfs_log_cil.c +0
-2@@ -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);fs/xfs/xfs_refcount_item.c +7
-10@@ -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, };fs/xfs/xfs_rmap_item.c +7
-10@@ -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, };fs/xfs/xfs_trace.h +1
-1@@ -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);fs/xfs/xfs_trans.c +3
-4@@ -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 fs/xfs/xfs_trans.h +2
-2@@ -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 *); };fs/xfs/xfs_trans_buf.c +1
-1@@ -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 */ Signature · 1 line
2.20.1
Re: [PATCH 07/20] xfs: split iop_unlock
Quoted 5 lines · Brian Foster
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()andxfs_trans_free_extent()for examples associated with the EFI/EFD items.
That's why I said theoretical.
Quoted 9 lines
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.
Quoted 6 lines
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.
Re: [PATCH 07/20] xfs: split iop_unlock
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Brian Foster
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()andxfs_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...
Quoted 19 lines
Quoted 9 lines
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.
Quoted 6 lines
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?
Quoted 2 lines
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
PATCH 8/20 xfs: add a flag to release log items on commit
In reply to Christoph HellwigWe 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.
--- 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(-)
fs/xfs/xfs_bmap_item.c +1 -26
@@ -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, };/*
fs/xfs/xfs_extfree_item.c +1 -26
@@ -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, };/*
fs/xfs/xfs_icreate_item.c +1 -17
@@ -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, };
fs/xfs/xfs_refcount_item.c +1 -26
@@ -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, };/*
fs/xfs/xfs_rmap_item.c +1 -26
@@ -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, };/*
fs/xfs/xfs_trans.c +5 -0
@@ -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)
fs/xfs/xfs_trans.h +7 -0
@@ -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);
Signature · 1 line
2.20.1
Re: [PATCH 08/20] xfs: add a flag to release log items on commit
Quoted 6 lines · Christoph Hellwig
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 <[email protected]>---
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?
Quoted 9 lines
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(-)
...
fs/xfs/xfs_trans.c xfs_trans_committed_bulk( · line 855
Quoted 12 lines
fs/xfs/xfs_trans.c +4
-0@@ -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
Quoted 32 lines
fs/xfs/xfs_trans.c +1
-0+if (aborted)set_bit (XFS_LI_ABORTED , &lip->li_flags);if (lip->li_ops->iop_committed)fs/xfs/xfs_trans.h +7
-0@@ -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);Signature · 1 line
2.20.1
Re: [PATCH 08/20] xfs: add a flag to release log items on commit
Quoted 8 lines · Brian Foster
Quoted 6 lines · Christoph Hellwig
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 <[email protected]>---
Quoted 6 lines
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_COMMITand thus doesn't indicate which event it actually refers to. Can we fix this up? Maybe just call it*_RELEASE_ON_COMMITTED?
Sounds fine.
Quoted 19 lines
Quoted 10 lines
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(-)...
Quoted 8 lines
fs/xfs/xfs_trans.c +0
-0@@ -849,6 +849,11 @@ xfs_trans_committed_bulk(struct xfs_log_item *lip = lv->lv_item;xfs_lsn_t item_lsn;
Quoted 8 lines
fs/xfs/xfs_trans.c xfs_trans_committed_bulk( · line 855
Quoted 4 lines
fs/xfs/xfs_trans.c +4
-0+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.
PATCH 9/20 xfs: don't cast inode_log_items to get the log_item
In reply to Christoph HellwigThe cast is not type safe, and we can just dereference the first member instead to start with.
--- fs/xfs/xfs_inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +2 -2
@@ -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);
Signature · 1 line
2.20.1
Re: [PATCH 09/20] xfs: don't cast inode_log_items to get the log_item
Quoted 5 lines · Christoph Hellwig
The cast is not type safe, and we can just dereference the first member instead to start with.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 28 lines
fs/xfs/xfs_inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/xfs_inode.c +2
-2@@ -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);Signature · 1 line
2.20.1
PATCH 10/20 xfs: remove the xfs_log_item_t typedef
In reply to Christoph Hellwig--- 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(-)
fs/xfs/xfs_buf_item.c +3 -3
@@ -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));
fs/xfs/xfs_buf_item.h +3 -3
@@ -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 *,
fs/xfs/xfs_dquot_item.h +2 -2
@@ -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 ;
fs/xfs/xfs_extfree_item.h +2 -2
@@ -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;
fs/xfs/xfs_inode.c +6 -6
@@ -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 );
fs/xfs/xfs_inode_item.h +1 -1
@@ -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 */
fs/xfs/xfs_log_recover.c +1 -1
@@ -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;
fs/xfs/xfs_trans.h +8 -8
@@ -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 *); };/*
fs/xfs/xfs_trans_ail.c +22 -22
123 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 10/20] xfs: remove the xfs_log_item_t typedef
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 334 lines
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(-)fs/xfs/xfs_buf_item.c +3
-3@@ -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));fs/xfs/xfs_buf_item.h +3
-3@@ -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 *,fs/xfs/xfs_dquot_item.h +2
-2@@ -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 ;fs/xfs/xfs_extfree_item.h +2
-2@@ -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;fs/xfs/xfs_inode.c +6
-6@@ -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 );fs/xfs/xfs_inode_item.h +1
-1@@ -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 */fs/xfs/xfs_log_recover.c +1
-1@@ -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;fs/xfs/xfs_trans.h +8
-8@@ -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 *); };/* fs/xfs/xfs_trans_ail.c +22
-22@@ -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);Signature · 1 line
2.20.1
PATCH 11/20 xfs: use a list_head for iclog callbacks
In reply to Christoph HellwigReplace the hand grown linked list handling and cil context attachment with the standard list_head structure.
--- 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(-)
fs/xfs/xfs_log.c +9 -42
@@ -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 ;
fs/xfs/xfs_log.h +3 -12
@@ -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);
fs/xfs/xfs_log_cil.c +24 -7
@@ -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
fs/xfs/xfs_log_priv.h +3 -7
@@ -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; };
Signature · 1 line
2.20.1
Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
Quoted 15 lines · Christoph Hellwig
Replace the hand grown linked list handling and cil context attachment with the standard
list_headstructure.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_log.c +0
-0
...
Quoted 11 lines
fs/xfs/xfs_log.c +2
-5@@ -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);
fs/xfs/xfs_log.c xlog_state_do_callback( · line 2810
Quoted 10 lines
fs/xfs/xfs_log.c +4
-5-/* 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.
Quoted 4 lines
fs/xfs/xfs_log.c +0
-1spin_lock (&iclog->ic_callback_lock); - cb = iclog->ic_callback; }
...
Quoted 4 lines
fs/xfs/xfs_log_cil.c +0
-0
...
fs/xfs/xfs_log_cil.c xlog_cil_committed( · line 624
Quoted 12 lines
fs/xfs/xfs_log_cil.c +8
-0@@ -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?
Quoted 5 lines
fs/xfs/xfs_log_cil.c +5
-0+ struct xfs_cil_ctx, iclog_entry))) { +list_del (&ctx->iclog_entry); +xlog_cil_committed (ctx, aborted); + } +}
...
fs/xfs/xfs_log_cil.c xlog_cil_push( · line 852
Quoted 4 lines
fs/xfs/xfs_log_cil.c +0
-0@@ -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:
Quoted 68 lines
fs/xfs/xfs_log_cil.c +8
-4- 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 fs/xfs/xfs_log_priv.h +3
-7@@ -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; };Signature · 1 line
2.20.1
Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
Quoted 4 lines · Brian Foster
fs/xfs/xfs_log.c xlog_state_do_callback( · line 2810
Quoted 2 lines
fs/xfs/xfs_log.c +2
-0+spin_unlock (&iclog->ic_callback_lock); +xlog_cil_process_commited (&tmp, aborted);s/commited/committed/ please.
Ok.
Quoted 3 lines
fs/xfs/xfs_log_cil.c xlog_cil_committed( · line 624
Quoted 1 line
fs/xfs/xfs_log_cil.c +1
-0+ 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,
Quoted 4 lines
Quoted 1 line
/* 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.
Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
Quoted 12 lines · Christoph Hellwig
Quoted 4 lines · Brian Foster
fs/xfs/xfs_log.c xlog_state_do_callback( · line 2810
Quoted 2 lines
fs/xfs/xfs_log.c +2
-0+spin_unlock (&iclog->ic_callback_lock); +xlog_cil_process_commited (&tmp, aborted);s/commited/committed/ please.
Ok.
Quoted 3 lines
fs/xfs/xfs_log_cil.c xlog_cil_committed( · line 624
Quoted 1 line
fs/xfs/xfs_log_cil.c +1
-0+ while ((ctx = list_first_entry_or_null(list,Are double braces necessary here?
Quoted 6 lines
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
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
/* 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.
Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
Quoted 4 lines · Brian Foster
fs/xfs/xfs_log.c xlog_state_do_callback( · line 2810
Quoted 2 lines
fs/xfs/xfs_log.c +2
-0+spin_unlock (&iclog->ic_callback_lock); +xlog_cil_process_commited (&tmp, aborted);s/commited/committed/ please.
Ok.
Quoted 2 lines
Quoted 1 line
+ while ((ctx = list_first_entry_or_null(list,
Quoted 8 lines
Quoted 1 line
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
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
/* 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.
Re: [PATCH 11/20] xfs: use a list_head for iclog callbacks
Quoted 9 lines · Bryan Gurney
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.
PATCH 12/20 xfs: remove a pointless comment duplicated above all xfs_item_ops instances
In reply to Christoph Hellwig--- 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(-)
fs/xfs/xfs_bmap_item.c +0 -6
@@ -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,
fs/xfs/xfs_buf_item.c +0 -3
@@ -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,
fs/xfs/xfs_dquot_item.c +0 -6
@@ -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,
fs/xfs/xfs_extfree_item.c +0 -6
@@ -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,
fs/xfs/xfs_icreate_item.c +0 -3
@@ -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,
fs/xfs/xfs_inode_item.c +0 -3
@@ -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,
fs/xfs/xfs_refcount_item.c +0 -6
@@ -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,
fs/xfs/xfs_rmap_item.c +0 -6
@@ -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,
Signature · 1 line
2.20.1
Re: [PATCH 12/20] xfs: remove a pointless comment duplicated above all xfs_item_ops instances
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 175 lines
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(-)fs/xfs/xfs_bmap_item.c +0
-6@@ -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,fs/xfs/xfs_buf_item.c +0
-3@@ -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,fs/xfs/xfs_dquot_item.c +0
-6@@ -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,fs/xfs/xfs_extfree_item.c +0
-6@@ -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,fs/xfs/xfs_icreate_item.c +0
-3@@ -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,fs/xfs/xfs_inode_item.c +0
-3@@ -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,fs/xfs/xfs_refcount_item.c +0
-6@@ -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,fs/xfs/xfs_rmap_item.c +0
-6@@ -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,Signature · 1 line
2.20.1
PATCH 13/20 xfs: merge xfs_efd_init into xfs_trans_get_efd
In reply to Christoph HellwigThere is no good reason to keep these two functions separate.
--- 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(-)
fs/xfs/xfs_extfree_item.c +15 -12
@@ -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; }
fs/xfs/xfs_extfree_item.h +0 -2
@@ -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 *);
fs/xfs/xfs_trans_extfree.c +0 -26
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
Quoted 36 lines · Christoph Hellwig
There is no good reason to keep these two functions separate.
Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_extfree_item.c +8
-8@@ -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;
fs/xfs/xfs_extfree_item.c static const struct xfs_item_ops xfs_efd_item_ops = { · line 332
Quoted 10 lines
fs/xfs/xfs_extfree_item.c +4
-3ASSERT (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>
Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
Quoted 6 lines · Nikolay Borisov
xfs_efd_logis really a struct which ends with an array. I think it will make it slightly more obvious if you use the newly introducedstruct_sizelike 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.
Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
In reply to Christoph HellwigQuoted 1 line · Christoph Hellwig
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?
Quoted 110 lines
Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)fs/xfs/xfs_extfree_item.c +15
-12@@ -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; }fs/xfs/xfs_extfree_item.h +0
-2@@ -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 *);fs/xfs/xfs_trans_extfree.c +0
-26@@ -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
Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
Quoted 9 lines · Eric Sandeen
Quoted 1 line · Christoph Hellwig
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(
Quoted 8 lines
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.
Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
There is no good reason to keep these two functions separate.
Signed-off-by Christoph Hellwig <[email protected]>---
Looks good, and there's only one more user of the xfs_efd_log_item_t typedef. ;)
Quoted 110 lines
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(-)fs/xfs/xfs_extfree_item.c +15
-12@@ -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; }fs/xfs/xfs_extfree_item.h +0
-2@@ -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 *);fs/xfs/xfs_trans_extfree.c +0
-26@@ -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 Signature · 1 line
2.20.1
PATCH 14/20 xfs: merge xfs_cud_init into xfs_trans_get_cud
In reply to Christoph HellwigThere is no good reason to keep these two functions separate.
--- 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(-)
fs/xfs/xfs_refcount_item.c +6 -8
@@ -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; }
fs/xfs/xfs_refcount_item.h +0 -2
@@ -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);
fs/xfs/xfs_trans_refcount.c +0 -16
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH 14/20] xfs: merge xfs_cud_init into xfs_trans_get_cud
Quoted 4 lines · Christoph Hellwig
There is no good reason to keep these two functions separate.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 81 lines
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(-)fs/xfs/xfs_refcount_item.c +6
-8@@ -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; }fs/xfs/xfs_refcount_item.h +0
-2@@ -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);fs/xfs/xfs_trans_refcount.c +0
-16@@ -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 Signature · 1 line
2.20.1
PATCH 15/20 xfs: merge xfs_rud_init into xfs_trans_get_rud
In reply to Christoph HellwigThere is no good reason to keep these two functions separate.
--- 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(-)
fs/xfs/xfs_rmap_item.c +6 -8
@@ -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; }
fs/xfs/xfs_rmap_item.h +0 -2
@@ -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 *);
fs/xfs/xfs_trans_rmap.c +0 -12
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH 15/20] xfs: merge xfs_rud_init into xfs_trans_get_rud
Quoted 4 lines · Christoph Hellwig
There is no good reason to keep these two functions separate.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 77 lines
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(-)fs/xfs/xfs_rmap_item.c +6
-8@@ -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; }fs/xfs/xfs_rmap_item.h +0
-2@@ -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 *);fs/xfs/xfs_trans_rmap.c +0
-12@@ -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 Signature · 1 line
2.20.1
PATCH 16/20 xfs: merge xfs_bud_init into xfs_trans_get_bud
In reply to Christoph HellwigThere is no good reason to keep these two functions separate.
--- 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(-)
fs/xfs/xfs_bmap_item.c +6 -8
@@ -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; }
fs/xfs/xfs_bmap_item.h +0 -2
@@ -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);
fs/xfs/xfs_trans_bmap.c +0 -16
@@ -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
Signature · 1 line
2.20.1
Re: [PATCH 16/20] xfs: merge xfs_bud_init into xfs_trans_get_bud
Quoted 4 lines · Christoph Hellwig
There is no good reason to keep these two functions separate.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 81 lines
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(-)fs/xfs/xfs_bmap_item.c +6
-8@@ -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; }fs/xfs/xfs_bmap_item.h +0
-2@@ -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);fs/xfs/xfs_trans_bmap.c +0
-16@@ -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 Signature · 1 line
2.20.1
PATCH 17/20 xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c
In reply to Christoph HellwigKeep all the extree item related code together in one file.
--- 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
fs/xfs/Makefile +0 -1
@@ -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 \
fs/xfs/xfs_extfree_item.c +246 -1
276 lines not on this page · raw message
fs/xfs/xfs_trans.h +0 -8
@@ -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 *);
fs/xfs/xfs_trans_extfree.c deleted +0 -260
260 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 17/20] xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c
Quoted 4 lines · Christoph Hellwig
Keep all the extree item related code together in one file.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 591 lines
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.cfs/xfs/Makefile +0
-1@@ -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 \fs/xfs/xfs_extfree_item.c +246
-1@@ -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. fs/xfs/xfs_trans.h +0
-8@@ -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 *);fs/xfs/xfs_trans_extfree.c deleted +0
-260@@ -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, -};Signature · 1 line
2.20.1
PATCH 18/20 xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c
In reply to Christoph HellwigKeep all the refcount item related code together in one file.
--- 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
fs/xfs/Makefile +0 -1
@@ -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
fs/xfs/xfs_refcount_item.c +207 -1
220 lines not on this page · raw message
fs/xfs/xfs_trans.h +0 -11
@@ -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 ;
fs/xfs/xfs_trans_refcount.c deleted +0 -224
224 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 18/20] xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c
Quoted 4 lines · Christoph Hellwig
Keep all the refcount item related code together in one file.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 500 lines
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.cfs/xfs/Makefile +0
-1@@ -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 featuresfs/xfs/xfs_refcount_item.c +207
-1@@ -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. fs/xfs/xfs_trans.h +0
-11@@ -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 ;fs/xfs/xfs_trans_refcount.c deleted +0
-224@@ -1,224 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2016 Oracle. All Rights Reserved. -* Author: Darrick J. Wong <[email protected]> -*/ -#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, -};Signature · 1 line
2.20.1
PATCH 19/20 xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c
In reply to Christoph HellwigKeep all rmap item related code together in one file.
--- 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
fs/xfs/Makefile +1 -2
@@ -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 \
fs/xfs/xfs_rmap_item.c +228 -1
241 lines not on this page · raw message
fs/xfs/xfs_trans.h +0 -11
@@ -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 ;
fs/xfs/xfs_trans_rmap.c deleted +0 -245
245 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 19/20] xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c
Quoted 4 lines · Christoph Hellwig
Keep all rmap item related code together in one file.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 544 lines
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.cfs/xfs/Makefile +1
-2@@ -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 \fs/xfs/xfs_rmap_item.c +228
-1@@ -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. fs/xfs/xfs_trans.h +0
-11@@ -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 ;fs/xfs/xfs_trans_rmap.c deleted +0
-245@@ -1,245 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2016 Oracle. All Rights Reserved. -* Author: Darrick J. Wong <[email protected]> -*/ -#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, -};Signature · 1 line
2.20.1
PATCH 20/20 xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c
In reply to Christoph HellwigKeep all bmap item related code together.
--- 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
fs/xfs/Makefile +0 -1
@@ -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
fs/xfs/xfs_bmap_item.c +199 -1
218 lines not on this page · raw message
fs/xfs/xfs_trans.h +0 -11
@@ -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__ */
fs/xfs/xfs_trans_bmap.c deleted +0 -216
216 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 20/20] xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c
Quoted 4 lines · Christoph Hellwig
Keep all bmap item related code together.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 489 lines
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.cfs/xfs/Makefile +0
-1@@ -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.ofs/xfs/xfs_bmap_item.c +199
-1@@ -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. fs/xfs/xfs_trans.h +0
-11@@ -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__ */ fs/xfs/xfs_trans_bmap.c deleted +0
-216@@ -1,216 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2016 Oracle. All Rights Reserved. -* Author: Darrick J. Wong <[email protected]> -*/ -#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, -};Signature · 1 line
2.20.1