1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Lustre Management Server (MGS) filesystem interface code
7 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
8 * Author: Nathan <nathan@clusterfs.com>
9 * Author: LinSongtao <lincent@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 EXPORT_SYMTAB
29 #define DEBUG_SUBSYSTEM S_MGS
31 #include <linux/module.h>
32 #include <linux/kmod.h>
33 #include <linux/version.h>
34 #include <linux/sched.h>
35 #include <linux/lustre_quota.h>
36 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
37 #include <linux/mount.h>
39 #include <linux/lustre_mgs.h>
40 #include <linux/obd_class.h>
41 #include <linux/obd_support.h>
42 #include <linux/lustre_lib.h>
43 #include <linux/lustre_fsfilt.h>
44 #include <libcfs/list.h>
46 #include "mgs_internal.h"
48 int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
50 struct mgs_obd *mgs = &obd->u.mgs;
51 struct lvfs_run_ctxt saved;
52 struct dentry *dentry;
56 rc = cleanup_group_info();
60 mgs->mgs_vfsmnt = mnt;
61 mgs->mgs_sb = mnt->mnt_root->d_inode->i_sb;
63 fsfilt_setup(obd, mgs->mgs_sb);
65 OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
66 obd->obd_lvfs_ctxt.pwdmnt = mnt;
67 obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
68 obd->obd_lvfs_ctxt.fs = get_ds();
69 obd->obd_lvfs_ctxt.cb_ops = mgs_lvfs_ops;
71 /* setup the directory tree */
72 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
74 dentry = simple_mkdir(current->fs->pwd, "CONFIGS", 0777, 1);
77 CERROR("cannot create CONFIGS directory: rc = %d\n", rc);
81 mgs->mgs_configs_dir = dentry;
83 INIT_LIST_HEAD(&mgs->mgs_opens_logs);
86 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
90 int mgs_fs_cleanup(struct obd_device *obd)
92 struct mgs_obd *mgs = &obd->u.mgs;
93 struct lvfs_run_ctxt saved;
97 CERROR("%s: shutting down for failover; client state will"
98 " be preserved.\n", obd->obd_name);
100 class_disconnect_exports(obd); /* cleans up client info too */
102 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
104 if (mgs->mgs_configs_dir) {
105 l_dput(mgs->mgs_configs_dir);
106 mgs->mgs_configs_dir = NULL;
109 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);