int mds_read_mid(struct obd_device *obd, struct lustre_id *id,
void *data, int data_len);
+int mds_read_md(struct obd_device *obd, struct lustre_id *id,
+ char **data, int *datalen);
#endif /* CM_INTERNAL_H */
ptlrpc_req_finished(req);
RETURN(rc);
}
-
+
static int cmobd_reint_create(struct obd_device *obd, void *record)
{
struct cm_obd *cmobd = &obd->u.cm;
struct ptlrpc_request *req = NULL;
struct mds_kml_pack_info *mkpi;
- int rc = 0, namelen, datalen;
+ int rc = 0, namelen, datalen, alloc = 0;
struct mds_rec_create *rec;
struct mdc_op_data *op_data;
struct lustre_msg *msg;
lid = rec->cr_replayid;
- /* zeroing @rec->cr_replayid out in request, as master MDS should create
- * own inode (with own store cookie). */
- memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
-
/* converting local inode store cookie to remote lustre_id. */
rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->cr_id,
&rec->cr_id, sizeof(rec->cr_id));
/* getting name to be created and its length */
name = lustre_msg_string(msg, 1, 0);
namelen = name ? msg->buflens[1] - 1 : 0;
-
+
/* getting misc data (symlink) and its length */
data = (char *)lustre_msg_buf(msg, 2, 0);
- datalen = data ? msg->buflens[2] : 0;
-
+ datalen = data ? msg->buflens[2] : 0;
+
+ if (datalen == 0 && S_ISREG(rec->cr_mode)) {
+ /*Get lov md from inode*/
+ mds_read_md(cmobd->cache_exp->exp_obd, &rec->cr_replayid,
+ &data, &datalen);
+ if (datalen > 0)
+ alloc = 1;
+ }
OBD_ALLOC(op_data, sizeof(*op_data));
- if (op_data == NULL)
- RETURN(-ENOMEM);
-
+ if (op_data == NULL)
+ GOTO(exit, rc = -ENOMEM);
+
+ /* zeroing @rec->cr_replayid out in request, as master MDS should create
+ * own inode (with own store cookie). */
+ memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
+
/* prepare mdc request data. */
cmobd_prepare_mdc_data(op_data, &rec->cr_id, &rec->cr_replayid,
name, namelen, rec->cr_mode);
rc = mds_update_mid(cmobd->cache_exp->exp_obd, &lid,
&body->id1, sizeof(body->id1));
}
-
+exit:
if (req)
ptlrpc_req_finished(req);
+
+ if (alloc == 1)
+ OBD_FREE(data, datalen);
+
RETURN(rc);
}
return -EINVAL;
}
cobd_exp = cobd_get_exp(obd);
- return md_getattr(cobd_exp, id, valid, NULL, 0, ea_size, request);
+ return md_getattr(cobd_exp, id, valid, ea_name, ea_namelen, ea_size,
+ request);
}
static int cobd_md_req2lustre_md (struct obd_export *mdc_exp,
}
EXPORT_SYMBOL(mds_read_mid);
+int mds_read_md(struct obd_device *obd, struct lustre_id *id,
+ char **data, int *datalen)
+{
+ struct dentry *dentry;
+ struct mds_obd *mds = &obd->u.mds;
+ int rc = 0, mea = 0;
+ char *ea;
+ ENTRY;
+
+ LASSERT(id);
+ LASSERT(obd);
+
+ dentry = mds_id2dentry(obd, id, NULL);
+ if (IS_ERR(dentry))
+ GOTO(out, rc = PTR_ERR(dentry));
+
+ if (!dentry->d_inode) {
+ CERROR("Can't find object "DLID4".\n",
+ OLID4(id));
+ GOTO(out_dentry, rc = -EINVAL);
+ }
+ if (S_ISDIR(dentry->d_inode->i_mode)) {
+ *datalen = obd_packmd(mds->mds_md_exp, NULL, NULL);
+ mea = 1;
+ } else {
+ *datalen = obd_packmd(mds->mds_dt_exp, NULL, NULL);
+ mea = 0;
+ }
+ OBD_ALLOC(ea, *datalen);
+ if (!ea) {
+ *datalen = 0;
+ GOTO(out_dentry, rc = PTR_ERR(dentry));
+ }
+ *data = ea;
+ down(&dentry->d_inode->i_sem);
+ rc = fsfilt_get_md(obd, dentry->d_inode, *data, *datalen,
+ (mea ? EA_MEA : EA_LOV));
+ up(&dentry->d_inode->i_sem);
+
+ if (rc < 0)
+ CERROR("Error %d reading eadata for ino %lu\n",
+ rc, dentry->d_inode->i_ino);
+out_dentry:
+ l_dput(dentry);
+out:
+ RETURN(rc);
+}
+EXPORT_SYMBOL(mds_read_md);
+
int mds_reint(struct ptlrpc_request *req, int offset,
struct lustre_handle *lockh)
{
if (r->ur_tgt == NULL)
RETURN (-EFAULT);
r->ur_tgtlen = req->rq_reqmsg->buflens[offset + 2];
- } else if (S_ISDIR(r->ur_mode)) {
+ } else if (S_ISDIR(r->ur_mode) ) {
/* Stripe info for mkdir - just a 16bit integer */
if (req->rq_reqmsg->buflens[offset + 2] != 2) {
CERROR("mkdir stripe info does not match "
r->ur_eadata = lustre_swab_buf (req->rq_reqmsg,
offset + 2, 2, __swab16s);
r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 2];
+ } else if (S_ISREG(r->ur_mode)){
+ r->ur_eadata = lustre_msg_buf (req->rq_reqmsg,
+ offset + 2, 0);
+ r->ur_eadatalen = req->rq_reqmsg->buflens[offset + 2];
} else {
/* Hm, no other users so far? */
LBUG();
if (IS_ERR(handle))
GOTO(cleanup, rc = PTR_ERR(handle));
rc = ll_vfs_create(dir, dchild, rec->ur_mode, NULL);
+
+ if (rc == 0 && rec->ur_eadata) {
+ /*for CMOBD to set lov md info when cmobd reint create*/
+ CDEBUG(D_INFO, "set lsm %p, len %d to inode %lu \n",
+ rec->ur_eadata, rec->ur_eadatalen,
+ dchild->d_inode->i_ino);
+ fsfilt_set_md(obd, dchild->d_inode, handle, rec->ur_eadata,
+ rec->ur_eadatalen, EA_LOV);
+ }
EXIT;
break;
}