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 Lustre, http://www.lustre.org.
13 * Lustre is free software; you can redistribute it and/or
14 * modify it under the terms of version 2 of the GNU General Public
15 * License as published by the Free Software Foundation.
17 * Lustre is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Lustre; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define DEBUG_SUBSYSTEM S_MDS
29 #include <linux/config.h>
30 #include <linux/module.h>
31 #include <linux/version.h>
33 #include <portals/list.h>
34 #include <linux/obd_class.h>
35 #include <linux/lustre_fsfilt.h>
36 #include <linux/lustre_commit_confd.h>
38 #include "mds_internal.h"
40 static int mds_llog_origin_add(struct llog_ctxt *ctxt,
41 struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
42 struct llog_cookie *logcookies, int numcookies)
44 struct obd_device *obd = ctxt->loc_obd;
45 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
46 struct llog_ctxt *lctxt;
50 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
51 rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
55 static int mds_llog_origin_connect(struct llog_ctxt *ctxt, int count,
56 struct llog_logid *logid,
57 struct llog_ctxt_gen *gen)
59 struct obd_device *obd = ctxt->loc_obd;
60 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
61 struct llog_ctxt *lctxt;
65 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
66 rc = llog_connect(lctxt, count, logid, gen);
70 static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
71 int count, struct llog_cookie *cookies, int flags)
73 struct obd_device *obd = ctxt->loc_obd;
74 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
75 struct llog_ctxt *lctxt;
79 lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
80 rc = llog_cancel(lctxt, lsm, count, cookies,flags);
84 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
85 struct lustre_msg *repmsg, int offset)
87 struct mds_obd *mds = &obd->u.mds;
88 struct lov_stripe_md *lsm = NULL;
90 struct llog_ctxt *ctxt;
95 if (IS_ERR(mds->mds_osc_obd))
96 RETURN(PTR_ERR(mds->mds_osc_obd));
98 rc = obd_unpackmd(mds->mds_osc_exp, &lsm,
99 lustre_msg_buf(repmsg, offset, 0),
100 repmsg->buflens[offset]);
104 #ifdef ENABLE_ORPHANS
105 ctxt = llog_get_context(obd, LLOG_UNLINK_ORIG_CTXT);
106 rc = llog_add(ctxt, NULL, lsm, lustre_msg_buf(repmsg, offset + 1, 0),
107 repmsg->buflens[offset + 1] / sizeof(struct llog_cookie));
110 obd_free_memmd(mds->mds_osc_exp, &lsm);
115 static struct llog_operations mds_unlink_orig_logops = {
116 lop_add: mds_llog_origin_add,
117 lop_connect: mds_llog_origin_connect,
120 static struct llog_operations mds_size_repl_logops = {
121 lop_cancel: mds_llog_repl_cancel
124 int mds_llog_init(struct obd_device *obd, struct obd_device *tgt,
125 int count, struct llog_logid *logid)
127 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
131 rc = llog_setup(obd, LLOG_UNLINK_ORIG_CTXT, tgt, 0, NULL,
132 &mds_unlink_orig_logops);
136 rc = llog_setup(obd, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
137 &mds_size_repl_logops);
141 rc = obd_llog_init(lov_obd, tgt, count, logid);
143 CERROR("error lov_llog_init\n");
148 int mds_llog_finish(struct obd_device *obd, int count)
150 struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
154 rc = llog_cleanup(llog_get_context(obd, LLOG_UNLINK_ORIG_CTXT));
158 rc = llog_cleanup(llog_get_context(obd, LLOG_SIZE_REPL_CTXT));
162 rc = obd_llog_finish(lov_obd, count);
164 CERROR("error lov_llog_finish\n");