1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
5 * Author: Andreas Dilger <adilger@clusterfs.com>
7 * This file is part of the Lustre file system, http://www.lustre.org
8 * Lustre is a trademark of Cluster File Systems, Inc.
10 * You may have signed or agreed to another license before downloading
11 * this software. If so, you are bound by the terms and conditions
12 * of that agreement, and the following does not apply to you. See the
13 * LICENSE file included with this distribution for more information.
15 * If you did not agree to a different license, then this copy of Lustre
16 * is open source software; you can redistribute it and/or modify it
17 * under the terms of version 2 of the GNU General Public License as
18 * published by the Free Software Foundation.
20 * In either case, Lustre is distributed in the hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
22 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * license text for more details.
25 * OST<->MDS recovery logging infrastructure.
27 * Invariants in implementation:
28 * - we do not share logs among different OST<->MDS connections, so that
29 * if an OST or MDS fails it need only look at log(s) relevant to itself
32 #define DEBUG_SUBSYSTEM S_LOG
39 #include <libcfs/libcfs.h>
41 #include <liblustre.h>
44 #include <obd_class.h>
45 #include <lustre_log.h>
46 #include <libcfs/list.h>
50 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
51 struct llog_logid *logid, struct llog_gen *gen,
52 struct obd_uuid *uuid)
54 struct llog_gen_rec *lgr;
55 struct obd_import *imp;
56 struct ptlrpc_request *request;
57 struct llogd_conn_body *req_body;
58 int size[2] = { sizeof(struct ptlrpc_body),
59 sizeof(struct llogd_conn_body) };
63 if (list_empty(&ctxt->loc_handle->u.chd.chd_head)) {
64 CDEBUG(D_HA, "there is no record related to ctxt %p\n", ctxt);
68 /* FIXME what value for gen->conn_cnt */
69 LLOG_GEN_INC(ctxt->loc_gen);
71 /* first add llog_gen_rec */
72 OBD_ALLOC(lgr, sizeof(*lgr));
75 lgr->lgr_hdr.lrh_len = lgr->lgr_tail.lrt_len = sizeof(*lgr);
76 lgr->lgr_hdr.lrh_type = LLOG_GEN_REC;
77 lgr->lgr_gen = ctxt->loc_gen;
78 rc = llog_add(ctxt, &lgr->lgr_hdr, NULL, NULL, 1);
79 OBD_FREE(lgr, sizeof(*lgr));
83 LASSERT(ctxt->loc_imp);
86 request = ptlrpc_prep_req(imp, LUSTRE_LOG_VERSION,
87 LLOG_ORIGIN_CONNECT, 2, size, NULL);
91 req_body = lustre_msg_buf(request->rq_reqmsg, REQ_REC_OFF,
94 req_body->lgdc_gen = ctxt->loc_gen;
95 req_body->lgdc_logid = ctxt->loc_handle->lgh_id;
96 req_body->lgdc_ctxt_idx = ctxt->loc_idx + 1;
97 ptlrpc_req_set_repsize(request, 1, NULL);
99 rc = ptlrpc_queue_wait(request);
100 ptlrpc_req_finished(request);
104 EXPORT_SYMBOL(llog_origin_connect);
106 int llog_handle_connect(struct ptlrpc_request *req)
108 struct obd_device *obd = req->rq_export->exp_obd;
109 struct llogd_conn_body *req_body;
110 struct llog_ctxt *ctxt;
114 req_body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
117 ctxt = llog_get_context(obd, req_body->lgdc_ctxt_idx);
118 rc = llog_connect(ctxt, 1, &req_body->lgdc_logid,
119 &req_body->lgdc_gen, NULL);
121 CERROR("failed at llog_relp_connect\n");
125 EXPORT_SYMBOL(llog_handle_connect);
127 int llog_receptor_accept(struct llog_ctxt *ctxt, struct obd_import *imp)
134 EXPORT_SYMBOL(llog_receptor_accept);
136 int llog_initiator_connect(struct llog_ctxt *ctxt)
140 ctxt->loc_imp = ctxt->loc_obd->u.cli.cl_import;
143 EXPORT_SYMBOL(llog_initiator_connect);
145 #else /* !__KERNEL__ */
147 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
148 struct llog_logid *logid, struct llog_gen *gen,
149 struct obd_uuid *uuid)
154 int llog_initiator_connect(struct llog_ctxt *ctxt)