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: Olof Johansson <o...@lixom.net>
Reviewed-by: Jan Kara <j...@suse.cz>
Cc: Geert Uytterhoeven <ge...@linux-m68k.org>
Cc: Stephen Rothwell <s...@canb.auug.org.au>
Cc: Al Viro <v...@zeniv.linux.org.uk>
Cc: Christoph Hellwig <h...@infradead.org>
Cc: Russell King <li...@arm.linux.org.uk>
Cc: H Peter Anvin <h...@zytor.com>

---
 fs/direct-io.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1782023..0e04142 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -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",
                                                      WQ_MEM_RECLAIM, 0,
                                                      sb->s_id);
@@ -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)
                destroy_workqueue(wq);
        return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to