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
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
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_log.h>
56 #include "mds_internal.h"
58 static int mds_llog_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
59 struct lov_stripe_md *lsm,
60 struct llog_cookie *logcookies, int numcookies)
62 struct obd_device *obd = ctxt->loc_obd;
63 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
64 struct llog_ctxt *lctxt;
68 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
69 rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
75 static int mds_llog_origin_connect(struct llog_ctxt *ctxt, int count,
76 struct llog_logid *logid,
78 struct obd_uuid *uuid)
80 struct obd_device *obd = ctxt->loc_obd;
81 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
82 struct llog_ctxt *lctxt;
86 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
87 rc = llog_connect(lctxt, count, logid, gen, uuid);
92 static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
93 int count, struct llog_cookie *cookies, int flags)
95 struct obd_device *obd = ctxt->loc_obd;
96 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
97 struct llog_ctxt *lctxt;
101 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
102 rc = llog_cancel(lctxt, lsm, count, cookies, flags);
103 llog_ctxt_put(lctxt);
107 static struct llog_operations mds_ost_orig_logops = {
108 lop_add: mds_llog_origin_add,
109 lop_connect: mds_llog_origin_connect,
112 static struct llog_operations mds_size_repl_logops = {
113 lop_cancel: mds_llog_repl_cancel,
116 int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
117 struct obd_device *tgt, int count, struct llog_catid *logid,
118 struct obd_uuid *uuid)
120 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
124 LASSERT(olg == &obd->obd_olg);
125 rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, 0, NULL,
126 &mds_ost_orig_logops);
130 rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
131 &mds_size_repl_logops);
135 rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, tgt, count, logid, uuid);
137 CERROR("lov_llog_init err %d\n", rc);
142 int mds_llog_finish(struct obd_device *obd, int count)
144 struct llog_ctxt *ctxt;
148 ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
150 rc = llog_cleanup(ctxt);
152 ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
154 rc2 = llog_cleanup(ctxt);