File 0046-LU-16258-llite-Explicitly-support-.splice_write.patch of Package lustre_2_12

From c619b6d6a54235cc0e34a65cf5916a632f4011c3 Mon Sep 17 00:00:00 2001
From: Shaun Tancheff <shaun.tancheff@hpe.com>
Date: Thu, 20 Oct 2022 23:54:49 -0500
Subject: [PATCH] LU-16258 llite: Explicitly support .splice_write

Linux commit v5.9-rc1-6-g36e2c7421f02
  fs: don't allow splice read/write without explicit ops

Lustre supports splice_write and previously provide handlers
for splice_read.
Explicitly use iter_file_splice_write, if it exists.

HPE-bug-id: LUS-11259
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I858688fc9b4dd370b6018c3b134f01e580477b25
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48928
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 lustre/autoconf/lustre-core.m4 |   26 +++++++++++++++++++++++++-
 lustre/llite/file.c            |    9 +++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -2890,7 +2890,7 @@ vfs_setxattr, [
 	__vfs_setxattr(NULL, NULL, NULL, NULL, 0, 0);
 ],[
 	AC_DEFINE(HAVE_VFS_SETXATTR, 1,
-		['__vfs_setxattr is available])
+		['__vfs_setxattr' is available])
 ])
 ]) # LC_VFS_SETXATTR
 
@@ -3546,6 +3546,9 @@ AC_DEFUN([LC_PROG_LINUX], [
 	# 5.1
 	LC_HAS_LINUX_SELINUX_ENABLED
 
+	# 5.10
+	LC_HAVE_ITER_FILE_SPLICE_WRITE
+
 	# 5.12
 	LC_HAVE_USER_NAMESPACE_ARG
 
@@ -3633,6 +3636,27 @@ AC_ARG_ENABLE([mpitests],
 ]) # LB_CONFIG_MPITESTS
 
 #
+# LC_HAVE_ITER_FILE_SPLICE_WRITE
+#
+# Linux commit v5.9-rc1-6-g36e2c7421f02
+#  fs: don't allow splice read/write without explicit ops
+#
+AC_DEFUN([LC_HAVE_ITER_FILE_SPLICE_WRITE], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'iter_file_splice_write' exists],
+iter_file_splice_write, [
+	#include <linux/fs.h>
+],[
+	(void)iter_file_splice_write(NULL, NULL, NULL, 1, 0);
+],[
+	AC_DEFINE(HAVE_ITER_FILE_SPLICE_WRITE, 1,
+		['iter_file_splice_write' exists])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_HAVE_ITER_FILE_SPLICE_WRITE
+
+#
 # LC_CONFIG_QUOTA
 #
 # whether to enable quota support global control
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -4795,6 +4795,9 @@ struct file_operations ll_file_operation
 	.mmap		= ll_file_mmap,
 	.llseek		= ll_file_seek,
 	.splice_read	= ll_file_splice_read,
+#ifdef HAVE_ITER_FILE_SPLICE_WRITE
+	.splice_write	= iter_file_splice_write,
+#endif
 	.fsync		= ll_fsync,
 	.flush		= ll_flush
 };
@@ -4819,6 +4822,9 @@ struct file_operations ll_file_operation
 	.mmap		= ll_file_mmap,
 	.llseek		= ll_file_seek,
 	.splice_read	= ll_file_splice_read,
+#ifdef HAVE_ITER_FILE_SPLICE_WRITE
+	.splice_write	= iter_file_splice_write,
+#endif
 	.fsync		= ll_fsync,
 	.flush		= ll_flush,
 	.flock		= ll_file_flock,
@@ -4846,6 +4852,9 @@ struct file_operations ll_file_operation
 	.mmap		= ll_file_mmap,
 	.llseek		= ll_file_seek,
 	.splice_read	= ll_file_splice_read,
+#ifdef HAVE_ITER_FILE_SPLICE_WRITE
+	.splice_write	= iter_file_splice_write,
+#endif
 	.fsync		= ll_fsync,
 	.flush		= ll_flush,
 	.flock		= ll_file_noflock,
openSUSE Build Service is sponsored by