Commit 45150c43 authored by Olof Johansson's avatar Olof Johansson Committed by Linus Torvalds
Browse files

direct-io: Use return from cmpxchg to decide of assignment happened

Not using the return value can in the generic case be racy, so it's
in general good practice to check the return value instead.

This also resolved the warning caused on ARM and other architectures:

  fs/direct-io.c: In function 'sb_init_dio_done_wq':
  fs/direct-io.c:557:2: warning: value computed is not used [-Wunused-value]
Signed-off-by: default avatarOlof Johansson <>
Reviewed-by: default avatarJan Kara <>
Cc: Geert Uytterhoeven <>
Cc: Stephen Rothwell <>
Cc: Al Viro <>
Cc: Christoph Hellwig <>
Cc: Russell King <>
Cc: H Peter Anvin <>
Signed-off-by: default avatarLinus Torvalds <>
parent ef9a61be
......@@ -544,6 +544,7 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
static int sb_init_dio_done_wq(struct super_block *sb)
struct workqueue_struct *old;
struct workqueue_struct *wq = alloc_workqueue("dio/%s",
......@@ -552,9 +553,9 @@ static int sb_init_dio_done_wq(struct super_block *sb)
* This has to be atomic as more DIOs can race to create the workqueue
cmpxchg(&sb->s_dio_done_wq, NULL, wq);
old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
/* Someone created workqueue before us? Free ours... */
if (wq != sb->s_dio_done_wq)
if (old)
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment