[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] GFS: update gfs-kernel HEAD to 2.6.20 (please review)



Hi Cluster Developers,

Attached is a patch for HEAD that allows it to compile and run on an
upstream kernel.  Currently, I'm using Linus' 2.6.20-rc7 kernel from git.
The biggest changes are to (1) ops_file.c regarding upstream changes to vfs's
aio operations, and (2) glock.c regarding upstream changes to how
workqueues work. It also contains a couple little cleanups. Please review and send me comments.

Special note about the aio changes to ops_file.c:  Wendy Cheng added
some code for AIO a while back, and this patch deviates from that code
a little bit.  Namely, there was a place in function do_read_buf where the
aio path was waiting for async io to complete, and I took that out. Let me know
if you think this needs to go back in.

I'd also like to hear your opinions on if/when we should make HEAD deviate
from RHEL5 and start tracking the upstream kernel rather than the RHEL5
kernel.

Regards,

Bob Peterson
Red Hat Cluster Suite

Index: glock.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/glock.c,v
retrieving revision 1.30
diff -w -u -p -p -u -r1.30 glock.c
--- glock.c	21 Dec 2006 20:50:43 -0000	1.30
+++ glock.c	1 Feb 2007 17:18:29 -0000
@@ -38,7 +38,7 @@ struct glock_plug {
 
 struct greedy {
 	struct gfs_holder gr_gh;
-	struct work_struct gr_work;
+	struct delayed_work gr_work;
 };
 
 typedef void (*glock_examiner) (struct gfs_glock * gl);
@@ -1757,9 +1757,9 @@ gfs_glock_force_drop(struct gfs_glock *g
  */
 
 static void
-greedy_work(void *data)
+greedy_work(struct work_struct *work)
 {
-	struct greedy *gr = (struct greedy *)data;
+	struct greedy *gr = container_of(work, struct greedy, gr_work.work);
 	struct gfs_holder *gh = &gr->gr_gh;
 	struct gfs_glock *gl = gh->gh_gl;
 	struct gfs_glock_operations *glops = gl->gl_ops;
@@ -1814,7 +1814,7 @@ gfs_glock_be_greedy(struct gfs_glock *gl
 	gfs_holder_init(gl, 0, 0, gh);
 	set_bit(HIF_GREEDY, &gh->gh_iflags);
 	gh->gh_owner = NULL;
-	INIT_WORK(&gr->gr_work, greedy_work, gr);
+	INIT_DELAYED_WORK(&gr->gr_work, greedy_work);
 
 	set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags);
 	schedule_delayed_work(&gr->gr_work, time);
Index: lm.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/lm.c,v
retrieving revision 1.20
diff -w -u -p -p -u -r1.20 lm.c
--- lm.c	5 Dec 2006 22:38:34 -0000	1.20
+++ lm.c	1 Feb 2007 17:18:29 -0000
@@ -13,7 +13,6 @@
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/delay.h>
-#include <linux/lm_interface.h>
 
 #include "gfs_ondisk.h"
 #include "gfs.h"
Index: ops_file.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/ops_file.c,v
retrieving revision 1.30
diff -w -u -p -p -u -r1.30 ops_file.c
--- ops_file.c	17 Nov 2006 16:15:31 -0000	1.30
+++ ops_file.c	1 Feb 2007 17:18:29 -0000
@@ -335,10 +335,12 @@ do_read_direct(struct file *file, char *
 	}
 	else {
 		if (!iocb) 
-			count = generic_file_read(file, buf, size, offset);
+			count = do_sync_read(file, buf, size, offset);
 		else {
 		        struct iovec local_iov = { .iov_base = buf, .iov_len = size};
-			count = __generic_file_aio_read(iocb, &local_iov, 1, offset);
+
+			count = generic_file_aio_read(iocb, &local_iov, 1, *offset);
+			iocb->ki_pos = *offset;
 		}
 	}
 
@@ -387,17 +389,12 @@ do_read_buf(struct file *file, char *buf
 		count = do_read_readi(file, buf, size, offset, iocb);
 	else {
 		if (!iocb) {
-			count = generic_file_read(file, buf, size, offset);
+			count = do_sync_read(file, buf, size, offset);
 		} else {
-			struct iovec local_iov = {
-				.iov_base = (char __user *)buf,
-				.iov_len = size 
-			};
+			struct iovec local_iov = { .iov_base = buf, .iov_len = size};
 
-		        count = __generic_file_aio_read(iocb, 
-					&local_iov, 1, offset);
-			if (count == -EIOCBQUEUED)
-				count = wait_on_sync_kiocb(iocb);
+			count = generic_file_aio_read(iocb, &local_iov, 1, *offset);
+			iocb->ki_pos = *offset;
 		}
 	}
 
@@ -443,12 +440,13 @@ gfs_read(struct file *file, char *buf, s
  * 	(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
  */
 static ssize_t
-gfs_aio_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
+gfs_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long count,
+			 loff_t pos)
 {
 	struct file *filp = iocb->ki_filp;
 
 	BUG_ON(iocb->ki_pos != pos);
-	return(__gfs_read(filp, buf, count, &iocb->ki_pos, iocb));
+	return(__gfs_read(filp, iov->iov_base, iov->iov_len, &iocb->ki_pos, iocb));
 }
 
 /**
@@ -483,6 +481,41 @@ grope_mapping(char *buf, size_t size)
 }
 
 /**
+ * gfs_file_aio_write_nolock - Call vfs aio layer to write bytes to a file
+ * @file: The file to write to
+ * @buf: The buffer to copy from
+ * @size: The amount of data requested
+ * @offset: The offset in the file to write
+ * @iocb: The io control block.  If NULL, a temporary one will be used.
+ *
+ * Returns: The number of bytes written, errno on failure
+ */
+static ssize_t
+gfs_file_aio_write_nolock(struct file *file, char *buf, size_t size,
+						  loff_t *offset, struct kiocb *iocb)
+{
+	struct iovec local_iov = { .iov_base = buf, .iov_len = size };
+	struct kiocb local_iocb, *kiocb = NULL;
+	ssize_t count;
+
+	if (!iocb) {
+		init_sync_kiocb(&local_iocb, file);
+		local_iocb.ki_nr_segs = 1;
+		kiocb = &local_iocb;
+	}
+	else
+		kiocb = iocb;
+	
+	kiocb->ki_pos = *offset;
+	count = generic_file_aio_write_nolock(kiocb, &local_iov, kiocb->ki_nr_segs,
+										  kiocb->ki_pos);
+	*offset = kiocb->ki_pos;
+	if (kiocb == &local_iocb && count == -EIOCBQUEUED)
+		count = wait_on_sync_kiocb(kiocb);
+	return count;
+}
+
+/**
  * do_write_direct_alloc - Write bytes to a file
  * @file: The file to write to
  * @buf: The buffer to copy from
@@ -502,7 +535,6 @@ do_write_direct_alloc(struct file *file,
 	struct gfs_inode *ip = get_v2ip(inode);
 	struct gfs_sbd *sdp = ip->i_sbd;
 	struct gfs_alloc *al = NULL;
-	struct iovec local_iov = { .iov_base = buf, .iov_len = size };
 	struct buffer_head *dibh;
 	unsigned int data_blocks, ind_blocks;
 	ssize_t count;
@@ -553,11 +585,7 @@ do_write_direct_alloc(struct file *file,
 			goto fail_end_trans;
 	}
 
-	if (!iocb)
-		count = generic_file_write_nolock(file, &local_iov, 1, offset);
-	else {
-		count = generic_file_aio_write_nolock(iocb, &local_iov, 1, offset);
-	}
+	count = gfs_file_aio_write_nolock(file, buf, size, offset, iocb);
 	if (count < 0) {
 		error = count;
 		goto fail_end_trans;
@@ -721,7 +749,6 @@ do_write_direct(struct file *file, char 
 			count += error;
 		}
 	} else {
-		struct iovec local_iov = { .iov_base = buf, .iov_len = size };
 		struct gfs_holder t_gh;
 
 		clear_bit(GFF_DID_DIRECT_ALLOC, &fp->f_flags);
@@ -733,13 +760,7 @@ do_write_direct(struct file *file, char 
 		/* Todo: It would be nice if init_sync_kiocb is exported.
 		 *  .. wcheng
 		 */
-		if (!iocb) 
-			count = 
-			generic_file_write_nolock(file, &local_iov, 1, offset);
-		else {
-			count = 
-			generic_file_aio_write_nolock(iocb, &local_iov, 1, offset);
-		}
+		count = gfs_file_aio_write_nolock(file, buf, size, offset, iocb);
 		gfs_glock_dq_uninit(&t_gh);
 	}
 
@@ -862,16 +883,7 @@ do_do_write_buf(struct file *file, char 
 		}
 		*offset += count;
 	} else {
-		struct iovec local_iov = { .iov_base = buf, .iov_len = size };
-
-		if (!iocb) {
-			count = generic_file_write_nolock(file, &local_iov, 1, offset);
-		} else {
-			count = generic_file_aio_write_nolock(iocb, 
-				&local_iov, 1, offset);
-			if (count == -EIOCBQUEUED)
-				count = wait_on_sync_kiocb(iocb);
-		}
+		count = gfs_file_aio_write_nolock(file, buf, size, offset, iocb);
 		if (count < 0) {
 			error = count;
 			goto fail_end_trans;
@@ -1047,13 +1059,15 @@ gfs_write(struct file *file, const char 
 }
 
 static ssize_t
-gfs_aio_write(struct kiocb *iocb, const char __user *buf, size_t size, loff_t pos)
+gfs_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long segs,
+			  loff_t pos)
 {
 	struct file *file = iocb->ki_filp;
 
 	BUG_ON(iocb->ki_pos != pos);
 
-	return(__gfs_write(file, buf, size, &iocb->ki_pos, iocb));
+	return(__gfs_write(file, iov->iov_base, iov->iov_len, &iocb->ki_pos, 
+					   iocb));
 }
 
 /**
Index: ops_inode.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/ops_inode.c,v
retrieving revision 1.15
diff -w -u -p -p -u -r1.15 ops_inode.c
--- ops_inode.c	23 Oct 2006 20:47:23 -0000	1.15
+++ ops_inode.c	1 Feb 2007 17:18:30 -0000
@@ -190,17 +190,17 @@ lookup_cdpn_sub_at(struct gfs_sbd *sdp, 
 	parent = dget_parent(dentry);
 
 	if (gfs_filecmp(&dentry->d_name, "@hostname", 9))
-		new = lookup_one_len(system_utsname.nodename,
+		new = lookup_one_len(init_utsname()->nodename,
 				     parent,
-				     strlen(system_utsname.nodename));
+				     strlen(init_utsname()->nodename));
 	else if (gfs_filecmp(&dentry->d_name, "@mach", 5))
-		new = lookup_one_len(system_utsname.machine,
+		new = lookup_one_len(init_utsname()->machine,
 				     parent,
-				     strlen(system_utsname.machine));
+				     strlen(init_utsname()->machine));
 	else if (gfs_filecmp(&dentry->d_name, "@os", 3))
-		new = lookup_one_len(system_utsname.sysname,
+		new = lookup_one_len(init_utsname()->sysname,
 				     parent,
-				     strlen(system_utsname.sysname));
+				     strlen(init_utsname()->sysname));
 	else if (gfs_filecmp(&dentry->d_name, "@uid", 4))
 		new = lookup_one_len(buf,
 				     parent,
@@ -213,8 +213,8 @@ lookup_cdpn_sub_at(struct gfs_sbd *sdp, 
 		new = lookup_one_len(buf,
 				     parent,
 				     sprintf(buf, "%s_%s",
-					     system_utsname.machine,
-					     system_utsname.sysname));
+					     init_utsname()->machine,
+					     init_utsname()->sysname));
 	else if (gfs_filecmp(&dentry->d_name, "@jid", 4))
 		new = lookup_one_len(buf,
 				     parent,
@@ -249,17 +249,17 @@ lookup_cdpn_sub_brace(struct gfs_sbd *sd
 	parent = dget_parent(dentry);
 
 	if (gfs_filecmp(&dentry->d_name, "{hostname}", 10))
-		new = lookup_one_len(system_utsname.nodename,
+		new = lookup_one_len(init_utsname()->nodename,
 				     parent,
-				     strlen(system_utsname.nodename));
+				     strlen(init_utsname()->nodename));
 	else if (gfs_filecmp(&dentry->d_name, "{mach}", 6))
-		new = lookup_one_len(system_utsname.machine,
+		new = lookup_one_len(init_utsname()->machine,
 				     parent,
-				     strlen(system_utsname.machine));
+				     strlen(init_utsname()->machine));
 	else if (gfs_filecmp(&dentry->d_name, "{os}", 4))
-		new = lookup_one_len(system_utsname.sysname,
+		new = lookup_one_len(init_utsname()->sysname,
 				     parent,
-				     strlen(system_utsname.sysname));
+				     strlen(init_utsname()->sysname));
 	else if (gfs_filecmp(&dentry->d_name, "{uid}", 5))
 		new = lookup_one_len(buf,
 				     parent,
@@ -272,8 +272,8 @@ lookup_cdpn_sub_brace(struct gfs_sbd *sd
 		new = lookup_one_len(buf,
 				     parent,
 				     sprintf(buf, "%s_%s",
-					     system_utsname.machine,
-					     system_utsname.sysname));
+					     init_utsname()->machine,
+					     init_utsname()->sysname));
 	else if (gfs_filecmp(&dentry->d_name, "{jid}", 5))
 		new = lookup_one_len(buf,
 				     parent,
Index: recovery.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/recovery.c,v
retrieving revision 1.10
diff -w -u -p -p -u -r1.10 recovery.c
--- recovery.c	10 Nov 2006 22:17:38 -0000	1.10
+++ recovery.c	1 Feb 2007 17:18:30 -0000
@@ -551,7 +551,7 @@ clean_journal(struct gfs_sbd *sdp, struc
 }
 
 /**
- * gfs_recover_journal - recovery a given journal
+ * gfs_recover_journal - recover a given journal
  * @sdp: the filesystem
  * @jid: the number of the journal to recover
  * @jdesc: the struct gfs_jindex describing the journal
@@ -576,7 +576,7 @@ gfs_recover_journal(struct gfs_sbd *sdp,
 	printk("GFS: fsid=%s: jid=%u: Trying to acquire journal lock...\n",
 	       sdp->sd_fsname, jid);
 
-	/*  Aquire the journal lock so we can do recovery  */
+	/*  Acquire the journal lock so we can do recovery  */
 
 	error = gfs_glock_nq_num(sdp,
 				 jdesc->ji_addr, &gfs_meta_glops,
Index: rgrp.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/rgrp.c,v
retrieving revision 1.19
diff -w -u -p -p -u -r1.19 rgrp.c
--- rgrp.c	10 Jul 2006 23:22:34 -0000	1.19
+++ rgrp.c	1 Feb 2007 17:18:30 -0000
@@ -666,6 +666,7 @@ compute_bitstructs(struct gfs_rgrpd *rgd
 	rgd->rd_bh = kmalloc(length * sizeof(struct buffer_head *), GFP_KERNEL);
 	if (!rgd->rd_bh) {
 		kfree(rgd->rd_bits);
+		rgd->rd_bits = NULL;
 		return -ENOMEM;
 	}
 	memset(rgd->rd_bh, 0, length * sizeof(struct buffer_head *));
Index: util.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/util.c,v
retrieving revision 1.13
diff -w -u -p -p -u -r1.13 util.c
--- util.c	10 Jul 2006 23:22:34 -0000	1.13
+++ util.c	1 Feb 2007 17:18:30 -0000
@@ -26,10 +26,10 @@
 
 uint32_t gfs_random_number;
 
-kmem_cache_t *gfs_glock_cachep = NULL;
-kmem_cache_t *gfs_inode_cachep = NULL;
-kmem_cache_t *gfs_bufdata_cachep = NULL;
-kmem_cache_t *gfs_mhc_cachep = NULL;
+struct kmem_cache *gfs_glock_cachep = NULL;
+struct kmem_cache *gfs_inode_cachep = NULL;
+struct kmem_cache *gfs_bufdata_cachep = NULL;
+struct kmem_cache *gfs_mhc_cachep = NULL;
 
 /**
  * gfs_random - Generate a random 32-bit number
Index: util.h
===================================================================
RCS file: /cvs/cluster/cluster/gfs-kernel/src/gfs/util.h,v
retrieving revision 1.10
diff -w -u -p -p -u -r1.10 util.h
--- util.h	10 Jul 2006 23:22:34 -0000	1.10
+++ util.h	1 Feb 2007 17:18:30 -0000
@@ -311,10 +311,10 @@ for (;;) { \
 	yield(); \
 }
 
-extern kmem_cache_t *gfs_glock_cachep;
-extern kmem_cache_t *gfs_inode_cachep;
-extern kmem_cache_t *gfs_bufdata_cachep;
-extern kmem_cache_t *gfs_mhc_cachep;
+extern struct kmem_cache *gfs_glock_cachep;
+extern struct kmem_cache *gfs_inode_cachep;
+extern struct kmem_cache *gfs_bufdata_cachep;
+extern struct kmem_cache *gfs_mhc_cachep;
 
 void *gmalloc(unsigned int size);
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]