[Ocfs2-commits] jlbec commits r1817 - trunk/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Jan 20 19:29:10 CST 2005


Author: jlbec
Date: 2005-01-20 19:29:08 -0600 (Thu, 20 Jan 2005)
New Revision: 1817

Added:
   trunk/fs/ocfs2/cluster/transaction_file.c
   trunk/fs/ocfs2/cluster/transaction_file.h
Modified:
   trunk/fs/ocfs2/cluster/Makefile
   trunk/fs/ocfs2/cluster/compat_libfs.c
   trunk/fs/ocfs2/cluster/compat_libfs.h
   trunk/fs/ocfs2/cluster/heartbeat.c
   trunk/fs/ocfs2/cluster/nodemanager.c
Log:

o Get compat_libfs to really be compat bits.  Preparatory to
  step 7.

o Create transaction_file.[ch] to contain the transaction_file stuff.
o Modify users of the transaction file stuff to use the appropriate
  changes.
o Fixup the makefiles.



Modified: trunk/fs/ocfs2/cluster/Makefile
===================================================================
--- trunk/fs/ocfs2/cluster/Makefile	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/Makefile	2005-01-21 01:29:08 UTC (rev 1817)
@@ -28,8 +28,6 @@
 endif
 endif
 
-# Ugh, for now
-COMPAT_LIBFS := compat_libfs.o
 
 obj-m := ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
 
@@ -37,9 +35,9 @@
 	dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o \
 	$(COMPAT_LIBFS)
 
-ocfs2_nodemanager-objs := nodemanager.o util.o $(COMPAT_LIBFS)
+ocfs2_nodemanager-objs := nodemanager.o util.o transaction_file.o $(COMPAT_LIBFS)
 
-ocfs2_heartbeat-objs := heartbeat.o util.o $(COMPAT_LIBFS)
+ocfs2_heartbeat-objs := heartbeat.o util.o transaction_file.o $(COMPAT_LIBFS)
 
 ocfs2_tcp-objs := tcp.o util.o $(COMPAT_LIBFS)
 
@@ -62,6 +60,7 @@
 	heartbeat.c	\
 	nodemanager.c	\
 	tcp.c		\
+	transaction_file.c	\
 	util.c
 
 HEADERS = 		\
@@ -72,6 +71,7 @@
 	heartbeat.h	\
 	nodemanager.h	\
 	tcp.h		\
+	transaction_file.h	\
 	util.h		\
 	warning_hack.h
 

Modified: trunk/fs/ocfs2/cluster/compat_libfs.c
===================================================================
--- trunk/fs/ocfs2/cluster/compat_libfs.c	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/compat_libfs.c	2005-01-21 01:29:08 UTC (rev 1817)
@@ -3,8 +3,7 @@
 
 /*
  *	compat_libfs.c
- *	Library for filesystems writers.
- *	PLUS... transaction file stuff stolen from nfsd
+ *	2.4 compat Library for filesystems writers.
  */
 
 #include "warning_hack.h"
@@ -18,20 +17,10 @@
 
 #include "compat_libfs.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-#define kstatfs statfs
-#endif
 
-#define __user
+int simple_statfs(struct super_block *sb, struct statfs *buf);
 
-
-int simple_statfs(struct super_block *sb, struct kstatfs *buf);
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd);
-#else
 struct dentry *simple_lookup(struct inode *dir,struct dentry *dentry);
-#endif
 
 int simple_sync_file(struct file *file, struct dentry *dentry, int datasync);
 int dcache_dir_open(struct inode *inode, struct file *file);
@@ -58,7 +47,7 @@
 }
 #endif
 
-int simple_statfs(struct super_block *sb, struct kstatfs *buf)
+int simple_statfs(struct super_block *sb, struct statfs *buf)
 {
 	buf->f_type = sb->s_magic;
 	buf->f_bsize = PAGE_CACHE_SIZE;
@@ -70,15 +59,6 @@
  * Lookup the data. This is trivial - if the dentry didn't already
  * exist, we know it is negative.
  */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
-{
-	if (dentry->d_name.len > NAME_MAX)
-		return ERR_PTR(-ENAMETOOLONG);
-	d_add(dentry, NULL);
-	return NULL;
-}
-#else
 struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry)
 {
 	if (dentry->d_name.len > NAME_MAX)
@@ -86,7 +66,6 @@
 	d_add(dentry, NULL);
 	return NULL;
 }
-#endif
 
 
 struct dentry * simple_find_child(struct dentry *dentry, struct qstr *name)
@@ -230,7 +209,7 @@
 	return 0;
 }
 
-ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
+ssize_t generic_read_dir(struct file *filp, char *buf, size_t siz, loff_t *ppos)
 {
 	return -EISDIR;
 }
@@ -599,110 +578,3 @@
 
 /* -----------------------------------------------------------------*/
 
-
-
-/* transaction file support */
-
-/*
- * transaction based IO methods.
- * The file expects a single write which triggers the transaction, and then
- * possibly a read which collects the result - which is stored in a 
- * file-local buffer.
- */
-static ssize_t TA_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
-{
-	ino_t ino =  file->f_dentry->d_inode->i_ino;
-	struct argresp *ar;
-	ssize_t rv = 0;
-	struct super_block *sb = file->f_dentry->d_inode->i_sb;
-	TA_write_ops *ops = TA_GENERIC_SB_MEMBER(sb);
-	TA_write_op *write_op;
-
-	printk("welcome to TA_write: num_ops=%d, op[%d]=%p, private=%p, size=%lld\n", 
-	       ops->num_ops, (int)ino, ops->write_op[ino], file->private_data, (long long)size);
-	if (ino >= ops->num_ops || ops->write_op[ino] == NULL)
-		return -EINVAL;
-	write_op = ops->write_op[ino];
-	if (file->private_data) 
-		return -EINVAL; /* only one write allowed per open */
-	if (size > PAGE_SIZE - sizeof(struct argresp))
-		return -EFBIG;
-
-	ar = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	if (!ar)
-		return -ENOMEM;
-	ar->size = 0;
-	down(&file->f_dentry->d_inode->i_sem);
-	if (file->private_data)
-		rv = -EINVAL;
-	else
-		file->private_data = ar;
-	up(&file->f_dentry->d_inode->i_sem);
-	if (rv) {
-		kfree(ar);
-		return rv;
-	}
-	if (copy_from_user(ar->data, buf, size))
-		return -EFAULT;
-
-	printk("now calling write_op...\n");	
-	rv = write_op(file, ar->data, size);
-	printk("write_op returned %lld\n", (long long)rv);
-	if (rv>0) {
-		ar->size = rv;
-		rv = size;
-	}
-	return rv;
-}
-
-
-static ssize_t TA_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
-{
-	struct argresp *ar;
-	ssize_t rv = 0;
-	
-	if (file->private_data == NULL)
-		rv = TA_write(file, buf, 0, pos);
-	if (rv < 0)
-		return rv;
-
-	ar = file->private_data;
-	if (!ar)
-		return 0;
-	if (*pos >= ar->size)
-		return 0;
-	if (*pos + size > ar->size)
-		size = ar->size - *pos;
-	if (copy_to_user(buf, ar->data + *pos, size))
-		return -EFAULT;
-	*pos += size;
-	return size;
-}
-
-static int TA_open(struct inode *inode, struct file *file)
-{
-	file->private_data = NULL;
-	return 0;
-}
-
-static int TA_release(struct inode *inode, struct file *file)
-{
-	void *p = file->private_data;
-	file->private_data = NULL;
-	kfree(p);
-	return 0;
-}
-
-
-
-
-
-
-
-
-struct file_operations transaction_ops = {
-	.write		= TA_write,
-	.read		= TA_read,
-	.open		= TA_open,
-	.release	= TA_release,
-};

Modified: trunk/fs/ocfs2/cluster/compat_libfs.h
===================================================================
--- trunk/fs/ocfs2/cluster/compat_libfs.h	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/compat_libfs.h	2005-01-21 01:29:08 UTC (rev 1817)
@@ -3,28 +3,6 @@
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define TA_GENERIC_SB_MEMBER(sb)  ((sb)->s_fs_info)
-#else
-#define TA_GENERIC_SB_MEMBER(sb)  ((sb)->u.generic_sbp)
-#endif
-
-
-/* an argresp is stored in an allocated page and holds the 
- * size of the argument or response, along with its content
- */
-struct argresp {
-	ssize_t size;
-	char data[0];
-};
-
-typedef ssize_t (TA_write_op)(struct file *, char *, size_t);
-typedef struct _TA_write_ops
-{
-	int num_ops;
-	TA_write_op *write_op[0];
-} TA_write_ops;
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 struct tree_descr 
 { 

Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-01-21 01:29:08 UTC (rev 1817)
@@ -73,6 +73,7 @@
 #include "nodemanager.h"
 
 #include "compat_libfs.h"
+#include "transaction_file.h"
 
 #ifndef __user
 #define __user
@@ -591,18 +592,18 @@
 static int hb_fill_super(struct super_block * sb, void * data, int silent)
 {
 	int ret;
-	TA_write_ops *ops;
+	struct TA_write_ops *ops;
 	static struct tree_descr hb_files[] = {
 		[HB_Disk] = {".disk", &transaction_ops, S_IWUSR},
 		/* last one */ {""}
 	};
 	
-	ops = kmalloc(sizeof(TA_write_ops) + (1 * sizeof(TA_write_op *)), 
+	ops = kmalloc(sizeof(struct TA_write_ops) +
+		      (sizeof(ops->write_op[0])), 
 		      GFP_KERNEL);
 	if (!ops)
 		return -ENOMEM;
 
-	memset(ops, 0, sizeof(TA_write_ops) + (1 * sizeof(TA_write_op *)));
 	ops->num_ops = HB_WriteOpArraySize;
 	ops->write_op[HB_Disk] = write_disk;
 

Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/nodemanager.c	2005-01-21 01:29:08 UTC (rev 1817)
@@ -74,6 +74,7 @@
 #include "heartbeat.h"
 
 #include "compat_libfs.h"
+#include "transaction_file.h"
 
 #ifndef __user
 #define __user
@@ -169,7 +170,6 @@
 /* support for adding files, dirs, hardlinks in /proc/cluster/nm/... */
 extern struct file_operations simple_dir_operations;
 extern struct inode_operations simple_dir_inode_operations;
-extern struct file_operations transaction_ops;
 
 static inline int nm_find_next_slot(void *bitmap, int max, int request);
 static struct dentry * nm_add_file(struct super_block *s, struct dentry *parent, struct tree_descr *file, int ino);
@@ -1279,7 +1279,7 @@
 static int nm_fill_super(struct super_block * sb, void * data, int silent)
 {
 	int ret, sz;
-	TA_write_ops *ops;
+	struct TA_write_ops *ops;
 	static struct tree_descr nm_files[] = {
 		[NM_Cluster] = {".cluster", &transaction_ops, S_IWUSR},
 		[NM_Node] = {".node", &transaction_ops, S_IWUSR},
@@ -1288,12 +1288,12 @@
 	};
 	
 	sz = sizeof(nm_files) / sizeof(struct tree_descr);
-	ops = kmalloc(sizeof(TA_write_ops) + (sz * sizeof(TA_write_op *)), 
+	ops = kmalloc(sizeof(struct TA_write_ops) +
+		      (sz * sizeof(ops->write_op[0])), 
 		      GFP_KERNEL);
 	if (!ops)
 		return -ENOMEM;
 
-	memset(ops, 0, sizeof(TA_write_ops) + (sz * sizeof(TA_write_op *)));
 	ops->num_ops = sz;
 	ops->write_op[NM_Cluster] = write_cluster;
 	ops->write_op[NM_Node] = write_node;

Added: trunk/fs/ocfs2/cluster/transaction_file.c
===================================================================
--- trunk/fs/ocfs2/cluster/transaction_file.c	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/transaction_file.c	2005-01-21 01:29:08 UTC (rev 1817)
@@ -0,0 +1,120 @@
+
+/*
+ * transaction_file.c
+ * Little library for transaction files.
+ */
+
+#include <linux/fs.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+
+#include "transaction_file.h"
+
+#ifndef __user
+#define __user
+#endif
+
+/*
+ * transaction based IO methods.
+ * The file expects a single write which triggers the transaction, and then
+ * possibly a read which collects the result - which is stored in a 
+ * file-local buffer.
+ */
+static ssize_t TA_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
+{
+	ino_t ino =  file->f_dentry->d_inode->i_ino;
+	struct argresp *ar;
+	ssize_t rv = 0;
+	struct super_block *sb = file->f_dentry->d_inode->i_sb;
+	struct TA_write_ops *ops = TA_GENERIC_SB_MEMBER(sb);
+        ssize_t (*write_op)(struct file *, char *, size_t);
+
+	printk("welcome to TA_write: num_ops=%d, op[%d]=%p, private=%p, size=%lld\n", 
+	       ops->num_ops, (int)ino, ops->write_op[ino], file->private_data, (long long)size);
+	if (ino >= ops->num_ops || ops->write_op[ino] == NULL)
+		return -EINVAL;
+	write_op = ops->write_op[ino];
+	if (file->private_data) 
+		return -EINVAL; /* only one write allowed per open */
+	if (size > PAGE_SIZE - sizeof(struct argresp))
+		return -EFBIG;
+
+	ar = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!ar)
+		return -ENOMEM;
+	ar->size = 0;
+	down(&file->f_dentry->d_inode->i_sem);
+	if (file->private_data)
+		rv = -EINVAL;
+	else
+		file->private_data = ar;
+	up(&file->f_dentry->d_inode->i_sem);
+	if (rv) {
+		kfree(ar);
+		return rv;
+	}
+	if (copy_from_user(ar->data, buf, size))
+		return -EFAULT;
+
+	printk("now calling write_op...\n");	
+	rv = write_op(file, ar->data, size);
+	printk("write_op returned %lld\n", (long long)rv);
+	if (rv>0) {
+		ar->size = rv;
+		rv = size;
+	}
+	return rv;
+}
+
+
+static ssize_t TA_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
+{
+	struct argresp *ar;
+	ssize_t rv = 0;
+	
+	if (file->private_data == NULL)
+		rv = TA_write(file, buf, 0, pos);
+	if (rv < 0)
+		return rv;
+
+	ar = file->private_data;
+	if (!ar)
+		return 0;
+	if (*pos >= ar->size)
+		return 0;
+	if (*pos + size > ar->size)
+		size = ar->size - *pos;
+	if (copy_to_user(buf, ar->data + *pos, size))
+		return -EFAULT;
+	*pos += size;
+	return size;
+}
+
+static int TA_open(struct inode *inode, struct file *file)
+{
+	file->private_data = NULL;
+	return 0;
+}
+
+static int TA_release(struct inode *inode, struct file *file)
+{
+	void *p = file->private_data;
+	file->private_data = NULL;
+	kfree(p);
+	return 0;
+}
+
+
+
+
+
+
+
+
+struct file_operations transaction_ops = {
+	.write		= TA_write,
+	.read		= TA_read,
+	.open		= TA_open,
+	.release	= TA_release,
+};

Added: trunk/fs/ocfs2/cluster/transaction_file.h
===================================================================
--- trunk/fs/ocfs2/cluster/transaction_file.h	2005-01-20 23:51:26 UTC (rev 1816)
+++ trunk/fs/ocfs2/cluster/transaction_file.h	2005-01-21 01:29:08 UTC (rev 1817)
@@ -0,0 +1,28 @@
+#ifndef _TRANSACTION_FILE_H
+#define _TRANSACTION_FILE_H
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#define TA_GENERIC_SB_MEMBER(sb)  ((sb)->s_fs_info)
+#else
+#define TA_GENERIC_SB_MEMBER(sb)  ((sb)->u.generic_sbp)
+#endif
+
+/* an argresp is stored in an allocated page and holds the
+ * size of the argument or response, along with its content
+ */
+struct argresp {
+	ssize_t size;
+	char data[0];
+};
+
+struct TA_write_ops
+{
+	int	num_ops;
+	ssize_t	(*write_op[0])(struct file *, char *, size_t);
+};
+
+extern struct file_operations transaction_ops;
+
+#endif  /* _TRANSACTION_FILE_H */



More information about the Ocfs2-commits mailing list