From bf146f78a29173c76bd06de6b60739cb9fc24e65 Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Mon, 17 Aug 2015 14:59:57 -0400 Subject: [PATCH] Add upstream patches for linux-4.2 support --- debian/changelog | 1 + ...nux-CM-Use-kernel-allocator-directly.patch | 91 +++++++++++++++ ...2-Pass-namespace-to-sock_create_kern.patch | 51 +++++++++ ...l_link_count-is-no-longer-accessible.patch | 59 ++++++++++ ...HECK_LINUX_OPERATION-configure-macro.patch | 46 ++++++++ ...x-4.2-Changes-in-link-operation-APIs.patch | 106 ++++++++++++++++++ debian/patches/series | 5 + 7 files changed, 359 insertions(+) create mode 100644 debian/patches/0004-Linux-CM-Use-kernel-allocator-directly.patch create mode 100644 debian/patches/0005-Linux-4.2-Pass-namespace-to-sock_create_kern.patch create mode 100644 debian/patches/0006-Linux-4.2-total_link_count-is-no-longer-accessible.patch create mode 100644 debian/patches/0007-Linux-Add-AC_CHECK_LINUX_OPERATION-configure-macro.patch create mode 100644 debian/patches/0008-Linux-4.2-Changes-in-link-operation-APIs.patch diff --git a/debian/changelog b/debian/changelog index b2acb0508..e8bd6da1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ openafs (1.6.14-1) UNRELEASED; urgency=medium * Note that the protocol document rfc5864.txt is dual licensed. (Closes: #768385) * Supply copyright notice for systemd helper scripts. (Closes: #779170) + * Import upstream patches to support the 4.2 Linux kernel. -- Benjamin Kaduk Mon, 17 Aug 2015 11:19:55 -0400 diff --git a/debian/patches/0004-Linux-CM-Use-kernel-allocator-directly.patch b/debian/patches/0004-Linux-CM-Use-kernel-allocator-directly.patch new file mode 100644 index 000000000..9a3042467 --- /dev/null +++ b/debian/patches/0004-Linux-CM-Use-kernel-allocator-directly.patch @@ -0,0 +1,91 @@ +From: Simon Wilkinson +Date: Sun, 17 Apr 2011 23:43:51 +0100 +Subject: Linux CM: Use kernel allocator directly + +In another few locations within the Linux portion of the cache +manager, directly use the kernel allocator. We can do so here +because we can guarantee that the amount of memory being allocated +is less than the page size, and there is a kfree() in all of the +exit paths, so we don't need the magic freeing behaviour, either. + +Change-Id: I9c9f3a0b8243b66cb081cd2b35f0d27aaa378934 +Reviewed-on: http://gerrit.openafs.org/4752 +Reviewed-by: Derrick Brashear +Reviewed-by: Marc Dionne +Tested-by: Derrick Brashear +(cherry picked from commit 7a70c2907b0435653098a611a140fea1ac0b2fac) +--- + src/afs/LINUX/osi_vfsops.c | 4 ++-- + src/afs/LINUX/osi_vnodeops.c | 16 ++++++++-------- + 2 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c +index d6504ae..934478d 100644 +--- a/src/afs/LINUX/osi_vfsops.c ++++ b/src/afs/LINUX/osi_vfsops.c +@@ -112,7 +112,7 @@ afs_fill_super(struct super_block *sb, void *data, int silent) + #endif + + /* used for inodes backing_dev_info field, also */ +- afs_backing_dev_info = osi_Alloc(sizeof(struct backing_dev_info)); ++ afs_backing_dev_info = kmalloc(sizeof(struct backing_dev_info), GFP_NOFS); + memset(afs_backing_dev_info, 0, sizeof(struct backing_dev_info)); + #if defined(HAVE_LINUX_BDI_INIT) + bdi_init(afs_backing_dev_info); +@@ -338,7 +338,7 @@ afs_put_super(struct super_block *sbp) + #if defined(HAVE_LINUX_BDI_INIT) + bdi_destroy(afs_backing_dev_info); + #endif +- osi_Free(afs_backing_dev_info, sizeof(struct backing_dev_info)); ++ kfree(afs_backing_dev_info); + AFS_GUNLOCK(); + + sbp->s_dev = 0; +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index 91c09ed..a8f0074 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -1893,7 +1893,7 @@ static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd) + int code; + char *name; + +- name = osi_Alloc(PATH_MAX); ++ name = kmalloc(PATH_MAX, GFP_NOFS); + if (!name) { + return -EIO; + } +@@ -1915,9 +1915,9 @@ static void + afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) + { + char *name = nd_get_link(nd); +- if (name && !IS_ERR(name)) { +- osi_Free(name, PATH_MAX); +- } ++ ++ if (name && !IS_ERR(name)) ++ kfree(name); + } + + #endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */ +@@ -2174,8 +2174,8 @@ afs_linux_fillpage(struct file *fp, struct page *pp) + address = kmap(pp); + ClearPageError(pp); + +- auio = osi_Alloc(sizeof(struct uio)); +- iovecp = osi_Alloc(sizeof(struct iovec)); ++ auio = kmalloc(sizeof(struct uio), GFP_NOFS); ++ iovecp = kmalloc(sizeof(struct iovec), GFP_NOFS); + + setup_uio(auio, iovecp, (char *)address, offset, PAGE_SIZE, UIO_READ, + AFS_UIOSYS); +@@ -2206,8 +2206,8 @@ afs_linux_fillpage(struct file *fp, struct page *pp) + + kunmap(pp); + +- osi_Free(auio, sizeof(struct uio)); +- osi_Free(iovecp, sizeof(struct iovec)); ++ kfree(auio); ++ kfree(iovecp); + + crfree(credp); + return afs_convert_code(code); diff --git a/debian/patches/0005-Linux-4.2-Pass-namespace-to-sock_create_kern.patch b/debian/patches/0005-Linux-4.2-Pass-namespace-to-sock_create_kern.patch new file mode 100644 index 000000000..90c01a749 --- /dev/null +++ b/debian/patches/0005-Linux-4.2-Pass-namespace-to-sock_create_kern.patch @@ -0,0 +1,51 @@ +From: Marc Dionne +Date: Wed, 8 Jul 2015 14:32:31 -0300 +Subject: Linux 4.2: Pass namespace to sock_create_kern + +sock_create_kern gains an additional network namespace +argument. + +Pass in the default system namesapce. + +Change-Id: I640e9497510242788e5060759779785ffb563a81 +Reviewed-on: http://gerrit.openafs.org/11925 +Tested-by: BuildBot +Reviewed-by: Perry Ruiter +Reviewed-by: Chas Williams <3chas3@gmail.com> +Reviewed-by: Benjamin Kaduk +Reviewed-by: Jeffrey Altman +(cherry picked from commit e597b879677d023165298adadfb88db031883ff4) +--- + acinclude.m4 | 3 +++ + src/rx/LINUX/rx_knet.c | 4 +++- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 79df95a..0d1bb61 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -989,6 +989,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) + AC_CHECK_LINUX_FUNC([sock_create_kern], + [#include ], + [sock_create_kern(0, 0, 0, NULL);]) ++ AC_CHECK_LINUX_FUNC([sock_create_kern_ns], ++ [#include ], ++ [sock_create_kern(NULL, 0, 0, 0, NULL);]) + AC_CHECK_LINUX_FUNC([splice_direct_to_actor], + [#include ], + [splice_direct_to_actor(NULL,NULL,NULL);]) +diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c +index 3f7f2bc..1a5cfde 100644 +--- a/src/rx/LINUX/rx_knet.c ++++ b/src/rx/LINUX/rx_knet.c +@@ -42,7 +42,9 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) + int pmtu = IP_PMTUDISC_DONT; + #endif + +-#ifdef HAVE_LINUX_SOCK_CREATE_KERN ++#ifdef HAVE_LINUX_SOCK_CREATE_KERN_NS ++ code = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sockp); ++#elif defined(HAVE_LINUX_SOCK_CREATE_KERN) + code = sock_create_kern(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sockp); + #elif defined(LINUX_KERNEL_SOCK_CREATE_V) + code = sock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sockp, 0); diff --git a/debian/patches/0006-Linux-4.2-total_link_count-is-no-longer-accessible.patch b/debian/patches/0006-Linux-4.2-total_link_count-is-no-longer-accessible.patch new file mode 100644 index 000000000..afc8ace75 --- /dev/null +++ b/debian/patches/0006-Linux-4.2-total_link_count-is-no-longer-accessible.patch @@ -0,0 +1,59 @@ +From: Marc Dionne +Date: Mon, 6 Jul 2015 11:00:13 -0300 +Subject: Linux 4.2: total_link_count is no longer accessible + +The value is now stored in the nameidata structure which +is private to fs/namei.c, so we can't modify it here. + +The effect is that using a path that contains 40+ directories +may fail with ELOOP, depending on which directories in the +path were previously used. After a directory is accessed once +its D_AUTOMOUNT flag is reset and it will no longer count +against the symlink limit in later path lookups. + +Change-Id: I90e4cb0e9004b075bff2330d165c67b7a923193f +Reviewed-on: http://gerrit.openafs.org/11926 +Tested-by: BuildBot +Reviewed-by: Jeffrey Altman +(cherry picked from commit 89aeb71a3e23c944f58cfa9572e9eae4d2130d37) +--- + acinclude.m4 | 1 + + src/afs/LINUX/osi_vnodeops.c | 12 ++++++++++-- + 2 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 0d1bb61..935fd00 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -894,6 +894,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) + AC_CHECK_LINUX_STRUCT([task_struct], [sigmask_lock], [sched.h]) + AC_CHECK_LINUX_STRUCT([task_struct], [tgid], [sched.h]) + AC_CHECK_LINUX_STRUCT([task_struct], [thread_info], [sched.h]) ++ AC_CHECK_LINUX_STRUCT([task_struct], [total_link_count], [sched.h]) + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM + + dnl Check for typed structure elements +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index a8f0074..a878eb4 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -1385,9 +1385,17 @@ afs_dentry_automount(afs_linux_path_t *path) + { + struct dentry *target; + +- /* avoid symlink resolution limits when resolving; we cannot contribute to +- * an infinite symlink loop */ ++ /* ++ * Avoid symlink resolution limits when resolving; we cannot contribute to ++ * an infinite symlink loop. ++ * ++ * On newer kernels the field has moved to the private nameidata structure ++ * so we can't adjust it here. This may cause ELOOP when using a path with ++ * 40 or more directories that are not already in the dentry cache. ++ */ ++#if defined(STRUCT_TASK_STRUCT_HAS_TOTAL_LINK_COUNT) + current->total_link_count--; ++#endif + + target = canonical_dentry(path->dentry->d_inode); + diff --git a/debian/patches/0007-Linux-Add-AC_CHECK_LINUX_OPERATION-configure-macro.patch b/debian/patches/0007-Linux-Add-AC_CHECK_LINUX_OPERATION-configure-macro.patch new file mode 100644 index 000000000..19b36a860 --- /dev/null +++ b/debian/patches/0007-Linux-Add-AC_CHECK_LINUX_OPERATION-configure-macro.patch @@ -0,0 +1,46 @@ +From: Marc Dionne +Date: Mon, 6 Jul 2015 12:00:10 -0300 +Subject: Linux: Add AC_CHECK_LINUX_OPERATION configure macro + +Add a new macro to check the signature of a particular +operation against a provided typed argument list. +One of the arguments is an arbitrary label that is used +to construct the pre-processor define name. This will +allow for testing of different forms for the same +operation. + +This can be used to replace many of the remaining odd +checks in src/cf/linux_test4.m4. + +Change-Id: Ic619ace54f81aa8e1eb744e2d11f541a303b9587 +Reviewed-on: http://gerrit.openafs.org/11927 +Tested-by: BuildBot +Reviewed-by: Jeffrey Altman +(cherry picked from commit c2c0b6bc86c6d67814d0f7fe14fa8eefc445b4a4) +--- + src/cf/linux-test1.m4 | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/src/cf/linux-test1.m4 b/src/cf/linux-test1.m4 +index f7176d2..fd5bfd8 100644 +--- a/src/cf/linux-test1.m4 ++++ b/src/cf/linux-test1.m4 +@@ -150,3 +150,18 @@ AC_DEFUN([AC_CHECK_LINUX_TYPED_STRUCT], + [Define if kernel typedef'd $1 has the $2 element]) + ]) + ++dnl AC_CHECK_LINUX_OPERATION([structure], [operation], [label], [includes], [return_type], [args]) ++AC_DEFUN([AC_CHECK_LINUX_OPERATION], ++ [AS_VAR_PUSHDEF([ac_linux_operation], [ac_cv_linux_operation_$1_$2_$3]) ++ AC_CACHE_CHECK([operation $2 in $1], [ac_linux_operation], ++ [save_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS -Werror" ++ AC_TRY_KBUILD([$4], [struct $1 ops; $5 op($6) { return ($5)0; }; ops.$2 = op;], ++ AS_VAR_SET([ac_linux_operation], [yes]), ++ AS_VAR_SET([ac_linux_operation], [no])) ++ CPPFLAGS="$save_CPPFLAGS" ++ ]) ++ AS_IF([test AS_VAR_GET([ac_linux_operation]) = yes], ++ [AC_DEFINE(AS_TR_CPP(HAVE_LINUX_$1_$2_$3), 1, ++ [Define if $1 has $2 operation of form $6])]) ++ ]) diff --git a/debian/patches/0008-Linux-4.2-Changes-in-link-operation-APIs.patch b/debian/patches/0008-Linux-4.2-Changes-in-link-operation-APIs.patch new file mode 100644 index 000000000..902bcecf5 --- /dev/null +++ b/debian/patches/0008-Linux-4.2-Changes-in-link-operation-APIs.patch @@ -0,0 +1,106 @@ +From: Marc Dionne +Date: Mon, 6 Jul 2015 13:01:38 -0300 +Subject: Linux 4.2: Changes in link operation APIs + +The follow_link and put_link operations are revised. +Test for the new signature and adapt the code. + +Change-Id: I2834589cbe36c41924ab0505e6ca4ecd797a57fd +Reviewed-on: http://gerrit.openafs.org/11928 +Tested-by: BuildBot +Reviewed-by: Jeffrey Altman +(cherry picked from commit 6c3ac6dc1ea865153a65b5c5c4f288617a3e6d0f) +--- + acinclude.m4 | 10 ++++++++++ + src/afs/LINUX/osi_vnodeops.c | 27 +++++++++++++++++++++++++++ + 2 files changed, 37 insertions(+) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 935fd00..af56ea4 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -837,6 +837,16 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) + LINUX_KBUILD_USES_EXTRA_CFLAGS + LINUX_KERNEL_COMPILE_WORKS + ++ dnl Operation signature checks ++ AC_CHECK_LINUX_OPERATION([inode_operations], [follow_link], [no_nameidata], ++ [#include ], ++ [const char *], ++ [struct dentry *dentry, void **link_data]) ++ AC_CHECK_LINUX_OPERATION([inode_operations], [put_link], [no_nameidata], ++ [#include ], ++ [void], ++ [struct inode *inode, void *link_data]) ++ + dnl Check for header files + AC_CHECK_LINUX_HEADER([config.h]) + AC_CHECK_LINUX_HEADER([completion.h]) +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index a878eb4..3c0cb33 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -1896,14 +1896,22 @@ afs_linux_readlink(struct dentry *dp, char *target, int maxlen) + /* afs_linux_follow_link + * a file system dependent link following routine. + */ ++#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) ++static const char *afs_linux_follow_link(struct dentry *dentry, void **link_data) ++#else + static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd) ++#endif + { + int code; + char *name; + + name = kmalloc(PATH_MAX, GFP_NOFS); + if (!name) { ++#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) ++ return ERR_PTR(-EIO); ++#else + return -EIO; ++#endif + } + + AFS_GLOCK(); +@@ -1911,14 +1919,32 @@ static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd) + AFS_GUNLOCK(); + + if (code < 0) { ++#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) ++ return ERR_PTR(code); ++#else + return code; ++#endif + } + + name[code] = '\0'; ++#if defined(HAVE_LINUX_INODE_OPERATIONS_FOLLOW_LINK_NO_NAMEIDATA) ++ return *link_data = name; ++#else + nd_set_link(nd, name); + return 0; ++#endif + } + ++#if defined(HAVE_LINUX_INODE_OPERATIONS_PUT_LINK_NO_NAMEIDATA) ++static void ++afs_linux_put_link(struct inode *inode, void *link_data) ++{ ++ char *name = link_data; ++ ++ if (name && !IS_ERR(name)) ++ kfree(name); ++} ++#else + static void + afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) + { +@@ -1927,6 +1953,7 @@ afs_linux_put_link(struct dentry *dentry, struct nameidata *nd) + if (name && !IS_ERR(name)) + kfree(name); + } ++#endif /* HAVE_LINUX_INODE_OPERATIONS_PUT_LINK_NO_NAMEIDATA */ + + #endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */ + diff --git a/debian/patches/series b/debian/patches/series index a55c8fbc1..a6c972ce1 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,8 @@ 0001-userok.c-Fix-fixed-size-on-stack-path-buffers.patch 0002-Tweak-AFSDIR_PATH_MAX-definition.patch 0003-Add-dummy-exit-command-for-afsd-to-do-nothing.patch +0004-Linux-CM-Use-kernel-allocator-directly.patch +0005-Linux-4.2-Pass-namespace-to-sock_create_kern.patch +0006-Linux-4.2-total_link_count-is-no-longer-accessible.patch +0007-Linux-Add-AC_CHECK_LINUX_OPERATION-configure-macro.patch +0008-Linux-4.2-Changes-in-link-operation-APIs.patch -- 2.39.5