]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Import upstream patches for kernel 4.14 compatibility
authorBenjamin Kaduk <kaduk@mit.edu>
Thu, 14 Dec 2017 01:14:22 +0000 (19:14 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 14 Dec 2017 01:15:43 +0000 (19:15 -0600)
Change-Id: Ie6ebcb13df93de968e602f121f626fcc1c7b9ba8

debian/changelog
debian/patches/0003-Linux-Test-for-__vfs_write-rather-than-__vfs_read.patch [new file with mode: 0644]
debian/patches/0004-Linux-Use-kernel_read-kernel_write-when-__vfs-varian.patch [new file with mode: 0644]
debian/patches/0005-afs-fix-kernel_write-kernel_read-arguments.patch [new file with mode: 0644]
debian/patches/series

index 4a4bccdf15aa8b58b62da7d2f79a229ed0d2da32..b5515cb43e12d267c64eb2d8b0e317eceb0bb025 100644 (file)
@@ -2,6 +2,7 @@ openafs (1.6.22-2) UNRELEASED; urgency=medium
 
   * Update Russian debconf translation; thanks Lev Lamberov.
     (Closes: #883916)
+  * Pull in upstream patches to build with kernel 4.14. (Closes: #884276)
 
  -- Benjamin Kaduk <kaduk@mit.edu>  Sat, 09 Dec 2017 20:38:43 -0600
 
diff --git a/debian/patches/0003-Linux-Test-for-__vfs_write-rather-than-__vfs_read.patch b/debian/patches/0003-Linux-Test-for-__vfs_write-rather-than-__vfs_read.patch
new file mode 100644 (file)
index 0000000..ffd70e7
--- /dev/null
@@ -0,0 +1,86 @@
+From: Damien Diederen <ddiederen@sinenomine.net>
+Date: Mon, 18 Sep 2017 11:59:40 +0200
+Subject: Linux: Test for __vfs_write rather than __vfs_read
+
+The following commit:
+
+    commit eb031849d52e61d24ba54e9d27553189ff328174
+    Author: Christoph Hellwig <hch@lst.de>
+    Date:   Fri Sep 1 17:39:23 2017 +0200
+
+        fs: unexport __vfs_read/__vfs_write
+
+unexports both __vfs_read and __vfs_write, but keeps the former in
+fs.h--as it is is still being used by another part of the tree.
+
+This situation results in a false positive in our Autoconf check,
+which does not see the export statements, and ends up marking the
+corresponding API as available.
+
+That, in turn, causes some code which assumes symmetry with
+__vfs_write to fail to compile.
+
+Switch to testing for __vfs_write, which correctly marks the API as
+unavailable.
+
+Change-Id: I392f2b17b4de7bd81d549c84e6f7b5ef05e1b999
+Reviewed-on: https://gerrit.openafs.org/12728
+Tested-by: BuildBot <buildbot@rampaginggeek.com>
+Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
+---
+ acinclude.m4                 | 4 ++--
+ src/afs/LINUX/osi_compat.h   | 4 ++--
+ src/afs/LINUX/osi_vnodeops.c | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/acinclude.m4 b/acinclude.m4
+index d80cacd..8353ca5 100644
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -939,9 +939,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
+                dnl Function existence checks
+-               AC_CHECK_LINUX_FUNC([__vfs_read],
++               AC_CHECK_LINUX_FUNC([__vfs_write],
+                                    [#include <linux/fs.h>],
+-                                   [__vfs_read(NULL, NULL, 0, NULL);])
++                                   [__vfs_write(NULL, NULL, 0, NULL);])
+                  AC_CHECK_LINUX_FUNC([bdi_init],
+                                    [#include <linux/backing-dev.h>],
+                                    [bdi_init(NULL);])
+diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
+index 8e72161..9ebe9c1 100644
+--- a/src/afs/LINUX/osi_compat.h
++++ b/src/afs/LINUX/osi_compat.h
+@@ -595,7 +595,7 @@ afs_d_invalidate(struct dentry *dp)
+ static inline int
+ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ {
+-#if defined(HAVE_LINUX___VFS_READ)
++#if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_read(filp, buf, len, pos);
+ #else
+     return filp->f_op->read(filp, buf, len, pos);
+@@ -605,7 +605,7 @@ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ static inline int
+ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ {
+-#if defined(HAVE_LINUX___VFS_READ)
++#if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_write(filp, buf, len, pos);
+ #else
+     return filp->f_op->write(filp, buf, len, pos);
+diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
+index f46d8dd..3d9d717 100644
+--- a/src/afs/LINUX/osi_vnodeops.c
++++ b/src/afs/LINUX/osi_vnodeops.c
+@@ -807,7 +807,7 @@ struct file_operations afs_file_fops = {
+ #ifdef STRUCT_FILE_OPERATIONS_HAS_READ_ITER
+   .read_iter =        afs_linux_read_iter,
+   .write_iter =       afs_linux_write_iter,
+-# if !defined(HAVE_LINUX___VFS_READ)
++# if !defined(HAVE_LINUX___VFS_WRITE)
+   .read =     new_sync_read,
+   .write =    new_sync_write,
+ # endif
diff --git a/debian/patches/0004-Linux-Use-kernel_read-kernel_write-when-__vfs-varian.patch b/debian/patches/0004-Linux-Use-kernel_read-kernel_write-when-__vfs-varian.patch
new file mode 100644 (file)
index 0000000..af36ae8
--- /dev/null
@@ -0,0 +1,129 @@
+From: Damien Diederen <ddiederen@sinenomine.net>
+Date: Mon, 18 Sep 2017 12:18:39 +0200
+Subject: Linux: Use kernel_read/kernel_write when __vfs variants are
+ unavailable
+
+We hide the uses of set_fs/get_fs behind a macro, as those functions
+are likely to soon become unavailable:
+
+> Christoph Hellwig suggested removing all calls outside of the core
+> filesystem and architecture code; Andy Lutomirski went one step
+> further and said they should all go.
+
+    https://lwn.net/Articles/722267/
+
+Change-Id: Ib668f8fdb62ca01fe14321c07bd14d218744d909
+Reviewed-on: https://gerrit.openafs.org/12729
+Tested-by: BuildBot <buildbot@rampaginggeek.com>
+Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
+Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
+---
+ acinclude.m4                 |  3 +++
+ src/afs/LINUX/osi_compat.h   | 12 ++++++++++++
+ src/afs/LINUX/osi_file.c     |  6 ++++++
+ src/afs/LINUX/osi_vnodeops.c |  2 +-
+ 4 files changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/acinclude.m4 b/acinclude.m4
+index 8353ca5..94b9436 100644
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -942,6 +942,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
+                AC_CHECK_LINUX_FUNC([__vfs_write],
+                                    [#include <linux/fs.h>],
+                                    [__vfs_write(NULL, NULL, 0, NULL);])
++               AC_CHECK_LINUX_FUNC([kernel_write],
++                                   [#include <linux/fs.h>],
++                                   [kernel_write(NULL, NULL, 0, NULL);])
+                  AC_CHECK_LINUX_FUNC([bdi_init],
+                                    [#include <linux/backing-dev.h>],
+                                    [bdi_init(NULL);])
+diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
+index 9ebe9c1..9871535 100644
+--- a/src/afs/LINUX/osi_compat.h
++++ b/src/afs/LINUX/osi_compat.h
+@@ -592,11 +592,21 @@ afs_d_invalidate(struct dentry *dp)
+ #endif
+ }
++#if defined(HAVE_LINUX___VFS_WRITE)
++# define AFS_FILE_NEEDS_SET_FS 1
++#elif defined(HAVE_LINUX_KERNEL_WRITE)
++/* #undef AFS_FILE_NEEDS_SET_FS */
++#else
++# define AFS_FILE_NEEDS_SET_FS 1
++#endif
++
+ static inline int
+ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ {
+ #if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_read(filp, buf, len, pos);
++#elif defined(HAVE_LINUX_KERNEL_WRITE)
++    return kernel_read(filp, buf, len, pos);
+ #else
+     return filp->f_op->read(filp, buf, len, pos);
+ #endif
+@@ -607,6 +617,8 @@ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ {
+ #if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_write(filp, buf, len, pos);
++#elif defined(HAVE_LINUX_KERNEL_WRITE)
++    return kernel_write(filp, buf, len, pos);
+ #else
+     return filp->f_op->write(filp, buf, len, pos);
+ #endif
+diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c
+index f889fd1..a028ee7 100644
+--- a/src/afs/LINUX/osi_file.c
++++ b/src/afs/LINUX/osi_file.c
+@@ -357,7 +357,9 @@ int
+ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw)
+ {
+     struct file *filp = osifile->filp;
++#ifdef AFS_FILE_NEEDS_SET_FS
+     mm_segment_t old_fs = {0};
++#endif /* AFS_FILE_NEEDS_SET_FS */
+     int code = 0;
+     struct iovec *iov;
+     size_t count;
+@@ -367,11 +369,13 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw)
+     savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
+     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
++#ifdef AFS_FILE_NEEDS_SET_FS
+     if (uiop->uio_seg == AFS_UIOSYS) {
+       /* Switch into user space */
+       old_fs = get_fs();
+       set_fs(get_ds());
+     }
++#endif /* AFS_FILE_NEEDS_SET_FS */
+     while (code == 0 && uiop->uio_resid > 0 && uiop->uio_iovcnt > 0) {
+       iov = uiop->uio_iov;
+@@ -408,10 +412,12 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw)
+       code = 0;
+     }
++#ifdef AFS_FILE_NEEDS_SET_FS
+     if (uiop->uio_seg == AFS_UIOSYS) {
+       /* Switch back into kernel space */
+       set_fs(old_fs);
+     }
++#endif /* AFS_FILE_NEEDS_SET_FS */
+     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim;
+diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
+index 3d9d717..051452b 100644
+--- a/src/afs/LINUX/osi_vnodeops.c
++++ b/src/afs/LINUX/osi_vnodeops.c
+@@ -807,7 +807,7 @@ struct file_operations afs_file_fops = {
+ #ifdef STRUCT_FILE_OPERATIONS_HAS_READ_ITER
+   .read_iter =        afs_linux_read_iter,
+   .write_iter =       afs_linux_write_iter,
+-# if !defined(HAVE_LINUX___VFS_WRITE)
++# if !defined(HAVE_LINUX___VFS_WRITE) && !defined(HAVE_LINUX_KERNEL_WRITE)
+   .read =     new_sync_read,
+   .write =    new_sync_write,
+ # endif
diff --git a/debian/patches/0005-afs-fix-kernel_write-kernel_read-arguments.patch b/debian/patches/0005-afs-fix-kernel_write-kernel_read-arguments.patch
new file mode 100644 (file)
index 0000000..c55e675
--- /dev/null
@@ -0,0 +1,85 @@
+From: Marcio Barbosa <mbarbosa@sinenomine.net>
+Date: Thu, 16 Nov 2017 17:24:03 -0500
+Subject: afs: fix kernel_write / kernel_read arguments
+
+The order / content of the arguments passed to kernel_write and
+kernel_read are not right. As a result, the kernel will panic if one of
+the functions in question is called.
+
+[kaduk@mit.edu: include configure check for multiple kernel_read()
+variants, per linux commits bdd1d2d3d251c65b74ac4493e08db18971c09240
+and e13ec939e96b13e664bb6cee361cc976a0ee621a]
+
+FIXES 134440
+
+Change-Id: I4753dee61f1b986bbe6a12b5568d1a8db30c65f8
+Reviewed-on: https://gerrit.openafs.org/12769
+Tested-by: BuildBot <buildbot@rampaginggeek.com>
+Tested-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
+Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
+---
+ acinclude.m4               |  1 +
+ src/afs/LINUX/osi_compat.h |  8 ++++++++
+ src/cf/linux-test4.m4      | 12 ++++++++++++
+ 3 files changed, 21 insertions(+)
+
+diff --git a/acinclude.m4 b/acinclude.m4
+index 94b9436..ebfa0cb 100644
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -1134,6 +1134,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
+                LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED
+                LINUX_IOP_LOOKUP_TAKES_UNSIGNED
+                LINUX_D_INVALIDATE_IS_VOID
++               LINUX_KERNEL_READ_OFFSET_IS_LAST
+                dnl If we are guaranteed that keyrings will work - that is
+                dnl  a) The kernel has keyrings enabled
+diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
+index 9871535..78be496 100644
+--- a/src/afs/LINUX/osi_compat.h
++++ b/src/afs/LINUX/osi_compat.h
+@@ -606,7 +606,11 @@ afs_file_read(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ #if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_read(filp, buf, len, pos);
+ #elif defined(HAVE_LINUX_KERNEL_WRITE)
++# if defined(LINUX_KERNEL_READ_OFFSET_IS_LAST)
+     return kernel_read(filp, buf, len, pos);
++# else
++    return kernel_read(filp, *pos, buf, len);
++# endif
+ #else
+     return filp->f_op->read(filp, buf, len, pos);
+ #endif
+@@ -618,7 +622,11 @@ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
+ #if defined(HAVE_LINUX___VFS_WRITE)
+     return __vfs_write(filp, buf, len, pos);
+ #elif defined(HAVE_LINUX_KERNEL_WRITE)
++# if defined(LINUX_KERNEL_READ_OFFSET_IS_LAST)
+     return kernel_write(filp, buf, len, pos);
++# else
++    return kernel_write(filp, buf, len, *pos);
++# endif
+ #else
+     return filp->f_op->write(filp, buf, len, pos);
+ #endif
+diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4
+index 46323ed..5a4615f 100644
+--- a/src/cf/linux-test4.m4
++++ b/src/cf/linux-test4.m4
+@@ -824,3 +824,15 @@ AC_DEFUN([LINUX_D_INVALIDATE_IS_VOID], [
+                      [define if your d_invalidate returns void],
+                      [])
+ ])
++
++AC_DEFUN([LINUX_KERNEL_READ_OFFSET_IS_LAST], [
++  AC_CHECK_LINUX_BUILD([whether offset is the last argument to kernel_read],
++                       [ac_cv_linux_func_kernel_read_offset_is_last],
++                       [#include <linux/fs.h>],
++                       [
++                       ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
++                       ],
++                       [KERNEL_READ_OFFSET_IS_LAST],
++                       [define if your kernel_read has offset as the last argument],
++                       [])
++])
index 2c50dd7efc249da9b71dbbb709d03ec5e82c537c..856cd32d7616da66f15178d85281a1225ecffd10 100644 (file)
@@ -1,2 +1,5 @@
 0003-Add-dummy-exit-command-for-afsd-to-do-nothing.patch
 AFS_component_version_number.c-Respect-SOURCE_DATE_E.patch
+0003-Linux-Test-for-__vfs_write-rather-than-__vfs_read.patch
+0004-Linux-Use-kernel_read-kernel_write-when-__vfs-varian.patch
+0005-afs-fix-kernel_write-kernel_read-arguments.patch