From fd5b31888038ef2a7c37ca3d2651d11630177fbb Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 23 Nov 2020 15:58:00 +0000 Subject: [PATCH] iscsi-scst: Port to Linux kernel v5.10 mm_segment_t, get_fs() and set_fs() have been removed from Linux kernel v5.10. Instead of adding more #ifdef / #endif directives, provide backports for this typedef and these functions in iscsi_scst.h. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9189 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/include/iscsi_scst.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/iscsi-scst/include/iscsi_scst.h b/iscsi-scst/include/iscsi_scst.h index 124ff131d..d6b7acd33 100644 --- a/iscsi-scst/include/iscsi_scst.h +++ b/iscsi-scst/include/iscsi_scst.h @@ -16,6 +16,28 @@ #ifndef _ISCSI_SCST_U_H #define _ISCSI_SCST_U_H +#ifdef __KERNEL__ +#include /* mm_segment_t */ +#include + +/* */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +/* + * With kernel 5.9 or older, certain kernel functions, e.g. setsockopt(), + * sock_recvmsg() only accept a pointer to a user space buffer. With kernel + * v5.10 these functions accept a sockptr_t, a data structure that includes + * information about the address space of a pointer. See also commit + * 47058bb54b57 ("x86: remove address space overrides using set_fs()"). See + * also https://lwn.net/Articles/832121/. The definitions below make it easy + * to write kernel code that is compatible with all kernel versions. + */ +#define KERNEL_DS ((mm_segment_t) { }) +static inline mm_segment_t get_fs(void) { return ((mm_segment_t) { }); } +static inline void set_fs(mm_segment_t seg) { } +#endif +#endif + #ifdef __KERNEL__ #include #else