diff -aurN fuse-2.7.2/fuse.spec fuse-2.7.2glfs9/fuse.spec
--- fuse-2.7.2/fuse.spec	1969-12-31 16:00:00.000000000 -0800
+++ fuse-2.7.2glfs9/fuse.spec	2008-04-18 12:39:35.000000000 -0700
@@ -0,0 +1,204 @@
+# Supported rpmbuild --define and --with options include:
+#
+#   --without userland
+#	Build without the userland packages
+#	(i.e. only build the kernel-module packages).
+#
+#   --with modules
+#	Force the building of a kernel-module package,
+#	even if the kernel has support built in.
+#
+#   --without modules
+#	Disable the building of a kernel-module package.
+#
+#   --define "ksrc <srcdir>"
+#	Build with kernel header files found in <srcdir>.
+#	By default, the build script will try to find the kernel headers
+#	matching the specified kernel or, if no kernel was specified, the
+#	current kernel.
+#
+#   --define "kernel <version>"
+#	Specify kernel version to build the module for.
+#	By default, the version is derived from the kernel source files, or
+#	failing that, from "uname -r".
+               
+
+%{!?ksrc: %{expand: %%define ksrc %(cd /lib/modules/`uname -r`/build && /bin/pwd)}}
+%{!?kernel: %{expand: %%define kernel %(cat %{ksrc}/include/config/kernel.release)}}
+%define fusemodule /lib/modules/%{kernel}/kernel/fs/fuse/fuse.ko
+
+%{?_with_modules: %{?_without_modules: %{error: both _with_modules and _without_modules defined}}}
+%if 0%{?_with_modules:1}
+%define buildmodule 1
+%else
+%if 0%{?_without_modules:1}
+%define buildmodule 0
+%else
+%{expand: %%define buildmodule %({ test -f %{fusemodule} && ! fgrep -q "fuse distribution version: " %{fusemodule}; }; echo $?)}
+%endif
+%endif
+
+%if %{buildmodule}
+%{!?ksrc: %{expand: %%define ksrc %(cd /lib/modules/%{kernel}/build && /bin/pwd)}}
+%{!?_with_modules: %{?ksrc: %{expand: %%define buildmodule %(egrep -q "^#define CONFIG_FUSE_FS(_MODULE)? 1" %{ksrc}/include/linux/autoconf.h; echo $?)}}}
+%endif
+
+Name:           fuse
+Version:        2.7.2glfs9
+Release:        1
+Epoch:		2
+Summary:        File System in Userspace (FUSE) utilities
+
+Group:          System Environment/Base
+License:        GPL
+URL:            http://fuse.sourceforge.net/
+Packager:	Harshavardhana <harsha@zresearch.com>
+Source: 	http://dl.sf.net/fuse/%{name}-%{version}.tar.gz
+
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Requires:	kernel >= 2.6
+Requires(post):   /sbin/MAKEDEV
+%if %{buildmodule}
+Requires:	kernel-module-%{name} >= %{epoch}:%{version}-%{release}
+%endif
+
+%description
+With FUSE it is possible to implement a fully functional filesystem in a 
+userspace program. This package contains the FUSE userspace tools to 
+mount a FUSE filesystem.
+
+%package libs
+Summary:        File System in Userspace (FUSE) libraries
+Group:          System Environment/Libraries
+License:        LGPL
+
+%description libs
+With FUSE it is possible to implement a fully functional filesystem in a 
+userspace program. This package contains the FUSE libraries.
+
+
+%package devel
+Summary:        File System in Userspace (FUSE) devel files
+Group:          Development/Libraries
+Requires:	%{name}-libs = %{epoch}:%{version}-%{release}
+Requires: 	pkgconfig
+License:        LGPL
+
+%description devel
+With FUSE it is possible to implement a fully functional filesystem in a 
+userspace program. This package contains development files (headers, 
+pgk-config) to develop FUSE based applications/filesystems.
+
+
+%package -n kernel-module-%{name}-%{kernel}
+Summary:        File System in Userspace (FUSE) kernel module
+Group:          System Environment/Kernel
+License:        GPL
+Provides:	kernel-module-%{name} = %{epoch}:%{version}-%{release}
+Requires:	/sbin/depmod
+%if %{buildmodule} && 0%{!?ksrc:1}
+BuildRequires:	kernel-devel = %{kernel}
+%endif
+
+%description -n kernel-module-%{name}-%{kernel}
+With FUSE it is possible to implement a fully functional filesystem in a 
+userspace program. This package contains the FUSE kernel module for
+kernel %{kernel} and architecture %{_target_cpu}.
+
+
+%prep
+%setup -q
+#disable device creation during build/install
+sed -i.mknod 's|\<mknod\>|echo Disabled: mknod |g' util/Makefile.in
+#disable depmod during kernel-module build/install
+sed -i.depmod 's|\(/[a-z/]*/\)\?\<depmod\>|echo Disabled: \0 |g' kernel/Makefile.in
+
+
+%build
+%configure \
+%if 0%{?_without_userland:1}
+ --disable-lib --disable-util --disable-example \
+%endif
+ --disable-static \
+%if %{buildmodule}
+ --enable-kernel-module %{?ksrc:--with-kernel=%{ksrc}}
+%else
+ --disable-kernel-module
+%endif
+ 
+make %{?_smp_mflags}
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT
+%if 0%{!?_without_userland:1}
+find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
+# change from 4755 to 0755 to allow stripping -- fixed later in files
+chmod 0755 $RPM_BUILD_ROOT/%{_bindir}/fusermount
+%else  # without userland
+# Without removing these directories rpmbuild will stop and complain about unpackaged files.
+rm -rf "$RPM_BUILD_ROOT/%{_includedir}" "$RPM_BUILD_ROOT/%{_libdir}"
+%endif # userland
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post
+/sbin/MAKEDEV fuse
+/sbin/ldconfig -n %{_libdir}
+
+%postun 
+/sbin/ldconfig 
+
+%post -n kernel-module-%{name}-%{kernel}
+if [ -f /boot/System.map-%{kernel} ]; then
+        /sbin/depmod -a -F /boot/System.map-%{kernel} %{kernel} || :
+else
+        /sbin/depmod -a || :
+fi
+
+%postun -n kernel-module-%{name}-%{kernel}
+if [ -f /boot/System.map-%{kernel} ]; then
+        /sbin/depmod -a -F /boot/System.map-%{kernel} %{kernel} || :
+else
+        /sbin/depmod -a || :
+fi
+
+%if 0%{!?_without_userland:1}
+%files
+%doc AUTHORS ChangeLog COPYING FAQ Filesystems NEWS README README.NFS 
+/sbin/mount.fuse
+%defattr(-,root,root) 
+%{_bindir}/fusermount
+%{_bindir}/ulockmgr_server
+%{_sysconfdir}/udev/rules.d/99-fuse.rules
+%{_sysconfdir}/init.d/fuse
+
+%files libs
+%doc COPYING.LIB
+%{_libdir}/libfuse.so.*
+%{_libdir}/libulockmgr.so*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/libfuse.so
+%{_libdir}/libulockmgr.so
+%{_libdir}/pkgconfig/*.pc
+%{_includedir}/fuse.h
+%{_includedir}/ulockmgr.h
+%{_includedir}/fuse
+%endif # userland
+
+%if %{buildmodule}
+%files -n kernel-module-%{name}-%{kernel}
+%defattr(0644,root,root,0755)
+%dir /lib/modules/%{kernel}/kernel/fs/fuse
+%{fusemodule}
+%endif # kernel module
+
+%changelog
+
+* Sun Mar 16 2008 Harshavardhana <harsha@zresearch.com> - 2.7.2glfs8
+- Initial Commit
+	
diff -aurN fuse-2.7.2/kernel/dev.c fuse-2.7.2glfs9/kernel/dev.c
--- fuse-2.7.2/kernel/dev.c	2007-10-16 09:35:22.000000000 -0700
+++ fuse-2.7.2glfs9/kernel/dev.c	2008-03-12 20:38:43.000000000 -0700
@@ -83,7 +83,7 @@
 {
 	req->in.h.uid = current->fsuid;
 	req->in.h.gid = current->fsgid;
-	req->in.h.pid = current->pid;
+	req->in.h.pid = current->tgid;
 }
 
 struct fuse_req *fuse_get_req(struct fuse_conn *fc)
diff -aurN fuse-2.7.2/kernel/dir.c fuse-2.7.2glfs9/kernel/dir.c
--- fuse-2.7.2/kernel/dir.c	2007-12-12 11:00:11.000000000 -0800
+++ fuse-2.7.2glfs9/kernel/dir.c	2008-01-04 15:52:13.000000000 -0800
@@ -380,6 +380,10 @@
 	d_instantiate(entry, inode);
 	fuse_invalidate_attr(dir);
 	fuse_change_timeout(entry, &outentry);
+	if (flags & O_DIRECT) {
+		outopen.open_flags |= FOPEN_DIRECT_IO;
+		nd->intent.open.flags &= ~O_DIRECT;
+	}
 	file = lookup_instantiate_filp(nd, entry, generic_file_open);
 	if (IS_ERR(file)) {
 		ff->fh = outopen.fh;
@@ -1135,11 +1139,12 @@
 {
 	struct inode *inode = entry->d_inode;
 	int err = fuse_revalidate(entry);
-	if (!err)
+	if (!err) {
 		/* FIXME: may want specialized function because of
 		   st_blksize on block devices on 2.6.19+ */
 		generic_fillattr(inode, stat);
-
+		stat->blksize = GLUSTER_BLKSIZE;
+	}
 	return err;
 }
 
diff -aurN fuse-2.7.2/kernel/file.c fuse-2.7.2glfs9/kernel/file.c
--- fuse-2.7.2/kernel/file.c	2007-10-16 09:35:22.000000000 -0700
+++ fuse-2.7.2glfs9/kernel/file.c	2008-01-04 15:52:13.000000000 -0800
@@ -91,10 +91,6 @@
 	struct fuse_file *ff;
 	int err;
 
-	/* VFS checks this, but only _after_ ->open() */
-	if (file->f_flags & O_DIRECT)
-		return -EINVAL;
-
 	err = generic_file_open(inode, file);
 	if (err)
 		return err;
@@ -115,6 +111,19 @@
 	if (err)
 		fuse_file_free(ff);
 	else {
+		if (file->f_flags & O_DIRECT) {
+			/* set fuse_direct_io_file_operations as fops
+			   in fuse_finish_open as though the FS
+			   enforced direct_io
+			*/
+                        outarg.open_flags |= FOPEN_DIRECT_IO;
+			/* make VFS think this is a regular open
+			   to make it not check for aops->direct_IO.
+			   the same effect is acheived by setting fops
+			   to fuse_direct_io_file_operations
+			*/
+			file->f_flags &= ~O_DIRECT;
+                }
 		if (isdir)
 			outarg.open_flags &= ~FOPEN_DIRECT_IO;
 		fuse_finish_open(inode, file, ff, &outarg);
@@ -578,6 +587,8 @@
 		}
 		nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset;
 		nbytes = min(count, nbytes);
+		nbytes = min(nmax, nbytes);
+
 		if (write)
 			nres = fuse_send_write(req, file, inode, pos, nbytes);
 		else
@@ -865,6 +876,7 @@
 	.release	= fuse_release,
 	.fsync		= fuse_fsync,
 	.lock		= fuse_file_lock,
+	.flock          = fuse_file_lock,
 #ifdef KERNEL_2_6_23_PLUS
 	.splice_read	= generic_file_splice_read,
 #else
@@ -881,6 +893,7 @@
 	.release	= fuse_release,
 	.fsync		= fuse_fsync,
 	.lock		= fuse_file_lock,
+	.flock          = fuse_file_lock,
 	/* no mmap and sendfile */
 };
 
diff -aurN fuse-2.7.2/kernel/fuse_i.h fuse-2.7.2glfs9/kernel/fuse_i.h
--- fuse-2.7.2/kernel/fuse_i.h	2007-12-12 11:00:11.000000000 -0800
+++ fuse-2.7.2glfs9/kernel/fuse_i.h	2008-01-04 15:52:13.000000000 -0800
@@ -102,7 +102,8 @@
 #endif
 
 /** Max number of pages that can be used in a single read request */
-#define FUSE_MAX_PAGES_PER_REQ 32
+/** Default 32, changed to 257 for GlusterFS */
+#define FUSE_MAX_PAGES_PER_REQ 257
 
 /** Maximum number of outstanding background requests */
 #define FUSE_MAX_BACKGROUND 10
@@ -122,6 +123,11 @@
     doing the mount will be allowed to access the filesystem */
 #define FUSE_ALLOW_OTHER         (1 << 1)
 
+/** GlusterFS options */
+#define GLUSTER_BLKSIZE 1048576
+#define GLUSTER_BLKSIZE_BITS 20
+#define GLUSTER_RA_PAGES 256
+
 /** List of active connections */
 extern struct list_head fuse_conn_list;
 
diff -aurN fuse-2.7.2/kernel/inode.c fuse-2.7.2glfs9/kernel/inode.c
--- fuse-2.7.2/kernel/inode.c	2007-12-12 11:01:04.000000000 -0800
+++ fuse-2.7.2glfs9/kernel/inode.c	2008-01-04 15:52:13.000000000 -0800
@@ -140,7 +140,7 @@
 	i_size_write(inode, attr->size);
 	spin_unlock(&fc->lock);
 #ifdef HAVE_I_BLKSIZE
-	inode->i_blksize = PAGE_CACHE_SIZE;
+	inode->i_blksize = GLUSTER_BLKSIZE;
 #endif
 	inode->i_blocks  = attr->blocks;
 	inode->i_atime.tv_sec   = attr->atime;
@@ -350,7 +350,7 @@
 	char *p;
 	memset(d, 0, sizeof(struct fuse_mount_data));
 	d->max_read = ~0;
-	d->blksize = 512;
+	d->blksize = GLUSTER_BLKSIZE;
 
 	/*
 	 * For unprivileged mounts use current uid/gid.  Still allow
@@ -481,7 +481,7 @@
 		INIT_LIST_HEAD(&fc->io);
 		INIT_LIST_HEAD(&fc->interrupts);
 		atomic_set(&fc->num_waiting, 0);
-		fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
+		fc->bdi.ra_pages = GLUSTER_RA_PAGES;
 		fc->bdi.unplug_io_fn = default_unplug_io_fn;
 		fc->reqctr = 0;
 		fc->blocked = 1;
@@ -776,8 +776,8 @@
 			return -EINVAL;
 #endif
 	} else {
-		sb->s_blocksize = PAGE_CACHE_SIZE;
-		sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+		sb->s_blocksize = GLUSTER_BLKSIZE;
+		sb->s_blocksize_bits = GLUSTER_BLKSIZE_BITS;
 	}
 	sb->s_magic = FUSE_SUPER_MAGIC;
 	sb->s_op = &fuse_super_operations;
diff -aurN fuse-2.7.2/lib/fuse_kern_chan.c fuse-2.7.2glfs9/lib/fuse_kern_chan.c
--- fuse-2.7.2/lib/fuse_kern_chan.c	2007-12-12 06:33:35.000000000 -0800
+++ fuse-2.7.2glfs9/lib/fuse_kern_chan.c	2008-01-04 15:52:13.000000000 -0800
@@ -80,7 +80,7 @@
 	close(fuse_chan_fd(ch));
 }
 
-#define MIN_BUFSIZE 0x21000
+#define MIN_BUFSIZE (1048576 + 0x1000)
 
 struct fuse_chan *fuse_kern_chan_new(int fd)
 {
diff -aurN fuse-2.7.2/util/Makefile.am fuse-2.7.2glfs9/util/Makefile.am
--- fuse-2.7.2/util/Makefile.am	2007-04-25 09:06:47.000000000 -0700
+++ fuse-2.7.2glfs9/util/Makefile.am	2007-04-25 09:06:47.000000000 -0700
@@ -5,7 +5,7 @@
 noinst_PROGRAMS = mount.fuse
 
 fusermount_SOURCES = fusermount.c
-fusermount_LDADD = ../lib/mount_util.o
+fusermount_LDADD = ../lib/mount_util.lo
 fusermount_CPPFLAGS = -I../lib
 mount_fuse_SOURCES = mount.fuse.c
 
diff -aurN fuse-2.7.2/util/Makefile.in fuse-2.7.2glfs9/util/Makefile.in
--- fuse-2.7.2/util/Makefile.in	2007-12-17 05:30:33.000000000 -0800
+++ fuse-2.7.2glfs9/util/Makefile.in	2008-04-18 12:37:32.000000000 -0700
@@ -53,7 +53,7 @@
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
 am_fusermount_OBJECTS = fusermount-fusermount.$(OBJEXT)
 fusermount_OBJECTS = $(am_fusermount_OBJECTS)
-fusermount_DEPENDENCIES = ../lib/mount_util.o
+fusermount_DEPENDENCIES = ../lib/mount_util.lo
 am_mount_fuse_OBJECTS = mount.fuse.$(OBJEXT)
 mount_fuse_OBJECTS = $(am_mount_fuse_OBJECTS)
 mount_fuse_LDADD = $(LDADD)
@@ -197,7 +197,7 @@
 target_vendor = @target_vendor@
 AM_CPPFLAGS = -D_FILE_OFFSET_BITS=64 
 fusermount_SOURCES = fusermount.c
-fusermount_LDADD = ../lib/mount_util.o
+fusermount_LDADD = ../lib/mount_util.lo
 fusermount_CPPFLAGS = -I../lib
 mount_fuse_SOURCES = mount.fuse.c
 ulockmgr_server_SOURCES = ulockmgr_server.c
diff -aurN fuse-2.7.2/util/udev.rules fuse-2.7.2glfs9/util/udev.rules
--- fuse-2.7.2/util/udev.rules	2006-10-05 03:35:46.000000000 -0700
+++ fuse-2.7.2glfs9/util/udev.rules	2008-04-18 12:36:59.000000000 -0700
@@ -1 +1 @@
-KERNEL=="fuse", MODE="0666"
+KERNEL=="fuse", NAME="%k", MODE="0660",OWNER="root",GROUP="fuse"
