From f8e05616b98c62a052f549eeba4d537dfac92d20 Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Sat, 19 Sep 2020 15:38:50 -0700 Subject: [PATCH] Pull in upstream patches to support kernel 5.8 Change-Id: Idac78a68e49f57d072829c088141337f8550131d --- debian/changelog | 6 + ...de-linux-time.h-for-linux-errqueue.h.patch | 45 +++++ ...ace-kernel_setsockopt-with-new-funcs.patch | 156 ++++++++++++++++++ ...t-set-name-field-in-backing_dev_info.patch | 46 ++++++ .../0010-LINUX-5.8-use-lru_cache_add.patch | 105 ++++++++++++ debian/patches/series | 4 + 6 files changed, 362 insertions(+) create mode 100644 debian/patches/0007-LINUX-Include-linux-time.h-for-linux-errqueue.h.patch create mode 100644 debian/patches/0008-LINUX-5.8-Replace-kernel_setsockopt-with-new-funcs.patch create mode 100644 debian/patches/0009-LINUX-5.8-do-not-set-name-field-in-backing_dev_info.patch create mode 100644 debian/patches/0010-LINUX-5.8-use-lru_cache_add.patch diff --git a/debian/changelog b/debian/changelog index b7e046d52..80fbc03a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +openafs (1.8.6-3) UNRELEASED; urgency=medium + + * Pull in upstream patches for linux kernel 5.8 support (Closes: #970258) + + -- Benjamin Kaduk Sat, 19 Sep 2020 15:38:14 -0700 + openafs (1.8.6-2) unstable; urgency=medium * Pull in upstream patches for -fcommon support (Closes: #966881) diff --git a/debian/patches/0007-LINUX-Include-linux-time.h-for-linux-errqueue.h.patch b/debian/patches/0007-LINUX-Include-linux-time.h-for-linux-errqueue.h.patch new file mode 100644 index 000000000..fd3787063 --- /dev/null +++ b/debian/patches/0007-LINUX-Include-linux-time.h-for-linux-errqueue.h.patch @@ -0,0 +1,45 @@ +From: Cheyenne Wills +Date: Thu, 2 Apr 2020 13:27:50 -0600 +Subject: LINUX: Include linux/time.h for linux/errqueue.h + +The configuration test for errqueue.h fails with an undefined structure +error on a Linux 3.17 (or higher) system. This prevents setting +HAVE_LINUX_ERRQUEUE_H, which is used to define AFS_RXERRQ_ENV. + +Linux commit f24b9be5957b38bb420b838115040dc2031b7d0c (net-timestamp: +extend SCM_TIMESTAMPING ancillary data struct) - which was picked up in +linux 3.17 added a structure that uses the timespec structure. After +this commit, we need to include linux/time.h to pull in the definition +of the timespec struct. + +Reviewed-on: https://gerrit.openafs.org/13950 +Reviewed-by: Andrew Deason +Tested-by: Andrew Deason +Reviewed-by: Benjamin Kaduk +(cherry picked from commit 086d185872da5f19447cf5ec7846e7ce5104563f) + +Change-Id: I67d01b11c5ea95b8b87832fc833f8fc850ade684 +Reviewed-on: https://gerrit.openafs.org/14130 +Tested-by: BuildBot +Reviewed-by: Benjamin Kaduk +Reviewed-by: Andrew Deason +Reviewed-by: Stephan Wiesand +(cherry picked from commit 0f67e733e82a9001f3f9253c5e1880be845d537b) +--- + src/cf/headers.m4 | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/cf/headers.m4 b/src/cf/headers.m4 +index 913af44..af4a4dd 100644 +--- a/src/cf/headers.m4 ++++ b/src/cf/headers.m4 +@@ -88,7 +88,8 @@ AC_CHECK_HEADERS([security/pam_modules.h],[],[],[AC_INCLUDES_DEFAULT + # include + #endif]) + +-AC_CHECK_HEADERS(linux/errqueue.h,,,[#include ]) ++AC_CHECK_HEADERS(linux/errqueue.h,,,[#include ++#include ]) + + AC_CHECK_TYPES([fsblkcnt_t],,,[ + #include diff --git a/debian/patches/0008-LINUX-5.8-Replace-kernel_setsockopt-with-new-funcs.patch b/debian/patches/0008-LINUX-5.8-Replace-kernel_setsockopt-with-new-funcs.patch new file mode 100644 index 000000000..405cb8fc6 --- /dev/null +++ b/debian/patches/0008-LINUX-5.8-Replace-kernel_setsockopt-with-new-funcs.patch @@ -0,0 +1,156 @@ +From: Cheyenne Wills +Date: Fri, 3 Jul 2020 10:33:51 -0600 +Subject: LINUX 5.8: Replace kernel_setsockopt with new funcs +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Linux 5.8-rc1 commit 'net: remove kernel_setsockopt' (5a892ff2facb) +retires the kernel_setsockopt function. In prior kernel commits new +functions (ip_sock_set_*) were added to replace the specific functions +performed by kernel_setsockopt. + +Define new config test 'HAVE_IP_SOCK_SET' if the 'ip_sock_set' functions +are available. The config define 'HAVE_KERNEL_SETSOCKOPT' is no longer +set in Linux 5.8. + +Create wrapper functions that replace the kernel_setsockopt calls with +calls to the appropriate Linux kernel function(s) (depending on what +functions the kernel supports). + +Remove the unused 'kernel_getsockopt' function (used for building with +pre 2.6.19 kernels). + +For reference + Linux 2.6.19 introduced kernel_setsockopt + Linux 5.8 removed kernel_setsockopt and replaced the functionality + with a set of new functions (ip_sock_set_*) + +Reviewed-on: https://gerrit.openafs.org/14247 +Tested-by: BuildBot +Reviewed-by: Benjamin Kaduk +(cherry picked from commit c48072b9800759ef1682b91ff1e962f6904a2594) + +Change-Id: I2724fad06b1882149d2066d13eced55eff5ee695 +Reviewed-on: https://gerrit.openafs.org/14267 +Tested-by: BuildBot +Reviewed-by: Michael Laß +Reviewed-by: Stephan Wiesand +(cherry picked from commit d7fc5bf9bf031089d80703c48daf30d5b15a80ca) +--- + src/afs/LINUX/osi_compat.h | 43 +++++++++++++++++++++++++++++-------------- + src/cf/linux-kernel-func.m4 | 6 ++++++ + src/rx/LINUX/rx_knet.c | 11 +++-------- + 3 files changed, 38 insertions(+), 22 deletions(-) + +diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h +index 4999b89..620b373 100644 +--- a/src/afs/LINUX/osi_compat.h ++++ b/src/afs/LINUX/osi_compat.h +@@ -314,9 +314,22 @@ zero_user_segment(struct page *pp, unsigned int from1, unsigned int to1) + } + #endif + +-#ifndef HAVE_LINUX_KERNEL_SETSOCKOPT ++#if defined(HAVE_LINUX_IP_SOCK_SET) ++# include ++/* ip_sock_set_* introduced in linux 5.8 */ ++static inline void ++afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu) ++{ ++ ip_sock_set_mtu_discover(sockp->sk, pmtu); ++} ++static inline void ++afs_linux_sock_set_recverr(struct socket *sockp) ++{ ++ ip_sock_set_recverr(sockp->sk); ++} ++#else ++# if !defined(HAVE_LINUX_KERNEL_SETSOCKOPT) + /* Available from 2.6.19 */ +- + static inline int + kernel_setsockopt(struct socket *sockp, int level, int name, char *val, + unsigned int len) { +@@ -329,20 +342,22 @@ kernel_setsockopt(struct socket *sockp, int level, int name, char *val, + + return ret; + } ++# endif /* !HAVE_LINUX_KERNEL_SETSOCKOPT */ + +-static inline int +-kernel_getsockopt(struct socket *sockp, int level, int name, char *val, +- int *len) { +- mm_segment_t old_fs = get_fs(); +- int ret; +- +- set_fs(get_ds()); +- ret = sockp->ops->getsockopt(sockp, level, name, val, len); +- set_fs(old_fs); +- +- return ret; ++static inline void ++afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu) ++{ ++ kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu, ++ sizeof(pmtu)); + } +-#endif ++static inline void ++afs_linux_sock_set_recverr(struct socket *sockp) ++{ ++ int recverr = 1; ++ kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr, ++ sizeof(recverr)); ++} ++#endif /* !HAVE_LINUX_IP_SOCK_SET */ + + #ifdef HAVE_TRY_TO_FREEZE + static inline int +diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 +index 07627db..78ff482 100644 +--- a/src/cf/linux-kernel-func.m4 ++++ b/src/cf/linux-kernel-func.m4 +@@ -151,6 +151,12 @@ AC_CHECK_LINUX_FUNC([lru_cache_add_file], + [#include ], + [lru_cache_add_file(NULL);]) + ++dnl Linux 5.8 replaced kernel_setsockopt with helper functions ++dnl e.g. ip_sock_set_mtu_discover, ip_sock_set_recverr ++AC_CHECK_LINUX_FUNC([ip_sock_set], ++ [#include ], ++ [ip_sock_set_mtu_discover(NULL, 0);]) ++ + dnl Consequences - things which get set as a result of the + dnl above tests + AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"], +diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c +index 9fbb563..50607c8 100644 +--- a/src/rx/LINUX/rx_knet.c ++++ b/src/rx/LINUX/rx_knet.c +@@ -34,7 +34,6 @@ + #include + #include + #endif +- + #include "osi_compat.h" + + /* rxk_NewSocket +@@ -76,14 +75,10 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) + return NULL; + } + +- kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu, +- sizeof(pmtu)); ++ afs_linux_sock_set_mtu_discover(sockp, pmtu); ++ + #ifdef AFS_RXERRQ_ENV +- { +- int recverr = 1; +- kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr, +- sizeof(recverr)); +- } ++ afs_linux_sock_set_recverr(sockp); + #endif + return (osi_socket *)sockp; + } diff --git a/debian/patches/0009-LINUX-5.8-do-not-set-name-field-in-backing_dev_info.patch b/debian/patches/0009-LINUX-5.8-do-not-set-name-field-in-backing_dev_info.patch new file mode 100644 index 000000000..f15117a4b --- /dev/null +++ b/debian/patches/0009-LINUX-5.8-do-not-set-name-field-in-backing_dev_info.patch @@ -0,0 +1,46 @@ +From: Cheyenne Wills +Date: Fri, 3 Jul 2020 10:34:42 -0600 +Subject: LINUX 5.8: do not set name field in backing_dev_info +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Linux-5.8-rc1 commit 'bdi: remove the name field in struct +backing_dev_info' (1cd925d5838) + +Do not set the name field in the backing_dev_info structure if it is +not available. Uses an existing config test + 'STRUCT_BACKING_DEV_INFO_HAS_NAME' + +Note the name field in the backing_dev_info structure was added in +Linux-2.6.32 + +Reviewed-on: https://gerrit.openafs.org/14248 +Tested-by: BuildBot +Reviewed-by: Benjamin Kaduk +(cherry picked from commit d8ec294534fcdee77a2ccd297b4b167dc4d5573d) + +Change-Id: I3d9e18092db998a4c4f26bd63ee3b75383a53d4c +Reviewed-on: https://gerrit.openafs.org/14268 +Tested-by: BuildBot +Reviewed-by: Michael Laß +Reviewed-by: Stephan Wiesand +(cherry picked from commit 335f37be13d2ff954e4aeea617ee66502170805e) +--- + src/afs/LINUX/osi_vfsops.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c +index 8bbb5f2..ca1d5c8 100644 +--- a/src/afs/LINUX/osi_vfsops.c ++++ b/src/afs/LINUX/osi_vfsops.c +@@ -121,7 +121,9 @@ afs_fill_super(struct super_block *sb, void *data, int silent) + code = super_setup_bdi(sb); + if (code) + goto out; ++# if defined(STRUCT_BACKING_DEV_INFO_HAS_NAME) + sb->s_bdi->name = "openafs"; ++# endif + sb->s_bdi->ra_pages = 32; + #else + /* used for inodes backing_dev_info field, also */ diff --git a/debian/patches/0010-LINUX-5.8-use-lru_cache_add.patch b/debian/patches/0010-LINUX-5.8-use-lru_cache_add.patch new file mode 100644 index 000000000..b942bab1b --- /dev/null +++ b/debian/patches/0010-LINUX-5.8-use-lru_cache_add.patch @@ -0,0 +1,105 @@ +From: Cheyenne Wills +Date: Fri, 3 Jul 2020 10:35:06 -0600 +Subject: LINUX 5.8: use lru_cache_add +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +With Linux-5.8-rc1 commit 'mm: fold and remove lru_cache_add_anon() and +lru_cache_add_file()' (6058eaec), the lru_cache_add_file function is +removed since it was functionally equivalent to lru_cache_add. + +Replace lru_cache_add_file with lru_cache_add. + +Introduce a new autoconf test to determine if lru_cache_add is present + +For reference, the Linux changes associated with the lru caches: + + __pagevec_lru_add introduced before v2.6.12-rc2 + + lru_cache_add_file introduced in v2.6.28-rc1 + __pagevec_lru_add_file replaces __pagevec_lru_add in v2.6.28-rc1 + vmscan: split LRU lists into anon & file sets (4f98a2fee) + + __pagevec_lru_add removed in v5.7 with a note to use lru_cache_add_file + mm/swap.c: not necessary to export __pagevec_lru_add() (bde07cfc6) + + lru_cache_add_file removed in v5.8 + mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() + (6058eaec) + lru_cache_add exported + mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() + (6058eaec) + +Openafs will use: + lru_cache_add on 5.8 kernels + lru_cache_add_file from 2.6.28 through 5.7 kernels + __pagevec_lru_add/__pagevec_lru_add_file on pre 2.6.28 kernels + +Reviewed-on: https://gerrit.openafs.org/14249 +Tested-by: BuildBot +Reviewed-by: Andrew Deason +Reviewed-by: Yadavendra Yadav +Reviewed-by: Benjamin Kaduk +(cherry picked from commit 7d85ce221d6ccc19cf76ce7680c74311e4ed2632) + +Change-Id: Iba6ef4441687dbf60d227a708e2a032c2c0dc79f +Reviewed-on: https://gerrit.openafs.org/14269 +Tested-by: BuildBot +Reviewed-by: Michael Laß +Reviewed-by: Stephan Wiesand +(cherry picked from commit facff58b840a47853592510617ba7a1da2e3eaa9) +--- + src/afs/LINUX/osi_vnodeops.c | 8 +++++++- + src/cf/linux-kernel-func.m4 | 7 +++++++ + 2 files changed, 14 insertions(+), 1 deletion(-) + +diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c +index 00995b2..36a4f68 100644 +--- a/src/afs/LINUX/osi_vnodeops.c ++++ b/src/afs/LINUX/osi_vnodeops.c +@@ -71,7 +71,7 @@ extern struct vcache *afs_globalVp; + + /* Handle interfacing with Linux's pagevec/lru facilities */ + +-#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) ++#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) || defined(HAVE_LINUX_LRU_CACHE_ADD) + + /* + * Linux's lru_cache_add_file provides a simplified LRU interface without +@@ -90,7 +90,13 @@ afs_lru_cache_init(struct afs_lru_pages *alrupages) + static inline void + afs_lru_cache_add(struct afs_lru_pages *alrupages, struct page *page) + { ++# if defined(HAVE_LINUX_LRU_CACHE_ADD) ++ lru_cache_add(page); ++# elif defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) + lru_cache_add_file(page); ++# else ++# error need a kernel function to add a page to the kernel lru cache ++# endif + } + + static inline void +diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 +index 78ff482..11d0718 100644 +--- a/src/cf/linux-kernel-func.m4 ++++ b/src/cf/linux-kernel-func.m4 +@@ -147,10 +147,17 @@ AC_CHECK_LINUX_FUNC([inode_lock], + [inode_lock(NULL);]) + + dnl lru_cache_add_file added to Linux 2.6.28. ++dnl removed in Linux 5.8 + AC_CHECK_LINUX_FUNC([lru_cache_add_file], + [#include ], + [lru_cache_add_file(NULL);]) + ++dnl lru_cache_add exported in Linux 5.8 ++dnl replaces lru_cache_add_file ++AC_CHECK_LINUX_FUNC([lru_cache_add], ++ [#include ], ++ [lru_cache_add(NULL);]) ++ + dnl Linux 5.8 replaced kernel_setsockopt with helper functions + dnl e.g. ip_sock_set_mtu_discover, ip_sock_set_recverr + AC_CHECK_LINUX_FUNC([ip_sock_set], diff --git a/debian/patches/series b/debian/patches/series index afa015325..cbae0c091 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,7 @@ 0007-Temporarily-disable-flaky-test.patch 0005-Avoid-duplicate-definitions-of-globals.patch 0006-afsmonitor-remove-unused-LWP_WaitProcess.patch +0007-LINUX-Include-linux-time.h-for-linux-errqueue.h.patch +0008-LINUX-5.8-Replace-kernel_setsockopt-with-new-funcs.patch +0009-LINUX-5.8-do-not-set-name-field-in-backing_dev_info.patch +0010-LINUX-5.8-use-lru_cache_add.patch -- 2.39.5