xfs: Add order IDs to log items in CIL
authorDave Chinner <dchinner@redhat.com>
Thu, 7 Jul 2022 08:53:59 +0000 (18:53 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 7 Jul 2022 08:53:59 +0000 (18:53 +1000)
commit016a23388cdcb2740deb1379dc408f21c84efb11
treeb16d2db66bf4dfc4b2cdd628c5e99c1364a0bea1
parentdf7a4a2134b0a201c93e96efe4bb2be747f9da9f
xfs: Add order IDs to log items in CIL

Before we split the ordered CIL up into per cpu lists, we need a
mechanism to track the order of the items in the CIL. We need to do
this because there are rules around the order in which related items
must physically appear in the log even inside a single checkpoint
transaction.

An example of this is intents - an intent must appear in the log
before it's intent done record so that log recovery can cancel the
intent correctly. If we have these two records misordered in the
CIL, then they will not be recovered correctly by journal replay.

We also will not be able to move items to the tail of
the CIL list when they are relogged, hence the log items will need
some mechanism to allow the correct log item order to be recreated
before we write log items to the hournal.

Hence we need to have a mechanism for recording global order of
transactions in the log items  so that we can recover that order
from un-ordered per-cpu lists.

Do this with a simple monotonic increasing commit counter in the CIL
context. Each log item in the transaction gets stamped with the
current commit order ID before it is added to the CIL. If the item
is already in the CIL, leave it where it is instead of moving it to
the tail of the list and instead sort the list before we start the
push work.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_log_cil.c
fs/xfs/xfs_log_priv.h
fs/xfs/xfs_trans.h