xfs_trans.c (d15cbf2f38b2fbc78512561052953c94cc82a9f5) xfs_trans.c (e8b78db77d48fddd13fd249e88ab7bfffa0661fe)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
4 * Copyright (C) 2010 Red Hat, Inc.
5 * All Rights Reserved.
6 */
7#include "xfs.h"
8#include "xfs_fs.h"

--- 765 unchanged lines hidden (view full) ---

774 bool abort)
775{
776 struct xfs_log_item *lip, *next;
777
778 trace_xfs_trans_free_items(tp, _RET_IP_);
779
780 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
781 xfs_trans_del_item(lip);
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
4 * Copyright (C) 2010 Red Hat, Inc.
5 * All Rights Reserved.
6 */
7#include "xfs.h"
8#include "xfs_fs.h"

--- 765 unchanged lines hidden (view full) ---

774 bool abort)
775{
776 struct xfs_log_item *lip, *next;
777
778 trace_xfs_trans_free_items(tp, _RET_IP_);
779
780 list_for_each_entry_safe(lip, next, &tp->t_items, li_trans) {
781 xfs_trans_del_item(lip);
782 if (commit_lsn != NULLCOMMITLSN)
782 if (commit_lsn != NULLCOMMITLSN &&
783 lip->li_ops->iop_committing)
783 lip->li_ops->iop_committing(lip, commit_lsn);
784 if (abort)
785 set_bit(XFS_LI_ABORTED, &lip->li_flags);
784 lip->li_ops->iop_committing(lip, commit_lsn);
785 if (abort)
786 set_bit(XFS_LI_ABORTED, &lip->li_flags);
786 lip->li_ops->iop_unlock(lip);
787
788 if (lip->li_ops->iop_unlock)
789 lip->li_ops->iop_unlock(lip);
787 }
788}
789
790static inline void
791xfs_log_item_batch_insert(
792 struct xfs_ail *ailp,
793 struct xfs_ail_cursor *cur,
794 struct xfs_log_item **log_items,

--- 4 unchanged lines hidden (view full) ---

799
800 spin_lock(&ailp->ail_lock);
801 /* xfs_trans_ail_update_bulk drops ailp->ail_lock */
802 xfs_trans_ail_update_bulk(ailp, cur, log_items, nr_items, commit_lsn);
803
804 for (i = 0; i < nr_items; i++) {
805 struct xfs_log_item *lip = log_items[i];
806
790 }
791}
792
793static inline void
794xfs_log_item_batch_insert(
795 struct xfs_ail *ailp,
796 struct xfs_ail_cursor *cur,
797 struct xfs_log_item **log_items,

--- 4 unchanged lines hidden (view full) ---

802
803 spin_lock(&ailp->ail_lock);
804 /* xfs_trans_ail_update_bulk drops ailp->ail_lock */
805 xfs_trans_ail_update_bulk(ailp, cur, log_items, nr_items, commit_lsn);
806
807 for (i = 0; i < nr_items; i++) {
808 struct xfs_log_item *lip = log_items[i];
809
807 lip->li_ops->iop_unpin(lip, 0);
810 if (lip->li_ops->iop_unpin)
811 lip->li_ops->iop_unpin(lip, 0);
808 }
809}
810
811/*
812 * Bulk operation version of xfs_trans_committed that takes a log vector of
813 * items to insert into the AIL. This uses bulk AIL insertion techniques to
814 * minimise lock traffic.
815 *

--- 31 unchanged lines hidden (view full) ---

847
848 /* unpin all the log items */
849 for (lv = log_vector; lv; lv = lv->lv_next ) {
850 struct xfs_log_item *lip = lv->lv_item;
851 xfs_lsn_t item_lsn;
852
853 if (aborted)
854 set_bit(XFS_LI_ABORTED, &lip->li_flags);
812 }
813}
814
815/*
816 * Bulk operation version of xfs_trans_committed that takes a log vector of
817 * items to insert into the AIL. This uses bulk AIL insertion techniques to
818 * minimise lock traffic.
819 *

--- 31 unchanged lines hidden (view full) ---

851
852 /* unpin all the log items */
853 for (lv = log_vector; lv; lv = lv->lv_next ) {
854 struct xfs_log_item *lip = lv->lv_item;
855 xfs_lsn_t item_lsn;
856
857 if (aborted)
858 set_bit(XFS_LI_ABORTED, &lip->li_flags);
855 item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
859 if (lip->li_ops->iop_committed)
860 item_lsn = lip->li_ops->iop_committed(lip, commit_lsn);
861 else
862 item_lsn = commit_lsn;
856
857 /* item_lsn of -1 means the item needs no further processing */
858 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
859 continue;
860
861 /*
862 * if we are aborting the operation, no point in inserting the
863 * object into the AIL as we are in a shutdown situation.
864 */
865 if (aborted) {
866 ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount));
863
864 /* item_lsn of -1 means the item needs no further processing */
865 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)
866 continue;
867
868 /*
869 * if we are aborting the operation, no point in inserting the
870 * object into the AIL as we are in a shutdown situation.
871 */
872 if (aborted) {
873 ASSERT(XFS_FORCED_SHUTDOWN(ailp->ail_mount));
867 lip->li_ops->iop_unpin(lip, 1);
874 if (lip->li_ops->iop_unpin)
875 lip->li_ops->iop_unpin(lip, 1);
868 continue;
869 }
870
871 if (item_lsn != commit_lsn) {
872
873 /*
874 * Not a bulk update option due to unusual item_lsn.
875 * Push into AIL immediately, rechecking the lsn once
876 * we have the ail lock. Then unpin the item. This does
877 * not affect the AIL cursor the bulk insert path is
878 * using.
879 */
880 spin_lock(&ailp->ail_lock);
881 if (XFS_LSN_CMP(item_lsn, lip->li_lsn) > 0)
882 xfs_trans_ail_update(ailp, lip, item_lsn);
883 else
884 spin_unlock(&ailp->ail_lock);
876 continue;
877 }
878
879 if (item_lsn != commit_lsn) {
880
881 /*
882 * Not a bulk update option due to unusual item_lsn.
883 * Push into AIL immediately, rechecking the lsn once
884 * we have the ail lock. Then unpin the item. This does
885 * not affect the AIL cursor the bulk insert path is
886 * using.
887 */
888 spin_lock(&ailp->ail_lock);
889 if (XFS_LSN_CMP(item_lsn, lip->li_lsn) > 0)
890 xfs_trans_ail_update(ailp, lip, item_lsn);
891 else
892 spin_unlock(&ailp->ail_lock);
885 lip->li_ops->iop_unpin(lip, 0);
893 if (lip->li_ops->iop_unpin)
894 lip->li_ops->iop_unpin(lip, 0);
886 continue;
887 }
888
889 /* Item is a candidate for bulk AIL insert. */
890 log_items[i++] = lv->lv_item;
891 if (i >= LOG_ITEM_BATCH_SIZE) {
892 xfs_log_item_batch_insert(ailp, &cur, log_items,
893 LOG_ITEM_BATCH_SIZE, commit_lsn);

--- 220 unchanged lines hidden ---
895 continue;
896 }
897
898 /* Item is a candidate for bulk AIL insert. */
899 log_items[i++] = lv->lv_item;
900 if (i >= LOG_ITEM_BATCH_SIZE) {
901 xfs_log_item_batch_insert(ailp, &cur, log_items,
902 LOG_ITEM_BATCH_SIZE, commit_lsn);

--- 220 unchanged lines hidden ---