struct md_object *next = mdt_object_child(parent);
struct lu_fid *child_fid = &info->mti_tmp_fid1;
struct lu_name *lname = NULL;
- const char *name;
+ const char *name = NULL;
int namelen = 0;
struct mdt_lock_handle *lhp;
struct ldlm_lock *lock;
namelen = req_capsule_get_size(info->mti_pill, &RMF_NAME,
RCL_CLIENT) - 1;
- LASSERT(namelen >= 0);
-
- /* XXX: "namelen == 0" is for getattr by fid (OBD_CONNECT_ATTRFID),
- * otherwise do not allow empty name, that is the name must contain
- * at least one character and the terminating '\0'*/
- if (namelen == 0) {
- reqbody =req_capsule_client_get(info->mti_pill, &RMF_MDT_BODY);
- LASSERT(fid_is_sane(&reqbody->fid2));
- name = NULL;
-
- CDEBUG(D_INODE, "getattr with lock for "DFID"/"DFID", "
- "ldlm_rep = %p\n",
- PFID(mdt_object_fid(parent)), PFID(&reqbody->fid2),
- ldlm_rep);
- } else {
- lname = mdt_name(info->mti_env, (char *)name, namelen);
- CDEBUG(D_INODE, "getattr with lock for "DFID"/%s, "
- "ldlm_rep = %p\n",
- PFID(mdt_object_fid(parent)), name, ldlm_rep);
- }
+ if (!info->mti_cross_ref) {
+ /*
+ * XXX: Check for "namelen == 0" is for getattr by fid
+ * (OBD_CONNECT_ATTRFID), otherwise do not allow empty name,
+ * that is the name must contain at least one character and
+ * the terminating '\0'
+ */
+ if (namelen == 0) {
+ reqbody = req_capsule_client_get(info->mti_pill,
+ &RMF_MDT_BODY);
+ LASSERT(fid_is_sane(&reqbody->fid2));
+ name = NULL;
+ CDEBUG(D_INODE, "getattr with lock for "DFID"/"DFID", "
+ "ldlm_rep = %p\n",
+ PFID(mdt_object_fid(parent)), PFID(&reqbody->fid2),
+ ldlm_rep);
+ } else {
+ lname = mdt_name(info->mti_env, (char *)name, namelen);
+ CDEBUG(D_INODE, "getattr with lock for "DFID"/%s, "
+ "ldlm_rep = %p\n", PFID(mdt_object_fid(parent)),
+ name, ldlm_rep);
+ }
+ }
mdt_set_disposition(info, ldlm_rep, DISP_LOOKUP_EXECD);
rc = mdt_object_exists(parent);
&parent->mot_obj.mo_lu,
"Parent doesn't exist!\n");
RETURN(-ESTALE);
- } else
+ } else if (!info->mti_cross_ref) {
LASSERTF(rc > 0, "Parent "DFID" is on remote server\n",
PFID(mdt_object_fid(parent)));
-
+ }
if (lname) {
rc = mdt_raw_lookup(info, parent, lname, ldlm_rep);
if (rc != 0) {
continue;
fid_le_to_cpu(lf, &ent->lde_fid);
- if (le32_to_cpu(ent->lde_hash) & MAX_HASH_HIGHEST_BIT)
+ if (le64_to_cpu(ent->lde_hash) & MAX_HASH_HIGHEST_BIT)
ma->ma_attr.la_mode = S_IFDIR;
else
ma->ma_attr.la_mode = 0;
memcpy(name, ent->lde_name, le16_to_cpu(ent->lde_namelen));
lname = mdt_name(info->mti_env, name,
- le16_to_cpu(ent->lde_namelen) + 1);
+ le16_to_cpu(ent->lde_namelen));
ma->ma_attr_flags |= MDS_PERM_BYPASS;
rc = mdo_name_insert(info->mti_env,
md_object_next(&object->mot_obj),
* reqbody->nlink contains number bytes to read.
*/
rdpg->rp_hash = reqbody->size;
- if ((__u64)rdpg->rp_hash != reqbody->size) {
- CERROR("Invalid hash: %#llx != %#llx\n",
- (__u64)rdpg->rp_hash, reqbody->size);
+ if (rdpg->rp_hash != reqbody->size) {
+ CERROR("Invalid hash: "LPX64" != "LPX64"\n",
+ rdpg->rp_hash, reqbody->size);
RETURN(-EFAULT);
}
rdpg->rp_count = reqbody->nlink;
ENTRY;
CDEBUG(D_INFO, "Find object for "DFID"\n", PFID(f));
- o = lu_object_find(env, d->mdt_md_dev.md_lu_dev.ld_site, f);
+ o = lu_object_find(env, &d->mdt_md_dev.md_lu_dev, f, NULL);
if (unlikely(IS_ERR(o)))
m = (struct mdt_object *)o;
else
LASSERT(lh->mlh_type != MDT_PDO_LOCK);
}
+ if (lh->mlh_type == MDT_PDO_LOCK) {
+ /* check for exists after object is locked */
+ if (mdt_object_exists(o) == 0) {
+ /* Non-existent object shouldn't have PDO lock */
+ RETURN(-ESTALE);
+ } else {
+ /* Non-dir object shouldn't have PDO lock */
+ LASSERT(S_ISDIR(lu_object_attr(&o->mot_obj.mo_lu)));
+ }
+ }
+
memset(policy, 0, sizeof(*policy));
fid_build_reg_res_name(mdt_object_fid(o), res_id);
}
/*
- * Finish res_id initializing by name hash marking patr of
+ * Finish res_id initializing by name hash marking part of
* directory which is taking modification.
*/
res_id->name[LUSTRE_RES_ID_HSH_OFF] = lh->mlh_pdo_hash;
/*
* Use LDLM_FL_LOCAL_ONLY for this lock. We do not know yet if it is
* going to be sent to client. If it is - mdt_intent_policy() path will
- * fix it up and turns FL_LOCAL flag off.
+ * fix it up and turn FL_LOCAL flag off.
*/
rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
res_id, LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB);
if (rc)
GOTO(out, rc);
- if (lh->mlh_type == MDT_PDO_LOCK) {
- /* check for exists after object is locked */
- if (mdt_object_exists(o) == 0) {
- /* Non-existent object shouldn't have PDO lock */
- rc = -ESTALE;
- } else {
- /* Non-dir object shouldn't have PDO lock */
- LASSERT(S_ISDIR(lu_object_attr(&o->mot_obj.mo_lu)));
- }
- }
out:
if (rc)
mdt_object_unlock(info, o, lh, 1);
* lock.
*/
if (new_lock == NULL)
- new_lock = ldlm_handle2lock(&lh->mlh_reg_lh);
+ new_lock = ldlm_handle2lock_long(&lh->mlh_reg_lh, 0);
if (new_lock == NULL && (flags & LDLM_FL_INTENT_ONLY)) {
lh->mlh_reg_lh.cookie = 0;
* Fixup the lock to be given to the client.
*/
lock_res_and_lock(new_lock);
- new_lock->l_readers = 0;
- new_lock->l_writers = 0;
+ /* Zero new_lock->l_readers and new_lock->l_writers without triggering
+ * possible blocking AST. */
+ while (new_lock->l_readers > 0) {
+ lu_ref_del(&new_lock->l_reference, "reader", new_lock);
+ lu_ref_del(&new_lock->l_reference, "user", new_lock);
+ new_lock->l_readers--;
+ }
+ while (new_lock->l_writers > 0) {
+ lu_ref_del(&new_lock->l_reference, "writer", new_lock);
+ lu_ref_del(&new_lock->l_reference, "user", new_lock);
+ new_lock->l_writers--;
+ }
new_lock->l_export = class_export_get(req->rq_export);
new_lock->l_blocking_ast = lock->l_blocking_ast;
&new_lock->l_exp_hash);
unlock_res_and_lock(new_lock);
- LDLM_LOCK_PUT(new_lock);
+ LDLM_LOCK_RELEASE(new_lock);
lh->mlh_reg_lh.cookie = 0;
RETURN(ELDLM_LOCK_REPLACED);
m->mdt_bottom = NULL;
}
-static struct lu_device *mdt_layer_setup(const struct lu_env *env,
+static struct lu_device *mdt_layer_setup(struct lu_env *env,
const char *typename,
struct lu_device *child,
struct lustre_cfg *cfg)
return ERR_PTR(rc);
}
-static int mdt_stack_init(const struct lu_env *env,
+static int mdt_stack_init(struct lu_env *env,
struct mdt_device *m, struct lustre_cfg *cfg)
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
}
/* init the stack */
- rc = mdt_stack_init(env, m, cfg);
+ rc = mdt_stack_init((struct lu_env *)env, m, cfg);
if (rc) {
CERROR("Can't init device stack, rc %d\n", rc);
GOTO(err_fini_proc, rc);
struct obd_device *obd = d->ld_obd;
lprocfs_mdt_init_vars(&lvars);
- rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, cfg, obd);
- if (rc)
- /* others are passed further */
+ rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars,
+ cfg, obd);
+ if (rc == -ENOSYS)
+ /* we don't understand; pass it on */
rc = next->ld_ops->ldo_process_config(env, next, cfg);
break;
}
RETURN(NULL);
}
-static int mdt_object_init(const struct lu_env *env, struct lu_object *o)
+static int mdt_object_init(const struct lu_env *env, struct lu_object *o,
+ const struct lu_object_conf *_)
{
struct mdt_device *d = mdt_dev(o->lo_dev);
struct lu_device *under;