From: Johann Lombardi Date: Wed, 28 Mar 2012 12:10:35 +0000 (+0200) Subject: LU-649 io: DIO doesn't need lock i_mutex X-Git-Tag: v1_8_7_81_WC1~13 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=01fcfed5fcc841903012e4e6cbc8da7c2c49c38c;p=fs%2Flustre-release.git LU-649 io: DIO doesn't need lock i_mutex 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 Change-Id: Ia7e12eaeeb87ef30d073e28391a25ffcd8ad146f Reviewed-on: http://review.whamcloud.com/2398 --- diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 2455212..f6a3da6 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -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); }