X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fcmobd%2Fcm_mds_reint.c;h=34f51a59f67caedb97f02f1f5671d11fc18d221a;hb=62a0d77038f9c69119fad5d76491edf986c5efbb;hp=d77acf277a5f70d7a638fddc90d451a28203e88e;hpb=9d4b898b1c1c7c318fda5f0c345ed726c774c06a;p=fs%2Flustre-release.git diff --git a/lustre/cmobd/cm_mds_reint.c b/lustre/cmobd/cm_mds_reint.c index d77acf2..34f51a5 100644 --- a/lustre/cmobd/cm_mds_reint.c +++ b/lustre/cmobd/cm_mds_reint.c @@ -49,7 +49,7 @@ static inline void cmobd_rec2iattr(struct mds_rec_setattr *rec, static void cmobd_prepare_mdc_data(struct mdc_op_data *data, struct lustre_id *id1, struct lustre_id *id2, const char *name, - int namelen, __u32 mode) + int namelen, __u32 mode, __u32 flags) { LASSERT(id1); LASSERT(data); @@ -59,14 +59,18 @@ cmobd_prepare_mdc_data(struct mdc_op_data *data, struct lustre_id *id1, data->id1 = *id1; if (id2) data->id2 = *id2; - else - memset(&data->id2, 0, sizeof(data->id2)); data->valid = 0; data->name = name; + data->flags = flags; data->namelen = namelen; data->create_mode = mode; - data->mod_time = CURRENT_TIME; + data->mod_time = LTIME_S(CURRENT_TIME); + + /* zeroing out store cookie, as it makes no sense on master MDS and may + * also confuse it as may be considered as recovery case. */ + memset(&data->id1.li_stc, 0, sizeof(data->id1.li_stc)); + memset(&data->id2.li_stc, 0, sizeof(data->id2.li_stc)); } /* If mdc_setattr() is called with an 'iattr', then it is a normal RPC that @@ -81,7 +85,7 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record) struct ptlrpc_request *req = NULL; struct mds_kml_pack_info *mkpi; struct mds_rec_setattr *rec; - struct mdc_op_data op_data; + struct mdc_op_data *op_data; struct lustre_msg *msg; int ea1len, ea2len; struct iattr iattr; @@ -102,17 +106,11 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record) /* FIXME-UMKA: here should be handling of setattr() from open. Bug * #249. Will be fixed later. */ - /* converting localstore cookie to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->sa_id, - &rec->sa_id, sizeof(rec->sa_id)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - cmobd_prepare_mdc_data(&op_data, &rec->sa_id, NULL, - NULL, 0, 0); + OBD_ALLOC(op_data, sizeof(*op_data)); + if (op_data == NULL) + RETURN(-ENOMEM); + cmobd_prepare_mdc_data(op_data, &rec->sa_id, NULL, + NULL, 0, 0, MDS_REINT_REQ); /* handling possible EAs. */ ea1 = lustre_msg_buf(msg, 1, 0); @@ -121,25 +119,24 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record) ea2 = lustre_msg_buf(msg, 2, 0); ea2len = ea2 ? msg->buflens[2] : 0; - rc = md_setattr(cmobd->master_exp, &op_data, &iattr, - ea1, ea1len, ea2, ea2len, &req); + rc = md_setattr(cmobd->master_exp, op_data, &iattr, + ea1, ea1len, ea2, ea2len, NULL, 0, &req); + OBD_FREE(op_data, sizeof(*op_data)); if (req) 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; + struct mdc_op_data *op_data; struct mds_rec_create *rec; - struct mdc_op_data op_data; struct lustre_msg *msg; - struct mds_body *body; - struct lustre_id lid; char *name, *data; ENTRY; @@ -149,50 +146,39 @@ static int cmobd_reint_create(struct obd_device *obd, void *record) rec = lustre_msg_buf(msg, 0, 0); if (!rec) RETURN(-EINVAL); - - 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_obd, &rec->cr_id, - &rec->cr_id, sizeof(rec->cr_id)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } /* 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; + + OBD_ALLOC(op_data, sizeof(*op_data)); + if (op_data == NULL) + GOTO(exit, rc = -ENOMEM); + + /* XXX: here is the issue preventing LMV from being used as master + * device for flushing cache to it. It is allusive to the fact that + * cache MDS parent id with wrong group component is used for forwarding + * reint requests to some MDS from those LMV knows about. As group is + * wrong - LMV forwards reqs to wrong MDS. Do not know how to fix it + * yet. --umka */ + /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->cr_id, &rec->cr_replayid, - name, namelen, rec->cr_mode); + cmobd_prepare_mdc_data(op_data, &rec->cr_id, &rec->cr_replayid, + name, namelen, rec->cr_mode, MDS_REINT_REQ); /* requesting to master to create object with passed attributes. */ - rc = md_create(cmobd->master_exp, &op_data, data, datalen, + rc = md_create(cmobd->master_exp, op_data, data, datalen, rec->cr_mode, current->fsuid, current->fsgid, rec->cr_rdev, &req); - - if (!rc) { - /* here we save store cookie from master MDS to local - * inode EA. */ - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - - rc = mds_update_mid(cmobd->cache_obd, &lid, - &body->id1, sizeof(body->id1)); - } - + OBD_FREE(op_data, sizeof(*op_data)); +exit: if (req) ptlrpc_req_finished(req); + RETURN(rc); } @@ -201,7 +187,7 @@ static int cmobd_reint_unlink(struct obd_device *obd, void *record) struct cm_obd *cmobd = &obd->u.cm; struct ptlrpc_request *req = NULL; struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; + struct mdc_op_data *op_data; struct mds_rec_unlink *rec; struct lustre_msg *msg; int rc = 0, namelen; @@ -215,24 +201,21 @@ static int cmobd_reint_unlink(struct obd_device *obd, void *record) if (!rec) RETURN(-EINVAL); - /* converting local store cookie to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->ul_id1, - &rec->ul_id1, sizeof(rec->ul_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - /* getting name to be created and its length */ name = lustre_msg_string(msg, 1, 0); namelen = name ? msg->buflens[1] - 1 : 0; + OBD_ALLOC(op_data, sizeof(*op_data)); + if (op_data == NULL) + RETURN(-ENOMEM); + /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->ul_id1, NULL, - name, namelen, rec->ul_mode); + cmobd_prepare_mdc_data(op_data, &rec->ul_id1, NULL, + name, namelen, rec->ul_mode, + MDS_REINT_REQ); - rc = md_unlink(cmobd->master_exp, &op_data, &req); + rc = md_unlink(cmobd->master_exp, op_data, &req); + OBD_FREE(op_data, sizeof(*op_data)); if (req) ptlrpc_req_finished(req); @@ -244,7 +227,7 @@ static int cmobd_reint_link(struct obd_device *obd, void *record) struct cm_obd *cmobd = &obd->u.cm; struct ptlrpc_request *req = NULL; struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; + struct mdc_op_data *op_data; struct mds_rec_link *rec; struct lustre_msg *msg; int rc = 0, namelen; @@ -258,32 +241,20 @@ static int cmobd_reint_link(struct obd_device *obd, void *record) if (!rec) RETURN(-EINVAL); - /* converting local store cookie for both ids to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id1, - &rec->lk_id1, sizeof(rec->lk_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id2, - &rec->lk_id2, sizeof(rec->lk_id2)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - /* getting name to be created and its length */ name = lustre_msg_string(msg, 1, 0); namelen = name ? msg->buflens[1] - 1: 0; + OBD_ALLOC(op_data, sizeof(*op_data)); + if (op_data == NULL) + RETURN(-ENOMEM); + /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->lk_id1, &rec->lk_id2, - name, namelen, 0); + cmobd_prepare_mdc_data(op_data, &rec->lk_id1, &rec->lk_id2, + name, namelen, 0, MDS_REINT_REQ); - rc = md_link(cmobd->master_exp, &op_data, &req); + rc = md_link(cmobd->master_exp, op_data, &req); + OBD_FREE(op_data, sizeof(*op_data)); if (req) ptlrpc_req_finished(req); @@ -295,7 +266,7 @@ static int cmobd_reint_rename(struct obd_device *obd, void *record) struct cm_obd *cmobd = &obd->u.cm; struct ptlrpc_request *req = NULL; struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; + struct mdc_op_data *op_data; struct mds_rec_rename *rec; int rc = 0, oldlen, newlen; struct lustre_msg *msg; @@ -308,23 +279,6 @@ static int cmobd_reint_rename(struct obd_device *obd, void *record) rec = lustre_msg_buf(msg, 0, 0); if (!rec) RETURN(-EINVAL); - - /* converting local store cookie for both ids to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id1, - &rec->rn_id1, sizeof(rec->rn_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id2, - &rec->rn_id2, sizeof(rec->rn_id2)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } /* getting old name and its length */ old = lustre_msg_string(msg, 1, 0); @@ -334,12 +288,17 @@ static int cmobd_reint_rename(struct obd_device *obd, void *record) new = lustre_msg_string(msg, 2, 0); newlen = new ? msg->buflens[2] - 1: 0; + OBD_ALLOC(op_data, sizeof(*op_data)); + if (op_data == NULL) + RETURN(-ENOMEM); + /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->rn_id1, &rec->rn_id1, - NULL, 0, 0); + cmobd_prepare_mdc_data(op_data, &rec->rn_id1, &rec->rn_id1, + NULL, 0, 0, MDS_REINT_REQ); - rc = md_rename(cmobd->master_exp, &op_data, old, oldlen, + rc = md_rename(cmobd->master_exp, op_data, old, oldlen, new, newlen, &req); + OBD_FREE(op_data, sizeof(*op_data)); if (req) ptlrpc_req_finished(req);