1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/smfs/smfs_llog.c
5 * Lustre filesystem abstraction routines
7 * Copyright (C) 2004 Cluster File Systems, Inc.
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DEBUG_SUBSYSTEM S_SM
27 #include <linux/lustre_log.h>
28 #include <linux/lustre_fsfilt.h>
29 #include <linux/lustre_smfs.h>
30 #include <linux/lvfs.h>
32 #include "smfs_internal.h"
33 int smfs_llog_setup(struct smfs_super_info *smb)
35 struct dentry *dentry = NULL;
38 /* create OBJECTS and LOGS for writing logs */
41 //push_ctxt(&saved, S2SMI(sb)->smsi_ctxt, NULL);
42 dentry = simple_mkdir(current->fs->pwd, "LOGS", 0777, 1);
45 CERROR("cannot create LOGS directory: rc = %d\n", rc);
50 smb->smsi_logs_dir = dentry;
52 dentry = simple_mkdir(current->fs->pwd, "OBJECTS", 0777, 1);
55 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
60 smb->smsi_objects_dir = dentry;
66 int smfs_llog_cleanup(struct smfs_super_info *smb)
71 if (SMFS_CACHE_HOOK(S2SMI(sb)))
72 rc = cache_space_hook_cleanup();
74 if (SMFS_DO_REC(S2SMI(sb))) {
75 rc2 = llog_catalog_cleanup(ctxt);
76 OBD_FREE(ctxt, sizeof(*ctxt));
81 if (smb->smsi_logs_dir) {
82 l_dput(smb->smsi_logs_dir);
83 smb->smsi_logs_dir = NULL;
85 if (smb->smsi_objects_dir) {
86 l_dput(smb->smsi_objects_dir);
87 smb->smsi_objects_dir = NULL;
92 int smfs_llog_add_rec(struct smfs_super_info *smb, void *data, int data_size)
94 struct llog_rec_hdr rec;
98 rec.lrh_len = size_round(data_size);
99 rec.lrh_type = SMFS_UPDATE_REC;
101 rc = llog_catalog_add(smb->smsi_kml_log, &rec, data, NULL, 0, NULL, NULL, NULL);
103 CERROR("error adding kml rec: %d\n", rc);