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 super_block *sb, struct vfsmount *mnt)
35 struct dentry *dentry = NULL;
38 /* create OBJECTS and LOGS for writing logs */
43 //push_ctxt(&saved, S2SMI(sb)->smsi_ctxt, NULL);
44 dentry = simple_mkdir(current->fs->pwd, "LOGS", 0777, 1);
47 CERROR("cannot create LOGS directory: rc = %d\n", rc);
52 S2SMI(sb)->smsi_logs_dir = dentry;
53 //SMFS_SET(I2SMI(dentry->d_inode)->smi_flags, SMFS_PLG_ALL);
55 dentry = simple_mkdir(current->fs->pwd, "OBJECTS", 0777, 1);
58 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
63 S2SMI(sb)->smsi_objects_dir = dentry;
64 //SMFS_SET(I2SMI(dentry->d_inode)->smi_flags, SMFS_PLG_ALL);
66 /* write log will not write to KML, cleanup kml flags */
67 //SMFS_CLEAN_INODE_REC(S2SMI(sb)->smsi_objects_dir->d_inode);
68 //SMFS_CLEAN_INODE_REC(S2SMI(sb)->smsi_logs_dir->d_inode);
70 /* log create does not call cache hooks, cleanup hook flags */
71 //SMFS_CLEAN_INODE_CACHE_HOOK(S2SMI(sb)->smsi_objects_dir->d_inode);
72 //SMFS_CLEAN_INODE_CACHE_HOOK(S2SMI(sb)->smsi_logs_dir->d_inode);
75 /*if (SMFS_CACHE_HOOK(S2SMI(sb))) {
76 rc2 = cache_space_hook_setup(sb);
81 //pop_ctxt(&saved, S2SMI(sb)->smsi_ctxt, NULL);
85 int smfs_llog_cleanup(struct super_block *sb)
90 if (SMFS_CACHE_HOOK(S2SMI(sb)))
91 rc = cache_space_hook_cleanup();
93 if (SMFS_DO_REC(S2SMI(sb))) {
94 rc2 = llog_catalog_cleanup(ctxt);
95 OBD_FREE(ctxt, sizeof(*ctxt));
100 if (S2SMI(sb)->smsi_logs_dir) {
101 l_dput(S2SMI(sb)->smsi_logs_dir);
102 S2SMI(sb)->smsi_logs_dir = NULL;
104 if (S2SMI(sb)->smsi_objects_dir) {
105 l_dput(S2SMI(sb)->smsi_objects_dir);
106 S2SMI(sb)->smsi_objects_dir = NULL;
111 int smfs_llog_add_rec(struct smfs_super_info *sinfo, void *data, int data_size)
113 struct llog_rec_hdr rec;
116 rec.lrh_len = size_round(data_size);
117 rec.lrh_type = SMFS_UPDATE_REC;
119 rc = llog_add(sinfo->smsi_kml_log, &rec, data, NULL, 0, NULL, NULL, NULL);
121 CERROR("error adding kml rec: %d\n", rc);