Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-6179 llite: Implement ladvise lockahead
[fs/lustre-release.git]
/
lustre
/
osc
/
osc_lock.c
diff --git
a/lustre/osc/osc_lock.c
b/lustre/osc/osc_lock.c
index
b17ebcc
..
6fd75da
100644
(file)
--- a/
lustre/osc/osc_lock.c
+++ b/
lustre/osc/osc_lock.c
@@
-160,11
+160,13
@@
static __u64 osc_enq2ldlm_flags(__u32 enqflags)
{
__u64 result = 0;
+ CDEBUG(D_DLMTRACE, "flags: %x\n", enqflags);
+
LASSERT((enqflags & ~CEF_MASK) == 0);
if (enqflags & CEF_NONBLOCK)
result |= LDLM_FL_BLOCK_NOWAIT;
- if (enqflags & CEF_
ASYNC
)
+ if (enqflags & CEF_
GLIMPSE
)
result |= LDLM_FL_HAS_INTENT;
if (enqflags & CEF_DISCARD_DATA)
result |= LDLM_FL_AST_DISCARD_DATA;
@@
-172,6
+174,10
@@
static __u64 osc_enq2ldlm_flags(__u32 enqflags)
result |= LDLM_FL_TEST_LOCK;
if (enqflags & CEF_LOCK_MATCH)
result |= LDLM_FL_MATCH_LOCK;
+ if (enqflags & CEF_LOCK_NO_EXPAND)
+ result |= LDLM_FL_NO_EXPANSION;
+ if (enqflags & CEF_SPECULATIVE)
+ result |= LDLM_FL_SPECULATIVE;
return result;
}
@@
-350,8
+356,9
@@
static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh,
RETURN(rc);
}
-static int osc_lock_upcall_agl(void *cookie, struct lustre_handle *lockh,
- int errcode)
+static int osc_lock_upcall_speculative(void *cookie,
+ struct lustre_handle *lockh,
+ int errcode)
{
struct osc_object *osc = cookie;
struct ldlm_lock *dlmlock;
@@
-374,7
+381,7
@@
static int osc_lock_upcall_agl(void *cookie, struct lustre_handle *lockh,
lock_res_and_lock(dlmlock);
LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode);
- /* there is no osc_lock associated with
AGL lock
*/
+ /* there is no osc_lock associated with
speculative locks
*/
osc_lock_lvb_update(env, osc, dlmlock, NULL);
unlock_res_and_lock(dlmlock);
@@
-817,7
+824,7
@@
static bool osc_lock_compatible(const struct osc_lock *qing,
struct cl_lock_descr *qed_descr = &qed->ols_cl.cls_lock->cll_descr;
struct cl_lock_descr *qing_descr = &qing->ols_cl.cls_lock->cll_descr;
- if (qed->ols_glimpse)
+ if (qed->ols_glimpse
|| qed->ols_speculative
)
return true;
if (qing_descr->cld_mode == CLM_READ && qed_descr->cld_mode == CLM_READ)
@@
-935,6
+942,7
@@
static int osc_lock_enqueue(const struct lu_env *env,
struct osc_io *oio = osc_env_io(env);
struct osc_object *osc = cl2osc(slice->cls_obj);
struct osc_lock *oscl = cl2osc_lock(slice);
+ struct obd_export *exp = osc_export(osc);
struct cl_lock *lock = slice->cls_lock;
struct ldlm_res_id *resname = &info->oti_resname;
union ldlm_policy_data *policy = &info->oti_policy;
@@
-951,11
+959,22
@@
static int osc_lock_enqueue(const struct lu_env *env,
if (oscl->ols_state == OLS_GRANTED)
RETURN(0);
+ if ((oscl->ols_flags & LDLM_FL_NO_EXPANSION) &&
+ !(exp_connect_lockahead_old(exp) || exp_connect_lockahead(exp))) {
+ result = -EOPNOTSUPP;
+ CERROR("%s: server does not support lockahead/locknoexpand:"
+ "rc = %d\n", exp->exp_obd->obd_name, result);
+ RETURN(result);
+ }
+
if (oscl->ols_flags & LDLM_FL_TEST_LOCK)
GOTO(enqueue_base, 0);
- if (oscl->ols_glimpse) {
- LASSERT(equi(oscl->ols_agl, anchor == NULL));
+ /* For glimpse and/or speculative locks, do not wait for reply from
+ * server on LDLM request */
+ if (oscl->ols_glimpse || oscl->ols_speculative) {
+ /* Speculative and glimpse locks do not have an anchor */
+ LASSERT(equi(oscl->ols_speculative, anchor == NULL));
async = true;
GOTO(enqueue_base, 0);
}
@@
-981,25
+1000,31
@@
enqueue_base:
/**
* DLM lock's ast data must be osc_object;
- * if glimpse or AGL lock, async of osc_enqueue_base() must be true,
+ * if glimpse or speculative lock, async of osc_enqueue_base()
+ * must be true
+ *
+ * For non-speculative locks:
* DLM's enqueue callback set to osc_lock_upcall() with cookie as
* osc_lock.
+ * For speculative locks:
+ * osc_lock_upcall_speculative & cookie is the osc object, since
+ * there is no osc_lock
*/
ostid_build_res_name(&osc->oo_oinfo->loi_oi, resname);
osc_lock_build_policy(env, lock, policy);
- if (oscl->ols_
agl
) {
+ if (oscl->ols_
speculative
) {
oscl->ols_einfo.ei_cbdata = NULL;
/* hold a reference for callback */
cl_object_get(osc2cl(osc));
- upcall = osc_lock_upcall_
agl
;
+ upcall = osc_lock_upcall_
speculative
;
cookie = osc;
}
- result = osc_enqueue_base(
osc_export(osc)
, resname, &oscl->ols_flags,
+ result = osc_enqueue_base(
exp
, resname, &oscl->ols_flags,
policy, &oscl->ols_lvb,
osc->oo_oinfo->loi_kms_valid,
upcall, cookie,
&oscl->ols_einfo, PTLRPCD_SET, async,
- oscl->ols_
agl
);
+ oscl->ols_
speculative
);
if (result == 0) {
if (osc_lock_is_lockless(oscl)) {
oio->oi_lockless = 1;
@@
-1008,9
+1033,12
@@
enqueue_base:
LASSERT(oscl->ols_hold);
LASSERT(oscl->ols_dlmlock != NULL);
}
- } else if (oscl->ols_
agl
) {
+ } else if (oscl->ols_
speculative
) {
cl_object_put(env, osc2cl(osc));
- result = 0;
+ if (oscl->ols_glimpse) {
+ /* hide error for AGL request */
+ result = 0;
+ }
}
out:
@@
-1178,10
+1206,15
@@
int osc_lock_init(const struct lu_env *env,
INIT_LIST_HEAD(&oscl->ols_wait_entry);
INIT_LIST_HEAD(&oscl->ols_nextlock_oscobj);
+ /* Speculative lock requests must be either no_expand or glimpse
+ * request (CEF_GLIMPSE). non-glimpse no_expand speculative extent
+ * locks will break ofd_intent_cb. (see comment there)*/
+ LASSERT(ergo((enqflags & CEF_SPECULATIVE) != 0,
+ (enqflags & (CEF_LOCK_NO_EXPAND | CEF_GLIMPSE)) != 0));
+
oscl->ols_flags = osc_enq2ldlm_flags(enqflags);
- oscl->ols_agl = !!(enqflags & CEF_AGL);
- if (oscl->ols_agl)
- oscl->ols_flags |= LDLM_FL_BLOCK_NOWAIT;
+ oscl->ols_speculative = !!(enqflags & CEF_SPECULATIVE);
+
if (oscl->ols_flags & LDLM_FL_HAS_INTENT) {
oscl->ols_flags |= LDLM_FL_BLOCK_GRANTED;
oscl->ols_glimpse = 1;