memset(&mci->mci_opdata, 0, sizeof(mci->mci_opdata));
- rc = md_getattr(mc->mc_desc.cl_exp, lu_object_fid(&mo->mo_lu),
- NULL, OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID |
- OBD_MD_FLFLAGS | OBD_MD_FLCROSSREF, 0, &mci->mci_req);
+ memcpy(&mci->mci_opdata.op_fid1, lu_object_fid(&mo->mo_lu),
+ sizeof (struct lu_fid));
+ mci->mci_opdata.op_valid = OBD_MD_FLMODE | OBD_MD_FLUID |
+ OBD_MD_FLGID | OBD_MD_FLFLAGS |
+ OBD_MD_FLCROSSREF;
+
+ rc = md_getattr(mc->mc_desc.cl_exp, &mci->mci_opdata, &mci->mci_req);
if (rc == 0) {
/* get attr from request */
rc = mdc_req2attr_update(env, ma);
check_gid:1,
check_uid:1,
check_pool:1,
- exclude_pool:1;
+ exclude_pool:1,
+ get_mdt_index:1;
int verbose;
int quiet;
extern int llapi_getstripe(char *path, struct find_param *param);
extern int llapi_find(char *path, struct find_param *param);
+extern int llapi_file_fget_mdtidx(int fd, int *mdtidx);
extern int llapi_obd_statfs(char *path, __u32 type, __u32 index,
struct obd_statfs *stat_buf,
struct obd_uuid *uuid_buf);
#define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */
#define OBD_MD_REINT (0x0000000200000000ULL) /* reintegrate oa */
#define OBD_MD_MEA (0x0000000400000000ULL) /* CMD split EA */
+#define OBD_MD_MDTIDX (0x0000000800000000ULL) /* Get MDT index */
#define OBD_MD_FLXATTR (0x0000001000000000ULL) /* xattr */
#define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */
#define LL_IOC_LLOOP_INFO _IOWR('f', 171, long)
#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long)
#define LL_IOC_PATH2FID _IOR ('f', 173, long)
+#define LL_IOC_GET_MDTIDX _IOR ('f', 174, int)
#define LL_STATFS_MDC 1
#define LL_STATFS_LOV 2
unsigned int op_attr_flags;
#endif
#endif
+ __u64 op_valid;
loff_t op_attr_blocks;
/* Size-on-MDS epoch and flags. */
struct lookup_intent *, struct md_op_data *,
struct lustre_handle *, void *, int,
struct ptlrpc_request **, int);
- int (*m_getattr)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, obd_valid, int,
+ int (*m_getattr)(struct obd_export *, struct md_op_data *,
struct ptlrpc_request **);
- int (*m_getattr_name)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, const char *, int, obd_valid,
- int, __u32, struct ptlrpc_request **);
+ int (*m_getattr_name)(struct obd_export *, struct md_op_data *,
+ struct ptlrpc_request **);
int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
void *, int, struct lookup_intent *, int,
struct ptlrpc_request **,
RETURN(rc);
}
-static inline int md_getattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, obd_valid valid, int ea_size,
+static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request)
{
int rc;
ENTRY;
EXP_CHECK_MD_OP(exp, getattr);
EXP_MD_COUNTER_INCREMENT(exp, getattr);
- rc = MDP(exp->exp_obd, getattr)(exp, fid, oc, valid,
- ea_size, request);
+ rc = MDP(exp->exp_obd, getattr)(exp, op_data, request);
RETURN(rc);
}
}
static inline int md_getattr_name(struct obd_export *exp,
- const struct lu_fid *fid, struct obd_capa *oc,
- const char *name, int namelen,
- obd_valid valid, int ea_size, __u32 suppgid,
+ struct md_op_data *op_data,
struct ptlrpc_request **request)
{
int rc;
ENTRY;
EXP_CHECK_MD_OP(exp, getattr_name);
EXP_MD_COUNTER_INCREMENT(exp, getattr_name);
- rc = MDP(exp->exp_obd, getattr_name)(exp, fid, oc, name, namelen,
- valid, ea_size, suppgid, request);
+ rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
RETURN(rc);
}
struct lustre_md md;
struct ptlrpc_request *req = NULL;
struct llu_sb_info *sbi = llu_i2sbi(inode);
+ struct md_op_data op_data = { { 0 } };
unsigned long valid = OBD_MD_FLGETATTR;
int rc, ealen = 0;
ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL);
valid |= OBD_MD_FLEASIZE;
}
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode),
- NULL, valid, ealen, &req);
+
+ llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, ealen,
+ LUSTRE_OPC_ANY);
+ op_data.op_valid = valid;
+
+ rc = md_getattr(sbi->ll_md_exp, &op_data, &req);
if (rc) {
CERROR("failure %d inode %llu\n", rc,
(long long)llu_i2stat(inode)->st_ino);
struct llu_sb_info *sbi = llu_i2sbi(inode);
struct mdt_body *body;
struct intnl_stat *st = llu_i2stat(inode);
+ struct md_op_data op_data = {{ 0 }};
int rc, symlen = st->st_size + 1;
ENTRY;
RETURN(0);
}
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), NULL,
- OBD_MD_LINKNAME, symlen, request);
+ llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, symlen,
+ LUSTRE_OPC_ANY);
+ op_data.op_valid = OBD_MD_LINKNAME;
+
+ rc = md_getattr(sbi->ll_md_exp, &op_data, request);
if (rc) {
CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc);
RETURN(rc);
char *osc = NULL, *mdc = NULL;
int async = 1, err = -EINVAL;
struct obd_connect_data ocd = {0,};
+ struct md_op_data op_data = {{0}};
ENTRY;
}
CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
+ op_data.op_fid1 = sbi->ll_root_fid;
+ op_data.op_valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS;
/* fetch attr of root inode */
- err = md_getattr(sbi->ll_md_exp, &sbi->ll_root_fid, NULL,
- OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request);
+ err = md_getattr(sbi->ll_md_exp, &op_data, &request);
if (err) {
CERROR("md_getattr failed for root: rc = %d\n", err);
GOTO(out_lock_cn_cb, err);
struct lov_mds_md *lmm = NULL;
struct ptlrpc_request *req = NULL;
int rc, lmmsize;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
rc = ll_get_max_mdsize(sbi, &lmmsize);
if (rc)
RETURN(rc);
- oc = ll_mdscapa_get(inode);
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode),
- oc, OBD_MD_FLEASIZE | OBD_MD_FLDIREA,
- lmmsize, &req);
- capa_put(oc);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL,
+ 0, lmmsize, LUSTRE_OPC_ANY,
+ NULL);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
+ rc = md_getattr(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
if (rc < 0) {
CDEBUG(D_INFO, "md_getattr failed on inode "
"%lu/%u: rc %d\n", inode->i_ino,
return rc;
}
+/*
+ * Get MDT index for the inode.
+ */
+int ll_get_mdt_idx(struct inode *inode)
+{
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ struct md_op_data *op_data;
+ int rc, mdtidx;
+ ENTRY;
+
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0,
+ 0, LUSTRE_OPC_ANY, NULL);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_valid |= OBD_MD_MDTIDX;
+ rc = md_getattr(sbi->ll_md_exp, op_data, NULL);
+ mdtidx = op_data->op_mds;
+ ll_finish_md_op_data(op_data);
+ if (rc < 0) {
+ CDEBUG(D_INFO, "md_getattr_name: %d\n", rc);
+ RETURN(rc);
+ }
+ return mdtidx;
+}
+
static int ll_dir_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
case FSFILT_IOC_SETVERSION_OLD:
case FSFILT_IOC_SETVERSION:
*/
+ case LL_IOC_GET_MDTIDX: {
+ int mdtidx;
+
+ mdtidx = ll_get_mdt_idx(inode);
+ if (mdtidx < 0)
+ RETURN(mdtidx);
+
+ if (put_user((int)mdtidx, (int*)arg))
+ RETURN(-EFAULT);
+
+ return 0;
+ }
case IOC_MDC_LOOKUP: {
struct ptlrpc_request *request = NULL;
int namelen, rc, len = 0;
char *buf = NULL;
char *filename;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
if (rc)
data = (void *)buf;
filename = data->ioc_inlbuf1;
- namelen = data->ioc_inllen1;
+ namelen = strlen(filename);
if (namelen < 1) {
CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
- GOTO(out, rc = -EINVAL);
+ GOTO(out_free, rc = -EINVAL);
}
- oc = ll_mdscapa_get(inode);
- rc = md_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- filename, namelen, OBD_MD_FLID, 0,
- ll_i2suppgid(inode), &request);
- capa_put(oc);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, filename, namelen,
+ 0, LUSTRE_OPC_ANY, NULL);
+ if (op_data == NULL)
+ GOTO(out_free, rc = -ENOMEM);
+
+ op_data->op_valid = OBD_MD_FLID;
+ rc = md_getattr_name(sbi->ll_md_exp, op_data, &request);
+ ll_finish_md_op_data(op_data);
if (rc < 0) {
CDEBUG(D_INFO, "md_getattr_name: %d\n", rc);
- GOTO(out, rc);
+ GOTO(out_free, rc);
}
-
ptlrpc_req_finished(request);
-
EXIT;
- out:
+out_free:
obd_ioctl_freedata(buf, len);
return rc;
}
struct mdt_body *body;
struct lov_mds_md *lmm = NULL;
struct ptlrpc_request *req = NULL;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
int rc, lmmsize;
rc = ll_get_max_mdsize(sbi, &lmmsize);
if (rc)
RETURN(rc);
- oc = ll_mdscapa_get(inode);
- rc = md_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode),
- oc, filename, strlen(filename) + 1,
- OBD_MD_FLEASIZE | OBD_MD_FLDIREA, lmmsize,
- ll_i2suppgid(inode), &req);
- capa_put(oc);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, filename,
+ strlen(filename), lmmsize,
+ LUSTRE_OPC_ANY, NULL);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
+ rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
if (rc < 0) {
CDEBUG(D_INFO, "md_getattr_name failed "
"on %s: rc %d\n", filename, rc);
case OBD_IOC_FID2PATH:
RETURN(ll_fid2path(ll_i2mdexp(inode), (void *)arg));
+ case LL_IOC_GET_MDTIDX: {
+ int mdtidx;
+
+ mdtidx = ll_get_mdt_idx(inode);
+ if (mdtidx < 0)
+ RETURN(mdtidx);
+
+ if (put_user((int)mdtidx, (int*)arg))
+ RETURN(-EFAULT);
+
+ RETURN(0);
+ }
+
default: {
int err;
ll_lookup_finish_locks(&oit, dentry);
} else if (!ll_have_md_lock(dentry->d_inode, ibits)) {
-
struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
obd_valid valid = OBD_MD_FLGETATTR;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
int ealen = 0;
if (S_ISREG(inode->i_mode)) {
RETURN(rc);
valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE;
}
+
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL,
+ 0, ealen, LUSTRE_OPC_ANY,
+ NULL);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_valid = valid;
/* Once OBD_CONNECT_ATTRFID is not supported, we can't find one
* capa for this inode. Because we only keep capas of dirs
* fresh. */
- oc = ll_mdscapa_get(inode);
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, valid,
- ealen, &req);
- capa_put(oc);
+ rc = md_getattr(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
if (rc) {
rc = ll_inode_revalidate_fini(inode, rc);
RETURN(rc);
extern struct inode_operations ll_dir_inode_operations;
struct page *ll_get_dir_page(struct inode *dir, __u64 hash, int exact,
struct ll_dir_chain *chain);
+
+int ll_get_mdt_idx(struct inode *inode);
/* llite/namei.c */
int ll_objects_destroy(struct ptlrpc_request *request,
struct inode *dir);
struct ptlrpc_request *request = NULL;
struct obd_connect_data *data = NULL;
struct obd_uuid *uuid;
+ struct md_op_data *op_data;
struct lustre_md lmd;
obd_valid valid;
int size, err, checksum;
else if (sbi->ll_flags & LL_SBI_ACL)
valid |= OBD_MD_FLACL;
- err = md_getattr(sbi->ll_md_exp, &sbi->ll_root_fid, oc, valid, 0,
- &request);
+ OBD_ALLOC_PTR(op_data);
+ if (op_data == NULL)
+ GOTO(out_lock_cn_cb, err = -ENOMEM);
+
+ op_data->op_fid1 = sbi->ll_root_fid;
+ op_data->op_mode = 0;
+ op_data->op_capa1 = oc;
+ op_data->op_valid = valid;
+
+ err = md_getattr(sbi->ll_md_exp, op_data, &request);
if (oc)
capa_put(oc);
+ OBD_FREE_PTR(op_data);
if (err) {
CERROR("md_getattr failed for root: rc = %d\n", err);
GOTO(out_lock_cn_cb, err);
switch(cmd) {
case FSFILT_IOC_GETFLAGS: {
struct mdt_body *body;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
- oc = ll_mdscapa_get(inode);
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- OBD_MD_FLFLAGS, 0, &req);
- capa_put(oc);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL,
+ 0, 0, LUSTRE_OPC_ANY,
+ NULL);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_valid = OBD_MD_FLFLAGS;
+ rc = md_getattr(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
if (rc) {
CERROR("failure %d inode %lu\n", rc, inode->i_ino);
RETURN(-abs(rc));
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct ptlrpc_request *req = NULL;
struct inode *inode = NULL;
- unsigned long valid = 0;
int eadatalen = 0;
ino_t ino = cl_fid_build_ino(fid);
+ struct md_op_data *op_data;
int rc;
ENTRY;
if (rc)
RETURN(ERR_PTR(rc));
- valid |= OBD_MD_FLEASIZE;
+ /* Because inode is NULL, ll_prep_md_op_data can not
+ * be used here. So we allocate op_data ourselves */
+ OBD_ALLOC_PTR(op_data);
+ if (op_data == NULL)
+ return ERR_PTR(-ENOMEM);
+
+ op_data->op_fid1 = *fid;
+ op_data->op_mode = eadatalen;
+ op_data->op_valid = OBD_MD_FLEASIZE;
/* mds_fid2dentry ignores f_type */
- rc = md_getattr(sbi->ll_md_exp, fid, NULL, valid, eadatalen, &req);
+ rc = md_getattr(sbi->ll_md_exp, op_data, &req);
+ OBD_FREE_PTR(op_data);
if (rc) {
CERROR("can't get object attrs, fid "DFID", rc %d\n",
PFID(fid), rc);
RETURN(ERR_PTR(rc));
}
-
rc = ll_prep_inode(&inode, req, sb);
ptlrpc_req_finished(req);
if (rc)
RETURN(entry);
}
#endif
-
static struct dentry *ll_get_parent(struct dentry *dchild)
{
struct ptlrpc_request *req = NULL;
struct dentry *result = NULL;
struct mdt_body *body;
static char dotdot[] = "..";
+ struct md_op_data *op_data;
int rc;
ENTRY;
sbi = ll_s2sbi(dir->i_sb);
- CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n",
+ CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n",
dir->i_ino, PFID(ll_inode2fid(dir)));
- rc = md_getattr_name(sbi->ll_md_exp, ll_inode2fid(dir), NULL,
- dotdot, strlen(dotdot) + 1, 0, 0,
- ll_i2suppgid(dir), &req);
+ op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot,
+ strlen(dotdot), 0,
+ LUSTRE_OPC_ANY, NULL);
+ if (op_data == NULL)
+ RETURN(ERR_PTR(-ENOMEM));
+
+ rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
if (rc) {
CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino);
RETURN(ERR_PTR(rc));
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
LASSERT(body->valid & OBD_MD_FLID);
- CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n",
+ CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n",
PFID(ll_inode2fid(dir)), PFID(&body->fid1));
result = ll_iget_for_nfs(dir->i_sb, &body->fid1);
struct ll_sb_info *sbi = ll_i2sbi(inode);
int rc, symlen = i_size_read(inode) + 1;
struct mdt_body *body;
- struct obd_capa *oc;
+ struct md_op_data *op_data;
ENTRY;
*request = NULL;
RETURN(0);
}
- oc = ll_mdscapa_get(inode);
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- OBD_MD_LINKNAME, symlen, request);
- capa_put(oc);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen,
+ LUSTRE_OPC_ANY, NULL);
+ op_data->op_valid = OBD_MD_LINKNAME;
+ rc = md_getattr(sbi->ll_md_exp, op_data, request);
+ ll_finish_md_op_data(op_data);
if (rc) {
if (rc != -ENOENT)
CERROR("inode %lu: rc = %d\n", inode->i_ino, rc);
RETURN(rc);
}
-static int lmv_getattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, obd_valid valid, int ea_size,
+static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
if (rc)
RETURN(rc);
- tgt = lmv_find_target(lmv, fid);
+ tgt = lmv_find_target(lmv, &op_data->op_fid1);
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
- rc = md_getattr(tgt->ltd_exp, fid, oc, valid, ea_size, request);
+ if (op_data->op_valid & OBD_MD_MDTIDX) {
+ op_data->op_mds = tgt->ltd_idx;
+ RETURN(0);
+ }
+
+ rc = md_getattr(tgt->ltd_exp, op_data, request);
if (rc)
RETURN(rc);
- obj = lmv_object_find_lock(obd, fid);
+ obj = lmv_object_find_lock(obd, &op_data->op_fid1);
- CDEBUG(D_INODE, "GETATTR for "DFID" %s\n", PFID(fid),
+ CDEBUG(D_INODE, "GETATTR for "DFID" %s\n", PFID(&op_data->op_fid1),
obj ? "(split)" : "");
/*
struct lmv_tgt_desc *tgt;
struct lmv_object *obj;
struct lustre_md md;
+ struct md_op_data *op_data;
int mealen;
int rc;
__u64 valid;
/*
* Time to update mea of parent fid.
*/
- rc = md_getattr(tgt->ltd_exp, fid, NULL, valid, mealen, &req);
+
+ OBD_ALLOC_PTR(op_data);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ op_data->op_fid1 = *fid;
+ op_data->op_mode = mealen;
+ op_data->op_valid = valid;
+
+ rc = md_getattr(tgt->ltd_exp, op_data, &req);
+ OBD_FREE_PTR(op_data);
if (rc) {
CERROR("md_getattr() failed, error %d\n", rc);
GOTO(cleanup, rc);
}
static int
-lmv_getattr_name(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, const char *name, int namelen,
- obd_valid valid, int ea_size, __u32 suppgid,
+lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
struct ptlrpc_request **request)
{
struct ptlrpc_request *req = NULL;
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
- struct lu_fid rid = *fid;
+ struct lu_fid rid = op_data->op_fid1;
struct lmv_tgt_desc *tgt;
struct mdt_body *body;
struct lmv_object *obj;
+ obd_valid valid = op_data->op_valid;
int rc;
int loop = 0;
int sidx;
obj = lmv_object_find(obd, &rid);
if (obj) {
sidx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
- name, namelen - 1);
+ op_data->op_name, op_data->op_namelen);
rid = obj->lo_stripes[sidx].ls_fid;
tgt = lmv_get_target(lmv, obj->lo_stripes[sidx].ls_mds);
+ op_data->op_mds = obj->lo_stripes[sidx].ls_mds;
valid &= ~OBD_MD_FLCKSPLIT;
lmv_object_put(obj);
} else {
tgt = lmv_find_target(lmv, &rid);
valid |= OBD_MD_FLCKSPLIT;
+ op_data->op_mds = tgt->ltd_idx;
}
if (IS_ERR(tgt))
RETURN(PTR_ERR(tgt));
CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" - "DFID" -> mds #%d\n",
- namelen, name, PFID(fid), PFID(&rid), tgt->ltd_idx);
+ op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
+ PFID(&rid), tgt->ltd_idx);
- rc = md_getattr_name(tgt->ltd_exp, &rid, oc, name, namelen, valid,
- ea_size, suppgid, request);
+ op_data->op_valid = valid;
+ op_data->op_fid1 = rid;
+ rc = md_getattr_name(tgt->ltd_exp, op_data, request);
if (rc == 0) {
body = req_capsule_server_get(&(*request)->rq_pill,
&RMF_MDT_BODY);
RETURN(PTR_ERR(tgt));
}
- rc = md_getattr_name(tgt->ltd_exp, &rid, NULL, NULL,
- 1, valid | OBD_MD_FLCROSSREF,
- ea_size, suppgid, &req);
+ op_data->op_fid1 = rid;
+ op_data->op_valid |= OBD_MD_FLCROSSREF;
+ op_data->op_namelen = 0;
+ op_data->op_name = NULL;
+ rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
ptlrpc_req_finished(*request);
*request = req;
}
PFID(fid));
md.mea = NULL;
-
+
if (mea == NULL) {
+ struct md_op_data *op_data;
__u64 valid;
CDEBUG(D_INODE, "Mea isn't passed in, get it now\n");
mealen = lmv_get_easize(lmv);
- /*
- * Time to update mea of parent fid.
+ /*
+ * Time to update mea of parent fid.
*/
md.mea = NULL;
valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
if (IS_ERR(tgt))
GOTO(cleanup, obj = (void *)tgt);
- rc = md_getattr(tgt->ltd_exp, fid, NULL, valid, mealen, &req);
+ OBD_ALLOC_PTR(op_data);
+ if (op_data == NULL)
+ GOTO(cleanup, obj = ERR_PTR(-ENOMEM));
+
+ op_data->op_fid1 = *fid;
+ op_data->op_mode = mealen;
+ op_data->op_valid = valid;
+ rc = md_getattr(tgt->ltd_exp, op_data, &req);
+ OBD_FREE_PTR(op_data);
if (rc) {
CERROR("md_getattr() failed, error %d\n", rc);
GOTO(cleanup, obj = ERR_PTR(rc));
mea = md.mea;
}
- /*
- * Got mea, now create obj for it.
+ /*
+ * Got mea, now create obj for it.
*/
obj = __lmv_object_create(obd, fid, mea);
if (!obj) {
RETURN(0);
}
-int mdc_getattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, obd_valid valid, int ea_size,
+int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
if (req == NULL)
RETURN(-ENOMEM);
- mdc_set_capa_size(req, &RMF_CAPA1, oc);
+ mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
if (rc) {
RETURN(rc);
}
- mdc_pack_body(req, fid, oc, valid, ea_size, -1, 0);
+ mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
+ op_data->op_valid, op_data->op_mode, -1, 0);
- req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, ea_size);
- if (valid & OBD_MD_FLRMTPERM) {
+ req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
+ op_data->op_mode);
+ if (op_data->op_valid & OBD_MD_FLRMTPERM) {
LASSERT(client_is_remote(exp));
req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
sizeof(struct mdt_remote_perm));
RETURN(rc);
}
-int mdc_getattr_name(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, const char *filename, int namelen,
- obd_valid valid, int ea_size, __u32 suppgid,
+int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
if (req == NULL)
RETURN(-ENOMEM);
- mdc_set_capa_size(req, &RMF_CAPA1, oc);
- req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, namelen);
+ mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
+ req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
+ op_data->op_namelen + 1);
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME);
if (rc) {
RETURN(rc);
}
- mdc_pack_body(req, fid, oc, valid, ea_size, suppgid, 0);
+ mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
+ op_data->op_valid, op_data->op_mode,
+ op_data->op_suppgids[0], 0);
- if (filename) {
+ if (op_data->op_name) {
char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
- LASSERT(strnlen(filename, namelen) == namelen - 1);
- memcpy(name, filename, namelen);
+ LASSERT(strnlen(op_data->op_name, op_data->op_namelen) ==
+ op_data->op_namelen);
+ memcpy(name, op_data->op_name, op_data->op_namelen);
}
- req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, ea_size);
+ req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
+ op_data->op_mode);
ptlrpc_request_set_replen(req);
rc = mdc_getattr_common(exp, req);
"usage: getstripe [--obd|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
" [--count | -c ] [--size | -s ] [--index | -i ]\n"
" [--offset | -o ] [--pool | -p ] [--directory | -d]\n"
- " [--recursive | -r] <dir|file> ..."},
+ " [--mdt | -M] [--recursive | -r] <dir|file> ..."},
{"pool_list", lfs_poollist, 0,
"List pools or pool OSTs\n"
"usage: pool_list <fsname>[.<pool>] | <pathname>\n"},
{"pool", 0, 0, 'p'},
{"verbose", 0, 0, 'v'},
{"directory", 0, 0, 'd'},
+ {"mdt", 0, 0, 'M'},
{0, 0, 0, 0}
};
int c, rc;
param.maxdepth = 1;
optind = 0;
- while ((c = getopt_long(argc, argv, "cdhioO:pqrsv",
+ while ((c = getopt_long(argc, argv, "cdhiMoO:pqrsv",
long_opts, NULL)) != -1) {
switch (c) {
case 'O':
case 'p':
param.verbose |= VERBOSE_POOL;
break;
+ case 'M':
+ param.get_mdt_index = 1;
+ break;
case '?':
return CMD_HELP;
default:
};
optind = 0;
- while ((c = getopt_long(argc, argv, "ihp:", long_opts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hip:", long_opts, NULL)) != -1) {
switch (c) {
case 'i':
ishow = 1;
qctl.qc_type = UGQUOTA;
optind = 0;
- while ((c = getopt_long(argc, argv, "ugb:i:t", long_opts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "b:i:gtu", long_opts, NULL)) != -1) {
switch (c) {
case 'u':
case 'g':
* isn't reinitialized from command line */
optind = 0;
- while ((c = getopt_long(argc, argv, "u:g:b:B:i:I:", long_opts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "b:B:i:I:g:u:", long_opts, NULL)) != -1) {
switch (c) {
case 'u':
case 'g':
if (ret) {
llapi_err(LLAPI_MSG_ERROR,
"error: %s: lstat failed for %s",
- __FUNCTION__, path);
+ __func__, path);
return ret;
}
} else if (errno == ENOENT) {
llapi_err(LLAPI_MSG_WARN,
"warning: %s: %s does not exist",
- __FUNCTION__, path);
+ __func__, path);
return -ENOENT;
} else {
llapi_err(LLAPI_MSG_ERROR,
"error: %s: IOC_MDC_GETFILEINFO failed for %s",
- __FUNCTION__, path);
+ __func__, path);
return ret;
}
}
d = opendir(path);
if (!d && errno != ENOTDIR) {
llapi_err(LLAPI_MSG_ERROR, "%s: Failed to open '%s'",
- __FUNCTION__, path);
+ __func__, path);
return -EINVAL;
} else if (!d && !parent) {
/* ENOTDIR. Open the parent dir. */
if ((len + dent->d_reclen + 2) > size) {
llapi_err(LLAPI_MSG_ERROR,
"error: %s: string buffer is too small",
- __FUNCTION__);
+ __func__);
break;
}
strcat(path, "/");
case DT_UNKNOWN:
llapi_err(LLAPI_MSG_ERROR,
"error: %s: '%s' is UNKNOWN type %d",
- __FUNCTION__, dent->d_name, dent->d_type);
+ __func__, dent->d_name, dent->d_type);
break;
case DT_DIR:
ret = llapi_semantic_traverse(path, size, d, sem_init,
if (param->obduuid && (param->obdindex == OBD_NOT_FOUND)) {
llapi_err_noerrno(LLAPI_MSG_ERROR,
"error: %s: unknown obduuid: %s",
- __FUNCTION__, param->obduuid->uuid);
+ __func__, param->obduuid->uuid);
rc = -EINVAL;
}
param->obdindexes[obdnum] = OBD_NOT_FOUND;
llapi_err_noerrno(LLAPI_MSG_ERROR,
"error: %s: unknown obduuid: %s",
- __FUNCTION__,
+ __func__,
param->obduuid[obdnum].uuid);
ret = -EINVAL;
}
if (ret) {
llapi_err(LLAPI_MSG_ERROR,
"error: %s: lstat failed for %s",
- __FUNCTION__, path);
+ __func__, path);
return ret;
}
} else if (errno == ENOENT) {
llapi_err(LLAPI_MSG_WARN,
"warning: %s: %s does not exist",
- __FUNCTION__, path);
+ __func__, path);
goto decided;
} else {
llapi_err(LLAPI_MSG_ERROR,"error: %s: %s failed for %s",
- __FUNCTION__, dir ? "LL_IOC_MDC_GETINFO" :
+ __func__, dir ? "LL_IOC_MDC_GETINFO" :
"IOC_MDC_GETFILEINFO", path);
return ret;
}
if (errno == ENOENT) {
llapi_err(LLAPI_MSG_ERROR,
"warning: %s: %s does not exist",
- __FUNCTION__, path);
+ __func__, path);
goto decided;
} else {
llapi_err(LLAPI_MSG_ERROR,
"%s: IOC_LOV_GETINFO on %s failed",
- __FUNCTION__, path);
+ __func__, path);
return ret;
}
}
int llapi_find(char *path, struct find_param *param)
{
- return param_callback(path, cb_find_init, cb_common_fini, param);
+ return param_callback(path, cb_find_init, cb_common_fini, param);
+}
+
+/*
+ * Get MDT number that the file/directory inode referenced
+ * by the open fd resides on.
+ * Return 0 and mdtidx on success, or -ve errno.
+ */
+int llapi_file_fget_mdtidx(int fd, int *mdtidx)
+{
+ if (ioctl(fd, LL_IOC_GET_MDTIDX, &mdtidx) < 0)
+ return -errno;
+ return 0;
+}
+
+static int cb_get_mdt_index(char *path, DIR *parent, DIR *d, void *data,
+ cfs_dirent_t *de)
+{
+ struct find_param *param = (struct find_param *)data;
+ int ret = 0;
+ int mdtidx;
+
+ LASSERT(parent != NULL || d != NULL);
+
+ if (d) {
+ ret = llapi_file_fget_mdtidx(dirfd(d), &mdtidx);
+ } else if (parent) {
+ int fd;
+
+ fd = open(path, O_RDONLY);
+ if (fd > 0) {
+ ret = llapi_file_fget_mdtidx(fd, &mdtidx);
+ close(fd);
+ } else {
+ ret = fd;
+ }
+ }
+
+ if (ret) {
+ if (errno == ENODATA) {
+ if (!param->obduuid)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%s has no stripe info\n", path);
+ goto out;
+ } else if (errno == ENOTTY) {
+ llapi_err(LLAPI_MSG_ERROR,
+ "%s: '%s' not on a Lustre fs?",
+ __func__, path);
+ } else if (errno == ENOENT) {
+ llapi_err(LLAPI_MSG_WARN,
+ "warning: %s: %s does not exist",
+ __func__, path);
+ goto out;
+ } else {
+ llapi_err(LLAPI_MSG_ERROR,
+ "error: %s: LL_IOC_GET_MDTIDX failed for %s",
+ __func__, path);
+ }
+ return ret;
+ }
+
+ if (param->quiet)
+ llapi_printf(LLAPI_MSG_NORMAL, "%d\n", mdtidx);
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "%s MDT index: %d\n",
+ path, mdtidx);
+
+out:
+ /* Do not get down anymore? */
+ if (param->depth == param->maxdepth)
+ return 1;
+
+ param->depth++;
+ return 0;
}
static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
fname = (fname == NULL ? path : fname + 1);
strncpy((char *)¶m->lmd->lmd_lmm, fname, param->lumlen);
+
ret = ioctl(dirfd(parent), IOC_MDC_GETFILESTRIPE,
(void *)¶m->lmd->lmd_lmm);
}
} else if (errno == ENOTTY) {
llapi_err(LLAPI_MSG_ERROR,
"%s: '%s' not on a Lustre fs?",
- __FUNCTION__, path);
+ __func__, path);
} else if (errno == ENOENT) {
llapi_err(LLAPI_MSG_WARN,
"warning: %s: %s does not exist",
- __FUNCTION__, path);
+ __func__, path);
goto out;
} else {
llapi_err(LLAPI_MSG_ERROR,
"error: %s: %s failed for %s",
- __FUNCTION__, d ? "LL_IOC_LOV_GETSTRIPE" :
+ __func__, d ? "LL_IOC_LOV_GETSTRIPE" :
"IOC_MDC_GETFILESTRIPE", path);
}
return ret;
}
- llapi_lov_dump_user_lmm(param, path, d ? 1 : 0);
+ if (!param->get_mdt_index)
+ llapi_lov_dump_user_lmm(param, path, d ? 1 : 0);
+
out:
/* Do not get down anymore? */
if (param->depth == param->maxdepth)
int llapi_getstripe(char *path, struct find_param *param)
{
- return param_callback(path, cb_getstripe, cb_common_fini, param);
+ return param_callback(path, param->get_mdt_index ?
+ cb_get_mdt_index : cb_getstripe,
+ cb_common_fini, param);
}
int llapi_obd_statfs(char *path, __u32 type, __u32 index,
if (fd < 0) {
rc = errno ? -errno : -EBADF;
llapi_err(LLAPI_MSG_ERROR, "error: %s: opening '%s'",
- __FUNCTION__, path);
+ __func__, path);
return rc;
}
rc = ioctl(fd, IOC_OBD_STATFS, (void *)rawbuf);
} else if (errno == ENOENT) {
llapi_err(LLAPI_MSG_ERROR,
"warning: %s: %s does not exist",
- __FUNCTION__, path);
+ __func__, path);
rc = 0;
} else if (errno != EISDIR) {
rc = errno;