From: Lai Siyao Date: Mon, 12 Dec 2011 15:12:42 +0000 (-0800) Subject: LU-649 io: DIO doesn't need lock i_mutex X-Git-Tag: v1_8_7_81_WC1~32 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=4ebec99e309fcafd1be8a0b10673d69a083ae87f;p=fs%2Flustre-release.git LU-649 io: DIO doesn't need lock i_mutex There is a dead lock if a file is written with with normal IO, and read with DIO at the mean time: regular write: extent lock -> i_mutex DIO read: i_mutex -> server take extent lock i_mutex taken at DIO read is redundant, because server will take extent lock to serialize with write and truncate. Removing it can avoid the deadlock. Change-Id: I280559cebae5d04e4fd943bf3fbe82d67e07834b Signed-off-by: Lai Siyao Reviewed-on: http://review.whamcloud.com/1829 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Johann Lombardi --- diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index f6a3da6..2455212 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -260,10 +260,6 @@ 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; @@ -343,9 +339,9 @@ out: int rc; rc = ptlrpc_set_wait(set); - if (unlikely(rc != 0)) - GOTO(unlock_mutex, tot_bytes = rc); - if (rw == WRITE && locked) { + if (unlikely(rc != 0)) { + tot_bytes = rc; + } else if (rw == WRITE && locked) { lov_stripe_lock(lsm); obd_adjust_kms(ll_i2obdexp(inode), lsm, file_offset, 0); @@ -354,10 +350,6 @@ out: } else { tot_bytes = result; } -unlock_mutex: - if (rw == READ) - UNLOCK_INODE_MUTEX(inode); - ptlrpc_set_destroy(set); RETURN(tot_bytes); }