gfs2: Fix missed wakeups in find_insert_glock
Subsystems (2)
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Fix missed wakeups in find_insert_glock
commit 605b0487f0bc1ae9963bf52ece0f5c8055186f81 upstream.
Mark Syms has reported seeing tasks that are stuck waiting in find_insert_glock. It turns out that struct lm_lockname contains four padding bytes on 64-bit architectures that function glock_waitqueue doesn't skip when hashing the glock name. As a result, we can end up waking up the wrong waitqueue, and the waiting tasks may be stuck forever.
Fix that by using ht_parms.key_len instead of sizeof(struct lm_lockname) for the key length.
--- fs/gfs2/glock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/glock.c +1 -1
@@ -107,7 +107,7 @@ static int glock_wake_function(wait_queue_entry_t *wait, unsigned int mode,static wait_queue_head_t *glock_waitqueue (struct lm_lockname *name) { -u32 hash =jhash2 ((u32 *)name,sizeof (*name) /4 ,0 ); +u32 hash =jhash2 ((u32 *)name, ht_parms.key_len /4 ,0 );return glock_wait_table +hash_32 (hash,GLOCK_WAIT_TABLE_BITS ); }
Signature · 1 line
2.20.1
Quoted 35 lines · Andreas Gruenbacher
commit
605b0487f0bc1ae9963bf52ece0f5c8055186f81upstream.Mark Syms has reported seeing tasks that are stuck waiting in
find_insert_glock. It turns out that structlm_locknamecontains four padding bytes on 64-bit architectures that functionglock_waitqueuedoesn't skip when hashing the glock name. As a result, we can end up waking up the wrong waitqueue, and the waiting tasks may be stuck forever.Fix that by using ht_parms.key_len instead of
sizeof(struct lm_lockname)for the key length.Reported-by Mark Syms <[email protected]>Signed-off-by Andreas Gruenbacher <[email protected]>Signed-off-by Bob Peterson <[email protected]>Cc [email protected] # v4.14+--- fs/gfs2/glock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/gfs2/glock.c +1
-1@@ -107,7 +107,7 @@ static int glock_wake_function(wait_queue_entry_t *wait, unsigned int mode,static wait_queue_head_t *glock_waitqueue (struct lm_lockname *name) { -u32 hash =jhash2 ((u32 *)name,sizeof (*name) /4 ,0 ); +u32 hash =jhash2 ((u32 *)name, ht_parms.key_len /4 ,0 );return glock_wait_table +hash_32 (hash,GLOCK_WAIT_TABLE_BITS ); }Signature · 1 line
2.20.1
Now queued up, thanks.
greg k-h