Function gfs2_glock_remove_revoke did atomic_dec_return for gl_revokes
without memory barriers. But according to Documentation/core-api/atomic_ops:

"Unlike the above routines, it is required that these primitives
include explicit memory barriers that are performed before and after
the operation.  It must be done such that all memory operations before
and after the atomic operation calls are strongly ordered with respect
to the atomic operation itself."

This patch adds the barriers.

Signed-off-by: Bob Peterson <rpete...@redhat.com>
---
 fs/gfs2/log.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 0644e58c6191..1d51b4781bdd 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -682,7 +682,12 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
 
 void gfs2_glock_remove_revoke(struct gfs2_glock *gl)
 {
-       if (atomic_dec_return(&gl->gl_revokes) == 0) {
+       int revokes;
+
+       smp_mb__before_atomic();
+       revokes = atomic_dec_return(&gl->gl_revokes);
+       smp_mb__after_atomic();
+       if (revokes == 0) {
                clear_bit(GLF_LFLUSH, &gl->gl_flags);
                gfs2_glock_queue_put(gl);
        }
-- 
2.26.2

Reply via email to