PATCH: Arla 0.90 on Linux 2.6.34 to 3.11

Bo Branten bosse at acc.umu.se
Tue Jan 12 14:07:31 CET 2016


The latest patch for Arla 0.90 on Linux 2.6.34 to 3.11:

diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs/nnnpfs.h arla-for-linux-3.11/nnpfs/linux/nnpfs/nnnpfs.h
--- arla-0.90/nnpfs/linux/nnpfs/nnnpfs.h	2002-09-07 12:47:17.000000000 +0200
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs/nnnpfs.h	2002-09-07 12:47:17.000000000 +0200
@@ -1,4 +1,4 @@
  /* $Id: nnnpfs.h,v 1.2 2002/09/07 10:47:17 lha Exp $ */
-/* $Source: /afs/stacken.kth.se/src/SourceRepository/arla/nnpfs/linux/nnpfs/nnnpfs.h,v $ */
+/* $Source: /Users/bo/tmp/ArlaSourceRepository/arla/nnpfs/linux/nnpfs/nnnpfs.h,v $ */

  #define NNNPFS 2
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs/nnpfs_locl.h arla-for-linux-3.11/nnpfs/linux/nnpfs/nnpfs_locl.h
--- arla-0.90/nnpfs/linux/nnpfs/nnpfs_locl.h	2007-01-08 14:52:49.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs/nnpfs_locl.h	2016-01-11 21:17:42.878326124 +0100
@@ -34,7 +34,7 @@
   * SUCH DAMAGE.
   */

-/* $Id: nnpfs_locl.h,v 1.77 2007/01/08 13:52:49 tol Exp $ */
+/* $Id: nnpfs_locl.h,v 1.78 2010/08/08 20:43:06 tol Exp $ */

  #ifdef HAVE_CONFIG_H
  #include <config.h>
@@ -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,15 +140,16 @@ typedef __u32  uint32_t;
  int
  nnpfs_fetch_root(struct inode *i);

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+#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 super_block *
-nnpfs_get_sb (struct file_system_type *fs_type,
-	      int flags, const char *dev_name, void *data);
+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;
@@ -200,16 +203,27 @@ 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);
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+    return atomic_read((const atomic_t*)&dentry->d_count);
+#else
+    return d_count(dentry);;
+#endif
+#endif
  }

  extern 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
  const
-#endif
  struct address_space_operations nnpfs_aops;

  #ifndef list_for_each
@@ -237,7 +251,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.txt arla-0.90/nnpfs/linux/nnpfs/nnpfs_node.h arla-for-linux-3.11/nnpfs/linux/nnpfs/nnpfs_node.h
--- arla-0.90/nnpfs/linux/nnpfs/nnpfs_node.h	2006-12-11 17:29:39.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs/nnpfs_node.h	2010-08-08 22:43:07.000000000 +0200
@@ -54,7 +54,7 @@ extern uint32_t nnpfs_blocksizebits;
   * flags.
   */

-#define NNPFS_NODE_IPUT	0x00010000   /* node is in iput(), avoid deadlock */
+#define NNPFS_NODE_IPUT	0x00010000   /* node is in iput(), avoid deadlock. Can be removed? */

  #define XN_HASHSIZE 1009
  #define XN_CLEANUP_ITERS 129
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_blocks.c arla-for-linux-3.11/nnpfs/linux/nnpfs_blocks.c
--- arla-0.90/nnpfs/linux/nnpfs_blocks.c	2007-01-08 14:24:24.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_blocks.c	2016-01-12 13:43:12.825379695 +0100
@@ -34,7 +34,7 @@
   * POSSIBILITY OF SUCH DAMAGE.
   */

-/* $Id: nnpfs_blocks.c,v 1.3 2007/01/08 13:24:24 tol Exp $ */
+/* $Id: nnpfs_blocks.c,v 1.6 2010/08/08 20:43:04 tol Exp $ */

  #include <nnpfs/nnpfs_locl.h>
  #include <nnpfs/nnpfs_fs.h>
@@ -290,7 +290,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
+    if(!inode_newsize_ok(backnode, nnpfs_blocksize)) {
+        truncate_setsize(backnode, nnpfs_blocksize);
+    }
+#endif
      mutex_unlock(&backnode->i_mutex);

      filp_close(backfile, NULL);
@@ -322,6 +328,13 @@ nnpfs_block_open(struct nnpfs_node *node
      uid_t saveuid;
      gid_t savegid;
      int ret;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+    const struct cred *old_cred;
+    struct cred *override_cred;
+#endif
+
+    (void)saveuid;
+    (void)savegid;

      BUG_ON(!nnpfsp);
      BUG_ON(flags & O_CREAT && file != NULL);
@@ -346,22 +359,34 @@ 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)
      saveuid = current->fsuid;
      savegid = current->fsgid;
      current->fsuid = nnpfsp->uid;
      current->fsgid = nnpfsp->gid;
-
-    nd.dentry = dget(nnpfsp->cachedir);
-    nd.mnt = mntget(nnpfsp->cacheroot);
-    nd.last_type = LAST_NORM;
-    nd.depth = 0;
-    nd.flags = 0;
- 
-    if (flags & O_CREAT)
-	nd.flags = LOOKUP_PARENT;
- 
-    ret = path_walk(cachename, &nd);
-    if (ret) {
+#else
+    saveuid = current_fsuid();
+    savegid = current_fsgid();
+    override_cred = prepare_creds();
+    if (override_cred == NULL)
+        return -ENOMEM;
+    override_cred->fsuid = nnpfsp->uid;
+    override_cred->fsgid = nnpfsp->gid;
+    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);
+#else
+    ret = vfs_path_lookup(nnpfsp->cachedir, nnpfsp->cacheroot,
+			  cachename,
+			  flags & O_CREAT ? LOOKUP_PARENT : 0,
+			  &nd.path);
+#endif
+     if (ret) {
  	uint32_t nmasks = node->data.nmasks;
  	uint32_t mask;

@@ -387,16 +412,26 @@ 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); 
+#else
+	/* TODO: check the call to kern_path_create(), is the second argument optional? */
+	struct dentry *dentry = kern_path_create(AT_FDCWD, NULL, &nd.path, 0); 
+#endif
  	if (IS_ERR(dentry)) {
  	    ret = PTR_ERR(dentry);
  	} else {
-	    ret = vfs_create(nd.dentry->d_inode, dentry, S_IRUSR|S_IWUSR, &nd);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
+	    ret = vfs_create(nd.path.dentry->d_inode, dentry, S_IRUSR|S_IWUSR, &nd);
+#else
+	    /* TODO: 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);
+#endif
  	    dput(dentry);
  	}

-	mutex_unlock(&nd.dentry->d_inode->i_mutex);
-	path_release(&nd);
+	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);
@@ -410,12 +445,21 @@ nnpfs_block_open(struct nnpfs_node *node
  	    ret = nnpfs_block_extend(node, offset);
  	}
      } else {
-	struct file *f = dentry_open(nd.dentry, nd.mnt, flags);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
+	struct file *f = dentry_open(nd.path.dentry, nd.path.mnt, flags);
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
+        struct file *f = dentry_open(nd.path.dentry, nd.path.mnt, flags, current_cred());
+#else
+	struct path path = { .mnt = nd.path.mnt, .dentry = nd.path.dentry };
+        struct file *f = dentry_open(&path, flags, current_cred());
+#endif
+#endif
  	if (IS_ERR(f)) {
  	    ret = PTR_ERR(f);
  	    printk("nnpfs_block_open(%s) open failed: %d\n", cachename, -ret);
  	    nnpfs_debug_oops();
-	    path_release(&nd);
+	    path_put(&nd.path);
  	} else {
  	    *file = f;
  	}
@@ -424,8 +468,13 @@ nnpfs_block_open(struct nnpfs_node *node
      /* path_release() is usually handled on close */

   out:
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      current->fsuid = saveuid;
      current->fsgid = savegid;
+#else
+    revert_creds(old_cred);
+    put_cred(override_cred);
+#endif

      return ret;
  }
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_common.c arla-for-linux-3.11/nnpfs/linux/nnpfs_common.c
--- arla-0.90/nnpfs/linux/nnpfs_common.c	2006-12-11 17:31:46.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_common.c	2016-01-11 20:47:22.874406174 +0100
@@ -112,10 +112,17 @@ 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;
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
+    struct hlist_node *alias;
+#endif
+#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 +138,24 @@ 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) {
+#else
+    hlist_for_each_entry(dentry, &inode->i_dentry, 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");
  }

diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_dev.c arla-for-linux-3.11/nnpfs/linux/nnpfs_dev.c
--- arla-0.90/nnpfs/linux/nnpfs_dev.c	2006-10-24 18:33:36.000000000 +0200
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_dev.c	2016-01-10 16:51:25.462254468 +0100
@@ -300,8 +300,10 @@ 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"));
  }

@@ -505,12 +507,23 @@ 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_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));
+#else
+    NNPFSDEB(XDEBDEV, ("nnpfs_devioctl dev = %d, flags = %d\n",
+		       file->f_dentry->d_inode->i_rdev, file->f_flags));
+#endif
      return -EINVAL;
  }

@@ -953,7 +966,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_devioctl,
+#endif
      release:		nnpfs_devclose,
      open:		nnpfs_devopen,
  };
@@ -968,8 +985,16 @@ 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);
+#else
+	sema_init(&nnpfs[i].inactive_sem, 1);
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
  	init_MUTEX(&nnpfs[i].channel_sem);
+#else
+	sema_init(&nnpfs[i].channel_sem, 1);
+#endif
  	INIT_LIST_HEAD(&nnpfs[i].inactive_list);
  	nnpfs[i].nnodes = 0;
      }
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_inodeops.c arla-for-linux-3.11/nnpfs/linux/nnpfs_inodeops.c
--- arla-0.90/nnpfs/linux/nnpfs_inodeops.c	2006-12-11 17:35:26.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_inodeops.c	2016-01-12 13:44:55.965383129 +0100
@@ -40,6 +40,7 @@
  #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>
@@ -48,17 +49,29 @@
  #include <asm/fcntl.h>

  #ifdef RCSID
-RCSID("$Id: nnpfs_inodeops.c,v 1.223 2006/12/11 16:35:26 tol Exp $");
+RCSID("$Id: nnpfs_inodeops.c,v 1.226 2010/08/08 20:43:04 tol Exp $");
  #endif

  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);
@@ -105,7 +118,7 @@ nnpfs_vma_close (struct vm_area_struct *
  }

  static struct vm_operations_struct nnpfs_file_vm_ops = {
-    .nopage	= filemap_nopage,
+    .fault      = filemap_fault,
      .close	= nnpfs_vma_close,
  };

@@ -134,12 +147,14 @@ nnpfs_print_path(struct dentry *dentry)
   *
   */

+#if 0
  void
  nnpfs_print_lock(char *s, struct semaphore *sem)
  {
      NNPFSDEB(XDEBLOCK, ("lock: %s sem: %p count: %d\n",
  		      s, sem, (int)atomic_read(&sem->count)));
  }
+#endif

  /*
   *
@@ -185,7 +200,7 @@ nnpfs_d_iput(struct dentry *dentry, stru
      NNPFSDEB(XDEBVNOPS,
  	     ("nnpfs_d_iput: dentry %p, inode %p\n", dentry, inode));

-    if (node->flags & NNPFS_NODE_IPUT) /* XXX locking */
+    if (node->flags & NNPFS_NODE_IPUT) /* XXX locking. never set? */
  	nnpfs_irele(inode);
      else
  	iput(inode);
@@ -212,8 +227,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;
@@ -240,7 +260,11 @@ nnpfs_lookup (struct inode *dir, struct

  	msg.header.opcode = NNPFS_MSG_GETNODE;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.cred.pag = nnpfs_get_pag();
  	msg.parent_handle = d->handle;

@@ -310,7 +334,11 @@ nnpfs_open_valid(struct inode *vp, u_int
        {
  	struct nnpfs_message_open msg;
  	msg.header.opcode = NNPFS_MSG_OPEN;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.cred.pag = nnpfs_get_pag();
  	msg.handle = xn->handle;
  	msg.tokens = tok;
@@ -425,7 +453,11 @@ nnpfs_fsync_int(struct file *file, u_int

  	msg.header.opcode = NNPFS_MSG_PUTDATA;
  	msg.cred.pag = nnpfs_get_pag();
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.handle = xn->handle;
  	msg.flag   = flag;
  	msg.offset = off;
@@ -460,14 +492,29 @@ nnpfs_fsync_int(struct file *file, u_int
   *
   */

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
  static int
  nnpfs_fsync(struct file *file, struct dentry *dentry, int datasync)
+#else
+#if (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
+#endif
  {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+    struct dentry *dentry = file->f_path.dentry;
+#endif
      struct inode *inode = DENTRY_TO_INODE(dentry);
      struct nnpfs *nnpfsp;
      struct nnpfs_node *xn;
      int error = 0;

+    (void)nnpfsp;
+
      error = nnpfs_inode_valid(inode);
      if (error)
  	return error;
@@ -511,7 +558,11 @@ nnpfs_attr_valid(struct inode * vp, u_in
              struct nnpfs_message_getattr msg;

              msg.header.opcode = NNPFS_MSG_GETATTR;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
              msg.cred.uid = current->uid;
+#else
+            msg.cred.uid = current_uid();
+#endif
              msg.cred.pag = pag;
              msg.handle = xn->handle;
              error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
@@ -551,7 +602,11 @@ nnpfs_rights_valid(struct inode * vp, nn
              struct nnpfs_message_getattr msg;

              msg.header.opcode = NNPFS_MSG_GETATTR;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
              msg.cred.uid = current->uid;
+#else
+            msg.cred.uid = current_uid();
+#endif
              msg.cred.pag = pag;
              msg.handle = xn->handle;
              error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
@@ -592,11 +647,28 @@ 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, struct nameidata *nd)
+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;
+    /* TODO: verify the use of IPERM_FLAG_RCU and MAY_NOT_BLOCK */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+    if (flags & IPERM_FLAG_RCU)
+        return -ECHILD;
+#else
+    if (mode & MAY_NOT_BLOCK)
+        return -ECHILD;
+#endif
+#endif
+
+    pag = nnpfs_get_pag();

      NNPFSDEB(XDEBVNOPS, ("nnpfs_access (%p) mode = 0%o aliases:", inode, mode));
      nnpfs_print_aliases(inode);
@@ -636,7 +708,11 @@ nnpfs_do_getdata(struct nnpfs_node *xn,
      int error;

      msg.header.opcode = NNPFS_MSG_GETDATA;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      msg.cred.uid = current->uid;
+#else
+    msg.cred.uid = current_uid();
+#endif
      msg.cred.pag = nnpfs_get_pag();
      msg.handle = xn->handle;
      msg.tokens = tok;
@@ -791,18 +867,12 @@ int nnpfs_file_mmap(struct file * file,

  static ssize_t
  nnpfs_aio_read(struct kiocb *iocb,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
  	       const struct iovec *iov, unsigned long nr_segs,
-#else
-	       char __user *buf, size_t count,
-#endif
  	       loff_t pos)
  {
      int error = 0;
      struct file *file = iocb->ki_filp;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
      ssize_t count = iocb->ki_left;
-#endif
      struct inode *inode = file->f_dentry->d_inode;
      struct nnpfs_node *xn = VNODE_TO_XNODE(inode);

@@ -816,11 +886,7 @@ nnpfs_aio_read(struct kiocb *iocb,
  	return error;
      }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
      error = generic_file_aio_read(iocb, iov, nr_segs, pos);
-#else
-    error = generic_file_aio_read(iocb, buf, count, pos);
-#endif
      NNPFSDEB(XDEBVNOPS, ("nnpfs_read_file: error = %d\n", error));
      return error;
  }
@@ -831,18 +897,12 @@ nnpfs_aio_read(struct kiocb *iocb,

  static ssize_t
  nnpfs_aio_write(struct kiocb *iocb,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
  		const struct iovec *iov, unsigned long nr_segs,
-#else
-		const char __user *buf, size_t count, 
-#endif
  		loff_t pos)
  {
      int error = 0;
      struct file *file = iocb->ki_filp;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
      ssize_t count = iocb->ki_left;
-#endif
      struct inode *inode = file->f_dentry->d_inode;
      struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
      loff_t realpos = pos;
@@ -859,11 +919,7 @@ nnpfs_aio_write(struct kiocb *iocb,
  	return error;
      }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
      error = generic_file_aio_write(iocb, iov, nr_segs, pos);
-#else
-    error = generic_file_aio_write(iocb, buf, count, pos);
-#endif
      if (!IS_ERR_VALUE(error))
  	xn->flags |= NNPFS_DATA_DIRTY; /* XXX race */

@@ -871,9 +927,21 @@ 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)
+#else
+#if (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
+#endif
  {
      struct nnpfs *nnpfsp;
      struct nnpfs_node *xn;
@@ -903,9 +971,17 @@ nnpfs_create(struct inode *dir, struct d
      XA_CLEAR(&msg.attr);
      XA_SET_MODE(&msg.attr, mode);
      XA_SET_TYPE(&msg.attr, NNPFS_FILE_REG);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      XA_SET_GID(&msg.attr, current->fsgid);
+#else
+    XA_SET_GID(&msg.attr, current_fsgid());
+#endif
      msg.mode = 0;		/* XXX */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      msg.cred.uid = current->uid;
+#else
+    msg.cred.uid = current_uid();
+#endif
      msg.cred.pag = nnpfs_get_pag();
      error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
      if (error == 0)
@@ -946,7 +1022,11 @@ nnpfs_unlink (struct inode * dir, struct
      if (strlcpy(msg.name, dentry->d_name.name, sizeof(msg.name)) >= NNPFS_MAX_NAME)
  	return -ENAMETOOLONG;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      msg.cred.uid = current->uid;
+#else
+    msg.cred.uid = current_uid();
+#endif
      msg.cred.pag = nnpfs_get_pag();
      error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
      if (error == 0)
@@ -991,7 +1071,11 @@ nnpfs_rename (struct inode * old_dir, st
      if (strlcpy(msg.new_name, new_dentry->d_name.name, sizeof(msg.new_name)) >= NNPFS_MAX_NAME)
  	return -ENAMETOOLONG;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      msg.cred.uid = current->uid;
+#else
+    msg.cred.uid = current_uid();
+#endif
      msg.cred.pag = nnpfs_get_pag();
      error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
      if (error == 0)
@@ -1008,8 +1092,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;
@@ -1040,9 +1129,17 @@ nnpfs_mkdir(struct inode * dir, struct d
  	XA_CLEAR(&msg.attr);
  	XA_SET_MODE(&msg.attr, mode);
  	XA_SET_TYPE(&msg.attr, NNPFS_FILE_DIR);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	XA_SET_GID(&msg.attr, current->fsgid);
+#else
+        XA_SET_GID(&msg.attr, current_fsgid());
+#endif

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.cred.pag = nnpfs_get_pag();
  	error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
  	if (error == 0)
@@ -1083,7 +1180,11 @@ nnpfs_rmdir(struct inode * dir, struct d
      msg.parent_handle = xn->handle;
      if (strlcpy(msg.name, dentry->d_name.name, sizeof(msg.name)) >= NNPFS_MAX_NAME)
  	    return -ENAMETOOLONG;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      msg.cred.uid = current->uid;
+#else
+    msg.cred.uid = current_uid();
+#endif
      msg.cred.pag = nnpfs_get_pag();
      error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
      if (error == 0)
@@ -1128,7 +1229,11 @@ static int nnpfs_link(struct dentry *old
  	if (strlcpy(msg.name, name, sizeof(msg.name)) >= NNPFS_MAX_NAME)
  	    return -ENAMETOOLONG;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.cred.pag = nnpfs_get_pag();
  	error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
  	if (error == 0)
@@ -1157,29 +1262,47 @@ static int nnpfs_symlink(struct inode *d
      xn = VNODE_TO_XNODE(dir);

      {
-	struct nnpfs_message_symlink msg;
+	struct nnpfs_message_symlink *msg = NULL;

-	msg.header.opcode = NNPFS_MSG_SYMLINK;
-	msg.parent_handle = xn->handle;
-	if (strlcpy(msg.name, name, sizeof(msg.name)) >= NNPFS_MAX_NAME)
-	    return -ENAMETOOLONG;
-	if (strlcpy(msg.contents, symname, sizeof(msg.contents)) >= NNPFS_MAX_SYMLINK_CONTENT)
-	    return -ENAMETOOLONG;
-	XA_CLEAR(&msg.attr);
-	XA_SET_MODE(&msg.attr, 0777);
-	XA_SET_TYPE(&msg.attr, NNPFS_FILE_LNK);
-	XA_SET_GID(&msg.attr, current->fsgid);
+	msg = kmalloc(sizeof(*msg), GFP_KERNEL);

-	msg.cred.uid = current->uid;
-	msg.cred.pag = nnpfs_get_pag();
-	error = nnpfs_message_rpc(nnpfsp, &msg.header, sizeof(msg));
+	if (msg == NULL)
+	  return -ENOMEM;
+
+	msg->header.opcode = NNPFS_MSG_SYMLINK;
+	msg->parent_handle = xn->handle;
+	if (strlcpy(msg->name, name, sizeof(msg->name)) >= NNPFS_MAX_NAME) {
+	  kfree(msg);
+	  return -ENAMETOOLONG;
+	}
+	if (strlcpy(msg->contents, symname, sizeof(msg->contents)) >= NNPFS_MAX_SYMLINK_CONTENT) {
+	  kfree(msg);
+	  return -ENAMETOOLONG;
+	}
+	XA_CLEAR(&msg->attr);
+	XA_SET_MODE(&msg->attr, 0777);
+	XA_SET_TYPE(&msg->attr, NNPFS_FILE_LNK);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+	XA_SET_GID(&msg->attr, current->fsgid);
+#else
+        XA_SET_GID(&msg->attr, current_fsgid());
+#endif
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+	msg->cred.uid = current->uid;
+#else
+        msg->cred.uid = current_uid();
+#endif
+	msg->cred.pag = nnpfs_get_pag();
+	error = nnpfs_message_rpc(nnpfsp, &msg->header, sizeof(*msg));
  	if (error == 0)
-	    error = NNPFS_MSG_WAKEUP_ERROR(&msg);
+	    error = NNPFS_MSG_WAKEUP_ERROR(msg);

  	/* XXX should this really be here */
  	if (DENTRY_TO_XDENTRY(dentry)->xd_flags == 0) {
  	    printk(KERN_EMERG "NNPFS Panic: nnpfs_symlink: dentry not valid\n");
  	}
+	kfree(msg);
      }

      return error;
@@ -1188,8 +1311,13 @@ 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;
@@ -1264,6 +1392,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,
@@ -1275,6 +1404,18 @@ 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) {
@@ -1398,7 +1539,11 @@ nnpfs_setattr (struct dentry *dentry, st
          struct nnpfs_message_putattr msg;

          msg.header.opcode = NNPFS_MSG_PUTATTR;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	msg.cred.uid = current->uid;
+#else
+        msg.cred.uid = current_uid();
+#endif
  	msg.cred.pag = nnpfs_get_pag();
          msg.handle = xn->handle;
          nnpfs_iattr2attr(xn, attr, &msg.attr);
@@ -1422,6 +1567,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);
@@ -1450,13 +1597,8 @@ nnpfs_release_file (struct inode *inode,
   *
   */

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
  static int
  nnpfs_flush(struct file *file, fl_owner_t id)
-#else
-static int
-nnpfs_flush(struct file *file)
-#endif
  {
      NNPFSDEB(XDEBVNOPS, ("nnpfs_flush\n"));

@@ -1470,8 +1612,13 @@ nnpfs_flush(struct file *file)
   * 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);
      NNPFSDEB(XDEBVNOPS, ("nnpfs_d_revalidate %p \"%.*s\" (inode %p)\n",
@@ -1519,9 +1666,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;
@@ -1546,8 +1699,9 @@ nnpfs_d_delete(struct dentry *dentry)
  }

  static ssize_t
-nnpfs_sendfile(struct file *file, loff_t *ppos, size_t count,
-	       read_actor_t actor, void *target)
+nnpfs_splice_read(struct file *file, loff_t *ppos,
+		  struct pipe_inode_info *pipe, size_t count,
+		  unsigned int flags)
  {
      int error = 0;
      struct inode *inode = file->f_dentry->d_inode;
@@ -1561,8 +1715,7 @@ nnpfs_sendfile(struct file *file, loff_t
  	NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: data not valid %d\n", error));
  	return error;
      }
-
-    error = generic_file_sendfile(file, ppos, count, actor, target);
+    error = file->f_op->splice_read(file, ppos, pipe, count, flags);

      NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: error = %d\n", error));
      return error;
@@ -1639,34 +1792,31 @@ nnpfs_write_backpage(struct page *page,
  	struct address_space *mapping = backfile->f_mapping;
  	unsigned len = PAGE_CACHE_SIZE;
  	struct page *backpage;
+	void *fsdata;
  	unsigned long offset;

  	int error;
- 
-	do {
-		backpage = grab_cache_page(mapping, nnpfs_get_backindex(page));
-		if (!backpage) {
-			printk("nnpfs_write_backpage: no page\n");
-			return -EIO;
-		}

-		error = mapping->a_ops->prepare_write(backfile, backpage,
-						      0, len);
+	(void)offset;
+
+	do {
+		error = pagecache_write_begin(backfile, mapping, 0, len,
+					      AOP_FLAG_UNINTERRUPTIBLE,
+					      &backpage, &fsdata);
  		if (!error) {
  			copy_highpage(backpage, page);
  			flush_dcache_page(backpage);
-			error = mapping->a_ops->commit_write(backfile, backpage,
-							     0, len);
+			error = pagecache_write_end(backfile, mapping, 0, len,
+					len, backpage, fsdata);
+			if (error > 0)
+				error = 0;
  		}
  		if (error == AOP_TRUNCATED_PAGE) {
-			page_cache_release(backpage);
  			continue;
  		}
  	} while (0);

  	offset = page_offset(backpage);
-	unlock_page(backpage);
-	page_cache_release(backpage);

  	if (error)
  		printk("nnpfs_write_backpage: EIO\n");
@@ -1689,13 +1839,9 @@ nnpfs_read_backpage(struct page *page, s
  	struct page *backpage;
  	unsigned long offset;

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+	(void)offset;
+
  	backpage = read_mapping_page(mapping, n, backfile);
-#else
-	backpage = read_cache_page(mapping, n,
-				   (filler_t *)mapping->a_ops->readpage,
-				   backfile);
-#endif
  	if (!IS_ERR(backpage)) {
  		wait_on_page_locked(backpage);

@@ -1841,12 +1987,18 @@ nnpfs_prepare_write(struct file *file, s
  		modsize = nnpfs_blocksize;

  	if (modsize > i_size_read(inode)) {
-		int error;
+		int error=0;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
  		error = vmtruncate(inode, modsize);
+#else
+		if(!inode_newsize_ok(inode, modsize)) {
+			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 */
  		}
  	}

@@ -1872,8 +2024,37 @@ nnpfs_prepare_write(struct file *file, s
  	return ret;
  }

+#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)
+{
+	struct page *page;
+	pgoff_t index;
+	unsigned from;
+
+	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)
+		return -ENOMEM;
+
+	*pagep = page;
+
+	return nnpfs_prepare_write(file, page, from, from + len);
+}
+
+#endif
+
  static int
-nnpfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to)
+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;
@@ -1902,14 +2083,51 @@ nnpfs_commit_write(struct file *file, st
      return 0;
  }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
-const
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+
+static int
+nnpfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
+		unsigned len, unsigned copied, struct page *page, void *fsdata)
+{
+	unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+
+	/* 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);
+
+	unlock_page(page);
+	page_cache_release(page);
+
+	return copied;
+}
+
+#endif
+
+const
  struct address_space_operations nnpfs_aops = {
  	.readpage = nnpfs_readpage,
  	.writepage = nnpfs_writepage,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
  	.prepare_write = nnpfs_prepare_write,
  	.commit_write = nnpfs_commit_write,
+#else
+	.write_begin = nnpfs_write_begin,
+	.write_end = nnpfs_write_end,
+#endif
  };

  /*
@@ -1924,14 +2142,18 @@ struct file_operations nnpfs_file_operat
      .flush	= nnpfs_flush,
      .release	= nnpfs_release_file,
      .fsync	= nnpfs_fsync,
-    .sendfile	= nnpfs_sendfile,
+    .splice_read = nnpfs_splice_read,
  };

  struct file_operations nnpfs_dead_operations = {
  };

  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,
  };

diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_load.c arla-for-linux-3.11/nnpfs/linux/nnpfs_load.c
--- arla-0.90/nnpfs/linux/nnpfs_load.c	2006-10-31 11:02:41.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_load.c	2016-01-10 20:33:16.062901957 +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.txt arla-0.90/nnpfs/linux/nnpfs_message.c arla-for-linux-3.11/nnpfs/linux/nnpfs_message.c
--- arla-0.90/nnpfs/linux/nnpfs_message.c	2007-01-09 17:33:31.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_message.c	2016-01-11 20:48:18.770403715 +0100
@@ -45,7 +45,7 @@
  #include <linux/mount.h>

  #ifdef RCSID
-RCSID("$Id: nnpfs_message.c,v 1.143.2.1 2007/01/09 16:33:31 tol Exp $");
+RCSID("$Id: nnpfs_message.c,v 1.145 2010/08/08 20:43:05 tol Exp $");
  #endif

  static void
@@ -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,8 +127,14 @@ 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;
- 
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
+    struct hlist_node *alias;
+#endif
+#endif
+
      NNPFSDEB(XDEBMSG, ("nnpfs_message_installnode\n"));

      error = nnpfs_node_find(nnpfsp, &message->parent_handle, &dp);
@@ -176,12 +188,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);
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
+    hlist_for_each_entry(parent, alias, &di->i_dentry, d_alias) {
+#else
+    hlist_for_each_entry(parent, &di->i_dentry, d_alias) {
+#endif
+#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 +259,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 +296,11 @@ 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);
+#else
+    dentry = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
+#endif

      NNPFSDEB(XDEBMSG, ("nnpfs_message_installattr name:%s\n",
  		       dentry->d_name.name));
@@ -396,17 +428,38 @@ 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;
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
+    struct hlist_node *alias;
+#endif
+#endif

   again:
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
      spin_lock(&dcache_lock);
+#else
+    /* TODO: find the dentry to lock */
+    /*spin_lock(&dentry->d_lock);*/
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
      alias = inode->i_dentry.next;
      while (alias != &inode->i_dentry) {
-	struct dentry *dentry;
+#else
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
+    hlist_for_each_entry(dentry, alias, &inode->i_dentry, d_alias) {
+#else
+    hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
+#endif
+#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;
@@ -442,14 +495,26 @@ 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
+		/* TODO: unlock the dentry */
+		/*spin_unlock(&dentry->d_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
+    /* TODO: unlock the dentry */
+    /*spin_unlock(&dentry->d_lock);*/
+#endif
  }

  static void
@@ -605,12 +670,10 @@ gc_block(struct nnpfs *nnpfsp,
      }

      if (!nnpfs_block_have_p(xn, offset)) {
-#if 0   /* happens when daemon sends several messages for same block */
  	printk(KERN_EMERG "NNPFS/gc_block: "
  	       "ENOENT (%d,%d,%d,%d) 0x%llx\n",
  	       xn->handle.a, xn->handle.b, xn->handle.c, xn->handle.d,
  	       (unsigned long long)offset);
-#endif
  	return -ENOENT;
      }

@@ -726,7 +789,11 @@ nnpfs_message_version(struct nnpfs *nnpf

  	uint64_t blocksize = message->blocksize;

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
  	error = path_lookup(".", 0, &nd);
+#else
+	error = kern_path(".", 0, &nd.path);
+#endif
  	if (error) {
  	    /*
  	     * Bad cache root, just return.
@@ -737,12 +804,16 @@ nnpfs_message_version(struct nnpfs *nnpf
  		   "nnpfs_message_version failed path_lookup, "
  		   "errno: %d\n", error);
  	} else {
-	    nnpfsp->cacheroot = mntget(nd.mnt);
-	    nnpfsp->cachedir = dget(nd.dentry);
-	    path_release(&nd);
- 
+	    nnpfsp->cacheroot = mntget(nd.path.mnt);
+	    nnpfsp->cachedir = dget(nd.path.dentry);
+	    path_put(&nd.path);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
  	    nnpfsp->uid = current->fsuid;
  	    nnpfsp->gid = current->fsgid;
+#else
+            nnpfsp->uid = current_fsuid();
+            nnpfsp->gid = current_fsgid();
+#endif

  	    /* XXX we should validate these values */
  	    nnpfs_blocksize = blocksize;
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_node.c arla-for-linux-3.11/nnpfs/linux/nnpfs_node.c
--- arla-0.90/nnpfs/linux/nnpfs_node.c	2007-01-03 14:52:02.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_node.c	2016-01-11 20:26:48.422460470 +0100
@@ -132,7 +132,13 @@ 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);
      }
  }
@@ -152,7 +158,11 @@ nnpfs_attr2inode(const struct nnpfs_attr
  	inode->i_mode   = 0;
  	inode->i_uid    = 0;
  	inode->i_gid    = 0;
+#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 +179,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);
@@ -510,11 +524,19 @@ 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
  	struct dentry *dentry = list_entry(pos, struct dentry, d_alias);
  	if (nnpfs_dcount(dentry) > 1)
  	    users++;
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_syscalls.c arla-for-linux-3.11/nnpfs/linux/nnpfs_syscalls.c
--- arla-0.90/nnpfs/linux/nnpfs_syscalls.c	2007-01-03 15:26:27.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_syscalls.c	2016-01-12 13:47:52.249388998 +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 later kernels, se nnpfs_syscalls-lossage.c */
+#endif
+
  #if 0
  #ifdef CONFIG_COMPAT
  #include <linux/ioctl32.h>
@@ -64,7 +71,7 @@
  #undef NEED_VICEIOCTL32

  #ifdef RCSID
-RCSID("$Id: nnpfs_syscalls.c,v 1.122 2007/01/03 14:26:27 tol Exp $");
+RCSID("$Id: nnpfs_syscalls.c,v 1.125 2010/08/08 20:43:06 tol Exp $");
  #endif

  static struct proc_dir_entry *nnpfs_procfs_dir;
@@ -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
  };


@@ -147,53 +164,46 @@ static int nnpfs_sec_registered = 0;
  #define SEC2PAG(s) (nnpfs_pag_t)(unsigned long)(s)
  #define PAG2SEC(p) (void *)(unsigned long)(p)

-static int
-nnpfs_sec_task_alloc(struct task_struct *p)
-{
-    nnpfs_pag_t pag = SEC2PAG(current->security);
-    if (pag)
-	p->security = PAG2SEC(pag);
-    return 0;
-}
-
-static void
-nnpfs_sec_task_free(struct task_struct *p)
-{
-    nnpfs_pag_t pag = SEC2PAG(p->security);
-    if (pag)
-	p->security = NULL;
-}
-
  static nnpfs_pag_t
  nnpfs_get_pag_sec(void)
  {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      nnpfs_pag_t pag = SEC2PAG(current->security);
+#else
+    nnpfs_pag_t pag = SEC2PAG(current_security());
+#endif
      if (pag)
  	return pag;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      return current->uid;
+#else
+    return current_uid();
+#endif
  }

  static int
  nnpfs_set_pag_sec(void)
  {
      static nnpfs_pag_t pagnum = NNPFS_PAG_LLIM;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+    struct cred *cred;
+#endif

      if (pagnum == NNPFS_PAG_ULIM)
  	return -ENOMEM;
      /* pagnum = NNPFS_PAG_LLIM; */

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      current->security = PAG2SEC(pagnum);
+#else
+    cred = (struct cred *) current->cred;
+    cred->security = PAG2SEC(pagnum);
+#endif
      pagnum++;
      return 0;
  }

-static struct security_operations nnpfs_sec_ops = {
-    .task_alloc_security = nnpfs_sec_task_alloc,
-    .task_free_security = nnpfs_sec_task_free,
-//    .task_reparent_to_init = nnpfs_sec_reparent_to_init,
-};
-
  #endif /* CONFIG_SECURITY */

  #ifdef GROUPPAGS
@@ -222,11 +232,18 @@ find_pag(struct group_info *gi)
  static nnpfs_pag_t
  nnpfs_get_pag_group(void)
  {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      struct group_info *gi = current->group_info;
      nnpfs_pag_t ret = current->uid;
+#else
+    struct group_info *gi = get_current_groups();
+    nnpfs_pag_t ret = current_uid();
+#endif
      int i;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      get_group_info(gi);
+#endif

      i = find_pag(gi);
      if (i != NNPFS_PAG_NOTFOUND)
@@ -242,13 +259,19 @@ nnpfs_get_pag_group(void)
  static int
  store_pag(nnpfs_pag_t pagnum)
  {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      struct group_info *old_gi = current->group_info;
+#else
+   struct group_info *old_gi = get_current_groups();
+#endif
      struct group_info *new_gi;
-    int nblocks, count;
+    unsigned int nblocks, count;
      int found = 0;
      int i, k;

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      get_group_info(old_gi);
+#endif

      i = find_pag(old_gi);
      if (i != NNPFS_PAG_NOTFOUND)
@@ -317,7 +340,11 @@ nnpfs_get_pag()
      return nnpfs_get_pag_group();
  #endif /* GROUPPAGS */

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
      return current->uid;
+#else
+    return current_uid();
+#endif
  }

  static inline int
@@ -422,7 +449,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;
@@ -512,11 +539,19 @@ nnpfs_debug_print (struct arlaViceIoctl
  static struct dentry *
  user_path2dentry (struct nameidata *nd, char *user_path, int follow)
  {
-    char *kname;
      int flags = 0;
      int error = 0;

-    kname = getname (user_path);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
+    char *kname;
+    kname = getname(user_path);
+#else
+    const char *kname;
+    struct filename *fname;
+    fname = getname(user_path);
+    kname = fname->name;
+#endif
+
      if (IS_ERR(kname))
  	return ERR_PTR(PTR_ERR(kname));
      if (follow)
@@ -524,11 +559,19 @@ user_path2dentry (struct nameidata *nd,

      NNPFSDEB(XDEBMSG, ("nnpfs_syscall: looking up: %s\n", kname));

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
      error = path_lookup(kname, flags, nd);
+#else
+    error = kern_path(kname, flags, &(nd->path));
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
      putname(kname);
+#else
+    kmem_cache_free(names_cachep, (void *)kname);
+#endif
      if (error)
  	return ERR_PTR(error);
-    return nd->dentry;
+    return nd->path.dentry;
  }

  asmlinkage long
@@ -540,12 +583,20 @@ sys_afs_int (int operation,
  {
      long error = 0;
      struct arlaViceIoctl vice_ioctl; 
-    struct nnpfs_message_pioctl msg;
+    struct nnpfs_message_pioctl *msg = NULL;
      struct nnpfs_message_wakeup *msg2;
      struct dentry *dentry = NULL;
      struct nameidata nd;

+    msg = kmalloc(sizeof(*msg), GFP_KERNEL);
+    if (msg == NULL)
+      return -ENOMEM;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
      lock_kernel();
+#else
+    /* TODO: lock_kernel() is removed, consider adding an private lock */
+#endif

      NNPFSDEB(XDEBSYS, ("sys_afs kernel locked\n"));

@@ -575,7 +626,7 @@ sys_afs_int (int operation,
  	    goto unlock;
  	}
  	if (vice_ioctl.in_size != 0) {
-	    if(copy_from_user(&msg.msg,
+	    if(copy_from_user(&msg->msg,
  			      vice_ioctl.in,
  			      vice_ioctl.in_size) != 0) {
  		error = -EFAULT;
@@ -628,19 +679,23 @@ sys_afs_int (int operation,
  		error = -EINVAL;
  		goto unlock;
  	    }
-	    msg.handle = xn->handle;
+	    msg->handle = xn->handle;
  	}

-	msg.header.opcode = NNPFS_MSG_PIOCTL;
-	msg.opcode = a_opcode;
+	msg->header.opcode = NNPFS_MSG_PIOCTL;
+	msg->opcode = a_opcode;

-	msg.insize   = vice_ioctl.in_size;
-	msg.outsize  = vice_ioctl.out_size;
-	msg.cred.uid = current->uid;
-	msg.cred.pag = nnpfs_get_pag();
+	msg->insize   = vice_ioctl.in_size;
+	msg->outsize  = vice_ioctl.out_size;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+	msg->cred.uid = current->uid;
+#else
+        msg->cred.uid = current_uid();
+#endif
+	msg->cred.pag = nnpfs_get_pag();

-	error = nnpfs_message_rpc(&nnpfs[0], &msg.header, sizeof(msg)); /* XXX */
-	msg2 = (struct nnpfs_message_wakeup *) &msg;
+	error = nnpfs_message_rpc(&nnpfs[0], &msg->header, sizeof(*msg)); /* XXX */
+	msg2 = (struct nnpfs_message_wakeup *) msg;
  	if (error == 0)
  	    error = msg2->error;

@@ -675,12 +730,17 @@ sys_afs_int (int operation,

   unlock:
      if (dentry)
-	path_release(&nd);
+	path_put(&nd.path);

      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
+    /* TODO: see the comment at lock_kernel() above */
+#endif

      return error;
  }
@@ -729,9 +789,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;
@@ -780,21 +846,31 @@ static int nnpfs_init_procfs(void)
  {
      struct proc_dir_entry *entry;

-    nnpfs_procfs_dir = proc_mkdir(NNPFS_PROC_DIR, proc_root_fs);
+    nnpfs_procfs_dir = proc_mkdir("fs/" NNPFS_PROC_DIR, NULL);
      if (nnpfs_procfs_dir == NULL)
  	return -ENOMEM;

+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
      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, 0, NULL, &nnpfs_procfs_fops);
+#endif
      if (entry == NULL) {
  	NNPFSDEB(XDEBSYS, ("nnpfs_init_procfs: no node\n"));
-	remove_proc_entry(NNPFS_PROC_DIR, proc_root_fs);
+	remove_proc_entry("fs/" NNPFS_PROC_DIR, NULL);
  	return -ENOMEM;
      }

+#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)) {
@@ -815,7 +891,7 @@ static void nnpfs_exit_procfs(void)
      }
  #endif /* SYSCALLCOMPAT */
      remove_proc_entry(NNPFS_PROC_NODE, nnpfs_procfs_dir);
-    remove_proc_entry(NNPFS_PROC_DIR, proc_root_fs);
+    remove_proc_entry("fs/" NNPFS_PROC_DIR, NULL);
  }

  #ifdef GROUPPAGS
@@ -839,14 +915,6 @@ install_setgroups(void)
  void
  install_afs_syscall(void)
  {
-#ifdef CONFIG_SECURITY
-    if (register_security(&nnpfs_sec_ops))
-	NNPFSDEB(XDEBSYS,
-		 ("install_afs_syscall: nnpfs_init_sec failed\n"));
-    else
-	nnpfs_sec_registered = 1;
-#endif
-
      nnpfs_init_procfs();

  #ifdef SYSCALLHACK
@@ -887,12 +955,6 @@ restore_afs_syscall (void)
  #endif
  #endif /* SYSCALLHACK */

-#ifdef CONFIG_SECURITY
-    if (nnpfs_sec_registered)
-	if (unregister_security(&nnpfs_sec_ops))
-	    printk(KERN_EMERG "nnpfs_exit_sec: couldn't unregister\n");
-#endif /* !CONFIG_SECURITY */
-
  #ifdef GROUPPAGS
  #ifdef SYSCALLHACK
      if (old_setgroups) {
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_syscalls-lossage.c arla-for-linux-3.11/nnpfs/linux/nnpfs_syscalls-lossage.c
--- arla-0.90/nnpfs/linux/nnpfs_syscalls-lossage.c	2006-12-11 17:31:45.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_syscalls-lossage.c	2016-01-12 13:37:05.657367471 +0100
@@ -47,11 +47,20 @@
  #include <linux/unistd.h>

  #ifdef RCSID
-RCSID("$Id: nnpfs_syscalls-lossage.c,v 1.17 2006/12/11 16:31:45 tol Exp $");
+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 later kernels */
+#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 =
@@ -63,6 +72,11 @@ const char * __attribute__((weak))
  		    unsigned long *offset,
  		    char **modname, char *namebuf);

+#ifdef __x86_64__
+extern rwlock_t tasklist_lock __attribute__((weak));
+#endif
+
+#ifdef SYSCALLHACK
  static void **
  get_start_addr(void) {
  #ifdef __x86_64__
@@ -71,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)
@@ -139,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)
@@ -188,3 +205,5 @@ nnpfs_fixup_syscall_lossage(void)

      return 0;
  }
+
+#endif
diff -uprN -Xnodiff.txt arla-0.90/nnpfs/linux/nnpfs_vfsops.c arla-for-linux-3.11/nnpfs/linux/nnpfs_vfsops.c
--- arla-0.90/nnpfs/linux/nnpfs_vfsops.c	2006-12-11 17:43:35.000000000 +0100
+++ arla-for-linux-3.11/nnpfs/linux/nnpfs_vfsops.c	2016-01-11 19:11:57.158658012 +0100
@@ -44,30 +44,26 @@
  #include <linux/mm.h>

  #ifdef RCSID
-RCSID("$Id: nnpfs_vfsops.c,v 1.109 2006/12/11 16:43:35 tol Exp $");
+RCSID("$Id: nnpfs_vfsops.c,v 1.111 2010/08/08 20:43:06 tol Exp $");
  #endif

  struct nnpfs nnpfs[NNNPFS];

-static void nnpfs_read_inode(struct inode *inode);
  static void nnpfs_put_super(struct super_block *sb);
-static void nnpfs_put_inode(struct inode *inode);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
  static void nnpfs_write_super(struct super_block * sb);
+#endif

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
  static int nnpfs_statfs(struct dentry *dentry, struct kstatfs *buf);
-#else
-static int nnpfs_statfs(struct super_block *sb, struct kstatfs *buf);
-#endif

  static struct super_operations nnpfs_sops = { 
-    read_inode		: nnpfs_read_inode,
-    put_inode		: nnpfs_put_inode,
      alloc_inode		: nnpfs_node_alloc,
      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,
  };

@@ -159,7 +155,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;
@@ -185,11 +185,15 @@ nnpfs_read_super (struct super_block * s
      if (data != NULL) {
  	struct nameidata nd;

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
  	error = path_lookup(data, 0, &nd);
+#else
+	error = kern_path(data, 0, &nd.path);
+#endif
  	if (error)
  	    ddev = ERR_PTR(error);
  	else
-	    ddev = nd.dentry;
+	    ddev = nd.path.dentry;

  	if (!IS_ERR(ddev)) {
  	    minordevice = MINOR(ddev->d_inode->i_rdev);
@@ -233,7 +237,7 @@ nnpfs_fill_super (struct super_block *sb
      return 0;
  }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+#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,
@@ -242,19 +246,22 @@ nnpfs_get_sb(struct file_system_type *fs
      return get_sb_nodev(fs_type, flags, data, nnpfs_fill_super, mnt);
  }
  #else
-struct super_block *
-nnpfs_get_sb (struct file_system_type *fs_type,
-	      int flags, const char *dev_name, void *data) 
+struct dentry*
+nnpfs_mount(struct file_system_type *fs_type,
+	     int flags, const char *dev_name,
+	     void *data)
  {
-    return get_sb_nodev(fs_type, flags, data, nnpfs_fill_super);
+    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? 
@@ -273,73 +280,6 @@ nnpfs_put_super(struct super_block *sb)
      NNPFSDEB(XDEBVFOPS, ("nnpfs_put_super exiting\n"));
  }

-static void
-nnpfs_read_inode(struct inode *inode)
-{
-    NNPFSDEB(XDEBVFOPS,("nnpfs_read_inode starting inode: %p\n",inode));
-    NNPFSDEB(XDEBVFOPS,("nnpfs_read_inode inode->i_ino: %ld\n",inode->i_ino));
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-    inode->i_blksize = 1024;
-#endif
-    inode->i_mode = 0;
-    inode->i_op = NULL;
-    NNPFSDEB(XDEBVFOPS,("nnpfs_read_inode exiting\n"));
-}
- 
-/*
- * Called when `inode' is de-referenced, ie when iput is called.
- */
-
-static void
-nnpfs_put_inode(struct inode *inode)
-{
-    struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
-    struct nnpfs *nnpfsp = NNPFS_FROM_VNODE(inode);
-    int bad;
-
-    NNPFSDEB(XDEBVFOPS,("nnpfs_put_inode: inode: %p count: %d aliases:",
-			inode, nnpfs_icount(inode)));
-    nnpfs_print_aliases(inode);
- 
-    down(&nnpfsp->inactive_sem);
-
-    if ((nnpfsp->status & NNPFS_DEVOPEN) == 0) {
-	if (!is_bad_inode(inode)) {
-	    if (inode != nnpfsp->root) {
-		make_bad_inode(inode);
-		nnpfs_irele(inode); /* see nnpfs_node_add() */
-	    }
-	    xn->flags |= NNPFS_STALE;
-	}
-	bad = 1; /* or root, really */
-    } else {
-	bad = is_bad_inode(inode);
-    }
-
-    if (xn->flags & NNPFS_STALE && !nnpfs_node_users(inode)) {
-	xn->flags |= NNPFS_NODE_IPUT; /* XXX locking */
-  	nnpfs_force_invalid_node(xn);
-	xn->flags &= ~NNPFS_NODE_IPUT;
-    }
- 
-    if (bad) {
-	if (nnpfs_icount(inode) == 1)
-	    nnpfs_node_clear(xn);
-    } else if (nnpfs_icount(inode) == 2) {
-	/* 
-	 * The last external reference is being dropped, only the one
-	 * from nnpfs_node_add() is left. Time to let daemon release
-	 * this node properly.
-	 */
-	if ((xn->flags & NNPFS_LIMBO) == 0) {
-	    nnpfs_node_clear(xn);
-	    nnpfs_queue_inactive(xn);
-	}
-    }
-
-    up(&nnpfsp->inactive_sem);
-}
-
  static int
  nnpfs_statfs_int(struct super_block *sb, struct kstatfs *buf)
  {
@@ -352,25 +292,21 @@ nnpfs_statfs_int(struct super_block *sb,
      tmp.f_bavail  = 1024*1024*2-50;
      tmp.f_files   = 1024*1024;
      tmp.f_ffree   = 1024*1024-100;
+    tmp.f_fsid.val[0] = 0;
+    tmp.f_fsid.val[1] = 0;
      tmp.f_namelen = NAME_MAX;
+    tmp.f_frsize  = 0;
+    tmp.f_spare[0] = 0;
+    tmp.f_spare[1] = 0;
+    tmp.f_spare[2] = 0;
+    tmp.f_spare[3] = 0;
+    tmp.f_spare[4] = 0;
      *buf = tmp;
      return 0;
  }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
-
  static int
  nnpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  {
      return nnpfs_statfs_int(dentry->d_sb, buf);
  }
-
-#else
-
-static int
-nnpfs_statfs(struct super_block *sb, struct kstatfs *buf)
-{
-    return nnpfs_statfs_int(sb, buf);
-}
-
-#endif


More information about the Arla-drinkers mailing list