ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio
authorRyan Ding <ryan.ding@oracle.com>
Fri, 4 Sep 2015 22:42:36 +0000 (15:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Sep 2015 23:54:41 +0000 (16:54 -0700)
ocfs2_file_write_iter() is usng the wrong return value ('written').  This
will cause ocfs2_rw_unlock() be called both in write_iter & end_io,
triggering a BUG_ON.

This issue was introduced by commit 7da839c47589 ("ocfs2: use
__generic_file_write_iter()").

Orabug: 21612107
Fixes: 7da839c47589 ("ocfs2: use __generic_file_write_iter()")
Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/file.c

index 7210583b472f52d054f89802a893dfd45ce203ac..2eb11363b1f78405d6994ea44cd702b05d396d15 100644 (file)
@@ -2378,6 +2378,20 @@ relock:
        /* buffered aio wouldn't have proper lock coverage today */
        BUG_ON(written == -EIOCBQUEUED && !(iocb->ki_flags & IOCB_DIRECT));
 
+       /*
+        * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
+        * function pointer which is called when o_direct io completes so that
+        * it can unlock our rw lock.
+        * Unfortunately there are error cases which call end_io and others
+        * that don't.  so we don't have to unlock the rw_lock if either an
+        * async dio is going to do it in the future or an end_io after an
+        * error has already done it.
+        */
+       if ((written == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
+               rw_level = -1;
+               unaligned_dio = 0;
+       }
+
        if (unlikely(written <= 0))
                goto no_sync;
 
@@ -2402,20 +2416,6 @@ relock:
        }
 
 no_sync:
-       /*
-        * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
-        * function pointer which is called when o_direct io completes so that
-        * it can unlock our rw lock.
-        * Unfortunately there are error cases which call end_io and others
-        * that don't.  so we don't have to unlock the rw_lock if either an
-        * async dio is going to do it in the future or an end_io after an
-        * error has already done it.
-        */
-       if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
-               rw_level = -1;
-               unaligned_dio = 0;
-       }
-
        if (unaligned_dio) {
                ocfs2_iocb_clear_unaligned_aio(iocb);
                mutex_unlock(&OCFS2_I(inode)->ip_unaligned_aio);
This page took 0.026925 seconds and 5 git commands to generate.