Whamcloud - gitweb
LU-2158 lvfs: move obdclass related functions to obclass
[fs/lustre-release.git] / lustre / lvfs / lvfs_linux.c
index b981fe9..a4f9340 100644 (file)
@@ -1,31 +1,42 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
+/*
+ * GPL HEADER START
  *
- *  lustre/lib/lvfs_linux.c
- *  Lustre filesystem abstraction routines
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  Copyright (C) 2002, 2003 Cluster File Systems, Inc.
- *   Author: Andreas Dilger <adilger@clusterfs.com>
+ * 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.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * 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 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.
+ * 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
  *
- *   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.
+ * 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.
  *
- *   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.
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/lvfs/lvfs_linux.c
+ *
+ * Author: Andreas Dilger <adilger@clusterfs.com>
  */
-
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 
 #define DEBUG_SUBSYSTEM S_FILTER
 
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
 #include <linux/version.h>
-#include <libcfs/kp30.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <libcfs/libcfs.h>
+#include <lustre_fsfilt.h>
+#include <obd.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/lustre_compat25.h>
-#include <linux/lvfs.h>
-#include "lvfs_internal.h"
+#include <lvfs.h>
 
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_mds.h>   /* for mds_grp_hash_entry */
+#include <obd.h>
+#include <lustre_lib.h>
 
-atomic_t obd_memory;
-int obd_memmax;
+struct lprocfs_stats *obd_memory = NULL;
+EXPORT_SYMBOL(obd_memory);
+/* refine later and change to seqlock or simlar from libcfs */
 
 /* Debugging check only needed during development */
 #ifdef OBD_CTXT_DEBUG
@@ -59,7 +68,6 @@ int obd_memmax;
 # define ASSERT_NOT_KERNEL_CTXT(msg) LASSERTF(!segment_eq(get_fs(), get_ds()),\
                                               msg)
 # define ASSERT_KERNEL_CTXT(msg) LASSERTF(segment_eq(get_fs(), get_ds()), msg)
-
 #else
 # define ASSERT_CTXT_MAGIC(magic) do {} while(0)
 # define ASSERT_NOT_KERNEL_CTXT(msg) do {} while(0)
@@ -73,24 +81,14 @@ static void push_group_info(struct lvfs_run_ctxt *save,
                 save->ngroups = current_ngroups;
                 current_ngroups = 0;
         } else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+                struct cred *cred;
                 task_lock(current);
-                save->group_info = current->group_info;
-                current->group_info = ginfo;
+                save->group_info = current_cred()->group_info;
+                if ((cred = prepare_creds())) {
+                        cred->group_info = ginfo;
+                        commit_creds(cred);
+                }
                 task_unlock(current);
-#else
-                LASSERT(ginfo->ngroups <= NGROUPS);
-                /* save old */
-                save->group_info.ngroups = current->ngroups;
-                if (current->ngroups)
-                        memcpy(save->group_info.small_block, current->groups,
-                               current->ngroups);
-                /* push new */
-                current->ngroups = ginfo->ngroups;
-                if (ginfo->ngroups)
-                        memcpy(current->groups, ginfo->small_block,
-                               current->ngroups);
-#endif
         }
 }
 
@@ -100,16 +98,13 @@ static void pop_group_info(struct lvfs_run_ctxt *save,
         if (!ginfo) {
                 current_ngroups = save->ngroups;
         } else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+                struct cred *cred;
                 task_lock(current);
-                current->group_info = save->group_info;
+                if ((cred = prepare_creds())) {
+                        cred->group_info = save->group_info;
+                        commit_creds(cred);
+                }
                 task_unlock(current);
-#else
-                current->ngroups = ginfo->ngroups;
-                if (current->ngroups)
-                        memcpy(current->groups, save->group_info.small_block,
-                               current->ngroups);
-#endif
         }
 }
 
@@ -117,30 +112,21 @@ static void pop_group_info(struct lvfs_run_ctxt *save,
 void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
                struct lvfs_ucred *uc)
 {
+       /* if there is underlaying dt_device then push_ctxt is not needed */
+       if (new_ctx->dt != NULL)
+               return;
+
         //ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n");
         ASSERT_CTXT_MAGIC(new_ctx->magic);
-        LASSERT(save->magic != OBD_RUN_CTXT_MAGIC || save->pid != current->pid);
         OBD_SET_CTXT_MAGIC(save);
-        save->pid = current->pid;
-
-        /*
-        CDEBUG(D_INFO,
-               "= push %p->%p = cur fs %p pwd %p:d%d:i%d (%.*s), pwdmnt %p:%d\n",
-               save, current, current->fs, current->fs->pwd,
-               atomic_read(&current->fs->pwd->d_count),
-               atomic_read(&current->fs->pwd->d_inode->i_count),
-               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
-               current->fs->pwdmnt,
-               atomic_read(&current->fs->pwdmnt->mnt_count));
-        */
 
         save->fs = get_fs();
-        LASSERT(atomic_read(&current->fs->pwd->d_count));
-        LASSERT(atomic_read(&new_ctx->pwd->d_count));
-        save->pwd = dget(current->fs->pwd);
-        save->pwdmnt = mntget(current->fs->pwdmnt);
-        save->ngroups = current_ngroups;
-        save->luc.luc_umask = current->fs->umask;
+       LASSERT(d_refcount(cfs_fs_pwd(current->fs)));
+       LASSERT(d_refcount(new_ctx->pwd));
+        save->pwd = dget(cfs_fs_pwd(current->fs));
+        save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
+        save->luc.luc_umask = cfs_curproc_umask();
+        save->ngroups = current_cred()->group_info->ngroups;
 
         LASSERT(save->pwd);
         LASSERT(save->pwdmnt);
@@ -148,484 +134,159 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
         LASSERT(new_ctx->pwdmnt);
 
         if (uc) {
-                save->luc.luc_uid = current->uid;
-                save->luc.luc_gid = current->gid;
-                save->luc.luc_fsuid = current->fsuid;
-                save->luc.luc_fsgid = current->fsgid;
-                save->luc.luc_cap = current->cap_effective;
-
-                current->uid = uc->luc_uid;
-                current->gid = uc->luc_gid;
-                current->fsuid = uc->luc_fsuid;
-                current->fsgid = uc->luc_fsgid;
-                current->cap_effective = uc->luc_cap;
-
-                push_group_info(save, uc->luc_ginfo);
+                struct cred *cred;
+                save->luc.luc_uid = current_uid();
+                save->luc.luc_gid = current_gid();
+                save->luc.luc_fsuid = current_fsuid();
+                save->luc.luc_fsgid = current_fsgid();
+                save->luc.luc_cap = current_cap();
+
+                if ((cred = prepare_creds())) {
+                        cred->uid = uc->luc_uid;
+                        cred->gid = uc->luc_gid;
+                        cred->fsuid = uc->luc_fsuid;
+                        cred->fsgid = uc->luc_fsgid;
+                        cred->cap_effective = uc->luc_cap;
+                        commit_creds(cred);
+                }
+
+                push_group_info(save,
+                                uc->luc_ginfo ?:
+                                uc->luc_identity ? uc->luc_identity->mi_ginfo :
+                                                   NULL);
         }
         current->fs->umask = 0; /* umask already applied on client */
         set_fs(new_ctx->fs);
-        set_fs_pwd(current->fs, new_ctx->pwdmnt, new_ctx->pwd);
-
-        /*
-        CDEBUG(D_INFO,
-               "= push %p->%p = cur fs %p pwd %p:d%d:i%d (%.*s), pwdmnt %p:%d\n",
-               new_ctx, current, current->fs, current->fs->pwd,
-               atomic_read(&current->fs->pwd->d_count),
-               atomic_read(&current->fs->pwd->d_inode->i_count),
-               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
-               current->fs->pwdmnt,
-               atomic_read(&current->fs->pwdmnt->mnt_count));
-        */
+        ll_set_fs_pwd(current->fs, new_ctx->pwdmnt, new_ctx->pwd);
 }
 EXPORT_SYMBOL(push_ctxt);
 
 void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
               struct lvfs_ucred *uc)
 {
-        //printk("pc0");
+       /* if there is underlaying dt_device then pop_ctxt is not needed */
+       if (new_ctx->dt != NULL)
+               return;
+
         ASSERT_CTXT_MAGIC(saved->magic);
-        LASSERT(saved->pid == current->pid);
-        saved->magic = 0;
-        saved->pid = 0;
-        //printk("pc1");
         ASSERT_KERNEL_CTXT("popping non-kernel context!\n");
 
-        /*
-        CDEBUG(D_INFO,
-               " = pop  %p==%p = cur %p pwd %p:d%d:i%d (%.*s), pwdmnt %p:%d\n",
-               new_ctx, current, current->fs, current->fs->pwd,
-               atomic_read(&current->fs->pwd->d_count),
-               atomic_read(&current->fs->pwd->d_inode->i_count),
-               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
-               current->fs->pwdmnt,
-               atomic_read(&current->fs->pwdmnt->mnt_count));
-        */
-
-        LASSERT(current->fs->pwd == new_ctx->pwd);
-        LASSERT(current->fs->pwdmnt == new_ctx->pwdmnt);
+        LASSERTF(cfs_fs_pwd(current->fs) == new_ctx->pwd, "%p != %p\n",
+                 cfs_fs_pwd(current->fs), new_ctx->pwd);
+        LASSERTF(cfs_fs_mnt(current->fs) == new_ctx->pwdmnt, "%p != %p\n",
+                 cfs_fs_mnt(current->fs), new_ctx->pwdmnt);
 
         set_fs(saved->fs);
-        set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
+        ll_set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
 
         dput(saved->pwd);
         mntput(saved->pwdmnt);
         current->fs->umask = saved->luc.luc_umask;
         if (uc) {
-                current->uid = saved->luc.luc_uid;
-                current->gid = saved->luc.luc_gid;
-                current->fsuid = saved->luc.luc_fsuid;
-                current->fsgid = saved->luc.luc_fsgid;
-                current->cap_effective = saved->luc.luc_cap;
+                struct cred *cred;
+                if ((cred = prepare_creds())) {
+                        cred->uid = saved->luc.luc_uid;
+                        cred->gid = saved->luc.luc_gid;
+                        cred->fsuid = saved->luc.luc_fsuid;
+                        cred->fsgid = saved->luc.luc_fsgid;
+                        cred->cap_effective = saved->luc.luc_cap;
+                        commit_creds(cred);
+                }
 
-                pop_group_info(saved, uc->luc_ginfo);
+                pop_group_info(saved,
+                               uc->luc_ginfo ?:
+                               uc->luc_identity ? uc->luc_identity->mi_ginfo :
+                                                  NULL);
         }
-
-        /*
-        CDEBUG(D_INFO,
-               "= pop  %p->%p = cur fs %p pwd %p:d%d:i%d (%.*s), pwdmnt %p:%d\n",
-               saved, current, current->fs, current->fs->pwd,
-               atomic_read(&current->fs->pwd->d_count),
-               atomic_read(&current->fs->pwd->d_inode->i_count),
-               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
-               current->fs->pwdmnt,
-               atomic_read(&current->fs->pwdmnt->mnt_count));
-        */
 }
 EXPORT_SYMBOL(pop_ctxt);
 
-/* utility to make a file */
-struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix)
-{
-        struct dentry *dchild;
-        int err = 0;
-        ENTRY;
-
-        ASSERT_KERNEL_CTXT("kernel doing mknod outside kernel context\n");
-        CDEBUG(D_INODE, "creating file %.*s\n", (int)strlen(name), name);
-
-        dchild = ll_lookup_one_len(name, dir, strlen(name));
-        if (IS_ERR(dchild))
-                GOTO(out_up, dchild);
-
-        if (dchild->d_inode) {
-                int old_mode = dchild->d_inode->i_mode;
-                if (!S_ISREG(old_mode))
-                        GOTO(out_err, err = -EEXIST);
-
-                /* Fixup file permissions if necessary */
-                if (fix && (old_mode & S_IALLUGO) != (mode & S_IALLUGO)) {
-                        CWARN("fixing permissions on %s from %o to %o\n",
-                              name, old_mode, mode);
-                        dchild->d_inode->i_mode = (mode & S_IALLUGO) |
-                                                  (old_mode & ~S_IALLUGO);
-                        mark_inode_dirty(dchild->d_inode);
-                }
-                GOTO(out_up, dchild);
-        }
-
-        err = ll_vfs_create(dir->d_inode, dchild, (mode & ~S_IFMT) | S_IFREG,
-                            NULL);
-        if (err)
-                GOTO(out_err, err);
-
-        RETURN(dchild);
-
-out_err:
-        dput(dchild);
-        dchild = ERR_PTR(err);
-out_up:
-        return dchild;
-}
-EXPORT_SYMBOL(simple_mknod);
-
-/* utility to make a directory */
-struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix)
+/* utility to rename a file */
+int lustre_rename(struct dentry *dir, struct vfsmount *mnt,
+                  char *oldname, char *newname)
 {
-        struct dentry *dchild;
+        struct dentry *dchild_old, *dchild_new;
         int err = 0;
         ENTRY;
 
-        ASSERT_KERNEL_CTXT("kernel doing mkdir outside kernel context\n");
-        CDEBUG(D_INODE, "creating directory %.*s\n", (int)strlen(name), name);
-        dchild = ll_lookup_one_len(name, dir, strlen(name));
-        if (IS_ERR(dchild))
-                GOTO(out_up, dchild);
-
-        if (dchild->d_inode) {
-                int old_mode = dchild->d_inode->i_mode;
-                if (!S_ISDIR(old_mode)) {
-                        CERROR("found %s (%lu/%u) is mode %o\n", name,
-                               dchild->d_inode->i_ino,
-                               dchild->d_inode->i_generation, old_mode);
-                        GOTO(out_err, err = -ENOTDIR);
-                }
+        ASSERT_KERNEL_CTXT("kernel doing rename outside kernel context\n");
+        CDEBUG(D_INODE, "renaming file %.*s to %.*s\n",
+               (int)strlen(oldname), oldname, (int)strlen(newname), newname);
 
-                /* Fixup directory permissions if necessary */
-                if (fix && (old_mode & S_IALLUGO) != (mode & S_IALLUGO)) {
-                        CWARN("fixing permissions on %s from %o to %o\n",
-                              name, old_mode, mode);
-                        dchild->d_inode->i_mode = (mode & S_IALLUGO) |
-                                                  (old_mode & ~S_IALLUGO);
-                        mark_inode_dirty(dchild->d_inode);
-                }
-                GOTO(out_up, dchild);
-        }
+        dchild_old = ll_lookup_one_len(oldname, dir, strlen(oldname));
+        if (IS_ERR(dchild_old))
+                RETURN(PTR_ERR(dchild_old));
 
-        err = vfs_mkdir(dir->d_inode, dchild, mode);
-        if (err)
-                GOTO(out_err, err);
+        if (!dchild_old->d_inode)
+                GOTO(put_old, err = -ENOENT);
 
-        RETURN(dchild);
-
-out_err:
-        dput(dchild);
-        dchild = ERR_PTR(err);
-out_up:
-        return dchild;
-}
-EXPORT_SYMBOL(simple_mkdir);
-
-/*
- * Read a file from within kernel context.  Prior to calling this
- * function we should already have done a push_ctxt().
- */
-int lustre_fread(struct file *file, void *buf, int len, loff_t *off)
-{
-        ASSERT_KERNEL_CTXT("kernel doing read outside kernel context\n");
-        if (!file || !file->f_op || !file->f_op->read || !off)
-                RETURN(-ENOSYS);
-
-        return file->f_op->read(file, buf, len, off);
-}
-EXPORT_SYMBOL(lustre_fread);
-
-/*
- * Write a file from within kernel context.  Prior to calling this
- * function we should already have done a push_ctxt().
- */
-int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off)
-{
-        ENTRY;
-        ASSERT_KERNEL_CTXT("kernel doing write outside kernel context\n");
-        if (!file)
-                RETURN(-ENOENT);
-        if (!file->f_op)
-                RETURN(-ENOSYS);
-        if (!off)
-                RETURN(-EINVAL);
-
-        if (!file->f_op->write)
-                RETURN(-EROFS);
-
-        RETURN(file->f_op->write(file, buf, len, off));
-}
-EXPORT_SYMBOL(lustre_fwrite);
+        dchild_new = ll_lookup_one_len(newname, dir, strlen(newname));
+        if (IS_ERR(dchild_new))
+                GOTO(put_old, err = PTR_ERR(dchild_new));
 
-/*
- * Sync a file from within kernel context.  Prior to calling this
- * function we should already have done a push_ctxt().
- */
-int lustre_fsync(struct file *file)
-{
-        ENTRY;
-        ASSERT_KERNEL_CTXT("kernel doing sync outside kernel context\n");
-        if (!file || !file->f_op || !file->f_op->fsync)
-                RETURN(-ENOSYS);
+        err = ll_vfs_rename(dir->d_inode, dchild_old, mnt,
+                            dir->d_inode, dchild_new, mnt);
 
-        RETURN(file->f_op->fsync(file, file->f_dentry, 0));
+        dput(dchild_new);
+put_old:
+        dput(dchild_old);
+        RETURN(err);
 }
-EXPORT_SYMBOL(lustre_fsync);
+EXPORT_SYMBOL(lustre_rename);
 
+/* Note: dput(dchild) will be called if there is an error */
 struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
                              int flags)
 {
         mntget(ctxt->pwdmnt);
-        return dentry_open(de, ctxt->pwdmnt, flags);
+        return ll_dentry_open(de, ctxt->pwdmnt, flags, current_cred());
 }
 EXPORT_SYMBOL(l_dentry_open);
 
-static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset,
-                     ino_t ino, unsigned int d_type)
+#ifdef LPROCFS
+__s64 lprocfs_read_helper(struct lprocfs_counter *lc,
+                         struct lprocfs_counter_header *header,
+                         enum lprocfs_stats_flags flags,
+                         enum lprocfs_fields_flags field)
 {
-        struct l_linux_dirent *dirent;
-        struct l_readdir_callback *buf = (struct l_readdir_callback *)__buf;
-        
-        dirent = buf->lrc_dirent;
-        if (dirent)
-               dirent->lld_off = offset; 
-
-        OBD_ALLOC(dirent, sizeof(*dirent));
-
-        list_add_tail(&dirent->lld_list, buf->lrc_list);
-
-        buf->lrc_dirent = dirent;
-        dirent->lld_ino = ino;
-        LASSERT(sizeof(dirent->lld_name) >= namlen + 1);
-        memcpy(dirent->lld_name, name, namlen);
-
-        return 0;
+       __s64 ret = 0;
+
+       if (lc == NULL || header == NULL)
+               RETURN(0);
+
+       switch (field) {
+               case LPROCFS_FIELDS_FLAGS_CONFIG:
+                       ret = header->lc_config;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_SUM:
+                       ret = lc->lc_sum;
+                       if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
+                               ret += lc->lc_sum_irq;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_MIN:
+                       ret = lc->lc_min;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_MAX:
+                       ret = lc->lc_max;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_AVG:
+                       ret = (lc->lc_max - lc->lc_min) / 2;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
+                       ret = lc->lc_sumsquare;
+                       break;
+               case LPROCFS_FIELDS_FLAGS_COUNT:
+                       ret = lc->lc_count;
+                       break;
+               default:
+                       break;
+       };
+
+       RETURN(ret);
 }
+EXPORT_SYMBOL(lprocfs_read_helper);
+#endif /* LPROCFS */
 
-long l_readdir(struct file *file, struct list_head *dentry_list)
-{
-        struct l_linux_dirent *lastdirent;
-        struct l_readdir_callback buf;
-        int error;
-
-        buf.lrc_dirent = NULL;
-        buf.lrc_list = dentry_list; 
-
-        error = vfs_readdir(file, l_filldir, &buf);
-        if (error < 0)
-                return error;
-
-        lastdirent = buf.lrc_dirent;
-        if (lastdirent)
-                lastdirent->lld_off = file->f_pos;
-
-        return 0; 
-}
-EXPORT_SYMBOL(l_readdir);
-EXPORT_SYMBOL(obd_memory);
-EXPORT_SYMBOL(obd_memmax);
-
-#if defined (CONFIG_DEBUG_MEMORY) && defined(__KERNEL__)
-static spinlock_t obd_memlist_lock = SPIN_LOCK_UNLOCKED;
-static struct hlist_head *obd_memtable;
-static unsigned long obd_memtable_size;
-
-static int lvfs_memdbg_init(int size)
-{
-        struct hlist_head *head;
-        int i;
-
-        LASSERT(size > sizeof(sizeof(struct hlist_head)));
-        obd_memtable_size = size / sizeof(struct hlist_head);
-
-        CWARN("Allocating %lu malloc entries...\n",
-              (unsigned long)obd_memtable_size);
-
-        obd_memtable = kmalloc(size, GFP_KERNEL);
-        if (!obd_memtable)
-                return -ENOMEM;
-
-        i = obd_memtable_size;
-        head = obd_memtable;
-        do {
-                INIT_HLIST_HEAD(head);
-                head++;
-                i--;
-        } while(i);
-
-        return 0;
-}
-
-static int lvfs_memdbg_cleanup(void)
-{
-        struct hlist_node *node = NULL, *tmp = NULL;
-        struct hlist_head *head;
-        struct mtrack *mt;
-        int i;
-
-        spin_lock(&obd_memlist_lock);
-        for (i = 0, head = obd_memtable; i < obd_memtable_size; i++, head++) {
-                hlist_for_each_safe(node, tmp, head) {
-                        mt = hlist_entry(node, struct mtrack, m_hash);
-                        hlist_del_init(&mt->m_hash);
-                        kfree(mt);
-                }
-        }
-        spin_unlock(&obd_memlist_lock);
-        kfree(obd_memtable);
-        return 0;
-}
-
-static inline unsigned long const hashfn(void *ptr)
-{
-        return (unsigned long)ptr &
-                (obd_memtable_size - 1);
-}
-
-static void __lvfs_memdbg_insert(struct mtrack *mt)
-{
-        struct hlist_head *head = obd_memtable +
-                hashfn(mt->m_ptr);
-        hlist_add_head(&mt->m_hash, head);
-}
-
-void lvfs_memdbg_insert(struct mtrack *mt)
-{
-        spin_lock(&obd_memlist_lock);
-        __lvfs_memdbg_insert(mt);
-        spin_unlock(&obd_memlist_lock);
-}
-EXPORT_SYMBOL(lvfs_memdbg_insert);
-
-static void __lvfs_memdbg_remove(struct mtrack *mt)
-{
-        hlist_del_init(&mt->m_hash);
-}
-
-void lvfs_memdbg_remove(struct mtrack *mt)
-{
-        spin_lock(&obd_memlist_lock);
-        __lvfs_memdbg_remove(mt);
-        spin_unlock(&obd_memlist_lock);
-}
-EXPORT_SYMBOL(lvfs_memdbg_remove);
-
-static struct mtrack *__lvfs_memdbg_find(void *ptr)
-{
-        struct hlist_node *node = NULL;
-        struct mtrack *mt = NULL;
-        struct hlist_head *head;
-
-        head = obd_memtable + hashfn(ptr);
-
-        hlist_for_each(node, head) {
-                mt = hlist_entry(node, struct mtrack, m_hash);
-                if ((unsigned long)mt->m_ptr == (unsigned long)ptr)
-                        break;
-                mt = NULL;
-        }
-        return mt;
-}
-
-struct mtrack *lvfs_memdbg_find(void *ptr)
-{
-        struct mtrack *mt;
-
-        spin_lock(&obd_memlist_lock);
-        mt = __lvfs_memdbg_find(ptr);
-        spin_unlock(&obd_memlist_lock);
-        
-        return mt;
-}
-EXPORT_SYMBOL(lvfs_memdbg_find);
-
-int lvfs_memdbg_check_insert(struct mtrack *mt)
-{
-        spin_lock(&obd_memlist_lock);
-        if (!__lvfs_memdbg_find(mt->m_ptr)) {
-                __lvfs_memdbg_insert(mt);
-                spin_unlock(&obd_memlist_lock);
-                return 1;
-        }
-        spin_unlock(&obd_memlist_lock);
-        return 0;
-}
-EXPORT_SYMBOL(lvfs_memdbg_check_insert);
-
-struct mtrack *
-lvfs_memdbg_check_remove(void *ptr)
-{
-        struct mtrack *mt;
-
-        spin_lock(&obd_memlist_lock);
-        mt = __lvfs_memdbg_find(ptr);
-        if (mt) {
-                __lvfs_memdbg_remove(mt);
-                spin_unlock(&obd_memlist_lock);
-                return mt;
-        }
-        spin_unlock(&obd_memlist_lock);
-        return NULL;
-}
-EXPORT_SYMBOL(lvfs_memdbg_check_remove);
-
-static void lvfs_memdbg_show(void)
-{
-        struct hlist_node *node = NULL;
-        struct hlist_head *head;
-        struct mtrack *mt;
-        int leaked, i;
-
-        leaked = atomic_read(&obd_memory);
-
-        if (leaked > 0) {
-                CWARN("Memory leaks detected (max %d, leaked %d):\n",
-                      obd_memmax, leaked);
-
-                spin_lock(&obd_memlist_lock);
-                for (i = 0, head = obd_memtable; i < obd_memtable_size; i++, head++) {
-                        hlist_for_each(node, head) {
-                                mt = hlist_entry(node, struct mtrack, m_hash);
-                                CWARN("  ptr: 0x%p, size: %d, src at \"%s\"\n",
-                                      mt->m_ptr, mt->m_size, mt->m_loc);
-                        }
-                }
-                spin_unlock(&obd_memlist_lock);
-        }
-}
-#endif
-
-static int __init lvfs_linux_init(void)
-{
-        ENTRY;
-#if defined (CONFIG_DEBUG_MEMORY) && defined(__KERNEL__)
-        lvfs_memdbg_init(PAGE_SIZE);
-#endif
-        lvfs_mount_list_init();
-        RETURN(0);
-}
-
-static void __exit lvfs_linux_exit(void)
-{
-        ENTRY;
-
-        lvfs_mount_list_cleanup();
-
-#if defined (CONFIG_DEBUG_MEMORY) && defined(__KERNEL__)
-        lvfs_memdbg_show();
-        lvfs_memdbg_cleanup();
-#endif
-        EXIT;
-        return;
-}
-
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre VFS Filesystem Helper v0.1");
 MODULE_LICENSE("GPL");
-
-module_init(lvfs_linux_init);
-module_exit(lvfs_linux_exit);