1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define DEBUG_SUBSYSTEM S_CMOBD
24 #include <linux/version.h>
25 #include <linux/init.h>
26 #include <linux/obd_support.h>
27 #include <linux/lustre_lib.h>
28 #include <linux/lustre_net.h>
29 #include <linux/lustre_idl.h>
30 #include <linux/obd_class.h>
31 #include <linux/lustre_log.h>
32 #include <linux/lustre_cmobd.h>
33 #include <linux/lustre_fsfilt.h>
34 #include <linux/lustre_smfs.h>
36 #include "cmobd_internal.h"
38 static int cmobd_reint_record(int opcode, struct obd_device *obd, char *record)
44 rc = cmobd_reint_create(obd, record);
47 rc = cmobd_reint_setattr(obd, record);
50 rc = cmobd_reint_write(obd, record);
53 rc = cmobd_reint_mds(obd, record);
56 CERROR("unrecognized format %d\n", opcode);
62 static int cmobd_reint_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
65 struct obd_device *obd = (struct obd_device*)data;
71 if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
72 CERROR("log is not plain log\n");
75 if (rec->lrh_type != SMFS_UPDATE_REC)
78 buf = (char *)(rec + 1);
79 rc = smfs_rec_unpack(NULL, buf, &pbuf, &opcode);
82 rc = cmobd_reint_record(opcode, obd, pbuf);
85 /*delete this record*/
91 int cmobd_reintegrate(struct obd_device *obd)
93 struct cache_manager_obd *cmobd = &obd->u.cmobd;
94 struct llog_ctxt *ctxt = NULL;
95 struct llog_handle *llh;
99 /* XXX just fetch the reintegration log context from
100 * cache ost directly, use logid later ?? */
101 val_size = sizeof(ctxt);
102 rc = obd_get_info(cmobd->cm_cache_exp, strlen("reint_log") + 1,
103 "reint_log", &val_size, &ctxt);
107 /* use the already opened log handle instead of
108 * reopen a new log handle */
109 llh = ctxt ? ctxt->loc_handle : NULL;
113 /* FIXME should we insert a LLOG_GEN_REC before process log ? */
114 rc = llog_cat_process(llh, (llog_cb_t)cmobd_reint_cb, obd);