From: kernel test robot <lkp@intel.com>
To: Dave Chinner <david@fromorbit.com>, linux-xfs@vger.kernel.org
Cc: kbuild-all@lists.01.org, clang-built-linux@googlegroups.com
Subject: Re: [PATCH 4/8] xfs: pass a CIL context to xlog_write()
Date: Thu, 17 Jun 2021 22:46:10 +0800 [thread overview]
Message-ID: <202106172226.S7cfRvEB-lkp@intel.com> (raw)
In-Reply-To: <20210617082617.971602-5-david@fromorbit.com>
[-- Attachment #1: Type: text/plain, Size: 33372 bytes --]
Hi Dave,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on next-20210617]
[cannot apply to v5.13-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dave-Chinner/xfs-log-fixes-for-for-next/20210617-162640
base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
config: x86_64-randconfig-a011-20210617 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/fc3370002b56bcb25440b96ef5099f508c48360e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dave-Chinner/xfs-log-fixes-for-for-next/20210617-162640
git checkout fc3370002b56bcb25440b96ef5099f508c48360e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
fs/xfs/xfs_log_cil.c:792:1: warning: no previous prototype for function 'xlog_cil_write_commit_record' [-Wmissing-prototypes]
xlog_cil_write_commit_record(
^
fs/xfs/xfs_log_cil.c:791:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int
^
static
>> fs/xfs/xfs_log_cil.c:1130:24: warning: variable 'commit_lsn' is uninitialized when used here [-Wuninitialized]
if (ctx->start_lsn != commit_lsn) {
^~~~~~~~~~
fs/xfs/xfs_log_cil.c:877:23: note: initialize the variable 'commit_lsn' to silence this warning
xfs_lsn_t commit_lsn;
^
= 0
2 warnings generated.
vim +/commit_lsn +1130 fs/xfs/xfs_log_cil.c
be05dd0e68ac999 Dave Chinner 2021-06-08 846
71e330b593905e4 Dave Chinner 2010-05-21 847 /*
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 848 * Push the Committed Item List to the log.
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 849 *
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 850 * If the current sequence is the same as xc_push_seq we need to do a flush. If
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 851 * xc_push_seq is less than the current sequence, then it has already been
a44f13edf0ebb4e Dave Chinner 2010-08-24 852 * flushed and we don't need to do anything - the caller will wait for it to
a44f13edf0ebb4e Dave Chinner 2010-08-24 853 * complete if necessary.
a44f13edf0ebb4e Dave Chinner 2010-08-24 854 *
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 855 * xc_push_seq is checked unlocked against the sequence number for a match.
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 856 * Hence we can allow log forces to run racily and not issue pushes for the
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 857 * same sequence twice. If we get a race between multiple pushes for the same
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 858 * sequence they will block on the first one and then abort, hence avoiding
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 859 * needless pushes.
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 860 */
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 861 static void
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 862 xlog_cil_push_work(
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 863 struct work_struct *work)
71e330b593905e4 Dave Chinner 2010-05-21 864 {
facd77e4e38b8f0 Dave Chinner 2021-06-04 865 struct xfs_cil_ctx *ctx =
facd77e4e38b8f0 Dave Chinner 2021-06-04 866 container_of(work, struct xfs_cil_ctx, push_work);
facd77e4e38b8f0 Dave Chinner 2021-06-04 867 struct xfs_cil *cil = ctx->cil;
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 868 struct xlog *log = cil->xc_log;
71e330b593905e4 Dave Chinner 2010-05-21 869 struct xfs_log_vec *lv;
71e330b593905e4 Dave Chinner 2010-05-21 870 struct xfs_cil_ctx *new_ctx;
71e330b593905e4 Dave Chinner 2010-05-21 871 struct xlog_in_core *commit_iclog;
66fc9ffa8638be2 Dave Chinner 2021-06-04 872 int num_iovecs = 0;
66fc9ffa8638be2 Dave Chinner 2021-06-04 873 int num_bytes = 0;
71e330b593905e4 Dave Chinner 2010-05-21 874 int error = 0;
877cf3473914ae4 Dave Chinner 2021-06-04 875 struct xlog_cil_trans_hdr thdr;
a47518453bf9581 Dave Chinner 2021-06-08 876 struct xfs_log_vec lvhdr = {};
71e330b593905e4 Dave Chinner 2010-05-21 877 xfs_lsn_t commit_lsn;
4c2d542f2e78653 Dave Chinner 2012-04-23 878 xfs_lsn_t push_seq;
0279bbbbc03f2ce Dave Chinner 2021-06-03 879 struct bio bio;
0279bbbbc03f2ce Dave Chinner 2021-06-03 880 DECLARE_COMPLETION_ONSTACK(bdev_flush);
e12213ba5d909a3 Dave Chinner 2021-06-04 881 bool push_commit_stable;
e469cbe84f4ade9 Dave Chinner 2021-06-08 882 struct xlog_ticket *ticket;
71e330b593905e4 Dave Chinner 2010-05-21 883
facd77e4e38b8f0 Dave Chinner 2021-06-04 884 new_ctx = xlog_cil_ctx_alloc();
71e330b593905e4 Dave Chinner 2010-05-21 885 new_ctx->ticket = xlog_cil_ticket_alloc(log);
71e330b593905e4 Dave Chinner 2010-05-21 886
71e330b593905e4 Dave Chinner 2010-05-21 887 down_write(&cil->xc_ctx_lock);
71e330b593905e4 Dave Chinner 2010-05-21 888
4bb928cdb900d06 Dave Chinner 2013-08-12 889 spin_lock(&cil->xc_push_lock);
4c2d542f2e78653 Dave Chinner 2012-04-23 890 push_seq = cil->xc_push_seq;
4c2d542f2e78653 Dave Chinner 2012-04-23 891 ASSERT(push_seq <= ctx->sequence);
e12213ba5d909a3 Dave Chinner 2021-06-04 892 push_commit_stable = cil->xc_push_commit_stable;
e12213ba5d909a3 Dave Chinner 2021-06-04 893 cil->xc_push_commit_stable = false;
71e330b593905e4 Dave Chinner 2010-05-21 894
0e7ab7efe77451c Dave Chinner 2020-03-24 895 /*
3682277520d6f4a Dave Chinner 2021-06-04 896 * As we are about to switch to a new, empty CIL context, we no longer
3682277520d6f4a Dave Chinner 2021-06-04 897 * need to throttle tasks on CIL space overruns. Wake any waiters that
3682277520d6f4a Dave Chinner 2021-06-04 898 * the hard push throttle may have caught so they can start committing
3682277520d6f4a Dave Chinner 2021-06-04 899 * to the new context. The ctx->xc_push_lock provides the serialisation
3682277520d6f4a Dave Chinner 2021-06-04 900 * necessary for safely using the lockless waitqueue_active() check in
3682277520d6f4a Dave Chinner 2021-06-04 901 * this context.
3682277520d6f4a Dave Chinner 2021-06-04 902 */
3682277520d6f4a Dave Chinner 2021-06-04 903 if (waitqueue_active(&cil->xc_push_wait))
c7f87f3984cfa1e Dave Chinner 2020-06-16 904 wake_up_all(&cil->xc_push_wait);
0e7ab7efe77451c Dave Chinner 2020-03-24 905
4c2d542f2e78653 Dave Chinner 2012-04-23 906 /*
4c2d542f2e78653 Dave Chinner 2012-04-23 907 * Check if we've anything to push. If there is nothing, then we don't
4c2d542f2e78653 Dave Chinner 2012-04-23 908 * move on to a new sequence number and so we have to be able to push
4c2d542f2e78653 Dave Chinner 2012-04-23 909 * this sequence again later.
4c2d542f2e78653 Dave Chinner 2012-04-23 910 */
0d11bae4bcf4aa9 Dave Chinner 2021-06-04 911 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) {
4c2d542f2e78653 Dave Chinner 2012-04-23 912 cil->xc_push_seq = 0;
4bb928cdb900d06 Dave Chinner 2013-08-12 913 spin_unlock(&cil->xc_push_lock);
a44f13edf0ebb4e Dave Chinner 2010-08-24 914 goto out_skip;
4c2d542f2e78653 Dave Chinner 2012-04-23 915 }
4c2d542f2e78653 Dave Chinner 2012-04-23 916
a44f13edf0ebb4e Dave Chinner 2010-08-24 917
cf085a1b5d22144 Joe Perches 2019-11-07 918 /* check for a previously pushed sequence */
facd77e4e38b8f0 Dave Chinner 2021-06-04 919 if (push_seq < ctx->sequence) {
8af3dcd3c89aef1 Dave Chinner 2014-09-23 920 spin_unlock(&cil->xc_push_lock);
df806158b0f6eb2 Dave Chinner 2010-05-17 921 goto out_skip;
8af3dcd3c89aef1 Dave Chinner 2014-09-23 922 }
8af3dcd3c89aef1 Dave Chinner 2014-09-23 923
8af3dcd3c89aef1 Dave Chinner 2014-09-23 924 /*
8af3dcd3c89aef1 Dave Chinner 2014-09-23 925 * We are now going to push this context, so add it to the committing
8af3dcd3c89aef1 Dave Chinner 2014-09-23 926 * list before we do anything else. This ensures that anyone waiting on
8af3dcd3c89aef1 Dave Chinner 2014-09-23 927 * this push can easily detect the difference between a "push in
8af3dcd3c89aef1 Dave Chinner 2014-09-23 928 * progress" and "CIL is empty, nothing to do".
8af3dcd3c89aef1 Dave Chinner 2014-09-23 929 *
8af3dcd3c89aef1 Dave Chinner 2014-09-23 930 * IOWs, a wait loop can now check for:
8af3dcd3c89aef1 Dave Chinner 2014-09-23 931 * the current sequence not being found on the committing list;
8af3dcd3c89aef1 Dave Chinner 2014-09-23 932 * an empty CIL; and
8af3dcd3c89aef1 Dave Chinner 2014-09-23 933 * an unchanged sequence number
8af3dcd3c89aef1 Dave Chinner 2014-09-23 934 * to detect a push that had nothing to do and therefore does not need
8af3dcd3c89aef1 Dave Chinner 2014-09-23 935 * waiting on. If the CIL is not empty, we get put on the committing
8af3dcd3c89aef1 Dave Chinner 2014-09-23 936 * list before emptying the CIL and bumping the sequence number. Hence
8af3dcd3c89aef1 Dave Chinner 2014-09-23 937 * an empty CIL and an unchanged sequence number means we jumped out
8af3dcd3c89aef1 Dave Chinner 2014-09-23 938 * above after doing nothing.
8af3dcd3c89aef1 Dave Chinner 2014-09-23 939 *
8af3dcd3c89aef1 Dave Chinner 2014-09-23 940 * Hence the waiter will either find the commit sequence on the
8af3dcd3c89aef1 Dave Chinner 2014-09-23 941 * committing list or the sequence number will be unchanged and the CIL
8af3dcd3c89aef1 Dave Chinner 2014-09-23 942 * still dirty. In that latter case, the push has not yet started, and
8af3dcd3c89aef1 Dave Chinner 2014-09-23 943 * so the waiter will have to continue trying to check the CIL
8af3dcd3c89aef1 Dave Chinner 2014-09-23 944 * committing list until it is found. In extreme cases of delay, the
8af3dcd3c89aef1 Dave Chinner 2014-09-23 945 * sequence may fully commit between the attempts the wait makes to wait
8af3dcd3c89aef1 Dave Chinner 2014-09-23 946 * on the commit sequence.
8af3dcd3c89aef1 Dave Chinner 2014-09-23 947 */
8af3dcd3c89aef1 Dave Chinner 2014-09-23 948 list_add(&ctx->committing, &cil->xc_committing);
8af3dcd3c89aef1 Dave Chinner 2014-09-23 949 spin_unlock(&cil->xc_push_lock);
df806158b0f6eb2 Dave Chinner 2010-05-17 950
71e330b593905e4 Dave Chinner 2010-05-21 951 /*
0279bbbbc03f2ce Dave Chinner 2021-06-03 952 * The CIL is stable at this point - nothing new will be added to it
0279bbbbc03f2ce Dave Chinner 2021-06-03 953 * because we hold the flush lock exclusively. Hence we can now issue
0279bbbbc03f2ce Dave Chinner 2021-06-03 954 * a cache flush to ensure all the completed metadata in the journal we
0279bbbbc03f2ce Dave Chinner 2021-06-03 955 * are about to overwrite is on stable storage.
0279bbbbc03f2ce Dave Chinner 2021-06-03 956 */
0279bbbbc03f2ce Dave Chinner 2021-06-03 957 xfs_flush_bdev_async(&bio, log->l_mp->m_ddev_targp->bt_bdev,
0279bbbbc03f2ce Dave Chinner 2021-06-03 958 &bdev_flush);
0279bbbbc03f2ce Dave Chinner 2021-06-03 959
a8613836d99e627 Dave Chinner 2021-06-08 960 xlog_cil_pcp_aggregate(cil, ctx);
a8613836d99e627 Dave Chinner 2021-06-08 961
1f18c0c4b78cfb1 Dave Chinner 2021-06-08 962 while (!list_empty(&ctx->log_items)) {
71e330b593905e4 Dave Chinner 2010-05-21 963 struct xfs_log_item *item;
71e330b593905e4 Dave Chinner 2010-05-21 964
1f18c0c4b78cfb1 Dave Chinner 2021-06-08 965 item = list_first_entry(&ctx->log_items,
71e330b593905e4 Dave Chinner 2010-05-21 966 struct xfs_log_item, li_cil);
a47518453bf9581 Dave Chinner 2021-06-08 967 lv = item->li_lv;
a1785f597c8b060 Dave Chinner 2021-06-08 968 lv->lv_order_id = item->li_order_id;
a47518453bf9581 Dave Chinner 2021-06-08 969 num_iovecs += lv->lv_niovecs;
66fc9ffa8638be2 Dave Chinner 2021-06-04 970 /* we don't write ordered log vectors */
66fc9ffa8638be2 Dave Chinner 2021-06-04 971 if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED)
66fc9ffa8638be2 Dave Chinner 2021-06-04 972 num_bytes += lv->lv_bytes;
a47518453bf9581 Dave Chinner 2021-06-08 973
a47518453bf9581 Dave Chinner 2021-06-08 974 list_add_tail(&lv->lv_list, &ctx->lv_chain);
a1785f597c8b060 Dave Chinner 2021-06-08 975 list_del_init(&item->li_cil);
a1785f597c8b060 Dave Chinner 2021-06-08 976 item->li_order_id = 0;
a1785f597c8b060 Dave Chinner 2021-06-08 977 item->li_lv = NULL;
71e330b593905e4 Dave Chinner 2010-05-21 978 }
71e330b593905e4 Dave Chinner 2010-05-21 979
71e330b593905e4 Dave Chinner 2010-05-21 980 /*
facd77e4e38b8f0 Dave Chinner 2021-06-04 981 * Switch the contexts so we can drop the context lock and move out
71e330b593905e4 Dave Chinner 2010-05-21 982 * of a shared context. We can't just go straight to the commit record,
71e330b593905e4 Dave Chinner 2010-05-21 983 * though - we need to synchronise with previous and future commits so
71e330b593905e4 Dave Chinner 2010-05-21 984 * that the commit records are correctly ordered in the log to ensure
71e330b593905e4 Dave Chinner 2010-05-21 985 * that we process items during log IO completion in the correct order.
71e330b593905e4 Dave Chinner 2010-05-21 986 *
71e330b593905e4 Dave Chinner 2010-05-21 987 * For example, if we get an EFI in one checkpoint and the EFD in the
71e330b593905e4 Dave Chinner 2010-05-21 988 * next (e.g. due to log forces), we do not want the checkpoint with
71e330b593905e4 Dave Chinner 2010-05-21 989 * the EFD to be committed before the checkpoint with the EFI. Hence
71e330b593905e4 Dave Chinner 2010-05-21 990 * we must strictly order the commit records of the checkpoints so
71e330b593905e4 Dave Chinner 2010-05-21 991 * that: a) the checkpoint callbacks are attached to the iclogs in the
71e330b593905e4 Dave Chinner 2010-05-21 992 * correct order; and b) the checkpoints are replayed in correct order
71e330b593905e4 Dave Chinner 2010-05-21 993 * in log recovery.
71e330b593905e4 Dave Chinner 2010-05-21 994 *
71e330b593905e4 Dave Chinner 2010-05-21 995 * Hence we need to add this context to the committing context list so
71e330b593905e4 Dave Chinner 2010-05-21 996 * that higher sequences will wait for us to write out a commit record
71e330b593905e4 Dave Chinner 2010-05-21 997 * before they do.
f876e44603ad091 Dave Chinner 2014-02-27 998 *
f39ae5297c5ce2f Dave Chinner 2021-06-04 999 * xfs_log_force_seq requires us to mirror the new sequence into the cil
f876e44603ad091 Dave Chinner 2014-02-27 1000 * structure atomically with the addition of this sequence to the
f876e44603ad091 Dave Chinner 2014-02-27 1001 * committing list. This also ensures that we can do unlocked checks
f876e44603ad091 Dave Chinner 2014-02-27 1002 * against the current sequence in log forces without risking
f876e44603ad091 Dave Chinner 2014-02-27 1003 * deferencing a freed context pointer.
71e330b593905e4 Dave Chinner 2010-05-21 1004 */
4bb928cdb900d06 Dave Chinner 2013-08-12 1005 spin_lock(&cil->xc_push_lock);
facd77e4e38b8f0 Dave Chinner 2021-06-04 1006 xlog_cil_ctx_switch(cil, new_ctx);
4bb928cdb900d06 Dave Chinner 2013-08-12 1007 spin_unlock(&cil->xc_push_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1008 up_write(&cil->xc_ctx_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1009
a1785f597c8b060 Dave Chinner 2021-06-08 1010 /*
a1785f597c8b060 Dave Chinner 2021-06-08 1011 * Sort the log vector chain before we add the transaction headers.
a1785f597c8b060 Dave Chinner 2021-06-08 1012 * This ensures we always have the transaction headers at the start
a1785f597c8b060 Dave Chinner 2021-06-08 1013 * of the chain.
a1785f597c8b060 Dave Chinner 2021-06-08 1014 */
a1785f597c8b060 Dave Chinner 2021-06-08 1015 list_sort(NULL, &ctx->lv_chain, xlog_cil_order_cmp);
a1785f597c8b060 Dave Chinner 2021-06-08 1016
71e330b593905e4 Dave Chinner 2010-05-21 1017 /*
71e330b593905e4 Dave Chinner 2010-05-21 1018 * Build a checkpoint transaction header and write it to the log to
71e330b593905e4 Dave Chinner 2010-05-21 1019 * begin the transaction. We need to account for the space used by the
71e330b593905e4 Dave Chinner 2010-05-21 1020 * transaction header here as it is not accounted for in xlog_write().
a47518453bf9581 Dave Chinner 2021-06-08 1021 * Add the lvhdr to the head of the lv chain we pass to xlog_write() so
a47518453bf9581 Dave Chinner 2021-06-08 1022 * it gets written into the iclog first.
71e330b593905e4 Dave Chinner 2010-05-21 1023 */
877cf3473914ae4 Dave Chinner 2021-06-04 1024 xlog_cil_build_trans_hdr(ctx, &thdr, &lvhdr, num_iovecs);
66fc9ffa8638be2 Dave Chinner 2021-06-04 1025 num_bytes += lvhdr.lv_bytes;
a47518453bf9581 Dave Chinner 2021-06-08 1026 list_add(&lvhdr.lv_list, &ctx->lv_chain);
71e330b593905e4 Dave Chinner 2010-05-21 1027
0279bbbbc03f2ce Dave Chinner 2021-06-03 1028 /*
0279bbbbc03f2ce Dave Chinner 2021-06-03 1029 * Before we format and submit the first iclog, we have to ensure that
0279bbbbc03f2ce Dave Chinner 2021-06-03 1030 * the metadata writeback ordering cache flush is complete.
0279bbbbc03f2ce Dave Chinner 2021-06-03 1031 */
0279bbbbc03f2ce Dave Chinner 2021-06-03 1032 wait_for_completion(&bdev_flush);
0279bbbbc03f2ce Dave Chinner 2021-06-03 1033
877cf3473914ae4 Dave Chinner 2021-06-04 1034 /*
877cf3473914ae4 Dave Chinner 2021-06-04 1035 * The LSN we need to pass to the log items on transaction commit is the
877cf3473914ae4 Dave Chinner 2021-06-04 1036 * LSN reported by the first log vector write, not the commit lsn. If we
877cf3473914ae4 Dave Chinner 2021-06-04 1037 * use the commit record lsn then we can move the tail beyond the grant
877cf3473914ae4 Dave Chinner 2021-06-04 1038 * write head.
877cf3473914ae4 Dave Chinner 2021-06-04 1039 */
fc3370002b56bcb Dave Chinner 2021-06-17 1040 error = xlog_write(log, ctx, &ctx->lv_chain, ctx->ticket,
a47518453bf9581 Dave Chinner 2021-06-08 1041 NULL, num_bytes);
a47518453bf9581 Dave Chinner 2021-06-08 1042
a47518453bf9581 Dave Chinner 2021-06-08 1043 /*
a47518453bf9581 Dave Chinner 2021-06-08 1044 * Take the lvhdr back off the lv_chain as it should not be passed
a47518453bf9581 Dave Chinner 2021-06-08 1045 * to log IO completion.
a47518453bf9581 Dave Chinner 2021-06-08 1046 */
a47518453bf9581 Dave Chinner 2021-06-08 1047 list_del(&lvhdr.lv_list);
71e330b593905e4 Dave Chinner 2010-05-21 1048 if (error)
7db37c5e6575b22 Dave Chinner 2011-01-27 1049 goto out_abort_free_ticket;
71e330b593905e4 Dave Chinner 2010-05-21 1050
71e330b593905e4 Dave Chinner 2010-05-21 1051 /*
71e330b593905e4 Dave Chinner 2010-05-21 1052 * now that we've written the checkpoint into the log, strictly
71e330b593905e4 Dave Chinner 2010-05-21 1053 * order the commit records so replay will get them in the right order.
71e330b593905e4 Dave Chinner 2010-05-21 1054 */
71e330b593905e4 Dave Chinner 2010-05-21 1055 restart:
4bb928cdb900d06 Dave Chinner 2013-08-12 1056 spin_lock(&cil->xc_push_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1057 list_for_each_entry(new_ctx, &cil->xc_committing, committing) {
ac983517ec5941d Dave Chinner 2014-05-07 1058 /*
ac983517ec5941d Dave Chinner 2014-05-07 1059 * Avoid getting stuck in this loop because we were woken by the
ac983517ec5941d Dave Chinner 2014-05-07 1060 * shutdown, but then went back to sleep once already in the
ac983517ec5941d Dave Chinner 2014-05-07 1061 * shutdown state.
ac983517ec5941d Dave Chinner 2014-05-07 1062 */
ac983517ec5941d Dave Chinner 2014-05-07 1063 if (XLOG_FORCED_SHUTDOWN(log)) {
ac983517ec5941d Dave Chinner 2014-05-07 1064 spin_unlock(&cil->xc_push_lock);
ac983517ec5941d Dave Chinner 2014-05-07 1065 goto out_abort_free_ticket;
ac983517ec5941d Dave Chinner 2014-05-07 1066 }
ac983517ec5941d Dave Chinner 2014-05-07 1067
71e330b593905e4 Dave Chinner 2010-05-21 1068 /*
71e330b593905e4 Dave Chinner 2010-05-21 1069 * Higher sequences will wait for this one so skip them.
ac983517ec5941d Dave Chinner 2014-05-07 1070 * Don't wait for our own sequence, either.
71e330b593905e4 Dave Chinner 2010-05-21 1071 */
71e330b593905e4 Dave Chinner 2010-05-21 1072 if (new_ctx->sequence >= ctx->sequence)
71e330b593905e4 Dave Chinner 2010-05-21 1073 continue;
71e330b593905e4 Dave Chinner 2010-05-21 1074 if (!new_ctx->commit_lsn) {
71e330b593905e4 Dave Chinner 2010-05-21 1075 /*
71e330b593905e4 Dave Chinner 2010-05-21 1076 * It is still being pushed! Wait for the push to
71e330b593905e4 Dave Chinner 2010-05-21 1077 * complete, then start again from the beginning.
71e330b593905e4 Dave Chinner 2010-05-21 1078 */
4bb928cdb900d06 Dave Chinner 2013-08-12 1079 xlog_wait(&cil->xc_commit_wait, &cil->xc_push_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1080 goto restart;
71e330b593905e4 Dave Chinner 2010-05-21 1081 }
71e330b593905e4 Dave Chinner 2010-05-21 1082 }
4bb928cdb900d06 Dave Chinner 2013-08-12 1083 spin_unlock(&cil->xc_push_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1084
fc3370002b56bcb Dave Chinner 2021-06-17 1085 error = xlog_cil_write_commit_record(ctx, &commit_iclog);
dd401770b0ff68f Dave Chinner 2020-03-25 1086 if (error)
dd401770b0ff68f Dave Chinner 2020-03-25 1087 goto out_abort_free_ticket;
dd401770b0ff68f Dave Chinner 2020-03-25 1088
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1089 spin_lock(&commit_iclog->ic_callback_lock);
1858bb0bec612df Christoph Hellwig 2019-10-14 1090 if (commit_iclog->ic_state == XLOG_STATE_IOERROR) {
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1091 spin_unlock(&commit_iclog->ic_callback_lock);
e469cbe84f4ade9 Dave Chinner 2021-06-08 1092 goto out_abort_free_ticket;
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1093 }
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1094 ASSERT_ALWAYS(commit_iclog->ic_state == XLOG_STATE_ACTIVE ||
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1095 commit_iclog->ic_state == XLOG_STATE_WANT_SYNC);
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1096 list_add_tail(&ctx->iclog_entry, &commit_iclog->ic_callbacks);
89ae379d564c5d8 Christoph Hellwig 2019-06-28 1097 spin_unlock(&commit_iclog->ic_callback_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1098
71e330b593905e4 Dave Chinner 2010-05-21 1099 /*
71e330b593905e4 Dave Chinner 2010-05-21 1100 * now the checkpoint commit is complete and we've attached the
71e330b593905e4 Dave Chinner 2010-05-21 1101 * callbacks to the iclog we can assign the commit LSN to the context
71e330b593905e4 Dave Chinner 2010-05-21 1102 * and wake up anyone who is waiting for the commit to complete.
71e330b593905e4 Dave Chinner 2010-05-21 1103 */
4bb928cdb900d06 Dave Chinner 2013-08-12 1104 spin_lock(&cil->xc_push_lock);
eb40a87500ac2f6 Dave Chinner 2010-12-21 1105 wake_up_all(&cil->xc_commit_wait);
4bb928cdb900d06 Dave Chinner 2013-08-12 1106 spin_unlock(&cil->xc_push_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1107
e469cbe84f4ade9 Dave Chinner 2021-06-08 1108 /*
e469cbe84f4ade9 Dave Chinner 2021-06-08 1109 * Pull the ticket off the ctx so we can ungrant it after releasing the
e469cbe84f4ade9 Dave Chinner 2021-06-08 1110 * commit_iclog. The ctx may be freed by the time we return from
e469cbe84f4ade9 Dave Chinner 2021-06-08 1111 * releasing the commit_iclog (i.e. checkpoint has been completed and
e469cbe84f4ade9 Dave Chinner 2021-06-08 1112 * callback run) so we can't reference the ctx after the call to
e469cbe84f4ade9 Dave Chinner 2021-06-08 1113 * xlog_state_release_iclog().
e469cbe84f4ade9 Dave Chinner 2021-06-08 1114 */
e469cbe84f4ade9 Dave Chinner 2021-06-08 1115 ticket = ctx->ticket;
e469cbe84f4ade9 Dave Chinner 2021-06-08 1116
5fd9256ce156ef7 Dave Chinner 2021-06-03 1117 /*
815753dc16bbca2 Dave Chinner 2021-06-17 1118 * If the checkpoint spans multiple iclogs, wait for all previous iclogs
815753dc16bbca2 Dave Chinner 2021-06-17 1119 * to complete before we submit the commit_iclog. We can't use state
815753dc16bbca2 Dave Chinner 2021-06-17 1120 * checks for this - ACTIVE can be either a past completed iclog or a
815753dc16bbca2 Dave Chinner 2021-06-17 1121 * future iclog being filled, while WANT_SYNC through SYNC_DONE can be a
815753dc16bbca2 Dave Chinner 2021-06-17 1122 * past or future iclog awaiting IO or ordered IO completion to be run.
815753dc16bbca2 Dave Chinner 2021-06-17 1123 * In the latter case, if it's a future iclog and we wait on it, the we
815753dc16bbca2 Dave Chinner 2021-06-17 1124 * will hang because it won't get processed through to ic_force_wait
815753dc16bbca2 Dave Chinner 2021-06-17 1125 * wakeup until this commit_iclog is written to disk. Hence we use the
815753dc16bbca2 Dave Chinner 2021-06-17 1126 * iclog header lsn and compare it to the commit lsn to determine if we
815753dc16bbca2 Dave Chinner 2021-06-17 1127 * need to wait on iclogs or not.
5fd9256ce156ef7 Dave Chinner 2021-06-03 1128 */
5fd9256ce156ef7 Dave Chinner 2021-06-03 1129 spin_lock(&log->l_icloglock);
cb1acb3f3246368 Dave Chinner 2021-06-04 @1130 if (ctx->start_lsn != commit_lsn) {
815753dc16bbca2 Dave Chinner 2021-06-17 1131 struct xlog_in_core *iclog;
815753dc16bbca2 Dave Chinner 2021-06-17 1132
815753dc16bbca2 Dave Chinner 2021-06-17 1133 for (iclog = commit_iclog->ic_prev;
815753dc16bbca2 Dave Chinner 2021-06-17 1134 iclog != commit_iclog;
815753dc16bbca2 Dave Chinner 2021-06-17 1135 iclog = iclog->ic_prev) {
815753dc16bbca2 Dave Chinner 2021-06-17 1136 xfs_lsn_t hlsn;
815753dc16bbca2 Dave Chinner 2021-06-17 1137
815753dc16bbca2 Dave Chinner 2021-06-17 1138 /*
815753dc16bbca2 Dave Chinner 2021-06-17 1139 * If the LSN of the iclog is zero or in the future it
815753dc16bbca2 Dave Chinner 2021-06-17 1140 * means it has passed through IO completion and
815753dc16bbca2 Dave Chinner 2021-06-17 1141 * activation and hence all previous iclogs have also
815753dc16bbca2 Dave Chinner 2021-06-17 1142 * done so. We do not need to wait at all in this case.
815753dc16bbca2 Dave Chinner 2021-06-17 1143 */
815753dc16bbca2 Dave Chinner 2021-06-17 1144 hlsn = be64_to_cpu(iclog->ic_header.h_lsn);
815753dc16bbca2 Dave Chinner 2021-06-17 1145 if (!hlsn || XFS_LSN_CMP(hlsn, commit_lsn) > 0)
815753dc16bbca2 Dave Chinner 2021-06-17 1146 break;
815753dc16bbca2 Dave Chinner 2021-06-17 1147
815753dc16bbca2 Dave Chinner 2021-06-17 1148 /*
815753dc16bbca2 Dave Chinner 2021-06-17 1149 * If the LSN of the iclog is older than the commit lsn,
815753dc16bbca2 Dave Chinner 2021-06-17 1150 * we have to wait on it. Waiting on this via the
815753dc16bbca2 Dave Chinner 2021-06-17 1151 * ic_force_wait should also order the completion of all
815753dc16bbca2 Dave Chinner 2021-06-17 1152 * older iclogs, too, but we leave checking that to the
815753dc16bbca2 Dave Chinner 2021-06-17 1153 * next loop iteration.
815753dc16bbca2 Dave Chinner 2021-06-17 1154 */
815753dc16bbca2 Dave Chinner 2021-06-17 1155 ASSERT(XFS_LSN_CMP(hlsn, commit_lsn) < 0);
815753dc16bbca2 Dave Chinner 2021-06-17 1156 xlog_wait_on_iclog(iclog);
cb1acb3f3246368 Dave Chinner 2021-06-04 1157 spin_lock(&log->l_icloglock);
815753dc16bbca2 Dave Chinner 2021-06-17 1158 }
815753dc16bbca2 Dave Chinner 2021-06-17 1159
815753dc16bbca2 Dave Chinner 2021-06-17 1160 /*
815753dc16bbca2 Dave Chinner 2021-06-17 1161 * Regardless of whether we need to wait or not, the the
815753dc16bbca2 Dave Chinner 2021-06-17 1162 * commit_iclog write needs to issue a pre-flush so that the
815753dc16bbca2 Dave Chinner 2021-06-17 1163 * ordering for this checkpoint is correctly preserved down to
815753dc16bbca2 Dave Chinner 2021-06-17 1164 * stable storage.
815753dc16bbca2 Dave Chinner 2021-06-17 1165 */
cb1acb3f3246368 Dave Chinner 2021-06-04 1166 commit_iclog->ic_flags |= XLOG_ICL_NEED_FLUSH;
5fd9256ce156ef7 Dave Chinner 2021-06-03 1167 }
5fd9256ce156ef7 Dave Chinner 2021-06-03 1168
cb1acb3f3246368 Dave Chinner 2021-06-04 1169 /*
cb1acb3f3246368 Dave Chinner 2021-06-04 1170 * The commit iclog must be written to stable storage to guarantee
cb1acb3f3246368 Dave Chinner 2021-06-04 1171 * journal IO vs metadata writeback IO is correctly ordered on stable
cb1acb3f3246368 Dave Chinner 2021-06-04 1172 * storage.
e12213ba5d909a3 Dave Chinner 2021-06-04 1173 *
e12213ba5d909a3 Dave Chinner 2021-06-04 1174 * If the push caller needs the commit to be immediately stable and the
e12213ba5d909a3 Dave Chinner 2021-06-04 1175 * commit_iclog is not yet marked as XLOG_STATE_WANT_SYNC to indicate it
e12213ba5d909a3 Dave Chinner 2021-06-04 1176 * will be written when released, switch it's state to WANT_SYNC right
e12213ba5d909a3 Dave Chinner 2021-06-04 1177 * now.
cb1acb3f3246368 Dave Chinner 2021-06-04 1178 */
cb1acb3f3246368 Dave Chinner 2021-06-04 1179 commit_iclog->ic_flags |= XLOG_ICL_NEED_FUA;
e12213ba5d909a3 Dave Chinner 2021-06-04 1180 if (push_commit_stable && commit_iclog->ic_state == XLOG_STATE_ACTIVE)
e12213ba5d909a3 Dave Chinner 2021-06-04 1181 xlog_state_switch_iclogs(log, commit_iclog, 0);
e469cbe84f4ade9 Dave Chinner 2021-06-08 1182 xlog_state_release_iclog(log, commit_iclog, ticket);
cb1acb3f3246368 Dave Chinner 2021-06-04 1183 spin_unlock(&log->l_icloglock);
e469cbe84f4ade9 Dave Chinner 2021-06-08 1184
e469cbe84f4ade9 Dave Chinner 2021-06-08 1185 xfs_log_ticket_ungrant(log, ticket);
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 1186 return;
71e330b593905e4 Dave Chinner 2010-05-21 1187
71e330b593905e4 Dave Chinner 2010-05-21 1188 out_skip:
71e330b593905e4 Dave Chinner 2010-05-21 1189 up_write(&cil->xc_ctx_lock);
71e330b593905e4 Dave Chinner 2010-05-21 1190 xfs_log_ticket_put(new_ctx->ticket);
71e330b593905e4 Dave Chinner 2010-05-21 1191 kmem_free(new_ctx);
c7cc296ddd1f6d1 Christoph Hellwig 2020-03-20 1192 return;
71e330b593905e4 Dave Chinner 2010-05-21 1193
7db37c5e6575b22 Dave Chinner 2011-01-27 1194 out_abort_free_ticket:
877cf3473914ae4 Dave Chinner 2021-06-04 1195 xfs_log_ticket_ungrant(log, ctx->ticket);
12e6a0f449d585b Christoph Hellwig 2020-03-20 1196 ASSERT(XLOG_FORCED_SHUTDOWN(log));
12e6a0f449d585b Christoph Hellwig 2020-03-20 1197 xlog_cil_committed(ctx);
4c2d542f2e78653 Dave Chinner 2012-04-23 1198 }
4c2d542f2e78653 Dave Chinner 2012-04-23 1199
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34451 bytes --]
next prev parent reply other threads:[~2021-06-17 14:47 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 8:26 [PATCH 0/8 V2] xfs: log fixes for for-next Dave Chinner
2021-06-17 8:26 ` [PATCH 1/8] xfs: add iclog state trace events Dave Chinner
2021-06-17 16:45 ` Darrick J. Wong
2021-06-18 14:09 ` Christoph Hellwig
2021-06-17 8:26 ` [PATCH 2/8] xfs: don't wait on future iclogs when pushing the CIL Dave Chinner
2021-06-17 17:49 ` Darrick J. Wong
2021-06-17 21:55 ` Dave Chinner
2021-06-17 8:26 ` [PATCH 3/8] xfs: move xlog_commit_record to xfs_log_cil.c Dave Chinner
2021-06-17 12:57 ` kernel test robot
2021-06-17 17:50 ` Darrick J. Wong
2021-06-17 21:56 ` Dave Chinner
2021-06-18 14:16 ` Christoph Hellwig
2021-06-17 8:26 ` [PATCH 4/8] xfs: pass a CIL context to xlog_write() Dave Chinner
2021-06-17 14:46 ` kernel test robot [this message]
2021-06-17 20:24 ` Darrick J. Wong
2021-06-17 22:03 ` Dave Chinner
2021-06-17 22:18 ` Darrick J. Wong
2021-06-18 14:23 ` Christoph Hellwig
2021-06-28 8:58 ` Dan Carpenter
2021-06-17 8:26 ` [PATCH 5/8] xfs: factor out log write ordering from xlog_cil_push_work() Dave Chinner
2021-06-17 19:59 ` Darrick J. Wong
2021-06-18 14:27 ` Christoph Hellwig
2021-06-18 22:34 ` Dave Chinner
2021-06-17 8:26 ` [PATCH 6/8] xfs: separate out setting CIL context LSNs from xlog_write Dave Chinner
2021-06-17 20:28 ` Darrick J. Wong
2021-06-17 22:10 ` Dave Chinner
2021-06-17 8:26 ` [PATCH 7/8] xfs: attached iclog callbacks in xlog_cil_set_ctx_write_state() Dave Chinner
2021-06-17 20:55 ` Darrick J. Wong
2021-06-17 22:20 ` Dave Chinner
2021-06-17 8:26 ` [PATCH 8/8] xfs: order CIL checkpoint start records Dave Chinner
2021-06-17 21:31 ` Darrick J. Wong
2021-06-17 22:49 ` Dave Chinner
2021-06-17 18:32 ` [PATCH 0/8 V2] xfs: log fixes for for-next Brian Foster
2021-06-17 19:05 ` Darrick J. Wong
2021-06-17 20:06 ` Brian Foster
2021-06-17 20:26 ` Darrick J. Wong
2021-06-17 23:31 ` Brian Foster
2021-06-17 23:43 ` Dave Chinner
2021-06-18 13:08 ` Brian Foster
2021-06-18 13:55 ` Christoph Hellwig
2021-06-18 14:02 ` Christoph Hellwig
2021-06-18 22:28 ` Dave Chinner
2021-06-18 22:15 ` Dave Chinner
2021-06-18 22:48 ` Dave Chinner
2021-06-19 20:22 ` Darrick J. Wong
2021-06-20 22:18 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202106172226.S7cfRvEB-lkp@intel.com \
--to=lkp@intel.com \
--cc=clang-built-linux@googlegroups.com \
--cc=david@fromorbit.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox