Hi Junjiro,

before switching my users to openSUSE 10.2 diskless, I tackled the job of 
backporting aufs to (at least) 2.6.11 for SuSE 9.3 (diff attached).

Note, that I did it "the dirty way" yesterday afternoon, e.g. without 
checking the exact kernel API change revision, and by deactivating some 
(debug?) tests.. 

I rolled out this version today, and the systems (and my users) still behave 
well ;-). I'm even able to write you a letter :-).

                              All kudos to you!

Given the problems, I faced with establishing a unionfs-based setup, this is 
just unbelievable. Even long standing minor problems like printing with 
kpdf vanished (which means, your mmap support is working "good enough"). 
I'm overwhelmed by this level of success. Thank you very much. If you visit 
Germany one day, or I am Japan, I would be pleased to invite you for a nice  
dinner at large - please let me know, seriously!

If you want to do me a(nother) favour, please have a look on my changes and 
give me a note if something stands out badly. I you consider applying 
something like that, let me know, and I will try to clean it up. 

If anybody want to use this patch, note that you're on your own, since 
Junjiro is probably not able to help you at all due to lacking a test 
environment, and I'm probably not fluent enough with kernel affairs, short 
in time, or the like.. You have been warned!

Junjiro, thanks again for this wonderful piece of software!

Best wishes and kind regards,
Pete

P.S.: Tomas, don't bash the unionfs people too heavily, relish silently ;-)
diff -up -r aufs-20070327/fs/aufs/aufs.h aufs-20070327-new/fs/aufs/aufs.h
--- aufs-20070327/fs/aufs/aufs.h	2007-03-27 23:41:11.000000000 +0200
+++ aufs-20070327-new/fs/aufs/aufs.h	2007-03-28 18:21:04.694373683 +0200
@@ -22,11 +22,19 @@
 #define __AUFS_H__
 
 #include <linux/version.h>
+#include <linux/types.h>    /* for size_t */
 
 /* ---------------------------------------------------------------------- */
 
-// limited support before 2.6.16, curretly 2.6.15 only.
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#    define LOCK_INODE(inode)   mutex_lock(&(inode)->i_mutex)
+#    define UNLOCK_INODE(inode) mutex_unlock(&(inode)->i_mutex)
+#else
+#    define LOCK_INODE(inode)   down(&(inode)->i_sem)
+#    define UNLOCK_INODE(inode) up(&(inode)->i_sem)
+#endif
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
 #define atomic_long_t		atomic_t
 #define atomic_long_set		atomic_set
 #define timespec_to_ns(ts)	({(long long)(ts)->tv_sec;})
@@ -35,6 +43,19 @@
 #define D_CHILD			d_u.d_child
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+# ifdef __CHECKER__
+#  define __bitwise__ __attribute__((bitwise))
+# else
+#  define __bitwise__
+# endif
+
+typedef unsigned __bitwise__ gfp_t;
+void *kzalloc(size_t size, gfp_t flags);
+
+#define do_exit(a)  /* not yet exported */
+#endif
+
 /* ---------------------------------------------------------------------- */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
diff -up -r aufs-20070327/fs/aufs/branch.c aufs-20070327-new/fs/aufs/branch.c
--- aufs-20070327/fs/aufs/branch.c	2007-03-27 23:41:11.000000000 +0200
+++ aufs-20070327-new/fs/aufs/branch.c	2007-03-28 16:16:01.956799716 +0200
@@ -754,7 +754,7 @@ int br_mod(struct super_block *sb, struc
 				dput(br->br_plink);
 				br->br_plink = NULL;
 			}
-#if 1 // test here
+#if 0 // test here
 			DiMustNoWaiters(root);
 			IiMustNoWaiters(root->d_inode);
 			di_write_unlock(root);
Nur in aufs-20070327-new/fs/aufs: .branch.c.swp.
diff -up -r aufs-20070327/fs/aufs/branch.h aufs-20070327-new/fs/aufs/branch.h
--- aufs-20070327/fs/aufs/branch.h	2007-03-27 23:41:11.000000000 +0200
+++ aufs-20070327-new/fs/aufs/branch.h	2007-03-29 09:42:07.897314461 +0200
@@ -65,10 +65,10 @@ enum {
 /* ---------------------------------------------------------------------- */
 
 #define _AuNoNfsBranchMsg "NFS branch is not supported"
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
-#define AuNoNfsBranch
-#define AuNoNfsBranchMsg _AuNoNfsBranchMsg
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) \
+//#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+//#define AuNoNfsBranch
+//#define AuNoNfsBranchMsg _AuNoNfsBranchMsg
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) \
 	&& !defined(CONFIG_AUFS_LHASH_PATCH)
 #define AuNoNfsBranch
 #define AuNoNfsBranchMsg _AuNoNfsBranchMsg \
Nur in aufs-20070327-new/fs/aufs: .branch.h.swp.
diff -up -r aufs-20070327/fs/aufs/debug.h aufs-20070327-new/fs/aufs/debug.h
--- aufs-20070327/fs/aufs/debug.h	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/debug.h	2007-03-28 15:40:51.459788803 +0200
@@ -31,10 +31,14 @@
 #define DEBUG_ON(a)	/* */
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
 static inline void MtxMustLock(struct mutex *mtx)
 {
 	DEBUG_ON(!mutex_is_locked(mtx));
 }
+#else
+#define MtxMustLock(a)	/* */
+#endif
 
 /* ---------------------------------------------------------------------- */
 
diff -up -r aufs-20070327/fs/aufs/file.c aufs-20070327-new/fs/aufs/file.c
--- aufs-20070327/fs/aufs/file.c	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/file.c	2007-03-28 20:46:58.563987042 +0200
@@ -680,7 +680,7 @@ static int aufs_commit_write(struct file
 {BUG();return 0;}
 static int aufs_writepage(struct page *page, struct writeback_control *wbc)
 {BUG();return 0;}
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
 static int aufs_sync_page(struct page *page)
 {BUG(); return 0;}
 #else
@@ -701,7 +701,7 @@ static sector_t aufs_bmap(struct address
 
 static int aufs_set_page_dirty(struct page *page)
 {BUG();return 0;}
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
 static int aufs_invalidatepage (struct page *page, unsigned long offset)
 {BUG(); return 0;}
 #else
@@ -788,7 +788,9 @@ struct address_space_operations aufs_aop
 	.invalidatepage	= aufs_invalidatepage,
 	.releasepage	= aufs_releasepage,
 	.direct_IO	= aufs_direct_IO,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
 	.get_xip_page	= aufs_get_xip_page,
 	//.migratepage	= aufs_migratepage
 #endif
+#endif
 };
diff -up -r aufs-20070327/fs/aufs/f_op.c aufs-20070327-new/fs/aufs/f_op.c
--- aufs-20070327/fs/aufs/f_op.c	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/f_op.c	2007-03-28 17:48:41.118229760 +0200
@@ -18,7 +18,10 @@
 
 /* $Id: f_op.c,v 1.21 2007/03/27 12:49:00 sfjro Exp $ */
 
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
 #include <linux/fsnotify.h>
+#endif
 #include <linux/pagemap.h>
 #include <linux/poll.h>
 #include <linux/security.h>
diff -up -r aufs-20070327/fs/aufs/inode.h aufs-20070327-new/fs/aufs/inode.h
--- aufs-20070327/fs/aufs/inode.h	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/inode.h	2007-03-28 15:42:06.004684827 +0200
@@ -22,7 +22,9 @@
 #define __AUFS_INODE_H__
 
 #include <linux/fs.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
 #include <linux/inotify.h>
+#endif
 #include <linux/version.h>
 #include <linux/aufs_type.h>
 #include "misc.h"
@@ -112,7 +114,7 @@ enum {
 	AuLsc_End
 };
 
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,15)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
 static inline void i_lock(struct inode *i)
 {
 	down(&i->i_sem);
Nur in aufs-20070327-new/fs/aufs: Kconfig.
diff -up -r aufs-20070327/fs/aufs/misc.c aufs-20070327-new/fs/aufs/misc.c
--- aufs-20070327/fs/aufs/misc.c	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/misc.c	2007-03-28 17:43:12.461373007 +0200
@@ -24,6 +24,16 @@
 //#include <asm/uaccess.h>
 #include "aufs.h"
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+void *kzalloc(size_t size, gfp_t flags)
+{
+        void *ret = kmalloc(size, flags);
+        if (ret)
+                memset(ret, 0, size);
+        return ret;
+}
+#endif
+
 void *au_kzrealloc(void *p, int nused, int new_sz)
 {
 	void *q;
@@ -173,9 +183,14 @@ int au_copy_file(struct file *dst, struc
 	/* the last block may be a hole */
 	if (unlikely(!err && all_zero)) {
 		struct iattr ia = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
 			.ia_size	= dst->f_pos,
 			.ia_valid	= ATTR_SIZE | ATTR_FILE,
 			.ia_file	= dst
+#else
+			.ia_size	= dst->f_pos,
+			.ia_valid	= ATTR_SIZE,
+#endif
 		};
 		struct dentry *h_d = dst->f_dentry;
 		struct inode *h_i = h_d->d_inode;
diff -up -r aufs-20070327/fs/aufs/whout.c aufs-20070327-new/fs/aufs/whout.c
--- aufs-20070327/fs/aufs/whout.c	2007-03-27 23:41:12.000000000 +0200
+++ aufs-20070327-new/fs/aufs/whout.c	2007-03-28 17:37:27.529700059 +0200
@@ -20,6 +20,7 @@
 
 #include <linux/fs.h>
 #include <linux/kthread.h>
+#include <linux/kernel.h>
 #include <linux/namei.h>
 #include <linux/random.h>
 #include <linux/security.h>
diff -up -r aufs-20070327/fs/aufs/xino.c aufs-20070327-new/fs/aufs/xino.c
--- aufs-20070327/fs/aufs/xino.c	2007-03-27 23:41:13.000000000 +0200
+++ aufs-20070327-new/fs/aufs/xino.c	2007-03-28 17:49:08.086895101 +0200
@@ -19,7 +19,10 @@
 /* $Id: xino.c,v 1.22 2007/03/27 12:51:44 sfjro Exp $ */
 
 //#include <linux/fs.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
 #include <linux/fsnotify.h>
+#endif
 #include <asm/uaccess.h>
 #include "aufs.h"
 
diff -up -r aufs-20070327/local.mk aufs-20070327-new/local.mk
--- aufs-20070327/local.mk	2007-03-27 23:41:11.000000000 +0200
+++ aufs-20070327-new/local.mk	2007-03-28 15:54:57.778188118 +0200
@@ -9,14 +9,14 @@ CONFIG_AUFS_BRANCH_MAX_127 = y
 CONFIG_AUFS_BRANCH_MAX_511 =
 CONFIG_AUFS_BRANCH_MAX_1023 =
 #CONFIG_AUFS_BRANCH_MAX_32767 =
-CONFIG_AUFS_SYSAUFS = y
+CONFIG_AUFS_SYSAUFS =
 CONFIG_AUFS_HINOTIFY =
 CONFIG_AUFS_EXPORT =
 #CONFIG_AUFS_AS_BRANCH =
 #CONFIG_AUFS_DLGT =
 CONFIG_AUFS_LHASH_PATCH =
 CONFIG_AUFS_KSIZE_PATCH =
-CONFIG_AUFS_DEBUG = y
+CONFIG_AUFS_DEBUG =
 CONFIG_AUFS_COMPAT =
 
 AUFS_DEF_CONFIG =
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Reply via email to