PATCH v14: Arla CVS Current on Linux 2.6.3x to 4.6

Bo Branten bosse at acc.umu.se
Thu May 19 17:37:57 CEST 2016


PATCH v14: Arla CVS Current on Linux 2.6.3x to 4.6

Updated for the Linux kernel v4.6.

Bo Branten
-------------- next part --------------
diff -uprN -Xnodiff arla-cvs-old/nnpfs/include/nnpfs/nnpfs_attr.h arla/nnpfs/include/nnpfs/nnpfs_attr.h
--- arla-cvs-old/nnpfs/include/nnpfs/nnpfs_attr.h	2006-10-24 18:33:30.000000000 +0200
+++ arla/nnpfs/include/nnpfs/nnpfs_attr.h	2016-01-22 12:51:07.000000000 +0100
@@ -113,8 +113,18 @@ struct nnpfs_attr {
     uint32_t		xa_nlink;
     uint32_t		xa_type;
 
+#ifndef __KERNEL__
     uint32_t		xa_uid;
     uint32_t		xa_gid;
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
+    kuid_t		xa_uid;
+    kgid_t		xa_gid;
+#else
+    uint32_t		xa_uid;
+    uint32_t		xa_gid;
+#endif
+#endif
 
     uint32_t		xa_atime;
     uint32_t		xa_mtime;
diff -uprN -Xnodiff arla-cvs-old/nnpfs/include/nnpfs/nnpfs_message.h arla/nnpfs/include/nnpfs/nnpfs_message.h
--- arla-cvs-old/nnpfs/include/nnpfs/nnpfs_message.h	2009-02-24 21:20:55.000000000 +0100
+++ arla/nnpfs/include/nnpfs/nnpfs_message.h	2016-01-22 12:53:29.000000000 +0100
@@ -52,7 +52,15 @@ typedef uint16_t nnpfs_rights;
  * The nnpfs_cred, if pag == 0, use uid 
  */
 typedef struct nnpfs_cred {
+#ifndef __KERNEL__
     uint32_t uid;
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
+    kuid_t uid;
+#else
+    uint32_t uid;
+#endif
+#endif
     nnpfs_pag_t pag;
 } nnpfs_cred;
 
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs/nnpfs_fs.h arla/nnpfs/linux/nnpfs/nnpfs_fs.h
--- arla-cvs-old/nnpfs/linux/nnpfs/nnpfs_fs.h	2006-10-24 18:33:48.000000000 +0200
+++ arla/nnpfs/linux/nnpfs/nnpfs_fs.h	2016-01-13 22:57:06.000000000 +0100
@@ -84,8 +84,13 @@ struct nnpfs {
     struct vfsmount *cacheroot; /* simplify open of cache blocks */
     struct dentry *cachedir;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     uid_t uid; /* keep track of daemon's identity */
     gid_t gid;
+#else
+    kuid_t uid; /* keep track of daemon's identity */
+    kgid_t gid;
+#endif
 
     struct {
 	int recurse;
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs/nnpfs_locl.h arla/nnpfs/linux/nnpfs/nnpfs_locl.h
--- arla-cvs-old/nnpfs/linux/nnpfs/nnpfs_locl.h	2010-08-08 22:43:06.000000000 +0200
+++ arla/nnpfs/linux/nnpfs/nnpfs_locl.h	2016-01-13 23:01:10.000000000 +0100
@@ -51,7 +51,9 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/namei.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 #include <linux/smp_lock.h>
+#endif
 #include <linux/wait.h>
 
 /*
@@ -138,10 +140,17 @@ typedef __u32  uint32_t;
 int
 nnpfs_fetch_root(struct inode *i);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 int
 nnpfs_get_sb(struct file_system_type *fs_type,
 	     int flags, const char *dev_name,
 	     void *data, struct vfsmount *mnt);
+#else
+struct dentry*
+nnpfs_mount(struct file_system_type *fs_type,
+	     int flags, const char *dev_name,
+	     void *data);
+#endif
 
 extern struct dentry_operations nnpfs_dentry_operations;
 
@@ -194,10 +203,21 @@ nnpfs_iwritecount (struct inode *inode)
  * Help function to read the dentry->d_count a portable way
  */
 
+/*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)*/
 static inline int
 nnpfs_dcount (const struct dentry *dentry)
+/*#else
+static inline int
+nnpfs_dcount (struct dentry *dentry)
+#endif*/
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
     return atomic_read(&dentry->d_count);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+    return atomic_read((const atomic_t*)&dentry->d_count);
+#else
+    return d_count(dentry);;
+#endif
 }
 
 extern 
@@ -229,7 +249,12 @@ nnpfs_fixup_syscall_lossage(void);
 #endif
 
 #define nnpfs_dev_t dev_t
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
 #define nnpfs_d_entry_unhashed(d) hlist_unhashed(d)
+#else
+#define nnpfs_d_entry_unhashed(d) hlist_bl_unhashed(d)
+#endif
 
 #define NNPFS_NOOP      while(0){}
 
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_blocks.c arla/nnpfs/linux/nnpfs_blocks.c
--- arla-cvs-old/nnpfs/linux/nnpfs_blocks.c	2010-08-08 22:43:04.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_blocks.c	2016-02-20 19:44:39.000000000 +0100
@@ -43,6 +43,11 @@
 #include <linux/mount.h>
 #include <linux/mm.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
+			   const char *, unsigned int, struct path *);
+#endif
+
 /*
  * return true if block is in cache
  */
@@ -290,7 +295,13 @@ nnpfs_block_extend(struct nnpfs_node *no
     backnode = backfile->f_mapping->host;
 
     mutex_lock(&backnode->i_mutex);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
     ret = vmtruncate(backnode, nnpfs_blocksize);
+#else
+    ret = inode_newsize_ok(backnode, nnpfs_blocksize);
+    if(!ret)
+        truncate_setsize(backnode, nnpfs_blocksize);
+#endif
     mutex_unlock(&backnode->i_mutex);
     
     filp_close(backfile, NULL);
@@ -313,19 +324,27 @@ nnpfs_block_open(struct nnpfs_node *node
 		 struct file **file)
 {
     char cachename[NNPFS_CACHE_PATH_SIZE];
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+    char full_cachename[NNPFS_CACHE_PATH_SIZE];
+#endif
     uint64_t blockindex = nnpfs_block_index(offset);
     uint32_t id = node->index;
     struct nnpfs *nnpfsp = NNPFS_FROM_XNODE(node);
     struct inode *inode = XNODE_TO_VNODE(node);
     int flags = O_LARGEFILE | flag;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct nameidata nd;
+#else
+    struct path path;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
     uid_t saveuid;
     gid_t savegid;
-    int ret;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+#else
     const struct cred *old_cred;
     struct cred *override_cred;
 #endif
+    int ret;
 
     BUG_ON(!nnpfsp);
     BUG_ON(flags & O_CREAT && file != NULL);
@@ -334,12 +353,22 @@ nnpfs_block_open(struct nnpfs_node *node
 	ret = snprintf(cachename, sizeof(cachename),
 		       NNPFS_CACHE_DIR_PATH,
 		       id / 0x100, id % 0x100);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+	ret = snprintf(full_cachename, sizeof(cachename),
+		       "/usr/arla/cache/" NNPFS_CACHE_DIR_PATH,
+		       id / 0x100, id % 0x100);
+#endif
     } else {
 	ret = snprintf(cachename, sizeof(cachename),
 		       NNPFS_CACHE_FILE_PATH,
 		       id / 0x100, id % 0x100,
 		       (unsigned long long)blockindex);
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+	ret = snprintf(full_cachename, sizeof(cachename),
+		       "/usr/arla/cache/" NNPFS_CACHE_FILE_PATH,
+		       id / 0x100, id % 0x100,
+		       (unsigned long long)blockindex);
+#endif
 	if (!nnpfs_block_have_p(node, offset) && (flags & O_CREAT) == 0) {
 	    printk(KERN_EMERG "reading block %s: not there\n", cachename);
 	    BUG();
@@ -350,14 +379,12 @@ nnpfs_block_open(struct nnpfs_node *node
     BUG_ON(!nnpfsp->cachedir || !nnpfsp->cacheroot);
     
     /* use the nfsd trick to give us access */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
     saveuid = current->fsuid;
     savegid = current->fsgid;
     current->fsuid = nnpfsp->uid;
     current->fsgid = nnpfsp->gid;
 #else
-    saveuid = current_fsuid();
-    savegid = current_fsgid();
     override_cred = prepare_creds();
     if (override_cred == NULL)
         return -ENOMEM;
@@ -366,11 +393,23 @@ nnpfs_block_open(struct nnpfs_node *node
     old_cred = override_creds(override_cred);
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
     ret = vfs_path_lookup(nnpfsp->cachedir, nnpfsp->cacheroot,
 			  cachename,
 			  flags & O_CREAT ? LOOKUP_PARENT : 0,
 			  &nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    ret = vfs_path_lookup(nnpfsp->cachedir, nnpfsp->cacheroot,
+			  cachename, 0, &nd.path);
+#else
+    ret = vfs_path_lookup(nnpfsp->cachedir, nnpfsp->cacheroot,
+			  cachename, 0, &path);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
     if (ret) {
+#else
+    if (ret && !(flags & O_CREAT)) {
+#endif
 	uint32_t nmasks = node->data.nmasks;
 	uint32_t mask;
 
@@ -396,17 +435,37 @@ nnpfs_block_open(struct nnpfs_node *node
     
     if (flags & O_CREAT) {
 	/* XXX mode bits on create -- S_IRUSR|S_IWUSR */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
 	struct dentry *dentry = lookup_create(&nd, 0);	
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+	struct dentry *dentry = kern_path_create(AT_FDCWD, full_cachename, &nd.path, 0);	
+#else
+	struct dentry *dentry = kern_path_create(AT_FDCWD, full_cachename, &path, 0);	
+#endif
 	if (IS_ERR(dentry)) {
 	    ret = PTR_ERR(dentry);
 	} else {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 	    ret = vfs_create(nd.path.dentry->d_inode, dentry, S_IRUSR|S_IWUSR, &nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+	    /* XXX should the last argument to vfs_create: bool want_excl, be 0 or 1? */
+	    ret = vfs_create(nd.path.dentry->d_inode, dentry, S_IRUSR|S_IWUSR, 0);
+#else
+	    /* XXX should the last argument to vfs_create: bool want_excl, be 0 or 1? */
+	    ret = vfs_create(path.dentry->d_inode, dentry, S_IRUSR|S_IWUSR, 0);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 	    dput(dentry);
+	    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
+	    path_put(&nd.path);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+	    done_path_create(&nd.path, dentry);
+#else
+	    done_path_create(&path, dentry);
+#endif
 	}
 
-	mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
-	path_put(&nd.path);
-
 	if (ret) {
 	    printk("nnpfs_block_open(%s) create failed: %d\n", cachename, -ret);
 	    nnpfs_debug_oops();
@@ -421,14 +480,22 @@ nnpfs_block_open(struct nnpfs_node *node
     } else {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
 	struct file *f = dentry_open(nd.path.dentry, nd.path.mnt, flags);
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
         struct file *f = dentry_open(nd.path.dentry, nd.path.mnt, flags, current_cred());
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+        struct file *f = dentry_open(&nd.path, flags, current_cred());
+#else
+        struct file *f = dentry_open(&path, flags, current_cred());
 #endif
 	if (IS_ERR(f)) {
 	    ret = PTR_ERR(f);
 	    printk("nnpfs_block_open(%s) open failed: %d\n", cachename, -ret);
 	    nnpfs_debug_oops();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	    path_put(&nd.path);
+#else
+	    path_put(&path);
+#endif
 	} else {
 	    *file = f;
 	}
@@ -437,7 +504,7 @@ nnpfs_block_open(struct nnpfs_node *node
     /* path_release() is usually handled on close */
 
  out:
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
     current->fsuid = saveuid;
     current->fsgid = savegid;
 #else
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_common.c arla/nnpfs/linux/nnpfs_common.c
--- arla-cvs-old/nnpfs/linux/nnpfs_common.c	2006-12-11 17:31:46.000000000 +0100
+++ arla/nnpfs/linux/nnpfs_common.c	2016-01-14 16:15:00.000000000 +0100
@@ -112,10 +112,15 @@ nnpfs_print_aliases(const struct inode *
 void
 nnpfs_print_aliases_real(const struct inode *inode)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     struct list_head *alias;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    struct hlist_node *alias;
+#endif
     struct dentry *dentry;
     int bailout = 100;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     alias = inode->i_dentry.next;
     while (alias != &inode->i_dentry) {
 	if (--bailout < 0) {
@@ -131,6 +136,26 @@ nnpfs_print_aliases_real(const struct in
 	}
 	alias = alias->next;
     }
+#else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    hlist_for_each_entry(dentry, alias, &inode->i_dentry, d_alias) {
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
+#else
+    hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
+#endif
+	if (--bailout < 0) {
+	    printk(" ...");
+	    break;
+	}
+	if (dentry) {
+	    printk(" %.*s(%p)", (int)dentry->d_name.len,
+		   dentry->d_name.name, dentry);
+	    if (nnpfs_d_entry_unhashed(&dentry->d_hash))
+		printk("(unhashed)");
+	}
+    }
+#endif
     printk("\n");
 }
 
@@ -146,7 +171,11 @@ nnpfs_print_children(const struct dentry
 
     while (subdirs != &dentry->d_subdirs) {
 	struct list_head *tmp = subdirs;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	struct dentry *child = list_entry(tmp, struct dentry, d_u.d_child);
+#else
+	struct dentry *child = list_entry(tmp, struct dentry, d_child);
+#endif
 
 	printk(" %.*s(%p)", (int)child->d_name.len,
 	       child->d_name.name, child);
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_dev.c arla/nnpfs/linux/nnpfs_dev.c
--- arla-cvs-old/nnpfs/linux/nnpfs_dev.c	2006-10-24 18:33:36.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_dev.c	2016-01-14 16:28:19.000000000 +0100
@@ -300,7 +300,9 @@ nnpfs_invalidate_all(struct nnpfs *nnpfs
     NNPFSDEB(XDEBNODE, ("free_all_nnpfs_nodes starting\n"));
 
     shrink_dcache_sb(nnpfs->sb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
     invalidate_inodes(nnpfs->sb);
+#endif
     
     NNPFSDEB(XDEBNODE, ("free_all_nnpfs_nodes done\n"));
 }
@@ -374,7 +376,11 @@ nnpfs_devclose(struct inode * inode, str
 static ssize_t
 nnpfs_devread(struct file *file, char *buf, size_t count, loff_t *ppos)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     nnpfs_dev_t dev = file->f_dentry->d_inode->i_rdev;
+#else
+    nnpfs_dev_t dev = file->f_path.dentry->d_inode->i_rdev;
+#endif
     struct nnpfs *nnpfsp = &nnpfs[MINOR(dev)];
     struct nnpfs_link *first;
     int ret = 0, error = 0;
@@ -439,8 +445,12 @@ nnpfs_devwrite(struct file *file, const 
 
     NNPFSDEB(XDEBDEV, ("nnpfs_devwrite\n"));
     
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     dev = file->f_dentry->d_inode->i_rdev;
-    nnpfsp = &nnpfs[MINOR(dev)];
+#else
+    dev = file->f_path.dentry->d_inode->i_rdev;
+#endif
+     nnpfsp = &nnpfs[MINOR(dev)];
 
     down(&nnpfsp->channel_sem);
     if (nnpfsp->status & NNPFS_DEVWRITE) {
@@ -505,19 +515,37 @@ nnpfs_devwrite(struct file *file, const 
 /*
  * Not used.
  */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
 static int
 nnpfs_devioctl(struct inode *inode, struct file *file,
 	       unsigned int cmd, unsigned long arg)
+#else
+static long
+nnpfs_unlocked_devioctl(struct file *file,
+	       unsigned int cmd, unsigned long arg)
+#endif
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
     NNPFSDEB(XDEBDEV, ("nnpfs_devioctl dev = %d, flags = %d\n",
 		       inode->i_rdev, file->f_flags));
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    NNPFSDEB(XDEBDEV, ("nnpfs_devioctl dev = %d, flags = %d\n",
+		       file->f_dentry->d_inode->i_rdev, file->f_flags));
+#else
+    NNPFSDEB(XDEBDEV, ("nnpfs_devioctl dev = %d, flags = %d\n",
+		       file->f_path.dentry->d_inode->i_rdev, file->f_flags));
+#endif
     return -EINVAL;
 }
 
 static unsigned int
 nnpfs_devpoll(struct file *file, poll_table *wait)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     nnpfs_dev_t dev = file->f_dentry->d_inode->i_rdev;
+#else
+    nnpfs_dev_t dev = file->f_path.dentry->d_inode->i_rdev;
+#endif
     struct nnpfs *nnpfsp = &nnpfs[MINOR(dev)];
     int ret = 0;
     
@@ -953,7 +981,11 @@ struct file_operations nnpfs_fops = {
     read:		nnpfs_devread,
     write:		nnpfs_devwrite,
     poll:		nnpfs_devpoll,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
     ioctl:		nnpfs_devioctl,
+#else
+    unlocked_ioctl:	nnpfs_unlocked_devioctl,
+#endif
     release:		nnpfs_devclose,
     open:		nnpfs_devopen,
 };
@@ -968,8 +1000,13 @@ nnpfs_init_device(void)
 	init_waitqueue_head(&(nnpfs[i].wait_queue));
 	nnpfs_initq(&nnpfs[i].messageq);
 	nnpfs_initq(&nnpfs[i].sleepq);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
 	init_MUTEX(&nnpfs[i].inactive_sem);
 	init_MUTEX(&nnpfs[i].channel_sem);
+#else
+	sema_init(&nnpfs[i].inactive_sem, 1);
+	sema_init(&nnpfs[i].channel_sem, 1);
+#endif
 	INIT_LIST_HEAD(&nnpfs[i].inactive_list);
 	nnpfs[i].nnodes = 0;
     }
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_inodeops.c arla/nnpfs/linux/nnpfs_inodeops.c
--- arla-cvs-old/nnpfs/linux/nnpfs_inodeops.c	2010-08-08 22:43:04.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_inodeops.c	2016-05-09 17:13:03.000000000 +0200
@@ -40,13 +40,24 @@
 #include <nnpfs/nnpfs_dev.h>
 #include <nnpfs/nnpfs_dirent.h>
 #include <nnpfs/nnpfs_syscalls.h>
+#include <linux/aio.h>
 #include <linux/binfmts.h>
 #include <linux/file.h>
 #include <linux/pagemap.h>
 #include <linux/page-flags.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+#include <linux/uio.h>
+#endif
 #include <linux/writeback.h>
 #include <asm/fcntl.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+#define PAGE_CACHE_SIZE			PAGE_SIZE
+#define PAGE_CACHE_SHIFT		PAGE_SHIFT
+#define page_cache_get(page)		get_page(page)
+#define page_cache_release(page)	put_page(page)
+#endif
+
 #ifdef RCSID
 RCSID("$Id: nnpfs_inodeops.c,v 1.226 2010/08/08 20:43:04 tol Exp $");
 #endif
@@ -54,11 +65,23 @@ RCSID("$Id: nnpfs_inodeops.c,v 1.226 201
 static int
 nnpfs_fsync_int(struct file *file, u_int flag);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 static int
 nnpfs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
-
+#else
 static int
+nnpfs_d_revalidate(struct dentry *dentry, unsigned int flags);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
+static
+int
 nnpfs_d_delete(struct dentry *dentry);
+#else
+static
+int
+nnpfs_d_delete(const struct dentry *dentry);
+#endif
 
 static void
 nnpfs_d_release(struct dentry *dentry);
@@ -214,8 +237,13 @@ nnpfs_inode_valid(struct inode *inode)
  * nnpfs_lookup now returns a dentry.
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 static struct dentry *
 nnpfs_lookup (struct inode *dir, struct dentry *dentry, struct nameidata *nd)
+#else
+static struct dentry *
+nnpfs_lookup (struct inode *dir, struct dentry *dentry, unsigned int flags)
+#endif
 {
     struct nnpfs_message_getnode msg;
     struct nnpfs *nnpfsp;
@@ -407,7 +435,11 @@ find_first_block(struct nnpfs_node *node
 static int
 nnpfs_fsync_int(struct file *file, u_int flag)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct nnpfs *nnpfsp = NNPFS_FROM_VNODE(inode);
     struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
     loff_t len = i_size_read(inode);
@@ -474,15 +506,18 @@ nnpfs_fsync_int(struct file *file, u_int
  *
  */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
 static int
 nnpfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
 static int
 nnpfs_fsync(struct file *file, int datasync)
+#else
+static int
+nnpfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 #endif
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
     struct dentry *dentry = file->f_path.dentry;
 #endif
     struct inode *inode = DENTRY_TO_INODE(dentry);
@@ -490,6 +525,8 @@ nnpfs_fsync(struct file *file, int datas
     struct nnpfs_node *xn;
     int error = 0;
 
+    (void)nnpfsp;
+
     error = nnpfs_inode_valid(inode);
     if (error)
 	return error;
@@ -622,11 +659,25 @@ check_rights (nnpfs_rights rights, int m
  * We don't hold i_mutex.
  */
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
 static int
 nnpfs_permission(struct inode *inode, int mode)
+#else
+static int
+nnpfs_permission(struct inode *inode, int mode, unsigned int flags)
+#endif
 {
     int error = 0;
-    nnpfs_pag_t pag = nnpfs_get_pag();
+    nnpfs_pag_t pag;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+    if (mode & MAY_NOT_BLOCK)
+        return -ECHILD;
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+    if (flags & IPERM_FLAG_RCU)
+        return -ECHILD;
+#endif
+
+    pag = nnpfs_get_pag();
     
     NNPFSDEB(XDEBVNOPS, ("nnpfs_access (%p) mode = 0%o aliases:", inode, mode));
     nnpfs_print_aliases(inode);
@@ -784,11 +835,19 @@ nnpfs_data_valid(struct inode *inode, u_
 int nnpfs_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
     int flags, error = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct address_space *mapping = file->f_mapping;
 
     NNPFSDEB(XDEBVNOPS, ("nnpfs_mmap inode: %p\n", inode));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     nnpfs_print_path(file->f_dentry);
+#else
+    nnpfs_print_path(file->f_path.dentry);
+#endif
     NNPFSDEB(XDEBVNOPS, ("nnpfs_mmap aliases:"));
     nnpfs_print_aliases(inode);
     
@@ -823,28 +882,51 @@ int nnpfs_file_mmap(struct file * file, 
  *
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
 static ssize_t
 nnpfs_aio_read(struct kiocb *iocb,
 	       const struct iovec *iov, unsigned long nr_segs,
 	       loff_t pos)
+#else
+static ssize_t
+nnpfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
+#endif
 {
     int error = 0;
     struct file *file = iocb->ki_filp;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
     ssize_t count = iocb->ki_left;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
+    ssize_t count = iocb->ki_nbytes;
+#else
+    ssize_t count = iov_iter_count(to);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
     
     if (xn != NULL)
 	NNPFSDEB(XDEBVNOPS, ("nnpfs_read_file(%p): tokens: 0x%x\n",
 			     inode, xn->tokens));
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
     error = nnpfs_data_valid(inode, NNPFS_DATA_R, pos, pos + count);
+#else
+    error = nnpfs_data_valid(inode, NNPFS_DATA_R, iocb->ki_pos, iocb->ki_pos + count);
+#endif
     if (error) {
 	NNPFSDEB(XDEBVNOPS, ("nnpfs_read_file: data not valid %d\n", error));
 	return error;
     }
     
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
     error = generic_file_aio_read(iocb, iov, nr_segs, pos);
+#else
+    error = generic_file_read_iter(iocb, to);
+#endif
     NNPFSDEB(XDEBVNOPS, ("nnpfs_read_file: error = %d\n", error));
     return error;
 }
@@ -853,17 +935,36 @@ nnpfs_aio_read(struct kiocb *iocb,
  *
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
 static ssize_t
 nnpfs_aio_write(struct kiocb *iocb,
 		const struct iovec *iov, unsigned long nr_segs,
 		loff_t pos)
+#else
+static ssize_t
+nnpfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
+#endif
 {
     int error = 0;
     struct file *file = iocb->ki_filp;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
     ssize_t count = iocb->ki_left;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
+    ssize_t count = iocb->ki_nbytes;
+#else
+    ssize_t count = iov_iter_count(from);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
     loff_t realpos = pos;
+#else
+    loff_t realpos = iocb->ki_pos;
+#endif
     
     NNPFSDEB(XDEBVNOPS, ("nnpfs_aio_write(%p): tokens: 0x%x\n",
 			 inode, xn->tokens));
@@ -877,7 +978,11 @@ nnpfs_aio_write(struct kiocb *iocb,
 	return error;
     }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
     error = generic_file_aio_write(iocb, iov, nr_segs, pos);
+#else
+    error = generic_file_write_iter(iocb, from);
+#endif
     if (!IS_ERR_VALUE(error))
 	xn->flags |= NNPFS_DATA_DIRTY; /* XXX race */
 
@@ -885,9 +990,19 @@ nnpfs_aio_write(struct kiocb *iocb,
     return error;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
 static int
 nnpfs_create(struct inode *dir, struct dentry *dentry,
 	     int mode, struct nameidata *nd)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
+static int
+nnpfs_create(struct inode *dir, struct dentry *dentry,
+	     umode_t mode, struct nameidata *nd)
+#else
+static int
+nnpfs_create(struct inode *dir, struct dentry *dentry,
+	     umode_t mode, bool excl)
+#endif
 {
     struct nnpfs *nnpfsp;
     struct nnpfs_node *xn;
@@ -1038,8 +1153,13 @@ nnpfs_rename (struct inode * old_dir, st
     return error;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
 static int
 nnpfs_mkdir(struct inode * dir, struct dentry *dentry, int mode)
+#else
+static int
+nnpfs_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode)
+#endif
 {
     struct nnpfs *nnpfsp;
     struct nnpfs_node *xn;
@@ -1252,12 +1372,21 @@ static int nnpfs_symlink(struct inode *d
 /*
  * We hold i_mutex.
  */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
 static int
 nnpfs_readdir(struct file * file, void * dirent, filldir_t filldir)
+#else
+static int
+nnpfs_iterate(struct file * file, struct dir_context *ctx)
+#endif
 {
     int error;
     loff_t offset, begin_offset;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct inode *cache_inode;
     struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
     char *buf;
@@ -1281,6 +1410,7 @@ nnpfs_readdir(struct file * file, void *
 
     cache_inode = backfile->f_mapping->host;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
     while (file->f_pos < i_size_read(cache_inode)) {
 	NNPFSDEB(XDEBREADDIR,
 	       ("nnpfs_readdir file->f_pos: %d i_size: %d\n",
@@ -1293,6 +1423,20 @@ nnpfs_readdir(struct file * file, void *
 	mapping = backfile->f_mapping;
 	inpage = file->f_pos & (PAGE_CACHE_SIZE-1);
 	page_num = file->f_pos >> PAGE_CACHE_SHIFT;
+#else
+    while (ctx->pos < i_size_read(cache_inode)) {
+	NNPFSDEB(XDEBREADDIR,
+	       ("nnpfs_readdir file->f_pos: %d i_size: %d\n",
+		(int) ctx->pos, (int) cache_inode->i_size));
+	begin_offset = ctx->pos &~ (NNPFS_DIRENT_BLOCKSIZE - 1);
+	offset = ctx->pos & (NNPFS_DIRENT_BLOCKSIZE - 1);
+	ctx->pos = begin_offset;
+	NNPFSDEB(XDEBREADDIR, ("nnpfs_readdir begin_offset: %d offset: %d\n",
+			     (int)begin_offset, (int)offset));
+	mapping = backfile->f_mapping;
+	inpage = ctx->pos & (PAGE_CACHE_SIZE-1);
+	page_num = ctx->pos >> PAGE_CACHE_SHIFT;
+#endif
 
 	NNPFSDEB(XDEBREADDIR,
 	       ("nnpfs_readdir inpage: %d page_num: %lu\n",
@@ -1328,6 +1472,7 @@ nnpfs_readdir(struct file * file, void *
 		    (int) xdirent->d_namlen,
 		    (int) (offset+begin_offset)));
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
 	    if (xdirent->d_fileno != 0
 		&& (filldir_error = filldir (dirent,
 				     xdirent->d_name,
@@ -1339,12 +1484,28 @@ nnpfs_readdir(struct file * file, void *
 			 ("nnpfs_readdir filldir: %d\n", filldir_error));
 		break;
 	    }
+#else
+	    if (xdirent->d_fileno != 0
+		&& (filldir_error = dir_emit (ctx,
+				     xdirent->d_name,
+				     xdirent->d_namlen,
+				     xdirent->d_fileno,
+				     DT_UNKNOWN)) < 0) {
+		NNPFSDEB(XDEBREADDIR,
+			 ("nnpfs_readdir filldir: %d\n", filldir_error));
+		break;
+	    }
+#endif
 	    offset += xdirent->d_reclen;
 
 	    if (xdirent->d_reclen == 0) {
 		printk(KERN_EMERG "NNPFS Panic: "
 		       "empty dirent at %lld in nnpfs_readdir, pos %d size %d\n",
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
 		       (long long)offset, (int)file->f_pos,
+#else
+		       (long long)offset, (int)ctx->pos,
+#endif
 		       (int)cache_inode->i_size);
 		NNPFSDEB(XDEBVNOPS, ("inode: %p aliases:", inode));
 		nnpfs_print_aliases(inode);
@@ -1362,7 +1523,11 @@ nnpfs_readdir(struct file * file, void *
 	if (offset > NNPFS_DIRENT_BLOCKSIZE)
 	    offset = NNPFS_DIRENT_BLOCKSIZE;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
 	file->f_pos = begin_offset + offset;
+#else
+	ctx->pos = begin_offset + offset;
+#endif
 
 	if (error || offset < NNPFS_DIRENT_BLOCKSIZE)
 	    break;
@@ -1395,12 +1560,25 @@ nnpfs_readlink (struct dentry *dentry, c
  * We don't hold i_mutex.
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
 static void *
 nnpfs_follow_link (struct dentry *dentry,
 		 struct nameidata *nd)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
+static const char *
+nnpfs_follow_link (struct dentry *dentry,
+		 void **page)
+#else
+static const char *
+nnpfs_get_link (struct dentry *dentry,
+		 struct inode *inode,
+		 struct delayed_call *done)
+#endif
 {
     int error = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
     struct inode *inode = DENTRY_TO_INODE(dentry);
+#endif
 
     NNPFSDEB(XDEBVNOPS, ("nnpfs_follow_link\n"));
     
@@ -1408,7 +1586,13 @@ nnpfs_follow_link (struct dentry *dentry
     if (error)
        return ERR_PTR(error);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
     return page_follow_link_light(dentry, nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
+    return page_follow_link_light(dentry, page);
+#else
+    return page_get_link(dentry, inode, done);
+#endif
 }
 
 /*
@@ -1490,6 +1674,8 @@ nnpfs_release_file (struct inode *inode,
     struct nnpfs_node *xn;
     int error = 0;
 
+    (void)nnpfsp;
+
     NNPFSDEB(XDEBVNOPS, ("nnpfs_release_file\n"));
 
     error = nnpfs_inode_valid(inode);
@@ -1523,8 +1709,13 @@ nnpfs_flush(struct file *file, fl_owner_
 {
     NNPFSDEB(XDEBVNOPS, ("nnpfs_flush\n"));
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     if (file && file->f_dentry && file->f_dentry->d_inode)
 	return nnpfs_release_file(file->f_dentry->d_inode, file);
+#else
+    if (file && file->f_path.dentry && file->f_path.dentry->d_inode)
+	return nnpfs_release_file(file->f_path.dentry->d_inode, file);
+#endif
     else
 	return 0;
 }
@@ -1533,10 +1724,24 @@ nnpfs_flush(struct file *file, fl_owner_
  * Return 1 if `dentry' is still valid, otherwise 0.
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
+static int
+nnpfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
+#else
 static int
-nnpfs_d_revalidate(struct dentry *dentry, struct nameidata *nd) 
+nnpfs_d_revalidate(struct dentry *dentry, unsigned int flags)
+#endif
 {
     struct inode *inode = DENTRY_TO_INODE(dentry);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+    if (flags & LOOKUP_RCU)
+        return -ECHILD;
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+    if (nd && nd->flags & LOOKUP_RCU)
+        return -ECHILD;
+#endif
+
     NNPFSDEB(XDEBVNOPS, ("nnpfs_d_revalidate %p \"%.*s\" (inode %p)\n",
 		       dentry,
 		       (int)dentry->d_name.len,
@@ -1582,9 +1787,15 @@ nnpfs_d_revalidate(struct dentry *dentry
     return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
 static
 int
 nnpfs_d_delete(struct dentry *dentry)
+#else
+static
+int
+nnpfs_d_delete(const struct dentry *dentry)
+#endif
 {
     struct inode *inode;
     struct nnpfs_node *xn;
@@ -1614,7 +1825,11 @@ nnpfs_splice_read(struct file *file, lof
 		  unsigned int flags)
 {
     int error = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct inode *inode = file->f_dentry->d_inode;
+#else
+    struct inode *inode = file->f_path.dentry->d_inode;
+#endif
     struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
     
     if (xn != NULL)
@@ -1707,6 +1922,8 @@ nnpfs_write_backpage(struct page *page, 
 
 	int error;
 	
+	(void)offset;
+
 	do {
 		error = pagecache_write_begin(backfile, mapping, 0, len,
 					      AOP_FLAG_UNINTERRUPTIBLE,
@@ -1730,7 +1947,11 @@ nnpfs_write_backpage(struct page *page, 
 		printk("nnpfs_write_backpage: EIO\n");
 #ifdef NNPFS_SAFE_SYNC
 	else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
 		(void)sync_page_range(mapping->host, mapping, offset, len);
+#else
+		(void)filemap_write_and_wait_range(mapping, offset, offset + len - 1);
+#endif
 #endif
 	
 	return error;
@@ -1747,6 +1968,8 @@ nnpfs_read_backpage(struct page *page, s
 	struct page *backpage;
 	unsigned long offset;
 
+	(void)offset;
+
 	backpage = read_mapping_page(mapping, n, backfile);
 	if (!IS_ERR(backpage)) {
 		wait_on_page_locked(backpage);
@@ -1894,11 +2117,17 @@ nnpfs_prepare_write(struct file *file, s
 
 	if (modsize > i_size_read(inode)) {
 		int error;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
 		error = vmtruncate(inode, modsize);
+#else
+		error = inode_newsize_ok(inode, modsize);
+		if(!error)
+			truncate_setsize(inode, modsize);
+#endif
 		if (error) {
 			printk("nnpfs_prepare_write: truncate(%llu) -> %d\n",
 			       modsize, -error);
-			BUG(); /* XXX not correct */
+			/*BUG();*/ /* XXX not correct */
 		}
 	}
 
@@ -1925,7 +2154,6 @@ nnpfs_prepare_write(struct file *file, s
 }
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
-
 static int
 nnpfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
 unsigned len, unsigned flags, struct page **pagep, void **fsdata)
@@ -1933,58 +2161,67 @@ unsigned len, unsigned flags, struct pag
 	struct page *page;
 	pgoff_t index;
 	unsigned from;
+	int ret = 0;
 
 	index = pos >> PAGE_CACHE_SHIFT;
 	from = pos & (PAGE_CACHE_SIZE - 1);
 
-#ifdef AOP_FLAG_NOFS
 	page = grab_cache_page_write_begin(mapping, index, flags);
-#else
-	page = __grab_cache_page(mapping, index);
-#endif
-	if (page == NULL)
+	if (!page)
 		return -ENOMEM;
 
 	*pagep = page;
 
-	return nnpfs_prepare_write(file, page, from, from + len);
-}
+	ret = nnpfs_prepare_write(file, page, from, from + len);
+	if (ret) {
+		unlock_page(page);
+		page_cache_release(page);
+	}
 
+	return ret;
+}
 #endif
 
+/* XXX we use the system provided simple_commit_write instead so this function is unused for now */
+#if 0
 static int
 nnpfs_commit_write(struct file *file, struct page *page,
 		   unsigned from, unsigned to)
 {
-    struct inode *inode = page->mapping->host;
-    loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+	struct inode *inode = page->mapping->host;
+	loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
 
-    if (pos > inode->i_size) {
-	i_size_write(inode, pos);
+	if (!PageUptodate(page))
+		SetPageUptodate(page);
 
-	spin_lock(&inode->i_lock);
-	inode->i_blocks = (pos + I_BLOCKS_UNIT - 1) >> I_BLOCKS_BITS;
-	spin_unlock(&inode->i_lock);
-    }
-    set_page_dirty(page);
+	if (pos > inode->i_size) {
+		i_size_write(inode, pos);
+
+		spin_lock(&inode->i_lock);
+		inode->i_blocks = (pos + I_BLOCKS_UNIT - 1) >> I_BLOCKS_BITS;
+		spin_unlock(&inode->i_lock);
+	}
+	set_page_dirty(page);
 
 #if 0
-    {
-	char *addr;
-	kmap(page);
-	addr = page_address(page);
-	NNPFSDEB(XDEBVNOPS, ("nnpfs_commit_write(%p): %x%x%x%x\n",
+	{
+	    char *addr;
+	    kmap(page);
+	    addr = page_address(page);
+	    NNPFSDEB(XDEBVNOPS, ("nnpfs_commit_write(%p): %x%x%x%x\n",
 			     file->f_mapping->host, 
 			     addr[0], addr[1], addr[2], addr[3]));
-	kunmap(page);
-    }
+	    kunmap(page);
+	}
 #endif
-    
-    return 0;
+ 
+	return 0;
 }
+#endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
-
+/* XXX we use the system provided simple_write_end instead so this function is unused for now */
+#if 0
 static int
 nnpfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 		unsigned len, unsigned copied, struct page *page, void *fsdata)
@@ -1993,10 +2230,18 @@ nnpfs_write_end(struct file *file, struc
 
 	/* zero the stale part of the page if we did a short copy */
 	if (copied < len) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 		void *kaddr = kmap_atomic(page, KM_USER0);
+#else
+		void *kaddr = kmap_atomic(page);
+#endif
 		memset(kaddr + from + copied, 0, len - copied);
 		flush_dcache_page(page);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 		kunmap_atomic(kaddr, KM_USER0);
+#else
+		kunmap_atomic(kaddr);
+#endif
 	}
 
 	nnpfs_commit_write(file, page, from, from + copied);
@@ -2006,7 +2251,7 @@ nnpfs_write_end(struct file *file, struc
 
 	return copied;
 }
-
+#endif
 #endif
 
 const
@@ -2015,10 +2260,10 @@ struct address_space_operations nnpfs_ao
 	.writepage = nnpfs_writepage,
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
 	.prepare_write = nnpfs_prepare_write,
-	.commit_write = nnpfs_commit_write,
+	.commit_write = simple_commit_write,
 #else
 	.write_begin = nnpfs_write_begin,
-	.write_end = nnpfs_write_end,
+	.write_end = simple_write_end,
 #endif
 };
 
@@ -2027,8 +2272,13 @@ struct address_space_operations nnpfs_ao
  */
 
 struct file_operations nnpfs_file_operations = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
     .aio_read	= nnpfs_aio_read,
     .aio_write	= nnpfs_aio_write,
+#else
+    .read_iter	= nnpfs_read_iter,
+    .write_iter	= nnpfs_write_iter,
+#endif
     .mmap	= nnpfs_file_mmap,
     .open	= nnpfs_open,
     .flush	= nnpfs_flush,
@@ -2041,7 +2291,11 @@ struct file_operations nnpfs_dead_operat
 };
 
 struct file_operations nnpfs_dir_operations = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
     .readdir	= nnpfs_readdir,
+#else
+    .iterate    = nnpfs_iterate,
+#endif
     .flush	= nnpfs_flush,
 };
 
@@ -2078,6 +2332,10 @@ struct inode_operations nnpfs_dead_inode
 
 struct inode_operations nnpfs_link_inode_operations = {
     .readlink 		= nnpfs_readlink,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
     .follow_link 	= nnpfs_follow_link,
     .put_link 		= page_put_link,
+#else
+    .get_link		= nnpfs_get_link,
+#endif
 };
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_load.c arla/nnpfs/linux/nnpfs_load.c
--- arla-cvs-old/nnpfs/linux/nnpfs_load.c	2006-10-31 11:02:41.000000000 +0100
+++ arla/nnpfs/linux/nnpfs_load.c	2016-01-13 20:14:02.000000000 +0100
@@ -54,7 +54,11 @@ extern struct file_operations nnpfs_fops
 
 struct file_system_type nnpfs_fs_type = {
        name:           "nnpfs",
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
        get_sb:         nnpfs_get_sb,
+#else
+       mount:          nnpfs_mount,
+#endif
        kill_sb:        kill_litter_super,
        owner:          THIS_MODULE,
 };
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_message.c arla/nnpfs/linux/nnpfs_message.c
--- arla-cvs-old/nnpfs/linux/nnpfs_message.c	2010-08-08 22:43:05.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_message.c	2016-01-24 18:52:28.000000000 +0100
@@ -55,9 +55,15 @@ static void
 nnpfs_d_remove(struct dentry *dentry)
 {
     NNPFSDEB(XDEBMSG, ("nnpfs_d_remove %p\n", dentry));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
     spin_lock(&dcache_lock);
     dget_locked(dentry);
     spin_unlock(&dcache_lock);
+#else
+    spin_lock(&dentry->d_lock);
+    dget_dlock(dentry);
+    spin_unlock(&dentry->d_lock);
+#endif
     d_drop(dentry);
     dput(dentry);
 }
@@ -121,7 +127,11 @@ nnpfs_message_installnode(struct nnpfs *
     struct inode *di, *inode;
     struct dentry *parent = NULL;
     struct qstr sqstr;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     struct list_head *alias;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    struct hlist_node *alias;
+#endif
     
     NNPFSDEB(XDEBMSG, ("nnpfs_message_installnode\n"));
     
@@ -176,12 +186,26 @@ nnpfs_message_installnode(struct nnpfs *
      *
      */
     
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     alias = di->i_dentry.next;
     while (alias != &di->i_dentry) {
 	parent = list_entry(alias, struct dentry, d_alias);
-	spin_lock(&dcache_lock);
-	dget_locked(parent);
-	spin_unlock(&dcache_lock);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    hlist_for_each_entry(parent, alias, &di->i_dentry, d_alias) {
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    hlist_for_each_entry(parent, &di->i_dentry, d_alias) {
+#else
+    hlist_for_each_entry(parent, &di->i_dentry, d_u.d_alias) {
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
+    spin_lock(&dcache_lock);
+    dget_locked(parent);
+    spin_unlock(&dcache_lock);
+#else
+    spin_lock(&parent->d_lock);
+    dget_dlock(parent);
+    spin_unlock(&parent->d_lock);
+#endif
 	dentry = d_lookup(parent, &sqstr);
 	NNPFSDEB(XDEBMSG,
 		 ("nnpfs_message_installnode: alias %p, lookup %p\n",
@@ -233,7 +257,9 @@ nnpfs_message_installnode(struct nnpfs *
 	
 	dput(dentry);
 	dentry = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 	alias = alias->next;
+#endif
 	dput(parent);
     }
     NNPFSDEB(XDEBMSG, ("nnpfs_message_installnode: done installing\n"));
@@ -268,7 +294,13 @@ nnpfs_message_installattr(struct nnpfs *
     }
 
     inode = XNODE_TO_VNODE(t);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    dentry = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
+#else
+    dentry = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
+#endif
     
     NNPFSDEB(XDEBMSG, ("nnpfs_message_installattr name:%s\n",
 		       dentry->d_name.name));
@@ -396,17 +428,35 @@ nnpfs_message_installdata(struct nnpfs *
 static void
 clear_all_children (struct inode *inode, int parent)
 {
+    struct dentry *dentry;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     struct list_head *alias;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    struct hlist_node *alias;
+#endif
 
  again:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
     spin_lock(&dcache_lock);
+#else
+    spin_lock(&inode->i_lock);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     alias = inode->i_dentry.next;
     while (alias != &inode->i_dentry) {
-	struct dentry *dentry;
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    hlist_for_each_entry(dentry, alias, &inode->i_dentry, d_alias) {
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
+#else
+    hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
+#endif
 	struct list_head *subdirs;
 	struct nnpfs_dentry_data *xd;
 	
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 	dentry = list_entry(alias, struct dentry, d_alias);
+#endif
 	if (dentry == NULL) {
 	    printk(KERN_EMERG "NNPFS Panic: dentry in alias list is null\n");
 	    break;
@@ -422,7 +472,11 @@ clear_all_children (struct inode *inode,
 	subdirs = dentry->d_subdirs.next;
 	while (subdirs != &dentry->d_subdirs) {
 	    struct list_head *tmp = subdirs;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	    struct dentry *child = list_entry(tmp, struct dentry, d_u.d_child);
+#else
+	    struct dentry *child = list_entry(tmp, struct dentry, d_child);
+#endif
 	    subdirs = tmp->next;
 	    NNPFSDEB(XDEBMSG, ("clear_all_children child: %.*s inode: %p/%p "
 			       "dcount: %d aliases:\n",
@@ -442,14 +496,24 @@ clear_all_children (struct inode *inode,
 
 	    /* Throw immediately */
 	    if (nnpfs_dcount(child) == 0) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
 	        spin_unlock(&dcache_lock);
+#else
+	        spin_unlock(&inode->i_lock);
+#endif
 		nnpfs_d_remove(child);
 		goto again;
 	    }
 	}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 	alias = alias->next;
+#endif
     }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
     spin_unlock(&dcache_lock);
+#else
+    spin_unlock(&inode->i_lock);
+#endif
 }
 
 static void
@@ -719,12 +783,22 @@ nnpfs_message_version(struct nnpfs *nnpf
 
     /* sanity check before we look at it */
     if (size == sizeof(*message) && message->version == NNPFS_VERSION) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	struct nameidata nd;
+#else
+	struct path path;
+#endif
 	int error;
 
 	uint64_t blocksize = message->blocksize;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 	error = path_lookup(".", 0, &nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+	error = kern_path(".", 0, &nd.path);
+#else
+	error = kern_path(".", 0, &path);
+#endif
 	if (error) {
 	    /*
 	     * Bad cache root, just return.
@@ -735,11 +809,17 @@ nnpfs_message_version(struct nnpfs *nnpf
 		   "nnpfs_message_version failed path_lookup, "
 		   "errno: %d\n", error);
 	} else {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	    nnpfsp->cacheroot = mntget(nd.path.mnt);
 	    nnpfsp->cachedir = dget(nd.path.dentry);
 	    path_put(&nd.path);
+#else
+	    nnpfsp->cacheroot = mntget(path.mnt);
+	    nnpfsp->cachedir = dget(path.dentry);
+	    path_put(&path);
+#endif
 	    
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
 	    nnpfsp->uid = current->fsuid;
 	    nnpfsp->gid = current->fsgid;
 #else
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_node.c arla/nnpfs/linux/nnpfs_node.c
--- arla-cvs-old/nnpfs/linux/nnpfs_node.c	2007-01-03 14:52:02.000000000 +0100
+++ arla/nnpfs/linux/nnpfs_node.c	2016-05-06 17:01:10.000000000 +0200
@@ -132,7 +132,12 @@ nnpfs_setsize(struct inode *inode, uint6
 	printk("nnpfs_setsize: truncating @0x%llu\n",
 	       (unsigned long long)size);
 #endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
 	vmtruncate(inode, size); /* XXX retval */
+#else
+	if(!inode_newsize_ok(inode, size))
+	    truncate_setsize(inode, size);
+#endif
 	nnpfs_block_truncate(xn, size);
     }
 }
@@ -150,9 +155,18 @@ nnpfs_attr2inode(const struct nnpfs_attr
 	struct timespec notime = {0};
 
 	inode->i_mode   = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 	inode->i_uid    = 0;
 	inode->i_gid    = 0;
+#else
+	inode->i_uid    = KUIDT_INIT(0);
+	inode->i_gid    = KGIDT_INIT(0);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
 	inode->i_nlink  = 1;
+#else
+	set_nlink(inode, 1);
+#endif
 	inode->i_atime  = notime;
 	inode->i_mtime  = notime;
 	inode->i_ctime  = notime;
@@ -169,7 +183,11 @@ nnpfs_attr2inode(const struct nnpfs_attr
     if (XA_VALID_GID(attr))
 	inode->i_gid    = attr->xa_gid;
     if (XA_VALID_NLINK(attr))
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
 	inode->i_nlink  = attr->xa_nlink;
+#else
+	set_nlink(inode, attr->xa_nlink);
+#endif
     
     if (XA_VALID_SIZE(attr)) {
 	nnpfs_setsize(inode, attr->xa_size);
@@ -266,6 +284,9 @@ nnpfs_fill_inode(struct inode *inode, st
 	inode->i_op  = &nnpfs_link_inode_operations;
 	inode->i_fop = &nnpfs_link_operations;
 	inode->i_mapping->a_ops = &nnpfs_aops;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
+	inode_nohighmem(inode);
+#endif
     } else {
 	inode->i_op  = &nnpfs_dead_inode_operations;
 	inode->i_fop = &nnpfs_dead_operations;
@@ -510,12 +531,24 @@ nnpfs_has_pag(const struct nnpfs_node *x
 int
 nnpfs_node_users(struct inode *inode)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     struct list_head *pos;
+#else
+    struct hlist_node *pos;
+#endif
     int users = 0;
     
     /* XXX this should probably be protected somehow */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     list_for_each(pos, &inode->i_dentry) {
+#else
+    hlist_for_each(pos, &inode->i_dentry) {
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	struct dentry *dentry = list_entry(pos, struct dentry, d_alias);
+#else
+	struct dentry *dentry = list_entry(pos, struct dentry, d_u.d_alias);
+#endif
 	if (nnpfs_dcount(dentry) > 1)
 	    users++;
     }
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_syscalls.c arla/nnpfs/linux/nnpfs_syscalls.c
--- arla-cvs-old/nnpfs/linux/nnpfs_syscalls.c	2010-08-08 22:43:06.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_syscalls.c	2016-02-20 19:43:42.000000000 +0100
@@ -42,7 +42,9 @@
 #include <nnpfs/nnpfs_syscalls.h>
 #include <nnpfs/nnpfs_common.h>
 #include <linux/file.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 #include <linux/smp_lock.h>
+#endif
 #include <linux/smp.h>
 #include <linux/proc_fs.h>
 
@@ -50,6 +52,11 @@
 #include <linux/security.h>
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+#undef SYSCALLHACK
+/* the method to read 'lower_bound' does not work on kernel 3.7 and later, se nnpfs_syscalls-lossage.c */
+#endif
+
 #if 0
 #ifdef CONFIG_COMPAT
 #include <linux/ioctl32.h>
@@ -82,12 +89,22 @@ typedef struct afsprocdata {
     unsigned long syscall;
 } afsprocdata;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
 static int
 nnpfs_procfs_ioctl(struct inode *inode, struct file *file,
 		   unsigned int cmd, unsigned long arg);
+#else
+static long
+nnpfs_procfs_ioctl(struct file *file,
+		   unsigned int cmd, unsigned long arg);
+#endif
 
 static struct file_operations nnpfs_procfs_fops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
     .ioctl = nnpfs_procfs_ioctl,
+#else
+    .unlocked_ioctl = nnpfs_procfs_ioctl,
+#endif
 };
 
 
@@ -160,8 +177,10 @@ nnpfs_get_pag_sec(void)
 
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
     return current->uid;
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     return current_uid();
+#else
+    { kuid_t kuid = current_uid(); return kuid.val; }
 #endif
 }
 
@@ -199,7 +218,12 @@ find_pag(struct group_info *gi)
     NNPFSDEB(XDEBSYS, ("find_pag: ngroups = %d\n", gi->ngroups));
 
     for (i = gi->ngroups - 1; i >= 0; i--) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 	gid_t group = GROUP_AT(gi, i);
+#else
+	kgid_t kgroup = GROUP_AT(gi, i);
+	gid_t group = kgroup.val;
+#endif
 	if ((nnpfs_pag_t)group >= NNPFS_PAG_LLIM && (nnpfs_pag_t)group < NNPFS_PAG_ULIM) {
 	    NNPFSDEB(XDEBSYS,
 		     ("find_pag: Existing pag %u at pos %u\n", group, i));
@@ -220,7 +244,12 @@ nnpfs_get_pag_group(void)
     nnpfs_pag_t ret = current->uid;
 #else
     struct group_info *gi = get_current_groups();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     nnpfs_pag_t ret = current_uid();
+#else
+    kuid_t kuid = current_uid();
+    nnpfs_pag_t ret = kuid.val;
+#endif
 #endif
     int i;
 
@@ -230,7 +259,11 @@ nnpfs_get_pag_group(void)
 
     i = find_pag(gi);
     if (i != NNPFS_PAG_NOTFOUND)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 	ret = GROUP_AT(gi, i);
+#else
+	{ kgid_t kgid = GROUP_AT(gi, i); ret = kgid.val; }
+#endif
 
     put_group_info(gi);
 
@@ -280,10 +313,17 @@ store_pag(nnpfs_pag_t pagnum)
 	count -= NGROUPS_PER_BLOCK;
     }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     if (found)
 	GROUP_AT(new_gi, i) = pagnum;
     else
 	GROUP_AT(new_gi, new_gi->ngroups - 1) = pagnum;
+#else
+    if (found)
+	{ kgid_t kgid = KGIDT_INIT(pagnum); GROUP_AT(new_gi, i) = kgid; }
+    else
+	{ kgid_t kgid = KGIDT_INIT(pagnum); GROUP_AT(new_gi, new_gi->ngroups - 1) = kgid; }
+#endif
     
     set_current_groups(new_gi);
     put_group_info(new_gi);
@@ -325,8 +365,10 @@ nnpfs_get_pag()
 
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
     return current->uid;
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     return current_uid();
+#else
+    { kuid_t kuid = current_uid(); return kuid.val; }
 #endif
 }
 
@@ -432,7 +474,7 @@ nnpfs_setgroups16 (int gidsetsize, old_g
 #endif /* SYSCALLHACK */
 #endif /* GROUPPAGS */
 
-struct file_handle {
+struct nnpfs_file_handle {
     nnpfs_dev_t dev;
     ino_t inode;
     __u32 gen;
@@ -519,26 +561,58 @@ nnpfs_debug_print (struct arlaViceIoctl 
  * follow symlinks iff `follow'
  */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 static struct dentry *
 user_path2dentry (struct nameidata *nd, char *user_path, int follow)
+#else
+static struct dentry *
+user_path2dentry (struct path *path, char *user_path, int follow)
+#endif
 {
     char *kname;
     int flags = 0;
     int error = 0;
 
-    kname = getname (user_path);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
+    kname = getname(user_path);
+#else
+    kname = __getname();
+#endif
+
     if (IS_ERR(kname))
 	return ERR_PTR(PTR_ERR(kname));
     if (follow)
 	flags |= LOOKUP_FOLLOW;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+    error = strncpy_from_user(kname, user_path, PATH_MAX);
+    if (error < 0 || error == PATH_MAX) {
+	__putname(kname);
+	return ERR_PTR(error);
+    }
+#endif
+
     NNPFSDEB(XDEBMSG, ("nnpfs_syscall: looking up: %s\n", kname));
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
     error = path_lookup(kname, flags, nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+    error = kern_path(kname, flags, &(nd->path));
+#else
+    error = kern_path(kname, flags, path);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
     putname(kname);
+#else
+    __putname(kname);
+#endif
     if (error)
 	return ERR_PTR(error);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     return nd->path.dentry;
+#else
+    return path->dentry;
+#endif
 }
 
 asmlinkage long
@@ -553,13 +627,21 @@ sys_afs_int (int operation,
     struct nnpfs_message_pioctl *msg = NULL;
     struct nnpfs_message_wakeup *msg2;
     struct dentry *dentry = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
     struct nameidata nd;
+#else
+    struct path path;
+#endif
     
     msg = kmalloc(sizeof(*msg), GFP_KERNEL);
     if (msg == NULL)
       return -ENOMEM;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
     lock_kernel();
+#else
+    /* XXX lock_kernel() is removed, consider adding an private lock */
+#endif
 
     NNPFSDEB(XDEBSYS, ("sys_afs kernel locked\n"));
 
@@ -597,7 +679,11 @@ sys_afs_int (int operation,
 	    }
 	}
 	if (a_pathP != NULL) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	    dentry = user_path2dentry (&nd, a_pathP, a_followSymlinks);
+#else
+	    dentry = user_path2dentry (&path, a_pathP, a_followSymlinks);
+#endif
 	    if (!dentry) {
 		error = -EINVAL;
 		goto unlock;
@@ -693,13 +779,21 @@ sys_afs_int (int operation,
     
  unlock:
     if (dentry)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	path_put(&nd.path);
+#else
+	path_put(&path);
+#endif
 
     NNPFSDEB(XDEBSYS, ("nnpfs_syscall returns error: %ld\n", error));
 
     NNPFSDEB(XDEBSYS, ("sys_afs kernel unlock\n"));
     kfree(msg);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
     unlock_kernel();
+#else
+    /* XXX see the comment at lock_kernel() above */
+#endif
 
     return error;
 }
@@ -748,9 +842,15 @@ sys_afs (int operation,
 		       a_followSymlinks);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
 static int
 nnpfs_procfs_ioctl(struct inode *inode, struct file *file,
 		   unsigned int cmd, unsigned long arg)
+#else
+static long
+nnpfs_procfs_ioctl(struct file *file,
+		   unsigned int cmd, unsigned long arg)
+#endif
 {
     afsprocdata args;
     long ret;
@@ -807,7 +907,11 @@ static int nnpfs_init_procfs(void)
     nnpfs_procfs_dir->owner = THIS_MODULE;
 #endif
     
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
     entry = create_proc_entry(NNPFS_PROC_NODE, 0666, nnpfs_procfs_dir);
+#else
+    entry = proc_create(NNPFS_PROC_NODE, 0666, NULL, &nnpfs_procfs_fops);
+#endif
     if (entry == NULL) {
 	NNPFSDEB(XDEBSYS, ("nnpfs_init_procfs: no node\n"));
 	remove_proc_entry("fs/" NNPFS_PROC_DIR, NULL);
@@ -817,7 +921,9 @@ static int nnpfs_init_procfs(void)
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
     entry->owner = THIS_MODULE;
 #endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
     entry->proc_fops = &nnpfs_procfs_fops;
+#endif
 
 #ifdef SYSCALLCOMPAT
     if (register_ioctl32_conversion(ARLA_VIOC_SYSCALL32, nnpfs_procfs_ioctl32)) {
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_syscalls-lossage.c arla/nnpfs/linux/nnpfs_syscalls-lossage.c
--- arla-cvs-old/nnpfs/linux/nnpfs_syscalls-lossage.c	2010-08-08 22:43:05.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_syscalls-lossage.c	2016-01-13 21:51:49.000000000 +0100
@@ -50,8 +50,17 @@
 RCSID("$Id: nnpfs_syscalls-lossage.c,v 1.19 2010/08/08 20:43:05 tol Exp $");
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+/* the method to read 'lower_bound' does not work on kernel 3.7 and later */
+#undef SYSCALLHACK
+#endif
+
 #include <linux/kallsyms.h>
+#ifdef SYSCALLHACK
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
 static void *lower_bound = &kernel_thread;
+#endif
+#endif
 
 void * __attribute__((weak)) sys_call_table(void);
 nnpfs_sys_call_function *nnpfs_sys_call_table =
@@ -66,6 +75,8 @@ const char * __attribute__((weak))
 #ifdef __x86_64__
 extern rwlock_t tasklist_lock __attribute__((weak));
 #endif
+
+#ifdef SYSCALLHACK
 static void **
 get_start_addr(void) {
 #ifdef __x86_64__
@@ -74,6 +85,7 @@ get_start_addr(void) {
     return (void **)&mutex_lock;
 #endif
 }
+#endif
 
 static inline int 
 kallsym_is_equal(unsigned long addr, const char *name)
@@ -142,6 +154,8 @@ verify(void **p) {
     return 1;
 }
 
+#ifdef SYSCALLHACK
+
 static inline int looks_good(void **p)
 {
     if (*p <= (void*)lower_bound || *p >= (void*)p)
@@ -191,3 +205,5 @@ nnpfs_fixup_syscall_lossage(void)
 
     return 0;
 }
+
+#endif
diff -uprN -Xnodiff arla-cvs-old/nnpfs/linux/nnpfs_vfsops.c arla/nnpfs/linux/nnpfs_vfsops.c
--- arla-cvs-old/nnpfs/linux/nnpfs_vfsops.c	2010-08-08 22:43:06.000000000 +0200
+++ arla/nnpfs/linux/nnpfs_vfsops.c	2016-02-14 01:36:06.000000000 +0100
@@ -50,7 +50,9 @@ RCSID("$Id: nnpfs_vfsops.c,v 1.111 2010/
 struct nnpfs nnpfs[NNNPFS];
 
 static void nnpfs_put_super(struct super_block *sb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 static void nnpfs_write_super(struct super_block * sb);
+#endif
 
 static int nnpfs_statfs(struct dentry *dentry, struct kstatfs *buf);
 
@@ -59,7 +61,9 @@ static struct super_operations nnpfs_sop
     destroy_inode	: nnpfs_node_free,
     drop_inode		: generic_delete_inode,
     put_super		: nnpfs_put_super,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
     write_super		: nnpfs_write_super,
+#endif
     statfs		: nnpfs_statfs,
 };
 
@@ -86,7 +90,11 @@ nnpfs_fetch_root(struct inode *i)
 	 * root's priviliges (usually none, and none is needed).
 	 */
 	
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 	msg.cred.uid = 0;
+#else
+	msg.cred.uid = KUIDT_INIT(0);
+#endif
 	msg.cred.pag = 0;
 	
 	error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
@@ -121,8 +129,13 @@ make_root_inode(struct nnpfs *nnpfsp)
     XA_SET_MODE(&node.attr, S_IFDIR | 0777);
     XA_SET_NLINK(&node.attr, 100);
     XA_SET_SIZE(&node.attr, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
     XA_SET_UID(&node.attr, 0);
     XA_SET_GID(&node.attr, 0);
+#else
+    XA_SET_UID(&node.attr, KUIDT_INIT(0));
+    XA_SET_GID(&node.attr, KGIDT_INIT(0));
+#endif
     XA_SET_ATIME(&node.attr, 0);
     XA_SET_MTIME(&node.attr, 0);
     XA_SET_CTIME(&node.attr, 0);
@@ -151,7 +164,11 @@ make_root (struct super_block *sb)
     nnpfs->root = inode;
 
     /* XXX error handling */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
     dp = d_alloc_root(inode);
+#else
+    dp = d_make_root(inode);
+#endif
     nnpfs_d_init(dp);
     sb->s_root = dp;
     return 0;
@@ -175,13 +192,27 @@ nnpfs_read_super (struct super_block * s
     NNPFSDEB(XDEBVFOPS, ("nnpfs_read_super: begin setting variables\n"));
 
     if (data != NULL) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	struct nameidata nd;
+#else
+	struct path path;
+#endif
 	
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 	error = path_lookup(data, 0, &nd);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+	error = kern_path(data, 0, &nd.path);
+#else
+	error = kern_path(data, 0, &path);
+#endif
 	if (error)
 	    ddev = ERR_PTR(error);
 	else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 	    ddev = nd.path.dentry;
+#else
+	    ddev = path.dentry;
+#endif
 
 	if (!IS_ERR(ddev)) {
 	    minordevice = MINOR(ddev->d_inode->i_rdev);
@@ -225,6 +256,7 @@ nnpfs_fill_super (struct super_block *sb
     return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 int
 nnpfs_get_sb(struct file_system_type *fs_type,
 	     int flags, const char *dev_name,
@@ -232,12 +264,23 @@ nnpfs_get_sb(struct file_system_type *fs
 {
     return get_sb_nodev(fs_type, flags, data, nnpfs_fill_super, mnt);
 }
+#else
+struct dentry*
+nnpfs_mount(struct file_system_type *fs_type,
+	     int flags, const char *dev_name,
+	     void *data) 
+{
+    return mount_nodev(fs_type, flags, data, nnpfs_fill_super);
+}
+#endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
 static void
 nnpfs_write_super(struct super_block * sb)
 {
     sb->s_dirt = 0;
 }
+#endif
 
 /*
  * XXX is this good? 
@@ -276,7 +319,11 @@ nnpfs_statfs_int(struct super_block *sb,
     tmp.f_spare[1] = 0;
     tmp.f_spare[2] = 0;
     tmp.f_spare[3] = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
     tmp.f_spare[4] = 0;
+#else
+    tmp.f_flags = 0;
+#endif
     *buf = tmp;
     return 0;
 }


More information about the Arla-drinkers mailing list