Skip to content

Commit 613e2fd

Browse files
Dave ChinnerChandan Babu R
authored andcommitted
xfs: move and rename xfs_trans_committed_bulk
Ever since the CIL and delayed logging was introduced, xfs_trans_committed_bulk() has been a purely CIL checkpoint completion function and not a transaction commit completion function. Now that we are adding log specific updates to this function, it really does not have anything to do with the transaction subsystem - it is really log and log item level functionality. This should be part of the CIL code as it is the callback that moves log items from the CIL checkpoint to the AIL. Move it and rename it to xlog_cil_ail_insert(). Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 9ff4490 commit 613e2fd

File tree

3 files changed

+131
-133
lines changed

3 files changed

+131
-133
lines changed

fs/xfs/xfs_log_cil.c

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,136 @@ xlog_cil_insert_items(
694694
}
695695
}
696696

697+
static inline void
698+
xlog_cil_ail_insert_batch(
699+
struct xfs_ail *ailp,
700+
struct xfs_ail_cursor *cur,
701+
struct xfs_log_item **log_items,
702+
int nr_items,
703+
xfs_lsn_t commit_lsn)
704+
{
705+
int i;
706+
707+
spin_lock(&ailp->ail_lock);
708+
/* xfs_trans_ail_update_bulk drops ailp->ail_lock */
709+
xfs_trans_ail_update_bulk(ailp, cur, log_items, nr_items, commit_lsn);
710+
711+
for (i = 0; i < nr_items; i++) {
712+
struct xfs_log_item *lip = log_items[i];
713+
714+
if (lip->li_ops->iop_unpin)
715+
lip->li_ops->iop_unpin(lip, 0);
716+
}
717+
}
718+
719+
/*
720+
* Take the checkpoint's log vector chain of items and insert the attached log
721+
* items into the AIL. This uses bulk insertion techniques to minimise AIL lock
722+
* traffic.
723+
*
724+
* If we are called with the aborted flag set, it is because a log write during
725+
* a CIL checkpoint commit has failed. In this case, all the items in the
726+
* checkpoint have already gone through iop_committed and iop_committing, which
727+
* means that checkpoint commit abort handling is treated exactly the same as an
728+
* iclog write error even though we haven't started any IO yet. Hence in this
729+
* case all we need to do is iop_committed processing, followed by an
730+
* iop_unpin(aborted) call.
731+
*
732+
* The AIL cursor is used to optimise the insert process. If commit_lsn is not
733+
* at the end of the AIL, the insert cursor avoids the need to walk the AIL to
734+
* find the insertion point on every xfs_log_item_batch_insert() call. This
735+
* saves a lot of needless list walking and is a net win, even though it
736+
* slightly increases that amount of AIL lock traffic to set it up and tear it
737+
* down.
738+
*/
739+
static void
740+
xlog_cil_ail_insert(
741+
struct xlog *log,
742+
struct list_head *lv_chain,
743+
xfs_lsn_t commit_lsn,
744+
bool aborted)
745+
{
746+
#define LOG_ITEM_BATCH_SIZE 32
747+
struct xfs_ail *ailp = log->l_ailp;
748+
struct xfs_log_item *log_items[LOG_ITEM_BATCH_SIZE];
749+
struct xfs_log_vec *lv;
750+
struct xfs_ail_cursor cur;
751+
int i = 0;
752+
753+
spin_lock(&ailp->ail_lock);
754+
xfs_trans_ail_cursor_last(ailp, &cur, commit_lsn);
755+
spin_unlock(&ailp->ail_lock);
756+
757+
/* unpin all the log items */
758+
list_for_each_entry(lv, lv_chain, lv_list) {
759+
struct xfs_log_item *lip = lv->lv_item;
760+
xfs_lsn_t item_lsn;
761+
762+
if (aborted)
763+
set_bit(XFS_LI_ABORTED, &lip->li_flags);
764+
765+
if (lip->li_ops->flags & XFS_ITEM_RELEASE_WHEN_COMMITTED) {
766+
lip->li_ops->iop_release(lip);
767+
continue;
768+
}
769+
770+
if (lip->li_ops->iop_committed)
771+
item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
772+
else
773+
item_lsn = commit_lsn;
774+
775+
/* item_lsn of -1 means the item needs no further processing */
776+
if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
777+
continue;
778+
779+
/*
780+
* if we are aborting the operation, no point in inserting the
781+
* object into the AIL as we are in a shutdown situation.
782+
*/
783+
if (aborted) {
784+
ASSERT(xlog_is_shutdown(ailp->ail_log));
785+
if (lip->li_ops->iop_unpin)
786+
lip->li_ops->iop_unpin(lip, 1);
787+
continue;
788+
}
789+
790+
if (item_lsn != commit_lsn) {
791+
792+
/*
793+
* Not a bulk update option due to unusual item_lsn.
794+
* Push into AIL immediately, rechecking the lsn once
795+
* we have the ail lock. Then unpin the item. This does
796+
* not affect the AIL cursor the bulk insert path is
797+
* using.
798+
*/
799+
spin_lock(&ailp->ail_lock);
800+
if (XFS_LSN_CMP(item_lsn, lip->li_lsn) > 0)
801+
xfs_trans_ail_update(ailp, lip, item_lsn);
802+
else
803+
spin_unlock(&ailp->ail_lock);
804+
if (lip->li_ops->iop_unpin)
805+
lip->li_ops->iop_unpin(lip, 0);
806+
continue;
807+
}
808+
809+
/* Item is a candidate for bulk AIL insert. */
810+
log_items[i++] = lv->lv_item;
811+
if (i >= LOG_ITEM_BATCH_SIZE) {
812+
xlog_cil_ail_insert_batch(ailp, &cur, log_items,
813+
LOG_ITEM_BATCH_SIZE, commit_lsn);
814+
i = 0;
815+
}
816+
}
817+
818+
/* make sure we insert the remainder! */
819+
if (i)
820+
xlog_cil_ail_insert_batch(ailp, &cur, log_items, i, commit_lsn);
821+
822+
spin_lock(&ailp->ail_lock);
823+
xfs_trans_ail_cursor_done(&cur);
824+
spin_unlock(&ailp->ail_lock);
825+
}
826+
697827
static void
698828
xlog_cil_free_logvec(
699829
struct list_head *lv_chain)
@@ -733,7 +863,7 @@ xlog_cil_committed(
733863
spin_unlock(&ctx->cil->xc_push_lock);
734864
}
735865

736-
xfs_trans_committed_bulk(ctx->cil->xc_log->l_ailp, &ctx->lv_chain,
866+
xlog_cil_ail_insert(ctx->cil->xc_log, &ctx->lv_chain,
737867
ctx->start_lsn, abort);
738868

739869
xfs_extent_busy_sort(&ctx->busy_extents.extent_list);

fs/xfs/xfs_trans.c

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -725,135 +725,6 @@ xfs_trans_free_items(
725725
}
726726
}
727727

728-
static inline void
729-
xfs_log_item_batch_insert(
730-
struct xfs_ail *ailp,
731-
struct xfs_ail_cursor *cur,
732-
struct xfs_log_item **log_items,
733-
int nr_items,
734-
xfs_lsn_t commit_lsn)
735-
{
736-
int i;
737-
738-
spin_lock(&ailp->ail_lock);
739-
/* xfs_trans_ail_update_bulk drops ailp->ail_lock */
740-
xfs_trans_ail_update_bulk(ailp, cur, log_items, nr_items, commit_lsn);
741-
742-
for (i = 0; i < nr_items; i++) {
743-
struct xfs_log_item *lip = log_items[i];
744-
745-
if (lip->li_ops->iop_unpin)
746-
lip->li_ops->iop_unpin(lip, 0);
747-
}
748-
}
749-
750-
/*
751-
* Bulk operation version of xfs_trans_committed that takes a log vector of
752-
* items to insert into the AIL. This uses bulk AIL insertion techniques to
753-
* minimise lock traffic.
754-
*
755-
* If we are called with the aborted flag set, it is because a log write during
756-
* a CIL checkpoint commit has failed. In this case, all the items in the
757-
* checkpoint have already gone through iop_committed and iop_committing, which
758-
* means that checkpoint commit abort handling is treated exactly the same
759-
* as an iclog write error even though we haven't started any IO yet. Hence in
760-
* this case all we need to do is iop_committed processing, followed by an
761-
* iop_unpin(aborted) call.
762-
*
763-
* The AIL cursor is used to optimise the insert process. If commit_lsn is not
764-
* at the end of the AIL, the insert cursor avoids the need to walk
765-
* the AIL to find the insertion point on every xfs_log_item_batch_insert()
766-
* call. This saves a lot of needless list walking and is a net win, even
767-
* though it slightly increases that amount of AIL lock traffic to set it up
768-
* and tear it down.
769-
*/
770-
void
771-
xfs_trans_committed_bulk(
772-
struct xfs_ail *ailp,
773-
struct list_head *lv_chain,
774-
xfs_lsn_t commit_lsn,
775-
bool aborted)
776-
{
777-
#define LOG_ITEM_BATCH_SIZE 32
778-
struct xfs_log_item *log_items[LOG_ITEM_BATCH_SIZE];
779-
struct xfs_log_vec *lv;
780-
struct xfs_ail_cursor cur;
781-
int i = 0;
782-
783-
spin_lock(&ailp->ail_lock);
784-
xfs_trans_ail_cursor_last(ailp, &cur, commit_lsn);
785-
spin_unlock(&ailp->ail_lock);
786-
787-
/* unpin all the log items */
788-
list_for_each_entry(lv, lv_chain, lv_list) {
789-
struct xfs_log_item *lip = lv->lv_item;
790-
xfs_lsn_t item_lsn;
791-
792-
if (aborted)
793-
set_bit(XFS_LI_ABORTED, &lip->li_flags);
794-
795-
if (lip->li_ops->flags & XFS_ITEM_RELEASE_WHEN_COMMITTED) {
796-
lip->li_ops->iop_release(lip);
797-
continue;
798-
}
799-
800-
if (lip->li_ops->iop_committed)
801-
item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
802-
else
803-
item_lsn = commit_lsn;
804-
805-
/* item_lsn of -1 means the item needs no further processing */
806-
if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
807-
continue;
808-
809-
/*
810-
* if we are aborting the operation, no point in inserting the
811-
* object into the AIL as we are in a shutdown situation.
812-
*/
813-
if (aborted) {
814-
ASSERT(xlog_is_shutdown(ailp->ail_log));
815-
if (lip->li_ops->iop_unpin)
816-
lip->li_ops->iop_unpin(lip, 1);
817-
continue;
818-
}
819-
820-
if (item_lsn != commit_lsn) {
821-
822-
/*
823-
* Not a bulk update option due to unusual item_lsn.
824-
* Push into AIL immediately, rechecking the lsn once
825-
* we have the ail lock. Then unpin the item. This does
826-
* not affect the AIL cursor the bulk insert path is
827-
* using.
828-
*/
829-
spin_lock(&ailp->ail_lock);
830-
if (XFS_LSN_CMP(item_lsn, lip->li_lsn) > 0)
831-
xfs_trans_ail_update(ailp, lip, item_lsn);
832-
else
833-
spin_unlock(&ailp->ail_lock);
834-
if (lip->li_ops->iop_unpin)
835-
lip->li_ops->iop_unpin(lip, 0);
836-
continue;
837-
}
838-
839-
/* Item is a candidate for bulk AIL insert. */
840-
log_items[i++] = lv->lv_item;
841-
if (i >= LOG_ITEM_BATCH_SIZE) {
842-
xfs_log_item_batch_insert(ailp, &cur, log_items,
843-
LOG_ITEM_BATCH_SIZE, commit_lsn);
844-
i = 0;
845-
}
846-
}
847-
848-
/* make sure we insert the remainder! */
849-
if (i)
850-
xfs_log_item_batch_insert(ailp, &cur, log_items, i, commit_lsn);
851-
852-
spin_lock(&ailp->ail_lock);
853-
xfs_trans_ail_cursor_done(&cur);
854-
spin_unlock(&ailp->ail_lock);
855-
}
856-
857728
/*
858729
* Sort transaction items prior to running precommit operations. This will
859730
* attempt to order the items such that they will always be locked in the same

fs/xfs/xfs_trans_priv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
1919
void xfs_trans_del_item(struct xfs_log_item *);
2020
void xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp);
2121

22-
void xfs_trans_committed_bulk(struct xfs_ail *ailp,
23-
struct list_head *lv_chain,
24-
xfs_lsn_t commit_lsn, bool aborted);
2522
/*
2623
* AIL traversal cursor.
2724
*

0 commit comments

Comments
 (0)