/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * mgs/mgs_fs.c * Lustre Management Server (MGS) filesystem interface code * * Copyright (C) 2002, 2003 Cluster File Systems, Inc. * Author: Nathan * Author: LinSongtao * * This file is part of Lustre, http://www.lustre.org. * * Lustre is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * Lustre is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Lustre; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif #define DEBUG_SUBSYSTEM S_MGS #include #include #include #include #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) #include #endif #include #include #include #include #include #include #include #include #include "mgs_internal.h" int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt) { struct mgs_obd *mgs = &obd->u.mgs; struct lvfs_run_ctxt saved; struct dentry *logs_dentry; int rc; ENTRY; rc = cleanup_group_info(); if (rc) RETURN(rc); mgs->mgs_vfsmnt = mnt; mgs->mgs_sb = mnt->mnt_root->d_inode->i_sb; fsfilt_setup(obd, mgs->mgs_sb); OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt); obd->obd_lvfs_ctxt.pwdmnt = mnt; obd->obd_lvfs_ctxt.pwd = mnt->mnt_root; obd->obd_lvfs_ctxt.fs = get_ds(); obd->obd_lvfs_ctxt.cb_ops = mgs_lvfs_ops; /* setup the directory tree */ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); logs_dentry = simple_mkdir(current->fs->pwd, MOUNT_CONFIGS_DIR, 0777, 1); if (IS_ERR(logs_dentry)) { rc = PTR_ERR(logs_dentry); CERROR("cannot create %s directory: rc = %d\n", MOUNT_CONFIGS_DIR, rc); GOTO(err_pop, rc); } mgs->mgs_configs_dir = logs_dentry; err_pop: pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); return rc; } int mgs_fs_cleanup(struct obd_device *obd) { struct mgs_obd *mgs = &obd->u.mgs; struct lvfs_run_ctxt saved; int rc = 0; if (obd->obd_fail) CERROR("%s: shutting down for failover; client state will" " be preserved.\n", obd->obd_name); class_disconnect_exports(obd); /* cleans up client info too */ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); if (mgs->mgs_configs_dir) { l_dput(mgs->mgs_configs_dir); mgs->mgs_configs_dir = NULL; } pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); return rc; }