1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * Copyright (c) 2001-2003 Cluster File Systems, Inc.
7 * Author: Peter Braam <braam@clusterfs.com>
8 * Author: Andreas Dilger <adilger@clusterfs.com>
9 * Author: Phil Schwan <phil@clusterfs.com>
11 * This file is part of the Lustre file system, http://www.lustre.org
12 * Lustre is a trademark of Cluster File Systems, Inc.
14 * You may have signed or agreed to another license before downloading
15 * this software. If so, you are bound by the terms and conditions
16 * of that agreement, and the following does not apply to you. See the
17 * LICENSE file included with this distribution for more information.
19 * If you did not agree to a different license, then this copy of Lustre
20 * is open source software; you can redistribute it and/or modify it
21 * under the terms of version 2 of the GNU General Public License as
22 * published by the Free Software Foundation.
24 * In either case, Lustre is distributed in the hope that it will be
25 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
26 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * license text for more details.
30 #define DEBUG_SUBSYSTEM S_MDS
32 #ifndef AUTOCONF_INCLUDED
33 #include <linux/config.h>
35 #include <linux/module.h>
36 #include <linux/version.h>
38 #include <libcfs/list.h>
39 #include <obd_class.h>
40 #include <lustre_fsfilt.h>
41 #include <lustre_mds.h>
42 #include <lustre_commit_confd.h>
43 #include <lustre_log.h>
45 #include "mds_internal.h"
47 static int mds_llog_origin_add(struct llog_ctxt *ctxt,
48 struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
49 struct llog_cookie *logcookies, int numcookies)
51 struct obd_device *obd = ctxt->loc_obd;
52 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
53 struct llog_ctxt *lctxt;
57 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
58 rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
64 static int mds_llog_origin_connect(struct llog_ctxt *ctxt, int count,
65 struct llog_logid *logid,
67 struct obd_uuid *uuid)
69 struct obd_device *obd = ctxt->loc_obd;
70 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
71 struct llog_ctxt *lctxt;
75 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
76 rc = llog_connect(lctxt, count, logid, gen, uuid);
81 static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
82 int count, struct llog_cookie *cookies, int flags)
84 struct obd_device *obd = ctxt->loc_obd;
85 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
86 struct llog_ctxt *lctxt;
90 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
91 rc = llog_cancel(lctxt, lsm, count, cookies, flags);
96 static struct llog_operations mds_ost_orig_logops = {
97 lop_add: mds_llog_origin_add,
98 lop_connect: mds_llog_origin_connect,
101 static struct llog_operations mds_size_repl_logops = {
102 lop_cancel: mds_llog_repl_cancel,
105 int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
106 struct obd_device *tgt, int count, struct llog_catid *logid,
107 struct obd_uuid *uuid)
109 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
113 LASSERT(olg == &obd->obd_olg);
114 rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, 0, NULL,
115 &mds_ost_orig_logops);
119 rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
120 &mds_size_repl_logops);
124 rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, tgt, count, logid, uuid);
126 CERROR("lov_llog_init err %d\n", rc);
131 int mds_llog_finish(struct obd_device *obd, int count)
133 struct llog_ctxt *ctxt;
137 ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
139 rc = llog_cleanup(ctxt);
141 ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
143 rc2 = llog_cleanup(ctxt);