[Ocfs2-commits] jlbec commits r1747 - branches/kabi/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jan 7 00:00:42 CST 2005


Author: jlbec
Date: 2005-01-07 00:00:41 -0600 (Fri, 07 Jan 2005)
New Revision: 1747

Added:
   branches/kabi/cluster/o2cbmapfs.c
Modified:
   branches/kabi/cluster/Makefile
Log:

o Start o2cbmapfs.



Modified: branches/kabi/cluster/Makefile
===================================================================
--- branches/kabi/cluster/Makefile	2005-01-07 00:57:19 UTC (rev 1746)
+++ branches/kabi/cluster/Makefile	2005-01-07 06:00:41 UTC (rev 1747)
@@ -43,7 +43,8 @@
 	nodemanager.c	\
 	tcp.c		\
 	util.c		\
-	test.c			
+	test.c		\
+	o2cbmapfs.c
 
 HFILES = 			\
 	compat_libfs.h		\
@@ -58,7 +59,8 @@
 	o2cb_kabi.h		\
 	ocfs2_nodemanager.h	\
 	ocfs2_heartbeat.h	\
-	ocfs2_tcp.h
+	ocfs2_tcp.h		\
+	o2cbmap.h
 
 CLEAN_RULES = clean-cluster
 
@@ -130,7 +132,7 @@
 
 CFLAGS += $(OPTIMIZE)
 
-MODULES = ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
+MODULES = ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o o2cbmapfs.o
 TEST_MODULES = ocfs2_cluster_test.o
 
 INSTALL_MODULES = $(MODULES)
@@ -168,7 +170,7 @@
 #	This will cause the kernel make system to call back into our makefile
 #	(2nd way).
 
-INSTALL_MODULES = ocfs2_dlm.ko ocfs2_heartbeat.ko ocfs2_nodemanager.ko ocfs2_tcp.ko
+INSTALL_MODULES = ocfs2_dlm.ko ocfs2_heartbeat.ko ocfs2_nodemanager.ko ocfs2_tcp.ko o2cbmapfs.ko
 
 #ALL_RULES = stamp-md5 build-cluster
 ALL_RULES = build-cluster
@@ -218,7 +220,7 @@
 CFLAGS_$(VERSION_OBJ) += $(VERDEFS)
 
 # Kernel Module file to produce
-obj-m += ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
+obj-m += ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o o2cbmapfs.o
 
 # list of object files that are used to create our module
 ocfs2_cluster_test-objs := test.o util.o compat_libfs.o

Added: branches/kabi/cluster/o2cbmapfs.c
===================================================================
--- branches/kabi/cluster/o2cbmapfs.c	2005-01-07 00:57:19 UTC (rev 1746)
+++ branches/kabi/cluster/o2cbmapfs.c	2005-01-07 06:00:41 UTC (rev 1747)
@@ -0,0 +1,204 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * NAME
+ *	o2cbmapfs.c - A pseudo-filesystem for mapping cluster objects.
+ *
+ * AUTHOR
+ * 	Joel Becker <joel.becker at oracle.com>
+ *
+ * Copyright (c) 2004 Oracle Corporation.  All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License, version 2 as published by the Free Software Foundation.
+ * 
+ * This library 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 recieved a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#include <linux/version.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/mount.h>
+#include <linux/pagemap.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <asm/uaccess.h>
+
+#define O2CBMAP_NAME	"o2cbmapfs"
+#define O2CBMAP_MAGIC	0x115702CB
+
+static struct super_operations o2cbmap_ops;
+
+static kmem_cache_t *o2cbmap_inode_cachep;
+
+
+struct o2cbmap_inode_info {
+	spinlock_t	i_lock;
+	struct inode	vfs_inode;
+};
+
+static inline struct o2cbmap_inode_info *O2CBMAP_I(struct inode *inode)
+{
+	return container_of(inode, struct o2cbmap_inode_info, vfs_inode);
+}
+
+
+static struct inode *o2cbmap_alloc_inode(struct super_block *sb)
+{
+	struct o2cbmap_inode_info *oi = kmem_cache_alloc(o2cbmap_inode_cachep, SLAB_KERNEL);
+	if (!oi)
+		return NULL;
+	return &oi->vfs_inode;
+}
+
+static void o2cbmap_destroy_inode(struct inode *inode)
+{
+	struct o2cbmap_inode_info *oi = O2CBMAP_I(inode);
+
+	kmem_cache_free(o2cbmap_inode_cachep, oi);
+}
+
+static void o2cbmap_clear_inode(struct inode *inode)
+{
+	struct o2cbmap_inode_info *oi = O2CBMAP_I(inode);
+}
+
+static void init_o2cbmap_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+{
+	struct o2cbmap_inode_info *oi = foo;
+
+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+	    SLAB_CTOR_CONSTRUCTOR)
+	{
+		memset(oi, 0, sizeof(struct o2cbmap_inode_info));
+		inode_init_once(&oi->vfs_inode);
+	}
+}
+
+static struct super_operations o2cbmap_ops = {
+	.statfs		= simple_statfs,
+	.alloc_inode	= o2cbmap_alloc_inode,
+	.destroy_inode	= o2cbmap_destroy_inode,
+	.clear_inode	= o2cbmap_clear_inode,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+	.put_inode	= force_delete,
+#else
+	.drop_inode	= generic_delete_inode,
+#endif
+};
+
+static int o2cbmap_fill_super(struct super_block *sb, void *data, int silent)
+{
+	struct inode *inode;
+	struct dentry *root, *dentry;
+	struct qstr name;
+
+	sb->s_blocksize = PAGE_CACHE_SIZE;
+	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+	sb->s_magic = O2CBMAP_MAGIC;
+	sb->s_op = &o2cbmap_ops;
+	sb->s_maxbytes = MAX_NON_LFS;
+
+	if (*((char *)data)) {
+		printk(O2CBMAP_NAME ": Options not supported: \"%s\"\n",
+		       (char *)data);
+	}
+
+	inode = new_inode(sb);
+	if (!inode)
+		return -ENOMEM;
+
+	inode->i_ino = (unsigned long)inode;
+	inode->i_mode = S_IFDIR | 0755;
+	inode->i_uid = inode->i_gid = 0;
+	inode->i_blksize = PAGE_CACHE_SIZE;
+	inode->i_blocks = 0;
+	inode->i_rdev = 0;
+	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+	inode->i_op = &simple_dir_inode_operations;
+	inode->i_fop = &simple_dir_operations;
+	inode->i_nlink++;  /* Directory inode */
+
+	root = d_alloc_root(inode);
+	if (!root) {
+		iput(inode);
+		return -ENOMEM;
+	}
+
+	sb->s_root = root;
+
+	printk(O2CBMAP_NAME ": Mounted\n");
+
+	return 0;
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+static struct super_block *o2cbmap_read_super(struct super_block *sb,
+					      void *data,
+					      int silent)
+{
+	return (o2cbmap_fill_super(sb, data, silent) < 0) ? NULL : sb;
+}
+
+static DECLARE_FSTYPE(o2cbmap_fs_type, O2CBMAP_NAME, o2cbmap_read_super, FS_SINGLE|FS_LITTER);
+#else
+static struct super_block *o2cbmap_get_sb(struct file_system_type *fs_type,
+					  int flags,
+					  const char *dev_name,
+					  void *data)
+{
+	return get_sb_single(fs_type, flags, data, o2cbmap_fill_super);
+}
+
+static struct file_system_type o2cbmap_fs_type = {
+	.owner		= THIS_MODULE,
+	.name		= O2CBMAP_NAME,
+	.get_sb		= o2cbmap_get_sb,
+	.kill_sb	= kill_litter_super,
+};
+#endif
+
+static int __init init_o2cbmap(void)
+{
+	int ret;
+
+	o2cbmap_inode_cachep = kmem_cache_create("o2cbmap_inode_cache",
+						 sizeof(struct o2cbmap_inode_info),
+						 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+						 init_o2cbmap_inode_once,
+						 NULL);
+	if (!o2cbmap_inode_cachep) {
+		printk(O2CBMAP_NAME ": Unable to allocate inode cache\n");
+		return -ENOMEM;
+	}
+
+	ret = register_filesystem(&o2cbmap_fs_type);
+	if (ret) {
+		printk(O2CBMAP_NAME ": Unable to register filesystem\n");
+		kmem_cache_destroy(o2cbmap_inode_cachep);
+	}
+
+	return ret;
+}
+
+static void __exit exit_o2cbmap(void)
+{
+	unregister_filesystem(&o2cbmap_fs_type);
+}
+
+module_init(init_o2cbmap);
+module_exit(exit_o2cbmap);
+MODULE_LICENSE("GPL");
+MODULE_VERSION("0.0.1");
+MODULE_AUTHOR("Joel Becker <joel.becker at oracle.com>");
+MODULE_DESCRIPTION("Simple RAM filesystem to store a cluster layout in a way both kernel and userspace can access.");



More information about the Ocfs2-commits mailing list