- obj2 = lmv_obj_grab(obd, &body->fid1);
-
- if (!obj2 && (mea = lmv_get_mea(*reqp))) {
-
- /* FIXME remote capability! */
- /* wow! this is split dir, we'd like to handle it. */
- obj2 = lmv_obj_create(exp, &body->fid1, mea);
- if (IS_ERR(obj2))
- GOTO(out_free_sop_data, rc = (int)PTR_ERR(obj2));
- }
-
- if (obj2) {
- /* this is split dir and we'd want to get attrs */
- CDEBUG(D_OTHER, "attrs from slaves for "DFID", rc %d\n",
- PFID(&body->fid1), rc);
-
- rc = lmv_revalidate_slaves(exp, reqp, &body->fid1, it, 1,
- cb_blocking, extra_lock_flags);
- lmv_obj_put(obj2);
- }
-
- EXIT;
-out_free_sop_data:
- OBD_FREE_PTR(sop_data);
- return rc;
-}
-
-/* this is not used currently */
-int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
-{
- struct obd_device *obd = exp->exp_obd;
- struct lmv_obd *lmv = &obd->u.lmv;
- struct lustre_handle *lockh;
- struct md_op_data *op_data;
- struct ldlm_lock *lock;
- struct mdt_body *body2;
- struct mdt_body *body;
- struct lmv_obj *obj;
- int i, rc = 0;
- ENTRY;
-
- LASSERT(reqp);
- LASSERT(*reqp);
-
- /*
- * Master is locked. we'd like to take locks on slaves and update
- * attributes to be returned from the slaves it's important that lookup
- * is called in two cases:
-
- * - for first time (dcache has no such a resolving yet). -
- * ->d_revalidate() returned false.
-
- * Last case possible only if all the objs (master and all slaves aren't
- * valid.
- */
-
- OBD_ALLOC_PTR(op_data);
- if (op_data == NULL)
- RETURN(-ENOMEM);
-
- body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY);
- LASSERT(body != NULL);
-
- LASSERT((body->valid & OBD_MD_FLID) != 0);
- obj = lmv_obj_grab(obd, &body->fid1);
- LASSERT(obj != NULL);
-
- CDEBUG(D_OTHER, "lookup slaves for "DFID"\n",
- PFID(&body->fid1));
-
- lmv_obj_lock(obj);
-
- for (i = 0; i < obj->lo_objcount; i++) {
- struct lu_fid fid = obj->lo_inodes[i].li_fid;
- struct ptlrpc_request *req = NULL;
- struct obd_export *tgt_exp;
- struct lookup_intent it;
-
- if (lu_fid_eq(&fid, &obj->lo_fid))
- /* skip master obj */
- continue;
-
- CDEBUG(D_OTHER, "lookup slave "DFID"\n", PFID(&fid));
-
- /* is obj valid? */
- memset(&it, 0, sizeof(it));
- it.it_op = IT_GETATTR;
-
- memset(op_data, 0, sizeof(*op_data));
- op_data->op_fid1 = fid;
- op_data->op_fid2 = fid;
- op_data->op_bias = MDS_CROSS_REF;
-
- tgt_exp = lmv_get_export(lmv, obj->lo_inodes[i].li_mds);
- if (IS_ERR(tgt_exp))
- GOTO(cleanup, rc = PTR_ERR(tgt_exp));
-
- rc = md_intent_lock(tgt_exp, op_data, NULL, 0, &it, 0,
- &req, lmv_blocking_ast, 0);
-
- lockh = (struct lustre_handle *)&it.d.lustre.it_lock_handle;
- if (rc > 0 && req == NULL) {
- /* nice, this slave is valid */
- LASSERT(req == NULL);
- CDEBUG(D_OTHER, "cached\n");
- goto release_lock;
- }
-
- if (rc < 0) {
- /* error during lookup */
- GOTO(cleanup, rc);
- }
- lock = ldlm_handle2lock(lockh);
- LASSERT(lock);
-
- lock->l_ast_data = lmv_obj_get(obj);
-
- body2 = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
- LASSERT(body2 != NULL);
-
- obj->lo_inodes[i].li_size = body2->size;
-
- CDEBUG(D_OTHER, "fresh: %lu\n",
- (unsigned long)obj->lo_inodes[i].li_size);
-
- LDLM_LOCK_PUT(lock);
-
- if (req)
- ptlrpc_req_finished(req);
-release_lock:
- lmv_update_body(body, obj->lo_inodes + i);
-
- if (it.d.lustre.it_lock_mode) {
- ldlm_lock_decref(lockh, it.d.lustre.it_lock_mode);
- it.d.lustre.it_lock_mode = 0;
- }
- }
-
- EXIT;
-cleanup:
- lmv_obj_unlock(obj);
- lmv_obj_put(obj);
- OBD_FREE_PTR(op_data);
- return rc;
-}
-
-int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
- void *lmm, int lmmsize, struct lookup_intent *it,
- int flags, struct ptlrpc_request **reqp,
- ldlm_blocking_callback cb_blocking,
- int extra_lock_flags)
-{
- struct obd_device *obd = exp->exp_obd;
- struct lu_fid rpid = op_data->op_fid1;
- struct lmv_obd *lmv = &obd->u.lmv;
- struct md_op_data *sop_data;
- struct lmv_stripe_md *mea;
- struct mdt_body *body;
- struct lmv_obj *obj;
- int rc, loop = 0;
- int mea_idx;
- mdsno_t mds;
- ENTRY;
-
- OBD_ALLOC_PTR(sop_data);
- if (sop_data == NULL)
- RETURN(-ENOMEM);
-
- /* save op_data fro repeat case */
- *sop_data = *op_data;
-
- /*
- * IT_LOOKUP is intended to produce name -> fid resolving (let's call
- * this lookup below) or to confirm requested resolving is still valid
- * (let's call this revalidation) fid_is_sane(&sop_data->op_fid2) specifies
- * revalidation.
- */
- if (fid_is_sane(&op_data->op_fid2)) {
- /*
- * This is revalidate: we have to check is LOOKUP lock still
- * valid for given fid. Very important part is that we have to
- * choose right mds because namespace is per mds.
- */
- rpid = op_data->op_fid1;
- obj = lmv_obj_grab(obd, &rpid);
- if (obj) {
- mea_idx = raw_name2idx(obj->lo_hashtype,
- obj->lo_objcount,
- (char *)op_data->op_name,
- op_data->op_namelen);
- rpid = obj->lo_inodes[mea_idx].li_fid;
- mds = obj->lo_inodes[mea_idx].li_mds;
- sop_data->op_bias &= ~MDS_CHECK_SPLIT;
- lmv_obj_put(obj);
- } else {
- rc = lmv_fld_lookup(lmv, &rpid, &mds);
- if (rc)
- GOTO(out_free_sop_data, rc);
- sop_data->op_bias |= MDS_CHECK_SPLIT;
- }
-
- CDEBUG(D_OTHER, "revalidate lookup for "DFID" to #"LPU64" MDS\n",
- PFID(&op_data->op_fid2), mds);
- } else {
-repeat:
- ++loop;
- LASSERT(loop <= 2);
-
- /*
- * This is lookup. During lookup we have to update all the
- * attributes, because returned values will be put in struct
- * inode.