Whamcloud - gitweb
Move mds_null.c back to mds_ext2.c - we have more than just the journaling
authoradilger <adilger>
Thu, 28 Mar 2002 00:00:17 +0000 (00:00 +0000)
committeradilger <adilger>
Thu, 28 Mar 2002 00:00:17 +0000 (00:00 +0000)
methods now (setattr, set_objid, get_objid, readpage), which extracts all
of the filesystem-specific hacks out of MDS.  We now have files with a very
high-density hacks for ext2 and ext3, but at least we can clean it up easily.

lustre/mds/mds_ext2.c [new file with mode: 0644]
lustre/mds/mds_null.c [deleted file]

diff --git a/lustre/mds/mds_ext2.c b/lustre/mds/mds_ext2.c
new file mode 100644 (file)
index 0000000..4649322
--- /dev/null
@@ -0,0 +1,86 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  linux/mds/mds_null.c
+ *
+ *  Lustre Metadata Server (mds) journal abstraction routines
+ *
+ *  Copyright (C) 2002  Cluster File Systems, Inc.
+ *  author: Andreas Dilger <adilger@clusterfs.com>
+ *
+ *  This code is issued under the GNU General Public License.
+ *  See the file COPYING in this distribution
+ *
+ */
+
+#define DEBUG_SUBSYSTEM S_MDS
+
+#include <linux/fs.h>
+#include <linux/ext2_fs.h>
+#include <linux/lustre_mds.h>
+
+static void *mds_ext2_start(struct inode *inode, int nblocks)
+{
+        return 0;
+}
+
+static int mds_ext2_stop(struct inode *inode, void *handle)
+{
+        return 0;
+}
+
+static int mds_ext2_setattr(struct inode *inode, void *handle,
+                            struct iattr *iattr)
+{
+        /* a _really_ horrible hack to avoid removing the data stored
+           in the block pointers; this data is the object id
+           this will go into an extended attribute at some point.
+        */
+        if (iattr->ia_valid & ATTR_SIZE ) {
+                /* ATTR_SIZE would invoke truncate: clear it */
+                iattr->ia_valid &= ~ATTR_SIZE;
+                inode->i_size = iattr->ia_size;
+
+                /* make sure _something_ gets set - so new inode
+                   goes to disk (probably won't work over XFS */
+                if (!iattr->ia_valid & ATTR_MODE) {
+                        iattr->ia_valid |= ATTR_MODE;
+                        iattr->ia_mode = inode->i_mode;
+                }
+        }
+
+        return 0;
+}
+
+/*
+ * FIXME: nasty hack - store the object id in the first two
+ *        direct block spots.  This should be done with EAs...
+ */
+static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id)
+{
+        memcpy(inode->u.ext2_i.i_data, &id, sizeof(id));
+        return 0;
+}
+
+static void mds_ext2_get_objid(struct inode *inode, obd_id *id)
+{
+        memcpy(id, &inode->u.ext2_i.i_data, sizeof(*id));
+}
+
+static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count,
+                                 loff_t *offset)
+{
+        if (S_ISREG(file->f_dentry->d_inode->i_mode))
+                return file->f_op->read(file, buf, count, offset);
+        else
+                return generic_file_read(file, buf, count, offset);
+}
+
+struct mds_fs_operations mds_ext2_fs_ops = {
+        fs_start:       mds_ext2_start,
+        fs_commit:      mds_ext2_stop,
+        fs_setattr:     mds_ext2_setattr,
+        fs_set_objid:   mds_ext2_set_objid,
+        fs_get_objid:   mds_ext2_get_objid,
+        fs_readpage:    mds_ext2_readpage,
+};
diff --git a/lustre/mds/mds_null.c b/lustre/mds/mds_null.c
deleted file mode 100644 (file)
index b65605d..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  linux/mds/mds_null.c
- *
- *  Lustre Metadata Server (mds) journal abstraction routines
- *
- *  Copyright (C) 2002  Cluster File Systems, Inc.
- *  author: Andreas Dilger <adilger@clusterfs.com>
- *
- *  This code is issued under the GNU General Public License.
- *  See the file COPYING in this distribution
- *
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/fs.h>
-#include <linux/lustre_mds.h>
-
-static void *mds_null_start(struct inode *inode, int nblocks)
-{
-        return 0;
-}
-
-static int mds_null_stop(void *handle, struct inode *inode)
-{
-        return 0;
-}
-
-struct mds_journal_operations mds_null_journal_ops = {
-        tr_start:       mds_null_start,
-        tr_commit:      mds_null_stop,
-};