* Use is subject to license terms.
*/
/*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
struct lmv_object *lmv_object_get(struct lmv_object *obj);
struct lmv_object *lmv_object_find(struct obd_device *obd,
- const struct lu_fid *fid);
+ const struct lu_fid *fid);
struct lmv_object *lmv_object_find_lock(struct obd_device *obd,
const struct lu_fid *fid);
static inline struct lmv_tgt_desc *
lmv_find_target(struct lmv_obd *lmv, const struct lu_fid *fid)
{
- mdsno_t mds;
+ mdsno_t mds = 0;
int rc;
- rc = lmv_fld_lookup(lmv, fid, &mds);
- if (rc)
- return ERR_PTR(rc);
+ if (lmv->desc.ld_tgt_count > 1) {
+ rc = lmv_fld_lookup(lmv, fid, &mds);
+ if (rc)
+ return ERR_PTR(rc);
+ }
return lmv_get_target(lmv, mds);
}
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_object *obj;
- struct lmv_tgt_desc *tgt;
+ struct lmv_tgt_desc *tgt = NULL;
int rc;
int sidx;
ENTRY;
if (rc)
RETURN(rc);
- if (!fid_is_sane(&op_data->op_fid2)) {
+ if (op_data->op_namelen) {
obj = lmv_object_find(obd, &op_data->op_fid1);
- if (obj && op_data->op_namelen) {
- sidx = raw_name2idx(obj->lo_hashtype,
- obj->lo_objcount,
+ if (obj) {
+ sidx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)op_data->op_name,
op_data->op_namelen);
op_data->op_fid1 = obj->lo_stripes[sidx].ls_fid;
- tgt = lmv_get_target(lmv,
- obj->lo_stripes[sidx].ls_mds);
- CDEBUG(D_INODE,
- "Choose slave dir ("DFID") -> mds #%d\n",
- PFID(&op_data->op_fid1), tgt->ltd_idx);
- } else {
- tgt = lmv_find_target(lmv, &op_data->op_fid1);
- }
- if (obj)
+ tgt = lmv_get_target(lmv, obj->lo_stripes[sidx].ls_mds);
lmv_object_put(obj);
- } else {
- op_data->op_fid1 = op_data->op_fid2;
- tgt = lmv_find_target(lmv, &op_data->op_fid2);
- op_data->op_bias = MDS_CROSS_REF;
- /*
- * Unfortunately, we have to lie to MDC/MDS to retrieve
- * attributes llite needs.
- */
- if (minfo->mi_it.it_op & IT_LOOKUP)
- minfo->mi_it.it_op = IT_GETATTR;
+ }
}
+ if (tgt == NULL)
+ tgt = lmv_find_target(lmv, &op_data->op_fid1);
+
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
* Use is subject to license terms.
*/
/*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
return NULL;
}
-struct lmv_object *lmv_object_find(struct obd_device *obd,
+struct lmv_object *lmv_object_find(struct obd_device *obd,
const struct lu_fid *fid)
{
- struct lmv_object *obj;
+ struct lmv_obd *lmv = &obd->u.lmv;
+ struct lmv_object *obj = NULL;
ENTRY;
- cfs_spin_lock(&obj_list_lock);
- obj = __lmv_object_find(obd, fid);
- cfs_spin_unlock(&obj_list_lock);
+ /* For single MDT case, lmv_object list is always empty. */
+ if (lmv->desc.ld_tgt_count > 1) {
+ cfs_spin_lock(&obj_list_lock);
+ obj = __lmv_object_find(obd, fid);
+ cfs_spin_unlock(&obj_list_lock);
+ }
RETURN(obj);
}