Whamcloud - gitweb
WARNING: we currently crash on unmount after the last phase of runtests.
[fs/lustre-release.git] / lustre / mds / mds_extN.c
index f9ee992..42b838e 100644 (file)
@@ -1,26 +1,39 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  linux/mds/mds_extN.c
- *
+ *  lustre/mds/mds_extN.c
  *  Lustre Metadata Server (mds) journal abstraction routines
  *
- *  Copyright (C) 2002  Cluster File Systems, Inc.
- *  author: Andreas Dilger <adilger@clusterfs.com>
+ *  Copyright (c) 2002 Cluster File Systems, Inc.
+ *   Author: Andreas Dilger <adilger@clusterfs.com>
+ *
+ *   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.
  *
- *  This code is issued under the GNU General Public License.
- *  See the file COPYING in this distribution
+ *   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.
  */
 
 #define DEBUG_SUBSYSTEM S_MDS
 
 #include <linux/fs.h>
 #include <linux/jbd.h>
+#include <linux/slab.h>
 #include <linux/extN_fs.h>
 #include <linux/extN_jbd.h>
 #include <linux/extN_xattr.h>
+#include <linux/kp30.h>
 #include <linux/lustre_mds.h>
+#include <linux/obd.h>
 #include <linux/module.h>
 #include <linux/obd_lov.h>
 
@@ -37,7 +50,7 @@ struct mds_cb_data {
 #define EXTN_XATTR_INDEX_LUSTRE         5
 #define XATTR_LUSTRE_MDS_OBJID          "system.lustre_mds_objid"
 
-#define XATTR_MDS_MO_MAGIC              0x4711
+#define XATTR_MDS_MO_MAGIC              0xEA0BD047
 
 /*
  * We don't currently need any additional blocks for rmdir and
@@ -86,6 +99,7 @@ static int mds_extN_commit(struct inode *inode, void *handle)
         return journal_stop((handle_t *)handle);
 }
 
+/* Assumes BKL is held */
 static int mds_extN_setattr(struct dentry *dentry, void *handle,
                             struct iattr *iattr)
 {
@@ -98,23 +112,23 @@ static int mds_extN_setattr(struct dentry *dentry, void *handle,
 }
 
 static int mds_extN_set_md(struct inode *inode, void *handle,
-                           struct lov_stripe_md *md)
+                           struct lov_mds_md *md)
 {
         int rc;
 
-        lock_kernel();
         down(&inode->i_sem);
+        lock_kernel();
         if (md == NULL)
                 rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
                                     XATTR_LUSTRE_MDS_OBJID, NULL, 0, 0);
-        else { 
+        else {
                 md->lmd_magic = cpu_to_le32(XATTR_MDS_MO_MAGIC);
                 rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE,
-                                    XATTR_LUSTRE_MDS_OBJID, md, 
+                                    XATTR_LUSTRE_MDS_OBJID, md,
                                     md->lmd_easize, XATTR_CREATE);
         }
-        up(&inode->i_sem);
         unlock_kernel();
+        up(&inode->i_sem);
 
         if (rc) {
                 CERROR("error adding objectid %Ld to inode %ld: %d\n",
@@ -124,24 +138,27 @@ static int mds_extN_set_md(struct inode *inode, void *handle,
         return rc;
 }
 
-static int mds_extN_get_md(struct inode *inode, struct lov_stripe_md *md)
+static int mds_extN_get_md(struct inode *inode, struct lov_mds_md *md)
 {
         int rc;
         int size = md->lmd_easize;
 
-        lock_kernel();
         down(&inode->i_sem);
+        lock_kernel();
         rc = extN_xattr_get(inode, EXTN_XATTR_INDEX_LUSTRE,
                             XATTR_LUSTRE_MDS_OBJID, md, size);
-
-        up(&inode->i_sem);
         unlock_kernel();
+        up(&inode->i_sem);
 
         if (rc < 0) {
                 CDEBUG(D_INFO, "error getting EA %s from MDS inode %ld: "
                        "rc = %d\n", XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc);
-                memset(md, 0, size); 
-        } else if (md->lmd_magic != cpu_to_le32(XATTR_MDS_MO_MAGIC)) {
+                memset(md, 0, size);
+                return rc;
+        } else if (md == NULL)
+                return rc;
+
+        if (md->lmd_magic != cpu_to_le32(XATTR_MDS_MO_MAGIC)) {
                 CERROR("MDS striping md for ino %ld has bad magic\n",
                        inode->i_ino);
                 rc = -EINVAL;
@@ -216,13 +233,6 @@ static void mds_extN_callback_status(void *jcb, int error)
         --jcb_cache_count;
 }
 
-#ifdef HAVE_JOURNAL_CALLBACK
-static void mds_extN_callback_func(void *cb_data)
-{
-        mds_extN_callback_status(cb_data, 0);
-}
-#endif
-
 static int mds_extN_set_last_rcvd(struct mds_obd *mds, void *handle)
 {
         struct mds_cb_data *mcb;
@@ -240,12 +250,6 @@ static int mds_extN_set_last_rcvd(struct mds_obd *mds, void *handle)
                (unsigned long long)mcb->cb_last_rcvd);
         journal_callback_set(handle, mds_extN_callback_status,
                              (void *)mcb);
-#elif defined(HAVE_JOURNAL_CALLBACK)
-        /* XXX original patch version - remove soon */
-#warning "using old journal callback kernel patch, please update"
-        CDEBUG(D_EXT2, "set callback for last_rcvd: %Ld\n",
-               (unsigned long long)mcb->cb_last_rcvd);
-        journal_callback_set(handle, mds_extN_callback_func, mcb);
 #else
 #warning "no journal callback kernel patch, faking it..."
         {