From 1682772245d15b0ac3c15ddf3e64ab97d3b70182 Mon Sep 17 00:00:00 2001 From: lincent Date: Mon, 17 Oct 2005 14:09:06 +0000 Subject: [PATCH] new mgc, mgs codes --- lustre/ptlrpc/llog_client.c | 29 +++++++++++++++++++---------- lustre/ptlrpc/llog_server.c | 12 ++++++------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lustre/ptlrpc/llog_client.c b/lustre/ptlrpc/llog_client.c index 00eec03..d85da42 100644 --- a/lustre/ptlrpc/llog_client.c +++ b/lustre/ptlrpc/llog_client.c @@ -41,20 +41,23 @@ #include #include #include +#include #include /* This is a callback from the llog_* functions. * Assumes caller has already pushed us into the kernel context. */ static int llog_client_create(struct llog_ctxt *ctxt, struct llog_handle **res, - struct llog_logid *logid, char* fsname ,char *name) + struct llog_logid *logid, char *name) { struct obd_import *imp; struct llogd_body req_body; struct llogd_body *body; struct llog_handle *handle; + struct obd_device *obd = ctxt->loc_obd; + struct mgc_open_llog *mol; struct ptlrpc_request *req = NULL; - int size[3] = {sizeof(req_body)}; - char *tmp[3] = {(char*) &req_body}; + int size[2] = {sizeof(req_body)}; + char *tmp[2] = {(char*) &req_body}; int bufcount = 1; int repsize[] = {sizeof (req_body)}; int rc; @@ -79,13 +82,14 @@ static int llog_client_create(struct llog_ctxt *ctxt, struct llog_handle **res, req_body.lgd_logid = *logid; req_body.lgd_ctxt_idx = ctxt->loc_idx - 1; - if (fsname) { - size[bufcount] = strlen(fsname) + 1; - tmp[bufcount] = fsname; - bufcount++; - } - if (name) { + mol = mgc_find_open_llog(obd, name); + if (!mol) { + CERROR("The llog have not registered " + "in mgc obd when mount.\n"); + GOTO(err_free, rc = -EINVAL); + } + handle->lgh_mol = mol; size[bufcount] = strlen(name) + 1; tmp[bufcount] = name; bufcount++; @@ -182,17 +186,20 @@ out: static int llog_client_read_header(struct llog_handle *handle) { + struct obd_import *imp = handle->lgh_ctxt->loc_imp; struct ptlrpc_request *req = NULL; struct llogd_body *body; struct llog_log_hdr *hdr; struct llog_rec_hdr *llh_hdr; + struct mgc_open_llog *mol = handle->lgh_mol; int size = sizeof(*body); int repsize = sizeof (*hdr); int rc; ENTRY; - req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_READ_HEADER,1,&size,NULL); + req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_READ_HEADER, + 1, &size, NULL); if (!req) GOTO(out, rc = -ENOMEM); @@ -200,6 +207,8 @@ static int llog_client_read_header(struct llog_handle *handle) body->lgd_logid = handle->lgh_id; body->lgd_ctxt_idx = handle->lgh_ctxt->loc_idx - 1; body->lgd_llh_flags = handle->lgh_hdr->llh_flags; + if (mol) + body->lgd_local_version = mol->mol_version; req->rq_replen = lustre_msg_size(1, &repsize); rc = ptlrpc_queue_wait(req); diff --git a/lustre/ptlrpc/llog_server.c b/lustre/ptlrpc/llog_server.c index 0e8f9e0..b875002 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -86,7 +86,7 @@ int llog_origin_handle_create(struct ptlrpc_request *req) disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); - rc = llog_create(ctxt, &loghandle, logid, NULL, name); + rc = llog_create(ctxt, &loghandle, logid, name); if (rc) GOTO(out_pop, rc); @@ -141,7 +141,7 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); - rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL, NULL); + rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL); if (rc) GOTO(out_pop, rc); @@ -208,7 +208,7 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); - rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL, NULL); + rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL); if (rc) GOTO(out_pop, rc); @@ -330,7 +330,7 @@ static int llog_catinfo_config(struct obd_device *obd, char *buf, int buf_len, for (i = 0; i < 4; i++) { int index, uncanceled = 0; - rc = llog_create(ctxt, &handle, NULL, NULL, name[i]); + rc = llog_create(ctxt, &handle, NULL, name[i]); if (rc) GOTO(out_pop, rc); rc = llog_init_handle(handle, 0, NULL); @@ -392,7 +392,7 @@ static int llog_catinfo_cb(struct llog_handle *cat, lir = (struct llog_logid_rec *)rec; logid = &lir->lid_id; - rc = llog_create(ctxt, &handle, logid, NULL, NULL); + rc = llog_create(ctxt, &handle, logid, NULL); if (rc) RETURN(-EINVAL); rc = llog_init_handle(handle, 0, NULL); @@ -461,7 +461,7 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf, int l, index, uncanceled = 0; id = &idarray[i].lci_logid; - rc = llog_create(ctxt, &handle, id, NULL, NULL); + rc = llog_create(ctxt, &handle, id, NULL); if (rc) GOTO(out_pop, rc); rc = llog_init_handle(handle, 0, NULL); -- 1.8.3.1