X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flvfs%2Flvfs_common.c;h=a1f6b268b61cbacaa074debae2ae475a50ec1668;hb=2d617260aaa5f778ab8dcb006e2a827f4b8f8567;hp=aa4d3f3def66eb1690717b3ab65dd0ed17bc3dd2;hpb=b3d95c9cba66aa985efea888a58c358ed788297b;p=fs%2Flustre-release.git diff --git a/lustre/lvfs/lvfs_common.c b/lustre/lvfs/lvfs_common.c index aa4d3f3..a1f6b26 100644 --- a/lustre/lvfs/lvfs_common.c +++ b/lustre/lvfs/lvfs_common.c @@ -1,151 +1,44 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: +/* + * GPL HEADER START * - * Copyright (c) 2003 Cluster File Systems, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This file is part of Lustre, http://www.lustre.org/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * 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. + * This program 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 version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * 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 + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * 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. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ - -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_FILTER -#include -#include -#include - -struct dentry *lvfs_id2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, - __u32 gen, __u64 gr, void *data) -{ - return ctxt->cb_ops.l_id2dentry(id, gen, gr, data); -} -EXPORT_SYMBOL(lvfs_id2dentry); - -static struct list_head lvfs_context_list; - -void lvfs_mount_list_init(void) -{ - INIT_LIST_HEAD(&lvfs_context_list); -} - -void lvfs_mount_list_cleanup(void) -{ - struct list_head *tmp; - - if (list_empty(&lvfs_context_list)) - return; - - list_for_each(tmp, &lvfs_context_list) { - struct lvfs_obd_ctxt *data = - list_entry(tmp, struct lvfs_obd_ctxt, loc_list); - CERROR("device %s still mounted with refcount %d\n", - data->loc_name, atomic_read(&data->loc_refcount)); - } -} +#include -static inline -struct lvfs_obd_ctxt *get_lvfs_mount(struct lvfs_obd_ctxt *lvfs_ctxt) +struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, + __u32 gen, __u64 gr, void *data) { - atomic_inc(&lvfs_ctxt->loc_refcount); - return lvfs_ctxt; -} - -static struct lvfs_obd_ctxt *add_lvfs_mount(struct vfsmount *mnt, char *name) -{ - struct lvfs_obd_ctxt *lvfs_ctxt; - ENTRY; - - OBD_ALLOC(lvfs_ctxt, sizeof(*lvfs_ctxt)); - if (!lvfs_ctxt) { - CERROR("No Memory\n"); - RETURN(NULL); - } - - if (name) { - int length = strlen(name) + 1; - - OBD_ALLOC(lvfs_ctxt->loc_name, length); - if (!lvfs_ctxt->loc_name) { - CERROR("No Memory\n"); - OBD_FREE(lvfs_ctxt, sizeof(*lvfs_ctxt)); - RETURN(NULL); - } - memcpy(lvfs_ctxt->loc_name, name, length); - } - lvfs_ctxt->loc_mnt = mnt; - list_add(&lvfs_ctxt->loc_list, &lvfs_context_list); - atomic_set(&lvfs_ctxt->loc_refcount, 1); - RETURN(lvfs_ctxt); -} - -void lvfs_umount_fs(struct lvfs_obd_ctxt *lvfs_ctxt) -{ - if (lvfs_ctxt && atomic_dec_and_test(&lvfs_ctxt->loc_refcount)) { - struct vfsmount *mnt = lvfs_ctxt->loc_mnt; - ll_sbdev_type save_dev = ll_sbdev(mnt->mnt_sb); - - list_del(&lvfs_ctxt->loc_list); - if (atomic_read(&mnt->mnt_count) > 2) - CERROR("mount busy, mnt %p mnt_count %d != 2\n", mnt, - atomic_read(&mnt->mnt_count)); - - mntput(mnt); - if (lvfs_ctxt->loc_name) - OBD_FREE(lvfs_ctxt->loc_name, - strlen(lvfs_ctxt->loc_name) + 1); - OBD_FREE(lvfs_ctxt, sizeof(*lvfs_ctxt)); - ll_clear_rdonly(save_dev); - } -} -EXPORT_SYMBOL(lvfs_umount_fs); - -int lvfs_mount_fs(char *name, char *fstype, char *options, int flags, - struct lvfs_obd_ctxt **lvfs_ctxt) -{ - struct vfsmount *mnt = NULL; - struct list_head *tmp; - int rc = 0; - ENTRY; - - list_for_each(tmp, &lvfs_context_list) { - struct lvfs_obd_ctxt *data = - list_entry(tmp, struct lvfs_obd_ctxt, loc_list); - if (strcmp(data->loc_name, name) == 0) { - *lvfs_ctxt = get_lvfs_mount(data); - RETURN(0); - } - } - mnt = do_kern_mount(fstype, flags, name, options); - - if (IS_ERR(mnt)) { - rc = PTR_ERR(mnt); - CERROR("do_kern_mount failed: rc = %d\n", rc); - GOTO(out, rc); - } - CDEBUG(D_SUPER, "%s: mnt = %p\n", name, mnt); - /*add this lvfs context to the lvfs_mount_list*/ - *lvfs_ctxt = add_lvfs_mount(mnt, name); - if (!*lvfs_ctxt) { - mntput(mnt); - CERROR("add_lvfs_mount failed\n"); - GOTO(out, rc = -EINVAL); - } -out: - RETURN(rc); + return ctxt->cb_ops.l_fid2dentry(id, gen, gr, data); } -EXPORT_SYMBOL(lvfs_mount_fs); +EXPORT_SYMBOL(lvfs_fid2dentry);