From: wangdi Date: Tue, 7 Jun 2005 16:07:59 +0000 (+0000) Subject: Branch: HEAD X-Git-Tag: 1.4.10~1031 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=deebfec5bfefc19941bc28c36bc99e3c986690e6;p=fs%2Flustre-release.git Branch: HEAD 1)set lsm when cmobd reint create one inode on master mds 2)some minor fix in cobd --- diff --git a/lustre/cmobd/cm_internal.h b/lustre/cmobd/cm_internal.h index 40b49a3..fabdb0b 100644 --- a/lustre/cmobd/cm_internal.h +++ b/lustre/cmobd/cm_internal.h @@ -42,4 +42,6 @@ int mds_update_mid(struct obd_device *obd, struct lustre_id *id, 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 */ diff --git a/lustre/cmobd/cm_mds_reint.c b/lustre/cmobd/cm_mds_reint.c index ba544c0..73b07d5 100644 --- a/lustre/cmobd/cm_mds_reint.c +++ b/lustre/cmobd/cm_mds_reint.c @@ -132,13 +132,13 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record) 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; @@ -156,10 +156,6 @@ static int cmobd_reint_create(struct obd_device *obd, void *record) 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)); @@ -172,15 +168,26 @@ static int cmobd_reint_create(struct obd_device *obd, void *record) /* 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); @@ -199,9 +206,13 @@ static int cmobd_reint_create(struct obd_device *obd, void *record) 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); } diff --git a/lustre/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index d13f85f..0710971 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -935,7 +935,8 @@ static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id, 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, diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 96a5b67..1384ed6 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1832,6 +1832,55 @@ out: } 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) { diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c index 2da62bf..c0ffede 100644 --- a/lustre/mds/mds_lib.c +++ b/lustre/mds/mds_lib.c @@ -329,7 +329,7 @@ static int mds_create_unpack(struct ptlrpc_request *req, int offset, 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 " @@ -340,6 +340,10 @@ static int mds_create_unpack(struct ptlrpc_request *req, int offset, 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(); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index f65eb1c..5997412 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -787,6 +787,15 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, 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; }