1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see [sun.com URL with a
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mds/mds_log.c
38 * Author: Peter Braam <braam@clusterfs.com>
39 * Author: Andreas Dilger <adilger@clusterfs.com>
40 * Author: Phil Schwan <phil@clusterfs.com>
43 #define DEBUG_SUBSYSTEM S_MDS
45 #ifndef AUTOCONF_INCLUDED
46 #include <linux/config.h>
48 #include <linux/module.h>
49 #include <linux/version.h>
51 #include <libcfs/list.h>
52 #include <obd_class.h>
53 #include <lustre_fsfilt.h>
54 #include <lustre_mds.h>
55 #include <lustre_commit_confd.h>
56 #include <lustre_log.h>
58 #include "mds_internal.h"
60 static int mds_llog_origin_add(struct llog_ctxt *ctxt,
61 struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
62 struct llog_cookie *logcookies, int numcookies)
64 struct obd_device *obd = ctxt->loc_obd;
65 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
66 struct llog_ctxt *lctxt;
70 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
71 rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
77 static int mds_llog_origin_connect(struct llog_ctxt *ctxt, int count,
78 struct llog_logid *logid,
80 struct obd_uuid *uuid)
82 struct obd_device *obd = ctxt->loc_obd;
83 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
84 struct llog_ctxt *lctxt;
88 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
89 rc = llog_connect(lctxt, count, logid, gen, uuid);
94 static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
95 int count, struct llog_cookie *cookies, int flags)
97 struct obd_device *obd = ctxt->loc_obd;
98 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
99 struct llog_ctxt *lctxt;
103 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
104 rc = llog_cancel(lctxt, lsm, count, cookies, flags);
105 llog_ctxt_put(lctxt);
109 static struct llog_operations mds_ost_orig_logops = {
110 lop_add: mds_llog_origin_add,
111 lop_connect: mds_llog_origin_connect,
114 static struct llog_operations mds_size_repl_logops = {
115 lop_cancel: mds_llog_repl_cancel,
118 int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
119 struct obd_device *tgt, int count, struct llog_catid *logid,
120 struct obd_uuid *uuid)
122 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
126 LASSERT(olg == &obd->obd_olg);
127 rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, 0, NULL,
128 &mds_ost_orig_logops);
132 rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
133 &mds_size_repl_logops);
137 rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, tgt, count, logid, uuid);
139 CERROR("lov_llog_init err %d\n", rc);
144 int mds_llog_finish(struct obd_device *obd, int count)
146 struct llog_ctxt *ctxt;
150 ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
152 rc = llog_cleanup(ctxt);
154 ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
156 rc2 = llog_cleanup(ctxt);