Skip to contentSkip to conversation

fs/gfs2:lock a spinlock always before returning from do_xmote()

PATCH In review Wu Bo 2 participants 2 messages Apr 28, 2020 GFS2 file system

lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 fs/gfs2:lock a spinlock always before returning from do_xmote()

The call stack is as follows:
finish_xmote()

        ...
        spin_lock(&gl->gl_lockref.lock);
        ...
	--> do_xmote()
            spin_unlock(&gl->gl_lockref.lock);
            ...
            return;
        ...
        spin_unlock(&gl->gl_lockref.lock);

do_xmote function needs to be locked before returning, Otherwise, there will be a double release lock in finish_xmote() function.

---
 fs/gfs2/glock.c | 1 +
 1 file changed, 1 insertion(+)
fs/gfs2/glock.c +1 -0
index 29f9b66..7129d10 100644
@@ -613,6 +613,7 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
 				fs_err(sdp, "Error %d syncing glock \n", ret);
 				gfs2_dump_glock(NULL, gl, true);
 			}
+			spin_lock(&gl->gl_lockref.lock);
 			return;
 		}
 	}
Signature · 1 line
1.8.3.1
#1 lore raw

Hi,

Quoted 33 lines · Wu Bo

The call stack is as follows:
finish_xmote()

        ...
        spin_lock(&gl->gl_lockref.lock);
        ...
        --> do_xmote()
            spin_unlock(&gl->gl_lockref.lock);
            ...
            return;
        ...
        spin_unlock(&gl->gl_lockref.lock);

do_xmote function needs to be locked before returning, Otherwise, there will be a double release lock in finish_xmote() function.

---
 fs/gfs2/glock.c | 1 +
 1 file changed, 1 insertion(+)
fs/gfs2/glock.c +1 -1
index 29f9b66..7129d10 100644
@@ -613,6 +613,7 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
                                fs_err(sdp, "Error %d syncing glock \n", ret);
                                gfs2_dump_glock(NULL, gl, true);
                        }
+                       spin_lock(&gl->gl_lockref.lock);
                        return;
                }
        }
--
Quoted 1 line

1.8.3.1

this patch looks correct. We've independently discovered this bug as well in the meantime, and we'll send the fix upstream.

Thanks,
Andreas