ceph: fix improper use of smp_mb__before_atomic() [Linux 4.9.188]

This Linux kernel change "ceph: fix improper use of smp_mb__before_atomic()" is included in the Linux 4.9.188 release. This change is authored by Andrea Parri <andrea.parri [at] amarulasolutions.com> on Mon May 20 19:23:58 2019 +0200. The commit for this change in Linux stable tree is 4e06406 (patch) which is from upstream commit 7496077. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 7496077.

ceph: fix improper use of smp_mb__before_atomic()

[ Upstream commit 749607731e26dfb2558118038c40e9c0c80d23b5 ]

This barrier only applies to the read-modify-write operations; in
particular, it does not apply to the atomic64_set() primitive.

Replace the barrier with an smp_mb().

Fixes: fdd4e15838e59 ("ceph: rework dcache readdir")
Reported-by: "Paul E. McKenney" <[email protected]>
Reported-by: Peter Zijlstra <[email protected]>
Signed-off-by: Andrea Parri <[email protected]>
Reviewed-by: "Yan, Zheng" <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 7 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/ceph/super.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 622d5dd..9bd0d92 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -476,7 +476,12 @@ static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
                       long long release_count,
                       long long ordered_count)
-   smp_mb__before_atomic();
+   /*
+    * Makes sure operations that setup readdir cache (update page
+    * cache and i_size) are strongly ordered w.r.t. the following
+    * atomic64_set() operations.
+    */
+   smp_mb();
    atomic64_set(&ci->i_complete_seq[0], release_count);
    atomic64_set(&ci->i_complete_seq[1], ordered_count);

Leave a Reply

Your email address will not be published. Required fields are marked *