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 <portals/list.h>
44 #include <linux/lvfs.h>
47 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
48 struct llog_logid *logid,
49 struct llog_ctxt_gen *gen)
51 struct obd_import *imp;
52 struct ptlrpc_request *request;
53 struct llogd_conn_body *req_body;
54 int size = sizeof(struct llogd_conn_body);
58 LASSERT(ctxt->loc_imp);
61 request = ptlrpc_prep_req(imp, LLOG_ORIGIN_CONNECT, 1, &size, NULL);
65 req_body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*req_body));
67 req_body->lgdc_gen = ctxt->loc_gen;
68 req_body->lgdc_logid = ctxt->loc_handle->lgh_id;
69 req_body->lgdc_ctxt_idx = ctxt->loc_idx + 1;
70 request->rq_replen = lustre_msg_size(0, NULL);
72 rc = ptlrpc_queue_wait(request);
73 ptlrpc_req_finished(request);
77 EXPORT_SYMBOL(llog_origin_connect);
79 int llog_handle_connect(struct ptlrpc_request *req)
81 struct obd_device *obd = req->rq_export->exp_obd;
82 struct llogd_conn_body *req_body;
83 struct llog_ctxt *ctxt;
87 req_body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_body));
89 ctxt = llog_get_context(obd, req_body->lgdc_ctxt_idx);
90 rc = llog_connect(ctxt, 1, &req_body->lgdc_logid,
93 CERROR("failed at llog_relp_connect\n");
97 EXPORT_SYMBOL(llog_handle_connect);
99 int llog_receptor_accept(struct llog_ctxt *ctxt, struct obd_import *imp)
106 EXPORT_SYMBOL(llog_receptor_accept);
108 int llog_initiator_connect(struct llog_ctxt *ctxt)
112 ctxt->loc_imp = ctxt->loc_obd->u.cli.cl_import;
115 EXPORT_SYMBOL(llog_initiator_connect);
117 #else /* !__KERNEL__ */
119 int llog_origin_connect(struct llog_ctxt *ctxt, int count,
120 struct llog_logid *logid,
121 struct llog_ctxt_gen *gen)
126 int llog_initiator_connect(struct llog_ctxt *ctxt)