Whamcloud - gitweb
LU-14073 ofd: remove use of smp_read_barrier_depends()
authorMr NeilBrown <neilb@suse.de>
Mon, 5 Jul 2021 23:59:55 +0000 (16:59 -0700)
committerLi Xi <lixi@ddn.com>
Tue, 13 Jul 2021 08:22:40 +0000 (08:22 +0000)
Linux 5.9 removes smp_read_barrier_depends(), so lustre must stop
using it.

There is only one use: in ofd_access_log.c.
This use is unnecessary and can simply be removed.

The code is based on "Documentation/core-api/circular-buffers.rst"
which gives no indication that this barrier is needed.

The comment say its purpose is to ensure the index is read before the
data is read. This is unnecessary.
The data is written in osl_write_entry(), then a barrier is issued
(smp_store_release) before the ->head is written.
oal_read_entry() issues a barrier (smp_load_acquire()) before reading
that head.
'tail' is read without a barrer, but it then compared against ->head
in CIRC_CNT().  Even if reading ->tail was racey, the fact that
comparing it wilth ->head succeeded means that the data written at
->tail must have been safely written, and we can now read it without
any further barrier.

Lustre-change: https://review.whamcloud.com/40394
Lustre-commit: 9d2776f02b67354b58e9ff93bd7fe5b5495ee288

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I9d0f0aeb67e1188d2012f4ae2e14b3656211c3e2
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/44140
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/ofd/ofd_access_log.c

index d7e96f5..706cdbf 100644 (file)
@@ -190,9 +190,6 @@ static ssize_t oal_read_entry(struct oal_circ_buf *ocb,
 
        BUG_ON(CIRC_CNT(head, tail, oal->oal_log_size) < oal->oal_entry_size);
 
-       /* Read index before reading contents at that index. */
-       smp_read_barrier_depends();
-
        /* Extract one entry from the buffer. */
        rc = min_t(size_t, oal->oal_entry_size, entry_buf_size);
        memcpy(entry_buf, &circ->buf[tail], rc);