linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/56] moved sendfile syscall to splice translation unit
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
@ 2014-11-13 21:22   ` Pieter Smith
  2014-11-13 21:22   ` [PATCH 02/56] moved kernel_write out of " Pieter Smith
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter; +Cc: Josh Triplett, Alexander Viro, linux-fsdevel, open list

sendfile functionally forms part of the splice group of syscalls (splice,
vmsplice and tee). Grouping sendfile with splice paves the way to compiling out
the splice group of syscalls for embedded systems that do not need these.

add/remove: 0/0 grow/shrink: 7/2 up/down: 86/-61 (25)
function                                     old     new   delta
file_start_write                              34      68     +34
file_end_write                                29      58     +29
sys_pwritev                                  115     122      +7
sys_preadv                                   115     122      +7
fdput_pos                                     29      36      +7
sys_pwrite64                                 115     116      +1
sys_pread64                                  115     116      +1
sys_tee                                      497     491      -6
sys_splice                                  1075    1020     -55

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/read_write.c | 175 -------------------------------------------------------
 fs/splice.c     | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 178 insertions(+), 175 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 009d854..3f7f04d 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1189,178 +1189,3 @@ COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
 }
 #endif
 
-static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
-		  	   size_t count, loff_t max)
-{
-	struct fd in, out;
-	struct inode *in_inode, *out_inode;
-	loff_t pos;
-	loff_t out_pos;
-	ssize_t retval;
-	int fl;
-
-	/*
-	 * Get input file, and verify that it is ok..
-	 */
-	retval = -EBADF;
-	in = fdget(in_fd);
-	if (!in.file)
-		goto out;
-	if (!(in.file->f_mode & FMODE_READ))
-		goto fput_in;
-	retval = -ESPIPE;
-	if (!ppos) {
-		pos = in.file->f_pos;
-	} else {
-		pos = *ppos;
-		if (!(in.file->f_mode & FMODE_PREAD))
-			goto fput_in;
-	}
-	retval = rw_verify_area(READ, in.file, &pos, count);
-	if (retval < 0)
-		goto fput_in;
-	count = retval;
-
-	/*
-	 * Get output file, and verify that it is ok..
-	 */
-	retval = -EBADF;
-	out = fdget(out_fd);
-	if (!out.file)
-		goto fput_in;
-	if (!(out.file->f_mode & FMODE_WRITE))
-		goto fput_out;
-	retval = -EINVAL;
-	in_inode = file_inode(in.file);
-	out_inode = file_inode(out.file);
-	out_pos = out.file->f_pos;
-	retval = rw_verify_area(WRITE, out.file, &out_pos, count);
-	if (retval < 0)
-		goto fput_out;
-	count = retval;
-
-	if (!max)
-		max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
-
-	if (unlikely(pos + count > max)) {
-		retval = -EOVERFLOW;
-		if (pos >= max)
-			goto fput_out;
-		count = max - pos;
-	}
-
-	fl = 0;
-#if 0
-	/*
-	 * We need to debate whether we can enable this or not. The
-	 * man page documents EAGAIN return for the output at least,
-	 * and the application is arguably buggy if it doesn't expect
-	 * EAGAIN on a non-blocking file descriptor.
-	 */
-	if (in.file->f_flags & O_NONBLOCK)
-		fl = SPLICE_F_NONBLOCK;
-#endif
-	file_start_write(out.file);
-	retval = do_splice_direct(in.file, &pos, out.file, &out_pos, count, fl);
-	file_end_write(out.file);
-
-	if (retval > 0) {
-		add_rchar(current, retval);
-		add_wchar(current, retval);
-		fsnotify_access(in.file);
-		fsnotify_modify(out.file);
-		out.file->f_pos = out_pos;
-		if (ppos)
-			*ppos = pos;
-		else
-			in.file->f_pos = pos;
-	}
-
-	inc_syscr(current);
-	inc_syscw(current);
-	if (pos > max)
-		retval = -EOVERFLOW;
-
-fput_out:
-	fdput(out);
-fput_in:
-	fdput(in);
-out:
-	return retval;
-}
-
-SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd, off_t __user *, offset, size_t, count)
-{
-	loff_t pos;
-	off_t off;
-	ssize_t ret;
-
-	if (offset) {
-		if (unlikely(get_user(off, offset)))
-			return -EFAULT;
-		pos = off;
-		ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS);
-		if (unlikely(put_user(pos, offset)))
-			return -EFAULT;
-		return ret;
-	}
-
-	return do_sendfile(out_fd, in_fd, NULL, count, 0);
-}
-
-SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, size_t, count)
-{
-	loff_t pos;
-	ssize_t ret;
-
-	if (offset) {
-		if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
-			return -EFAULT;
-		ret = do_sendfile(out_fd, in_fd, &pos, count, 0);
-		if (unlikely(put_user(pos, offset)))
-			return -EFAULT;
-		return ret;
-	}
-
-	return do_sendfile(out_fd, in_fd, NULL, count, 0);
-}
-
-#ifdef CONFIG_COMPAT
-COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd,
-		compat_off_t __user *, offset, compat_size_t, count)
-{
-	loff_t pos;
-	off_t off;
-	ssize_t ret;
-
-	if (offset) {
-		if (unlikely(get_user(off, offset)))
-			return -EFAULT;
-		pos = off;
-		ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS);
-		if (unlikely(put_user(pos, offset)))
-			return -EFAULT;
-		return ret;
-	}
-
-	return do_sendfile(out_fd, in_fd, NULL, count, 0);
-}
-
-COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
-		compat_loff_t __user *, offset, compat_size_t, count)
-{
-	loff_t pos;
-	ssize_t ret;
-
-	if (offset) {
-		if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
-			return -EFAULT;
-		ret = do_sendfile(out_fd, in_fd, &pos, count, 0);
-		if (unlikely(put_user(pos, offset)))
-			return -EFAULT;
-		return ret;
-	}
-
-	return do_sendfile(out_fd, in_fd, NULL, count, 0);
-}
-#endif
diff --git a/fs/splice.c b/fs/splice.c
index f5cb9ba..c1a2861 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -28,6 +28,7 @@
 #include <linux/export.h>
 #include <linux/syscalls.h>
 #include <linux/uio.h>
+#include <linux/fsnotify.h>
 #include <linux/security.h>
 #include <linux/gfp.h>
 #include <linux/socket.h>
@@ -2039,3 +2040,180 @@ SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
 
 	return error;
 }
+
+static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
+			   size_t count, loff_t max)
+{
+	struct fd in, out;
+	struct inode *in_inode, *out_inode;
+	loff_t pos;
+	loff_t out_pos;
+	ssize_t retval;
+	int fl;
+
+	/*
+	 * Get input file, and verify that it is ok..
+	 */
+	retval = -EBADF;
+	in = fdget(in_fd);
+	if (!in.file)
+		goto out;
+	if (!(in.file->f_mode & FMODE_READ))
+		goto fput_in;
+	retval = -ESPIPE;
+	if (!ppos) {
+		pos = in.file->f_pos;
+	} else {
+		pos = *ppos;
+		if (!(in.file->f_mode & FMODE_PREAD))
+			goto fput_in;
+	}
+	retval = rw_verify_area(READ, in.file, &pos, count);
+	if (retval < 0)
+		goto fput_in;
+	count = retval;
+
+	/*
+	 * Get output file, and verify that it is ok..
+	 */
+	retval = -EBADF;
+	out = fdget(out_fd);
+	if (!out.file)
+		goto fput_in;
+	if (!(out.file->f_mode & FMODE_WRITE))
+		goto fput_out;
+	retval = -EINVAL;
+	in_inode = file_inode(in.file);
+	out_inode = file_inode(out.file);
+	out_pos = out.file->f_pos;
+	retval = rw_verify_area(WRITE, out.file, &out_pos, count);
+	if (retval < 0)
+		goto fput_out;
+	count = retval;
+
+	if (!max)
+		max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
+
+	if (unlikely(pos + count > max)) {
+		retval = -EOVERFLOW;
+		if (pos >= max)
+			goto fput_out;
+		count = max - pos;
+	}
+
+	fl = 0;
+#if 0
+	/*
+	 * We need to debate whether we can enable this or not. The
+	 * man page documents EAGAIN return for the output at least,
+	 * and the application is arguably buggy if it doesn't expect
+	 * EAGAIN on a non-blocking file descriptor.
+	 */
+	if (in.file->f_flags & O_NONBLOCK)
+		fl = SPLICE_F_NONBLOCK;
+#endif
+	file_start_write(out.file);
+	retval = do_splice_direct(in.file, &pos, out.file, &out_pos, count, fl);
+	file_end_write(out.file);
+
+	if (retval > 0) {
+		add_rchar(current, retval);
+		add_wchar(current, retval);
+		fsnotify_access(in.file);
+		fsnotify_modify(out.file);
+		out.file->f_pos = out_pos;
+		if (ppos)
+			*ppos = pos;
+		else
+			in.file->f_pos = pos;
+	}
+
+	inc_syscr(current);
+	inc_syscw(current);
+	if (pos > max)
+		retval = -EOVERFLOW;
+
+fput_out:
+	fdput(out);
+fput_in:
+	fdput(in);
+out:
+	return retval;
+}
+
+SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd, off_t __user *, offset, size_t, count)
+{
+	loff_t pos;
+	off_t off;
+	ssize_t ret;
+
+	if (offset) {
+		if (unlikely(get_user(off, offset)))
+			return -EFAULT;
+		pos = off;
+		ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS);
+		if (unlikely(put_user(pos, offset)))
+			return -EFAULT;
+		return ret;
+	}
+
+	return do_sendfile(out_fd, in_fd, NULL, count, 0);
+}
+
+SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, size_t, count)
+{
+	loff_t pos;
+	ssize_t ret;
+
+	if (offset) {
+		if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
+			return -EFAULT;
+		ret = do_sendfile(out_fd, in_fd, &pos, count, 0);
+		if (unlikely(put_user(pos, offset)))
+			return -EFAULT;
+		return ret;
+	}
+
+	return do_sendfile(out_fd, in_fd, NULL, count, 0);
+}
+
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd,
+		compat_off_t __user *, offset, compat_size_t, count)
+{
+	loff_t pos;
+	off_t off;
+	ssize_t ret;
+
+	if (offset) {
+		if (unlikely(get_user(off, offset)))
+			return -EFAULT;
+		pos = off;
+		ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS);
+		if (unlikely(put_user(pos, offset)))
+			return -EFAULT;
+		return ret;
+	}
+
+	return do_sendfile(out_fd, in_fd, NULL, count, 0);
+}
+
+COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
+		compat_loff_t __user *, offset, compat_size_t, count)
+{
+	loff_t pos;
+	ssize_t ret;
+
+	if (offset) {
+		if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
+			return -EFAULT;
+		ret = do_sendfile(out_fd, in_fd, &pos, count, 0);
+		if (unlikely(put_user(pos, offset)))
+			return -EFAULT;
+		return ret;
+	}
+
+	return do_sendfile(out_fd, in_fd, NULL, count, 0);
+}
+#endif
+
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/56] moved kernel_write out of splice translation unit
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
  2014-11-13 21:22   ` [PATCH 01/56] moved sendfile syscall to splice translation unit Pieter Smith
@ 2014-11-13 21:22   ` Pieter Smith
       [not found]   ` <1415913813-362-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter; +Cc: Josh Triplett, Alexander Viro, linux-fsdevel, open list

kernel_write shares infrastructure with the read_write translation unit but not
with the splice translation unit. Grouping kernel_write with the read_write
translation unit is more logical. It also paves the way to compiling out the
splice group of syscalls for embedded systems that do not need them.

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/read_write.c | 16 ++++++++++++++++
 fs/splice.c     | 16 ----------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 3f7f04d..4361261 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1189,3 +1189,19 @@ COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
 }
 #endif
 
+ssize_t kernel_write(struct file *file, const char *buf, size_t count,
+			    loff_t pos)
+{
+	mm_segment_t old_fs;
+	ssize_t res;
+
+	old_fs = get_fs();
+	set_fs(get_ds());
+	/* The cast to a user pointer is valid due to the set_fs() */
+	res = vfs_write(file, (__force const char __user *)buf, count, &pos);
+	set_fs(old_fs);
+
+	return res;
+}
+EXPORT_SYMBOL(kernel_write);
+
diff --git a/fs/splice.c b/fs/splice.c
index c1a2861..44b201b 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -583,22 +583,6 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
 	return res;
 }
 
-ssize_t kernel_write(struct file *file, const char *buf, size_t count,
-			    loff_t pos)
-{
-	mm_segment_t old_fs;
-	ssize_t res;
-
-	old_fs = get_fs();
-	set_fs(get_ds());
-	/* The cast to a user pointer is valid due to the set_fs() */
-	res = vfs_write(file, (__force const char __user *)buf, count, &pos);
-	set_fs(old_fs);
-
-	return res;
-}
-EXPORT_SYMBOL(kernel_write);
-
 ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
 				 struct pipe_inode_info *pipe, size_t len,
 				 unsigned int flags)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/56] fs: Support compiling out splice-family syscalls
       [not found]   ` <1415913813-362-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
@ 2014-11-13 21:22     ` Pieter Smith
  0 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter-qeJ+1H9vRZbz+pZb47iToQ
  Cc: Josh Triplett, Alexander Viro, Andrew Morton, Matt Turner,
	Michal Hocko, Fabian Frederick, Paul Gortmaker, Tejun Heo,
	Paul E. McKenney, Luis R. Rodriguez, Peter Foley,
	Eric W. Biederman, Oleg Nesterov, H. Peter Anvin, Andy Lutomirski,
	Vivek Goyal, David Herrmann, Kees Cook, Mailing List, open list,
	open list:ABI/API

Many embedded systems will not need the splice-family syscalls (splice,
vmsplice, tee and sendfile). Omitting them saves space.  This adds a new EXPERT
config option CONFIG_SYSCALL_SPLICE (default y) to support compiling them out.

This patch removes almost all callers of .splice_read() and .splice_write()
in the file_operations struct. This paves the way to eventually compile out the
.splice_read and .splice_write members of the file_operations struct as well as
the remaining splice-related infrastructure.

add/remove: 0/16 grow/shrink: 2/5 up/down: 114/-3693 (-3579)
function                                     old     new   delta
splice_direct_to_actor                       348     416     +68
splice_to_pipe                               371     417     +46
splice_from_pipe_next                        107     106      -1
fdput                                         11       -     -11
signal_pending                                39      26     -13
fdget                                         56      42     -14
user_page_pipe_buf_ops                        20       -     -20
user_page_pipe_buf_steal                      25       -     -25
file_end_write                                58      29     -29
file_start_write                              68      34     -34
pipe_to_user                                  43       -     -43
wakeup_pipe_readers                           54       -     -54
do_splice_to                                  87       -     -87
ipipe_prep.part                               92       -     -92
opipe_prep.part                              119       -    -119
sys_sendfile                                 122       -    -122
sys_sendfile64                               126       -    -126
sys_vmsplice                                 137       -    -137
vmsplice_to_user                             205       -    -205
sys_tee                                      491       -    -491
do_sendfile                                  492       -    -492
vmsplice_to_pipe                             558       -    -558
sys_splice                                  1020       -   -1020

Signed-off-by: Pieter Smith <pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
---
 fs/splice.c     |  2 ++
 init/Kconfig    | 10 ++++++++++
 kernel/sys_ni.c |  8 ++++++++
 3 files changed, 20 insertions(+)

diff --git a/fs/splice.c b/fs/splice.c
index 44b201b..7c4c695 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1316,6 +1316,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
 	return ret;
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
 			       struct pipe_inode_info *opipe,
 			       size_t len, unsigned int flags);
@@ -2200,4 +2201,5 @@ COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
 	return do_sendfile(out_fd, in_fd, NULL, count, 0);
 }
 #endif
+#endif
 
diff --git a/init/Kconfig b/init/Kconfig
index 782a65b..25ee289 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1547,6 +1547,16 @@ config ADVISE_SYSCALLS
 	  applications use these syscalls, you can disable this option to save
 	  space.
 
+config SYSCALL_SPLICE
+	bool "Enable splice/vmsplice/tee/sendfile syscalls" if EXPERT
+	default y
+	help
+	  This option enables the splice, vmsplice, tee and sendfile syscalls. These
+	  are used by applications to: move data between buffers and arbitrary file
+	  descriptors; "copy" data between buffers; or copy data from userspace into
+	  buffers. If building an embedded system where no applications use these
+	  syscalls, you can disable this option to save space.
+
 config PCI_QUIRKS
 	default y
 	bool "Enable PCI quirk workarounds" if EXPERT
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index d4709d4..2913337 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -159,6 +159,14 @@ cond_syscall(sys_uselib);
 cond_syscall(sys_fadvise64);
 cond_syscall(sys_fadvise64_64);
 cond_syscall(sys_madvise);
+cond_syscall(sys_vmsplice);
+cond_syscall(sys_splice);
+cond_syscall(sys_tee);
+cond_syscall(sys_sendfile);
+cond_syscall(sys_sendfile64);
+cond_syscall(compat_sys_vmsplice);
+cond_syscall(compat_sys_sendfile);
+cond_syscall(compat_sys_sendfile64);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/56] fs: Macros to define splice file_operations
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (2 preceding siblings ...)
       [not found]   ` <1415913813-362-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
@ 2014-11-13 21:22   ` Pieter Smith
  2014-11-13 21:49     ` Richard Weinberger
  2014-11-13 21:51     ` Al Viro
  2014-11-13 21:22   ` [PATCH 07/56] fs/affs: support compiling out splice Pieter Smith
                     ` (6 subsequent siblings)
  10 siblings, 2 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter
  Cc: Josh Triplett, Jeff Layton, J. Bruce Fields, linux-fsdevel,
	open list

Provides a CONFIG_SYSCALL_SPLICE compatible way of defining the .splice_read
and .splice_write file_operations so that they can later be compiled out when
the kernel is configured without the splice-family syscalls

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 include/linux/fs.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9418772..a88de9f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1512,6 +1512,32 @@ struct file_operations {
 	int (*show_fdinfo)(struct seq_file *m, struct file *f);
 };
 
+#ifdef CONFIG_SYSCALL_SPLICE
+
+/*
+ * Define and init the splice_read member of a file_operations struct
+ */
+#define SPLICE_READ_INIT(read) .splice_read = read,
+
+/*
+ * Define and init the splice_read member of a file_operations struct
+ */
+#define SPLICE_WRITE_INIT(write) .splice_write = write,
+
+#else /* #ifdef CONFIG_SYSCALL_SPLICE */
+
+/*
+ * Define and init the splice_read member of a file_operations struct
+ */
+#define SPLICE_READ_INIT(read)
+
+/*
+ * Define and init the splice_read member of a file_operations struct
+ */
+#define SPLICE_WRITE_INIT(write)
+
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 struct inode_operations {
 	struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
 	void * (*follow_link) (struct dentry *, struct nameidata *);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/56] fs/affs: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (3 preceding siblings ...)
  2014-11-13 21:22   ` [PATCH 04/56] fs: Macros to define splice file_operations Pieter Smith
@ 2014-11-13 21:22   ` Pieter Smith
  2014-11-13 21:22   ` [PATCH 09/56] fs/bad_inode: " Pieter Smith
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter
  Cc: Josh Triplett, Andrew Morton, Fabian Frederick, Al Viro,
	open list:AFFS FILE SYSTEM, open list

Compile out splice support from affs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/affs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index a7fe57d..8c2752d 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -35,7 +35,7 @@ const struct file_operations affs_file_operations = {
 	.open		= affs_file_open,
 	.release	= affs_file_release,
 	.fsync		= affs_file_fsync,
-	.splice_read	= generic_file_splice_read,
+	SPLICE_READ_INIT(generic_file_splice_read)
 };
 
 const struct inode_operations affs_file_inode_operations = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/56] fs/bad_inode: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (4 preceding siblings ...)
  2014-11-13 21:22   ` [PATCH 07/56] fs/affs: support compiling out splice Pieter Smith
@ 2014-11-13 21:22   ` Pieter Smith
  2014-11-13 21:22   ` [PATCH 10/56] fs/block_dev: " Pieter Smith
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter; +Cc: Josh Triplett, Alexander Viro, linux-fsdevel, open list

Compile out splice support from bad_inode when the splice-family of syscalls is
not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-12 (-12)
function                                     old     new   delta
bad_file_splice_write                          6       -      -6
bad_file_splice_read                           6       -      -6

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/bad_inode.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index afd2b44..ccb076d 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -131,14 +131,16 @@ static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl)
 	return -EIO;
 }
 
-static ssize_t bad_file_splice_write(struct pipe_inode_info *pipe,
+static ssize_t __maybe_unused bad_file_splice_write(
+			struct pipe_inode_info *pipe,
 			struct file *out, loff_t *ppos, size_t len,
 			unsigned int flags)
 {
 	return -EIO;
 }
 
-static ssize_t bad_file_splice_read(struct file *in, loff_t *ppos,
+static ssize_t __maybe_unused bad_file_splice_read(
+			struct file *in, loff_t *ppos,
 			struct pipe_inode_info *pipe, size_t len,
 			unsigned int flags)
 {
@@ -168,8 +170,8 @@ static const struct file_operations bad_file_ops =
 	.get_unmapped_area = bad_file_get_unmapped_area,
 	.check_flags	= bad_file_check_flags,
 	.flock		= bad_file_flock,
-	.splice_write	= bad_file_splice_write,
-	.splice_read	= bad_file_splice_read,
+	SPLICE_WRITE_INIT(bad_file_splice_write)
+	SPLICE_READ_INIT(bad_file_splice_read)
 };
 
 static int bad_inode_create (struct inode *dir, struct dentry *dentry,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/56] fs/block_dev: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (5 preceding siblings ...)
  2014-11-13 21:22   ` [PATCH 09/56] fs/bad_inode: " Pieter Smith
@ 2014-11-13 21:22   ` Pieter Smith
  2014-11-13 21:23   ` [PATCH 25/56] fs/hfs: " Pieter Smith
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:22 UTC (permalink / raw)
  To: pieter; +Cc: Josh Triplett, Alexander Viro, linux-fsdevel, open list

Compile out splice support from block_dev when the splice-family of syscalls is
not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/block_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6d72746..ce7096b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1645,8 +1645,8 @@ const struct file_operations def_blk_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= compat_blkdev_ioctl,
 #endif
-	.splice_read	= generic_file_splice_read,
-	.splice_write	= iter_file_splice_write,
+	SPLICE_READ_INIT(generic_file_splice_read)
+	SPLICE_WRITE_INIT(iter_file_splice_write)
 };
 
 int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 25/56] fs/hfs: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (6 preceding siblings ...)
  2014-11-13 21:22   ` [PATCH 10/56] fs/block_dev: " Pieter Smith
@ 2014-11-13 21:23   ` Pieter Smith
  2014-11-13 21:23   ` [PATCH 26/56] fs/hfsplus: " Pieter Smith
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:23 UTC (permalink / raw)
  To: pieter
  Cc: Josh Triplett, Al Viro, Andrew Morton, Minchan Kim, Rik van Riel,
	Johannes Weiner, open list:HFS FILESYSTEM, open list

Compile out splice support from hfs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/hfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index d0929bc..17c7963 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -679,7 +679,7 @@ static const struct file_operations hfs_file_operations = {
 	.write		= new_sync_write,
 	.write_iter	= generic_file_write_iter,
 	.mmap		= generic_file_mmap,
-	.splice_read	= generic_file_splice_read,
+	SPLICE_READ_INIT(generic_file_splice_read)
 	.fsync		= hfs_file_fsync,
 	.open		= hfs_file_open,
 	.release	= hfs_file_release,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 26/56] fs/hfsplus: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (7 preceding siblings ...)
  2014-11-13 21:23   ` [PATCH 25/56] fs/hfs: " Pieter Smith
@ 2014-11-13 21:23   ` Pieter Smith
  2014-11-13 21:23   ` [PATCH 50/56] fs/read_write: " Pieter Smith
  2014-11-13 21:23   ` [PATCH 56/56] fs/splice: full support for " Pieter Smith
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:23 UTC (permalink / raw)
  To: pieter
  Cc: Josh Triplett, Al Viro, Christoph Hellwig, Andrew Morton,
	Vyacheslav Dubeyko, Sergei Antonov, Sougata Santra,
	open list:HFSPLUS FILESYSTEM, open list

Compile out splice support from hfsplus when the splice-family of syscalls is
not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/hfsplus/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 0cf786f..8dfd889 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -346,7 +346,7 @@ static const struct file_operations hfsplus_file_operations = {
 	.write		= new_sync_write,
 	.write_iter	= generic_file_write_iter,
 	.mmap		= generic_file_mmap,
-	.splice_read	= generic_file_splice_read,
+	SPLICE_READ_INIT(generic_file_splice_read)
 	.fsync		= hfsplus_file_fsync,
 	.open		= hfsplus_file_open,
 	.release	= hfsplus_file_release,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 50/56] fs/read_write: support compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (8 preceding siblings ...)
  2014-11-13 21:23   ` [PATCH 26/56] fs/hfsplus: " Pieter Smith
@ 2014-11-13 21:23   ` Pieter Smith
  2014-11-13 21:23   ` [PATCH 56/56] fs/splice: full support for " Pieter Smith
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:23 UTC (permalink / raw)
  To: pieter; +Cc: Josh Triplett, Alexander Viro, linux-fsdevel, open list

Compile out splice support from read_write when the splice-family of syscalls
is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 4361261..55dee62 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -32,7 +32,7 @@ const struct file_operations generic_ro_fops = {
 	.read		= new_sync_read,
 	.read_iter	= generic_file_read_iter,
 	.mmap		= generic_file_readonly_mmap,
-	.splice_read	= generic_file_splice_read,
+	SPLICE_READ_INIT(generic_file_splice_read)
 };
 
 EXPORT_SYMBOL(generic_ro_fops);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 56/56] fs/splice: full support for compiling out splice
       [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
                     ` (9 preceding siblings ...)
  2014-11-13 21:23   ` [PATCH 50/56] fs/read_write: " Pieter Smith
@ 2014-11-13 21:23   ` Pieter Smith
  10 siblings, 0 replies; 14+ messages in thread
From: Pieter Smith @ 2014-11-13 21:23 UTC (permalink / raw)
  To: pieter
  Cc: Josh Triplett, Alexander Viro, Jeff Layton, J. Bruce Fields,
	Andrew Morton, Konrad Rzeszutek Wilk, Minchan Kim,
	Fabian Frederick, Randy Dunlap, Xiao Guangrong, open list,
	linux-fsdevel

Entirely compile out splice translation unit when the system is configured
without splice family of syscalls (i.e. CONFIG_SYSCALL_SPLICE is undefined).

add/remove: 0/26 grow/shrink: 0/22 up/down: 0/-5001 (-5001)
function                                     old     new   delta
generic_pipe_buf_nosteal                       6       -      -6
zero_fops                                    116     108      -8
urandom_fops                                 116     108      -8
simple_dir_operations                        116     108      -8
random_fops                                  116     108      -8
ramfs_file_operations                        116     108      -8
posix_clock_file_operations                  116     108      -8
pm_qos_power_fops                            116     108      -8
pipefifo_fops                                116     108      -8
perf_fops                                    116     108      -8
null_fops                                    116     108      -8
misc_fops                                    116     108      -8
memory_fops                                  116     108      -8
mem_fops                                     116     108      -8
generic_ro_fops                              116     108      -8
full_fops                                    116     108      -8
def_chr_fops                                 116     108      -8
def_blk_fops                                 116     108      -8
bad_sock_fops                                116     108      -8
bad_file_ops                                 116     108      -8
spd_release_page                              10       -     -10
PageUptodate                                  22      11     -11
lock_page                                     36      24     -12
page_cache_pipe_buf_release                   16       -     -16
empty_fops                                   232     216     -16
page_cache_pipe_buf_ops                       20       -     -20
nosteal_pipe_buf_ops                          20       -     -20
default_pipe_buf_ops                          20       -     -20
generic_splice_sendpage                       24       -     -24
splice_shrink_spd                             27       -     -27
direct_splice_actor                           47       -     -47
default_file_splice_write                     49       -     -49
wakeup_pipe_writers                           54       -     -54
write_pipe_buf                                71       -     -71
page_cache_pipe_buf_confirm                   80       -     -80
splice_grow_spd                               87       -     -87
splice_from_pipe                              93       -     -93
splice_from_pipe_next                        106       -    -106
pipe_to_sendpage                             109       -    -109
page_cache_pipe_buf_steal                    114       -    -114
generic_file_splice_read                     131       -    -131
do_splice_direct                             148       -    -148
__splice_from_pipe                           246       -    -246
splice_direct_to_actor                       416       -    -416
splice_to_pipe                               417       -    -417
default_file_splice_read                     688       -    -688
iter_file_splice_write                       702       -    -702
__generic_file_splice_read                  1109       -   -1109

Signed-off-by: Pieter Smith <pieter@boesman.nl>
---
 drivers/block/Kconfig  | 1 +
 fs/Makefile            | 4 +++-
 fs/splice.c            | 2 --
 include/linux/fs.h     | 4 ++++
 include/linux/splice.h | 3 +++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 014a1cf..804125ea 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -210,6 +210,7 @@ config BLK_DEV_COW_COMMON
 
 config BLK_DEV_LOOP
 	tristate "Loopback device support"
+	depends on SYSCALL_SPLICE
 	---help---
 	  Saying Y here will allow you to use a regular file as a block
 	  device; you can then create a file system on that block device and
diff --git a/fs/Makefile b/fs/Makefile
index 90c8852..13f9cfa 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -10,7 +10,7 @@ obj-y :=	open.o read_write.o file_table.o super.o \
 		ioctl.o readdir.o select.o dcache.o inode.o \
 		attr.o bad_inode.o file.o filesystems.o namespace.o \
 		seq_file.o xattr.o libfs.o fs-writeback.o \
-		pnode.o splice.o sync.o utimes.o \
+		pnode.o sync.o utimes.o \
 		stack.o fs_struct.o statfs.o fs_pin.o
 
 ifeq ($(CONFIG_BLOCK),y)
@@ -21,6 +21,8 @@ endif
 
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
+obj-$(CONFIG_SYSCALL_SPLICE)	+= splice.o
+
 obj-y				+= notify/
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)	+= anon_inodes.o
diff --git a/fs/splice.c b/fs/splice.c
index 7c4c695..44b201b 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1316,7 +1316,6 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
 	return ret;
 }
 
-#ifdef CONFIG_SYSCALL_SPLICE
 static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
 			       struct pipe_inode_info *opipe,
 			       size_t len, unsigned int flags);
@@ -2201,5 +2200,4 @@ COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
 	return do_sendfile(out_fd, in_fd, NULL, count, 0);
 }
 #endif
-#endif
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a88de9f..5d6b759 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1504,8 +1504,10 @@ struct file_operations {
 	unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 	int (*check_flags)(int);
 	int (*flock) (struct file *, int, struct file_lock *);
+#ifdef CONFIG_SYSCALL_SPLICE
 	ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
 	ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
 	int (*setlease)(struct file *, long, struct file_lock **);
 	long (*fallocate)(struct file *file, int mode, loff_t offset,
 			  loff_t len);
@@ -2486,6 +2488,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
 			int datasync);
 extern void block_sync_page(struct page *page);
 
+#ifdef CONFIG_SYSCALL_SPLICE
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
 		struct pipe_inode_info *, size_t, unsigned int);
@@ -2495,6 +2498,7 @@ extern ssize_t iter_file_splice_write(struct pipe_inode_info *,
 		struct file *, loff_t *, size_t, unsigned int);
 extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
 		struct file *out, loff_t *, size_t len, unsigned int flags);
+#endif
 
 extern void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
diff --git a/include/linux/splice.h b/include/linux/splice.h
index da2751d..ecd176f 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -10,6 +10,7 @@
 
 #include <linux/pipe_fs_i.h>
 
+#ifdef CONFIG_SYSCALL_SPLICE
 /*
  * Flags passed in from splice/tee/vmsplice
  */
@@ -83,4 +84,6 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
 extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
 
 extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 04/56] fs: Macros to define splice file_operations
  2014-11-13 21:22   ` [PATCH 04/56] fs: Macros to define splice file_operations Pieter Smith
@ 2014-11-13 21:49     ` Richard Weinberger
  2014-11-13 22:24       ` josh
  2014-11-13 21:51     ` Al Viro
  1 sibling, 1 reply; 14+ messages in thread
From: Richard Weinberger @ 2014-11-13 21:49 UTC (permalink / raw)
  To: Pieter Smith
  Cc: Josh Triplett, Jeff Layton, J. Bruce Fields, linux-fsdevel,
	open list

On Thu, Nov 13, 2014 at 10:22 PM, Pieter Smith <pieter@boesman.nl> wrote:
> Provides a CONFIG_SYSCALL_SPLICE compatible way of defining the .splice_read
> and .splice_write file_operations so that they can later be compiled out when
> the kernel is configured without the splice-family syscalls
>
> Signed-off-by: Pieter Smith <pieter@boesman.nl>
> ---
>  include/linux/fs.h | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 9418772..a88de9f 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1512,6 +1512,32 @@ struct file_operations {
>         int (*show_fdinfo)(struct seq_file *m, struct file *f);
>  };
>
> +#ifdef CONFIG_SYSCALL_SPLICE
> +
> +/*
> + * Define and init the splice_read member of a file_operations struct
> + */
> +#define SPLICE_READ_INIT(read) .splice_read = read,
> +
> +/*
> + * Define and init the splice_read member of a file_operations struct
> + */
> +#define SPLICE_WRITE_INIT(write) .splice_write = write,

This is ugly like hell.
Why can't you do something like __exit_p()?

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 04/56] fs: Macros to define splice file_operations
  2014-11-13 21:22   ` [PATCH 04/56] fs: Macros to define splice file_operations Pieter Smith
  2014-11-13 21:49     ` Richard Weinberger
@ 2014-11-13 21:51     ` Al Viro
  1 sibling, 0 replies; 14+ messages in thread
From: Al Viro @ 2014-11-13 21:51 UTC (permalink / raw)
  To: Pieter Smith
  Cc: Josh Triplett, Jeff Layton, J. Bruce Fields, linux-fsdevel,
	open list

On Thu, Nov 13, 2014 at 10:22:41PM +0100, Pieter Smith wrote:
> Provides a CONFIG_SYSCALL_SPLICE compatible way of defining the .splice_read
> and .splice_write file_operations so that they can later be compiled out when
> the kernel is configured without the splice-family syscalls

This (and subsequent stuff making use of that) is bloody pointless.  You
save 2 words per file_operations instance, at the cost of making things
uglier and harder to grep.  NAK.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 04/56] fs: Macros to define splice file_operations
  2014-11-13 21:49     ` Richard Weinberger
@ 2014-11-13 22:24       ` josh
  0 siblings, 0 replies; 14+ messages in thread
From: josh @ 2014-11-13 22:24 UTC (permalink / raw)
  To: Richard Weinberger, Al Viro
  Cc: Pieter Smith, Jeff Layton, J. Bruce Fields, linux-fsdevel,
	open list

On Thu, Nov 13, 2014 at 10:49:07PM +0100, Richard Weinberger wrote:
> On Thu, Nov 13, 2014 at 10:22 PM, Pieter Smith <pieter@boesman.nl> wrote:
> > Provides a CONFIG_SYSCALL_SPLICE compatible way of defining the .splice_read
> > and .splice_write file_operations so that they can later be compiled out when
> > the kernel is configured without the splice-family syscalls
[...]
> > --- a/include/linux/fs.h
> > +++ b/include/linux/fs.h
> > @@ -1512,6 +1512,32 @@ struct file_operations {
> >         int (*show_fdinfo)(struct seq_file *m, struct file *f);
> >  };
> >
> > +#ifdef CONFIG_SYSCALL_SPLICE
> > +
> > +/*
> > + * Define and init the splice_read member of a file_operations struct
> > + */
> > +#define SPLICE_READ_INIT(read) .splice_read = read,
> > +
> > +/*
> > + * Define and init the splice_read member of a file_operations struct
> > + */
> > +#define SPLICE_WRITE_INIT(write) .splice_write = write,
> 
> This is ugly like hell.
> Why can't you do something like __exit_p()?

On Thu, Nov 13, 2014 at 09:51:39PM +0000, Al Viro wrote:
> This (and subsequent stuff making use of that) is bloody pointless.  You
> save 2 words per file_operations instance, at the cost of making things
> uglier and harder to grep.  NAK.

Given the large number of uses of these, I agree that it doesn't seem
worth the tradeoff, particularly since very few file_operations
structures will exist on any individual tiny configuration.  I think we
should go with a wrapper similar to __exit_p (splice_p?), which just
becomes NULL when !CONFIG_SYSCALL_SPLICE.  Removing the actual pointers
from file_operations can wait until we have compiler support for tagging
specific fields in a structure (like splice_read and splice_write) as
dead.

Similarly, you shouldn't wrap the functions that get assigned to those
pointers with #ifdef; instead, mark them as __maybe_unused, which
doesn't even add any lines of code.  The compiler will then
automatically throw them out when not used, without emiting a warning.

That should drastically reduce the number of changes, and in particular
eliminate almost all of the ifdefs.

- Josh Triplett

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-11-13 22:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <pieter@boesman.nl>
     [not found] ` <1415913813-362-1-git-send-email-pieter@boesman.nl>
2014-11-13 21:22   ` [PATCH 01/56] moved sendfile syscall to splice translation unit Pieter Smith
2014-11-13 21:22   ` [PATCH 02/56] moved kernel_write out of " Pieter Smith
     [not found]   ` <1415913813-362-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
2014-11-13 21:22     ` [PATCH 03/56] fs: Support compiling out splice-family syscalls Pieter Smith
2014-11-13 21:22   ` [PATCH 04/56] fs: Macros to define splice file_operations Pieter Smith
2014-11-13 21:49     ` Richard Weinberger
2014-11-13 22:24       ` josh
2014-11-13 21:51     ` Al Viro
2014-11-13 21:22   ` [PATCH 07/56] fs/affs: support compiling out splice Pieter Smith
2014-11-13 21:22   ` [PATCH 09/56] fs/bad_inode: " Pieter Smith
2014-11-13 21:22   ` [PATCH 10/56] fs/block_dev: " Pieter Smith
2014-11-13 21:23   ` [PATCH 25/56] fs/hfs: " Pieter Smith
2014-11-13 21:23   ` [PATCH 26/56] fs/hfsplus: " Pieter Smith
2014-11-13 21:23   ` [PATCH 50/56] fs/read_write: " Pieter Smith
2014-11-13 21:23   ` [PATCH 56/56] fs/splice: full support for " Pieter Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).