Whamcloud - gitweb
LU-649 io: DIO doesn't need lock i_mutex
authorJohann Lombardi <johann@whamcloud.com>
Wed, 28 Mar 2012 12:10:35 +0000 (14:10 +0200)
committerJohann Lombardi <johann@whamcloud.com>
Wed, 28 Mar 2012 12:15:04 +0000 (08:15 -0400)
Revert "LU-649 io: DIO doesn't need lock i_mutex"
This reverts commit 4ebec99e309fcafd1be8a0b10673d69a083ae87f.

There is a concern that this patch is wrong, so i'm reverting it until
the situation is clarified.

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Change-Id: Ia7e12eaeeb87ef30d073e28391a25ffcd8ad146f
Reviewed-on: http://review.whamcloud.com/2398

lustre/llite/rw26.c

index 2455212..f6a3da6 100644 (file)
@@ -260,6 +260,10 @@ ssize_t ll_direct_IO(int rw, struct file *file,
         oinfo.oi_oa = &oa;
         oinfo.oi_md = lsm;
 
+        /* need locking between buffered and direct access. and race with 
+         *size changing by concurrent truncates and writes. */
+        if (rw == READ)
+                LOCK_INODE_MUTEX(inode);
         for (seg = 0; seg < nr_segs; seg++) {
                 size_t iov_left = iov[seg].iov_len;
                 unsigned long user_addr = (unsigned long)iov[seg].iov_base;
@@ -339,9 +343,9 @@ out:
                 int rc;
 
                 rc = ptlrpc_set_wait(set);
-                if (unlikely(rc != 0)) {
-                        tot_bytes = rc;
-                } else if (rw == WRITE && locked) {
+                if (unlikely(rc != 0))
+                        GOTO(unlock_mutex, tot_bytes = rc);
+                if (rw == WRITE && locked) {
                         lov_stripe_lock(lsm);
                         obd_adjust_kms(ll_i2obdexp(inode),
                                        lsm, file_offset, 0);
@@ -350,6 +354,10 @@ out:
         } else {
                 tot_bytes = result;
         }
+unlock_mutex:
+        if (rw == READ)
+                UNLOCK_INODE_MUTEX(inode);
+
         ptlrpc_set_destroy(set);
         RETURN(tot_bytes);
 }