X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_io.c;h=5924aa197194374175376129eb59f6edd1c1cd54;hb=a54ecd2c2d964e2ae226fca5b043b5462a34eb7b;hp=929563b7178b1555104b4c5223453205c856f4dc;hpb=3c75d2522786a2a86db450a44da4e764d5ea8f30;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index 929563b..5924aa1 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -63,7 +63,7 @@ static void mdt_dom_resource_prolong(struct ldlm_prolong_args *arg) ENTRY; res = ldlm_resource_get(arg->lpa_export->exp_obd->obd_namespace, NULL, - &arg->lpa_resid, LDLM_EXTENT, 0); + &arg->lpa_resid, LDLM_IBITS, 0); if (IS_ERR(res)) { CDEBUG(D_DLMTRACE, "Failed to get resource for resid %llu/%llu\n", @@ -76,7 +76,11 @@ static void mdt_dom_resource_prolong(struct ldlm_prolong_args *arg) if (ldlm_has_dom(lock)) { LDLM_DEBUG(lock, "DOM lock to prolong "); ldlm_lock_prolong_one(lock, arg); - break; + /* only one PW or EX lock can be granted, + * no need to continue search + */ + if (lock->l_granted_mode & (LCK_PW | LCK_EX)) + break; } } unlock_res(res); @@ -137,7 +141,7 @@ static int mdt_rw_hpreq_lock_match(struct ptlrpc_request *req, RETURN(0); /* a bulk write can only hold a reference on a PW extent lock. */ - mode = LCK_PW; + mode = LCK_PW | LCK_GROUP; if (opc == OST_READ) /* whereas a bulk read can be protected by either a PR or PW * extent lock */ @@ -177,7 +181,7 @@ static int mdt_rw_hpreq_check(struct ptlrpc_request *req) LASSERT(rnb != NULL); LASSERT(!(rnb->rnb_flags & OBD_BRW_SRVLOCK)); - pa.lpa_mode = LCK_PW; + pa.lpa_mode = LCK_PW | LCK_GROUP; if (opc == OST_READ) pa.lpa_mode |= LCK_PR; @@ -265,7 +269,7 @@ static int mdt_punch_hpreq_lock_match(struct ptlrpc_request *req, if (!fid_res_name_eq(&oa->o_oi.oi_fid, &lock->l_resource->lr_name)) RETURN(0); - if (!(lock->l_granted_mode & LCK_PW)) + if (!(lock->l_granted_mode & (LCK_PW | LCK_GROUP))) RETURN(0); RETURN(1); @@ -303,14 +307,13 @@ static int mdt_punch_hpreq_check(struct ptlrpc_request *req) LASSERT(!(oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & OBD_FL_SRVLOCK)); - pa.lpa_mode = LCK_PW; + pa.lpa_mode = LCK_PW | LCK_GROUP; CDEBUG(D_DLMTRACE, "%s: refresh DOM lock for "DFID"\n", tgt_name(tsi->tsi_tgt), PFID(&tsi->tsi_fid)); mdt_prolong_dom_lock(tsi, &pa); - if (pa.lpa_blocks_cnt > 0) { CDEBUG(D_DLMTRACE, "%s: refreshed %u locks timeout for req %p.\n", @@ -595,7 +598,7 @@ static int mdt_commitrw_write(const struct lu_env *env, struct obd_export *exp, struct thandle *th; int rc = 0; int retries = 0; - int i; + int i, restart = 0; ENTRY; @@ -655,8 +658,10 @@ retry: dt_write_lock(env, dob, 0); rc = dt_write_commit(env, dob, lnb, niocount, th, oa->o_size); - if (rc) + if (rc) { + restart = th->th_restart_tran; GOTO(unlock, rc); + } if (la->la_valid) { rc = dt_attr_set(env, dob, la, th); @@ -680,13 +685,23 @@ out_stop: granted = 0; } - th->th_result = rc; + th->th_result = restart ? 0 : rc; dt_trans_stop(env, dt, th); if (rc == -ENOSPC && retries++ < 3) { CDEBUG(D_INODE, "retry after force commit, retries:%d\n", retries); goto retry; } + if (restart) { + retries++; + restart = 0; + if (retries % 10000 == 0) + CERROR("%s: restart IO write too many times: %d\n", + exp->exp_obd->obd_name, retries); + CDEBUG(D_INODE, "retry transaction, retries:%d\n", + retries); + goto retry; + } out: dt_bufs_put(env, dob, lnb, niocount);