From: Jinshan Xiong Date: Thu, 13 Dec 2012 01:17:47 +0000 (-0800) Subject: LU-2304 lov: check enq flags when matching top lock X-Git-Tag: 2.1.4-RC1~3 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=648873f1f27fe8b99573e88c4a3192159ea73326;p=fs%2Flustre-release.git LU-2304 lov: check enq flags when matching top lock cld_enq_flags must be checked when matching top lock, otherwise if a sublock is missing then it will be reenqueued with wrong enq flags. For LU-2304, a previous truncate to zero lock(with CEF_DISCARD_DATA) flags was matched by not-to-zero truncate and then wrongly reenqueued with discard flag. This caused dirty pages to be discarded on the other clients. Signed-off-by: Jinshan Xiong Change-Id: I0575509b3ec30982fe7e5a7ff018ff4dd3dbe911 Reviewed-on: http://review.whamcloud.com/4818 Tested-by: Hudson Reviewed-by: Bobi Jam Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index d1f54da..edd6191 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -830,7 +830,9 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, if (einfo->ei_type == LDLM_EXTENT) lock->l_req_extent = policy->l_extent; - LDLM_DEBUG(lock, "client-side enqueue START"); + + LDLM_DEBUG(lock, "client-side enqueue START, flags %x\n", + *flags); } /* lock not sent to server yet */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 639e9f5..7526bbe 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1307,8 +1307,11 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) int rc = 0, rc1 = 0; ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu valid %x\n", inode->i_ino, + CDEBUG(D_VFSTRACE, + "Setattr inode %p/fid:"DFID" from %llu to %llu, valid %x\n", + inode, PFID(&lli->lli_fid), i_size_read(inode), attr->ia_size, attr->ia_valid); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETATTR, 1); if (ia_valid & ATTR_SIZE) { diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 6497488..bc9397d 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -299,10 +299,10 @@ static int vvp_io_setattr_iter_init(const struct lu_env *env, static int vvp_io_setattr_lock(const struct lu_env *env, const struct cl_io_slice *ios) { - struct ccc_io *cio = ccc_env_io(env); - struct cl_io *io = ios->cis_io; - size_t new_size; - __u32 enqflags = 0; + struct ccc_io *cio = ccc_env_io(env); + struct cl_io *io = ios->cis_io; + __u64 new_size; + __u32 enqflags = 0; if (cl_io_is_trunc(io)) { new_size = io->u.ci_setattr.sa_attr.lvb_size; diff --git a/lustre/lov/lov_lock.c b/lustre/lov/lov_lock.c index b9b308f..1bc4e6a 100644 --- a/lustre/lov/lov_lock.c +++ b/lustre/lov/lov_lock.c @@ -984,6 +984,11 @@ static int lov_lock_fits_into(const struct lu_env *env, ENTRY; + /* for top lock, it's necessary to match enq flags otherwise it will + * run into problem if a sublock is missing and reenqueue. */ + if (need->cld_enq_flags != lov->lls_orig.cld_enq_flags) + return 0; + if (need->cld_mode == CLM_GROUP) /* * always allow to match group lock. diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index e30e309..f6d73f5 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -1638,6 +1638,9 @@ int osc_lock_init(const struct lu_env *env, if (clk->ols_locklessable && !(enqflags & CEF_DISCARD_DATA)) clk->ols_flags |= LDLM_FL_DENY_ON_CONTENTION; + LDLM_DEBUG_NOLOCK("lock %p, osc lock %p, flags %x\n", + lock, clk, clk->ols_flags); + result = 0; } else result = -ENOMEM;