Re: arla on linux-2.6.24

Frej Drejhammar <[email protected]>
Newsgroups gmane.comp.file-systems.arla.general
Message-ID <[email protected]>
> On Sun, 2008-03-02 at 15:31 +0100, [email protected] wrote:
>> An /eventual /next release of arla might then address the module
>> compilation under linux-2.6.24 (path_walk symbol not exported
>> anymore as far as I remember, so the arla module fails to build).
> Ah, good to know. Let us know if you have any ideas on how to sort
> it out.

I have spent some time getting nnpfs to compile on linux >= 2.6.23
which unexports path_walk (use vfs_path_lookup instead), changes
struct vm_operations_struct (nopage is replaced by fault) and struct
file_operations (sendfile is replaced by splice_read). The attached
patch works for me but in is only tested on 2.6.24.2.

Regards,

--Frej

_______________________________________________
Arla-drinkers mailing list
[email protected]
https://lists.stacken.kth.se/mailman/listinfo/arla-drinkers
0001-Get-nnpfs-to-work-on-linux-2.6.23.patch (text/x-patch, 3.5 KB)
diff -u a/nnpfs/linux/nnpfs_blocks.c b/nnpfs/linux/nnpfs_blocks.c
--- a/nnpfs/linux/nnpfs_blocks.c
+++ b/nnpfs/linux/nnpfs_blocks.c
@@ -302,6 +302,23 @@ nnpfs_block_extend(struct nnpfs_node *node, uint64_t offset)
     return ret;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
+/*
+ * Helper to emulate vfs_path_lookup() on linux < 2.6.23
+ */
+static int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
+			   const char *cachename, unsigned int flags,
+			   struct nameidata *nd)
+{
+    nd->dentry = dentry;
+    nd->mnt = mnt;
+    nd->last_type = LAST_NORM;
+    nd->depth = 0;
+    nd->flags = flags;
+    return path_walk(cachename, nd);
+}
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */
+
 /*
  * open indicated cache block file. needs to be closed by caller.
  *
@@ -351,16 +368,10 @@ nnpfs_block_open(struct nnpfs_node *node, uint64_t offset, int flag,
     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);
+    ret = vfs_path_lookup(nnpfsp->cachedir,nnpfsp->cacheroot,
+			  cachename,
+			  flags & O_CREAT ? LOOKUP_PARENT : 0,
+			  &nd);
     if (ret) {
 	uint32_t nmasks = node->data.nmasks;
 	uint32_t mask;
diff -u a/nnpfs/linux/nnpfs_inodeops.c b/nnpfs/linux/nnpfs_inodeops.c
--- a/nnpfs/linux/nnpfs_inodeops.c
+++ b/nnpfs/linux/nnpfs_inodeops.c
@@ -105,7 +105,11 @@ nnpfs_vma_close (struct vm_area_struct *vma)
 }
 
 static struct vm_operations_struct nnpfs_file_vm_ops = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
     .nopage	= filemap_nopage,
+#else
+    .fault      = filemap_fault,
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */
     .close	= nnpfs_vma_close,
 };
 
@@ -1545,6 +1549,7 @@ nnpfs_d_delete(struct dentry *dentry)
     return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
 static ssize_t
 nnpfs_sendfile(struct file *file, loff_t *ppos, size_t count,
 	       read_actor_t actor, void *target)
@@ -1567,6 +1572,30 @@ nnpfs_sendfile(struct file *file, loff_t *ppos, size_t count,
     NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: error = %d\n", error));
     return error;
 }
+#else
+static ssize_t
+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;
+    struct nnpfs_node *xn = VNODE_TO_XNODE(inode);
+    
+    if (xn != NULL)
+	NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: tokens: 0x%x\n", xn->tokens));
+
+    error = nnpfs_data_valid(inode, NNPFS_DATA_R, *ppos, *ppos + count);
+    if (error) {
+	NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: data not valid %d\n", error));
+	return error;
+    }
+    error = file->f_op->splice_read(file, ppos, pipe, count, flags);
+
+    NNPFSDEB(XDEBVNOPS, ("nnpfs_sendfile: error = %d\n", error));
+    return error;
+}
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */
 
 /*
  *
@@ -1924,7 +1953,11 @@ struct file_operations nnpfs_file_operations = {
     .flush	= nnpfs_flush,
     .release	= nnpfs_release_file,
     .fsync	= nnpfs_fsync,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
     .sendfile	= nnpfs_sendfile,
+#else
+    .splice_read = nnpfs_splice_read,
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */
 };
 
 struct file_operations nnpfs_dead_operations = {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.