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 Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * OST<->MDS recovery logging infrastructure.
24 * Invariants in implementation:
25 * - we do not share logs among different OST<->MDS connections, so that
26 * if an OST or MDS fails it need only look at log(s) relevant to itself
29 #define DEBUG_SUBSYSTEM S_LOG
38 #include <liblustre.h>
41 #include <linux/obd_class.h>
42 #include <linux/lustre_log.h>
43 #include <libcfs/list.h>
44 #include <linux/lvfs.h>
47 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
48 struct llog_logid *logid, struct llog_gen *gen,
49 struct obd_uuid *uuid)
51 struct llog_gen_rec *lgr;
52 struct obd_import *imp;
53 struct ptlrpc_request *request;
54 struct llogd_conn_body *req_body;
55 int size = sizeof(struct llogd_conn_body);
59 if (list_empty(&ctxt->loc_handle->u.chd.chd_head)) {
60 CDEBUG(D_HA, "there is no record related to ctxt %p\n", ctxt);
64 /* FIXME what value for gen->conn_cnt */
65 LLOG_GEN_INC(ctxt->loc_gen);
67 /* first add llog_gen_rec */
68 OBD_ALLOC(lgr, sizeof(*lgr));
71 lgr->lgr_hdr.lrh_len = lgr->lgr_tail.lrt_len = sizeof(*lgr);
72 lgr->lgr_hdr.lrh_type = LLOG_GEN_REC;
73 lgr->lgr_gen = ctxt->loc_gen;
74 rc = llog_add(ctxt, &lgr->lgr_hdr, NULL, NULL, 1);
75 OBD_FREE(lgr, sizeof(*lgr));
79 LASSERT(ctxt->loc_imp);
82 request = ptlrpc_prep_req(imp, LLOG_ORIGIN_CONNECT, 1, &size, NULL);
86 req_body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*req_body));
88 req_body->lgdc_gen = ctxt->loc_gen;
89 req_body->lgdc_logid = ctxt->loc_handle->lgh_id;
90 req_body->lgdc_ctxt_idx = ctxt->loc_idx + 1;
91 request->rq_replen = lustre_msg_size(0, NULL);
93 rc = ptlrpc_queue_wait(request);
94 ptlrpc_req_finished(request);
98 EXPORT_SYMBOL(llog_origin_connect);
100 int llog_handle_connect(struct ptlrpc_request *req)
102 struct obd_device *obd = req->rq_export->exp_obd;
103 struct llogd_conn_body *req_body;
104 struct llog_ctxt *ctxt;
108 req_body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_body));
110 ctxt = llog_get_context(obd, req_body->lgdc_ctxt_idx);
111 rc = llog_connect(ctxt, 1, &req_body->lgdc_logid,
112 &req_body->lgdc_gen, NULL);
114 CERROR("failed at llog_relp_connect\n");
118 EXPORT_SYMBOL(llog_handle_connect);
120 int llog_receptor_accept(struct llog_ctxt *ctxt, struct obd_import *imp)
127 EXPORT_SYMBOL(llog_receptor_accept);
129 int llog_initiator_connect(struct llog_ctxt *ctxt)
133 ctxt->loc_imp = ctxt->loc_obd->u.cli.cl_import;
136 EXPORT_SYMBOL(llog_initiator_connect);
138 #else /* !__KERNEL__ */
140 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
141 struct llog_logid *logid, struct llog_gen *gen,
142 struct obd_uuid *uuid)
147 int llog_initiator_connect(struct llog_ctxt *ctxt)