From 3b4e8bab57af9ce0edb52db3f1fa76bd498f0e5d Mon Sep 17 00:00:00 2001 From: tianying Date: Thu, 13 Nov 2003 05:56:59 +0000 Subject: [PATCH] b:2215 - OSTs fetch unlink llog records from MDS post replay 1. add lop_connect and lop_precleanup to llog_operations 2. rename llog_obd_ctxt to llog_ctxt; llog_commit_data to llog_canceld_ctxt 3. split out llog functions in llog_client.c and llog_server.c and remove llogd.c 4. add one test-59 to sanity.sh to verify cancellation of llog records async 5. fix calling of mds_cleanup_orphans, add test-34 to replay-single.sh 6. fix some codes about llog --- lustre/obdclass/llog_test.c | 20 +-- lustre/obdclass/obd_config.c | 4 +- lustre/ptlrpc/llogd.c | 401 ------------------------------------------- 3 files changed, 12 insertions(+), 413 deletions(-) delete mode 100644 lustre/ptlrpc/llogd.c diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 268330f..4b1dfbb 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -75,7 +75,7 @@ static int verify_handle(char * test, struct llog_handle *llh, int num_recs) static int llog_test_1(struct obd_device *obd, char * name) { struct llog_handle *llh; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); int rc; int rc2; ENTRY; @@ -110,7 +110,7 @@ static int llog_test_2(struct obd_device *obd, char * name, struct llog_handle * struct llog_handle *loghandle; struct llog_logid logid; int rc; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); ENTRY; CERROR("2a: re-open a log with name: %s\n", name); @@ -223,7 +223,7 @@ static int llog_test_4(struct obd_device *obd) int rc, i, buflen; struct llog_mini_rec lmr; struct llog_cookie cookie; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); int num_recs = 0; char *buf; struct llog_rec_hdr rec; @@ -362,7 +362,7 @@ static int llog_test_5(struct obd_device *obd) char name[10]; int rc; struct llog_mini_rec lmr; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); ENTRY; @@ -426,13 +426,13 @@ static int llog_test_5(struct obd_device *obd) static int llog_test_6(struct obd_device *obd, char * name) { struct obd_device *mdc_obd; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); struct obd_uuid *mds_uuid = &ctxt->loc_exp->exp_obd->obd_uuid; struct lustre_handle exph = {0, }; struct obd_export * exp; struct obd_uuid uuid = {"LLOG_TEST6_UUID"}; struct llog_handle *llh = NULL; - struct llog_obd_ctxt *nctxt; + struct llog_ctxt *nctxt; int rc; CERROR("6a: re-open log %s using client API\n", name); @@ -450,7 +450,7 @@ static int llog_test_6(struct obd_device *obd, char * name) } exp = class_conn2export(&exph); - nctxt = mdc_obd->obd_llog_ctxt[LLOG_CONFIG_REPL_CTXT]; + nctxt = llog_get_context(mdc_obd, LLOG_CONFIG_REPL_CTXT); rc = llog_create(nctxt, &llh, NULL, name); if (rc) { CERROR("6: llog_create failed %d\n", rc); @@ -464,10 +464,10 @@ static int llog_test_6(struct obd_device *obd, char * name) } rc = llog_process(llh, (llog_cb_t)plain_print_cb, NULL); -parse_out: if (rc) CERROR("6: llog_process failed %d\n", rc); +parse_out: rc = llog_close(llh); if (rc) { CERROR("6: llog_close failed: rc = %d\n", rc); @@ -485,7 +485,7 @@ static int llog_run_tests(struct obd_device *obd) { struct llog_handle *llh; struct obd_run_ctxt saved; - struct llog_obd_ctxt *ctxt = obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]; + struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); int rc, err, cleanup_phase = 0; char name[10]; ENTRY; @@ -549,7 +549,7 @@ static int llog_test_llog_finish(struct obd_device *obd, int count) int rc; ENTRY; - rc = llog_cleanup(obd->obd_llog_ctxt[LLOG_TEST_ORIG_CTXT]); + rc = llog_cleanup(llog_get_context(obd, LLOG_TEST_ORIG_CTXT)); RETURN(rc); } diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 950a3f0..e52effc 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -585,7 +585,7 @@ out: RETURN(rc); } -int class_config_parse_llog(struct llog_obd_ctxt *ctxt, char *name, +int class_config_parse_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg) { struct llog_handle *llh; @@ -680,7 +680,7 @@ out: RETURN(rc); } -int class_config_dump_llog(struct llog_obd_ctxt *ctxt, char *name, +int class_config_dump_llog(struct llog_ctxt *ctxt, char *name, struct config_llog_instance *cfg) { struct llog_handle *llh; diff --git a/lustre/ptlrpc/llogd.c b/lustre/ptlrpc/llogd.c deleted file mode 100644 index d2d14e6..0000000 --- a/lustre/ptlrpc/llogd.c +++ /dev/null @@ -1,401 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001-2003 Cluster File Systems, Inc. - * Author: Andreas Dilger - * - * This file is part of Lustre, http://www.lustre.org. -n * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * remote api for llog - * - */ - -#define DEBUG_SUBSYSTEM S_LOG - -#ifndef EXPORT_SYMTAB -#define EXPORT_SYMTAB -#endif - -#include -#include -#include -#include -#include - -int llog_origin_handle_create(struct llog_obd_ctxt * lctxt, - struct ptlrpc_request *req) -{ - struct obd_export *exp = req->rq_export; - struct obd_device *obd = exp->exp_obd; - struct llog_handle *loghandle; - struct llogd_body *body; - struct obd_run_ctxt saved; - struct llog_logid *logid = NULL; - char * name = NULL; - int size = sizeof (*body); - int rc, rc2; - ENTRY; - - body = lustre_swab_reqbuf(req, 0, sizeof(*body), - lustre_swab_llogd_body); - if (body == NULL) { - CERROR ("Can't unpack llogd_body\n"); - GOTO(out, rc =-EFAULT); - } - - if (body->lgd_logid.lgl_oid > 0) - logid = &body->lgd_logid; - - if (req->rq_reqmsg->bufcount > 1) { - name = lustre_msg_string(req->rq_reqmsg, 1, 0); - if (name == NULL) { - CERROR("Can't unpack name\n"); - GOTO(out, rc = -EFAULT); - } - } - - push_ctxt(&saved, &obd->obd_ctxt, NULL); - - rc = llog_create(lctxt, &loghandle, logid, name); - if (rc) - GOTO(out_pop, rc); - - rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - GOTO(out_close, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); - body->lgd_logid = loghandle->lgh_id; - -out_close: - rc2 = llog_close(loghandle); - if (!rc) - rc = rc2; -out_pop: - pop_ctxt(&saved, &obd->obd_ctxt, NULL); -out: - RETURN(rc); -} - -int llog_origin_handle_next_block(struct llog_obd_ctxt *lctxt, - struct ptlrpc_request *req) -{ - struct obd_export *exp = req->rq_export; - struct obd_device *obd = exp->exp_obd; - struct llog_handle *loghandle; - struct llogd_body *body; - struct obd_run_ctxt saved; - __u8 *buf; - void * ptr; - int size[] = {sizeof (*body), - LLOG_CHUNK_SIZE}; - int rc, rc2; - ENTRY; - - body = lustre_swab_reqbuf(req, 0, sizeof(*body), - lustre_swab_llogd_body); - if (body == NULL) { - CERROR ("Can't unpack llogd_body\n"); - GOTO(out, rc =-EFAULT); - } - - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); - if (!buf) - GOTO(out, rc = -ENOMEM); - - push_ctxt(&saved, &obd->obd_ctxt, NULL); - rc = llog_create(lctxt, &loghandle, &body->lgd_logid, NULL); - if (rc) - GOTO(out_pop, rc); - - rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL); - if (rc) - GOTO(out_close, rc); - - memset(buf, 0, LLOG_CHUNK_SIZE); - rc = llog_next_block(loghandle, &body->lgd_saved_index, - body->lgd_index, - &body->lgd_cur_offset, buf, LLOG_CHUNK_SIZE); - if (rc) - GOTO(out_close, rc); - - - rc = lustre_pack_msg(2, size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - GOTO(out_close, rc = -ENOMEM); - - ptr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (body)); - memcpy(ptr, body, sizeof(*body)); - - ptr = lustre_msg_buf(req->rq_repmsg, 1, LLOG_CHUNK_SIZE); - memcpy(ptr, buf, LLOG_CHUNK_SIZE); - -out_close: - rc2 = llog_close(loghandle); - if (!rc) - rc = rc2; - -out_pop: - pop_ctxt(&saved, &obd->obd_ctxt, NULL); - OBD_FREE(buf, LLOG_CHUNK_SIZE); -out: - RETURN(rc); -} - -int llog_origin_handle_read_header(struct llog_obd_ctxt *lctxt, - struct ptlrpc_request *req) -{ - struct obd_export *exp = req->rq_export; - struct obd_device *obd = exp->exp_obd; - struct llog_handle *loghandle; - struct llogd_body *body; - struct llog_log_hdr *hdr; - struct obd_run_ctxt saved; - __u8 *buf; - int size[] = {sizeof (*hdr)}; - int rc, rc2; - ENTRY; - - body = lustre_swab_reqbuf(req, 0, sizeof(*body), - lustre_swab_llogd_body); - if (body == NULL) { - CERROR ("Can't unpack llogd_body\n"); - GOTO(out, rc =-EFAULT); - } - - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); - if (!buf) - GOTO(out, rc = -ENOMEM); - - push_ctxt(&saved, &obd->obd_ctxt, NULL); - rc = llog_create(lctxt, &loghandle, &body->lgd_logid, NULL); - if (rc) - GOTO(out_pop, rc); - - /* init_handle reads the header */ - rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL); - if (rc) - GOTO(out_close, rc); - - - rc = lustre_pack_msg(1, size, NULL, &req->rq_replen, &req->rq_repmsg); - if (rc) - GOTO(out_close, rc = -ENOMEM); - - hdr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*hdr)); - memcpy(hdr, loghandle->lgh_hdr, sizeof(*hdr)); - -out_close: - rc2 = llog_close(loghandle); - if (!rc) - rc = rc2; - -out_pop: - pop_ctxt(&saved, &obd->obd_ctxt, NULL); - OBD_FREE(buf, LLOG_CHUNK_SIZE); - -out: - RETURN(rc); -} - -int llog_origin_handle_close(struct llog_obd_ctxt *lctxt, - struct ptlrpc_request *req) -{ - int rc; - - rc = 0; - - RETURN(rc); -} - - -/* This is a callback from the llog_* functions. - * Assumes caller has already pushed us into the kernel context. */ -int llog_client_create(struct llog_obd_ctxt *ctxt, struct llog_handle **res, - struct llog_logid *logid, char *name) -{ - struct obd_device *obd = ctxt->loc_obd; - struct client_obd *cli = &obd->u.cli; - struct obd_import *imp = cli->cl_import; - struct llogd_body req_body; - struct llogd_body *body; - struct llog_handle *handle; - struct ptlrpc_request *req = NULL; - int size[2] = {sizeof(req_body)}; - char *tmp[2] = {(char*) &req_body}; - int bufcount = 1; - int repsize[] = {sizeof (req_body)}; - int rc; - ENTRY; - - handle = llog_alloc_handle(); - if (handle == NULL) - RETURN(-ENOMEM); - *res = handle; - - memset(&req_body, 0, sizeof(req_body)); - if (logid) - req_body.lgd_logid = *logid; - - if (name) { - size[bufcount] = strlen(name) + 1; - tmp[bufcount] = name; - bufcount++; - } - - req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_CREATE, bufcount, size, tmp); - if (!req) - GOTO(err_free, rc = -ENOMEM); - - req->rq_replen = lustre_msg_size(1, repsize); - rc = ptlrpc_queue_wait(req); - if (rc) - GOTO(err_free, rc); - - body = lustre_swab_repbuf(req, 0, sizeof(*body), - lustre_swab_llogd_body); - if (body == NULL) { - CERROR ("Can't unpack llogd_body\n"); - GOTO(err_free, rc =-EFAULT); - } - - handle->lgh_id = body->lgd_logid; - handle->lgh_obd = obd; - handle->lgh_ctxt = ctxt; - -out: - if (req) - ptlrpc_req_finished(req); - RETURN(rc); - -err_free: - llog_free_handle(handle); - goto out; -} - - -struct obd_import *llog_lgh2imp(struct llog_handle *lgh) -{ - struct client_obd *cli = &lgh->lgh_obd->u.cli; - return cli->cl_import; -} - -int llog_client_next_block(struct llog_handle *loghandle, - int *cur_idx, int next_idx, - __u64 *cur_offset, void *buf, int len) -{ - struct obd_import *imp = llog_lgh2imp(loghandle); - struct ptlrpc_request *req = NULL; - struct llogd_body *body; - void * ptr; - int size = sizeof(*body); - int repsize[2] = {sizeof (*body)}; - int rc; - ENTRY; - - req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_NEXT_BLOCK, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body)); - body->lgd_logid = loghandle->lgh_id; - body->lgd_cur_offset = *cur_offset; - body->lgd_index = next_idx; - body->lgd_saved_index = *cur_idx; - body->lgd_len = len; - repsize[1] = len; - - req->rq_replen = lustre_msg_size(2, repsize); - rc = ptlrpc_queue_wait(req); - if (rc) - GOTO(out, rc); - - body = lustre_swab_repbuf(req, 0, sizeof(*body), - lustre_swab_llogd_body); - if (body == NULL) { - CERROR ("Can't unpack llogd_body\n"); - GOTO(out, rc =-EFAULT); - } - - ptr = lustre_msg_buf(req->rq_repmsg, 1, len); - if (ptr == NULL) { - CERROR ("Can't unpack bitmap\n"); - GOTO(out, rc =-EFAULT); - } - - *cur_idx = body->lgd_saved_index; - *cur_offset = body->lgd_cur_offset; - - memcpy(buf, ptr, len); - -out: - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - - -int llog_client_read_header(struct llog_handle *handle) -{ - struct obd_import *imp = llog_lgh2imp(handle); - struct ptlrpc_request *req = NULL; - struct llogd_body *body; - struct llog_log_hdr *hdr; - int size = sizeof(*body); - int repsize = sizeof (*hdr); - int rc; - ENTRY; - - req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_READ_HEADER, 1, &size, NULL); - if (!req) - GOTO(out, rc = -ENOMEM); - - body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body)); - body->lgd_logid = handle->lgh_id; - - req->rq_replen = lustre_msg_size(1, &repsize); - rc = ptlrpc_queue_wait(req); - if (rc) - GOTO(out, rc); - - hdr = lustre_swab_repbuf(req, 0, sizeof(*hdr), - lustre_swab_llog_hdr); - if (hdr == NULL) { - CERROR ("Can't unpack llog_hdr\n"); - GOTO(out, rc =-EFAULT); - } - memcpy(handle->lgh_hdr, hdr, sizeof (*hdr)); - -out: - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -int llog_client_close(struct llog_handle *handle) -{ - int rc = 0; - - RETURN(rc); -} - - -struct llog_operations llog_client_ops = { - lop_next_block: llog_client_next_block, - lop_read_header: llog_client_read_header, - lop_create: llog_client_create, - lop_close: llog_client_close, -}; -- 1.8.3.1