Re: [PATCH v6 4/7] fs/fuse: support compiling out splice

2014-12-07 Thread Pieter Smith
On Fri, Dec 05, 2014 at 11:44:36AM +0100, Miklos Szeredi wrote:
> On Thu, Dec 4, 2014 at 6:50 PM, Pieter Smith  wrote:
> > To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
> > struct is exported by fs/splice. The goal of the larger patch set is to
> > completely compile out fs/splice, so uses of the exported struct need to be
> > compiled out along with fs/splice.
> >
> > This patch therefore compiles out splice support in fs/fuse when
> > CONFIG_SYSCALL_SPLICE is undefined.
> >
> > Signed-off-by: Pieter Smith 
> 
> 
> In the future could you PLEASE PLEASE cut the fuse-devel Cc from the
> non-fuse specific patches (and I guess that goes for any other
> subsystem specific lists and persons as well)?
> 
> Otherwise:
> 
> Acked-by: Miklos Szeredi 
> 
> Thanks,
> Miklos

I added your Acked-by and removed you and fuse-dev from postings on future
versions of this patch-set.

Thanks,
Pieter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v6 4/7] fs/fuse: support compiling out splice

2014-12-07 Thread Pieter Smith
On Fri, Dec 05, 2014 at 11:44:36AM +0100, Miklos Szeredi wrote:
 On Thu, Dec 4, 2014 at 6:50 PM, Pieter Smith pie...@boesman.nl wrote:
  To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
  struct is exported by fs/splice. The goal of the larger patch set is to
  completely compile out fs/splice, so uses of the exported struct need to be
  compiled out along with fs/splice.
 
  This patch therefore compiles out splice support in fs/fuse when
  CONFIG_SYSCALL_SPLICE is undefined.
 
  Signed-off-by: Pieter Smith pie...@boesman.nl
 
 
 In the future could you PLEASE PLEASE cut the fuse-devel Cc from the
 non-fuse specific patches (and I guess that goes for any other
 subsystem specific lists and persons as well)?
 
 Otherwise:
 
 Acked-by: Miklos Szeredi mszer...@suse.cz
 
 Thanks,
 Miklos

I added your Acked-by and removed you and fuse-dev from postings on future
versions of this patch-set.

Thanks,
Pieter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/7] fs: moved kernel_write to fs/read_write

2014-12-04 Thread Pieter Smith
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 
---
 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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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, );
+   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, );
-   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)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/7] fs: move sendfile syscall into fs/splice

2014-12-04 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith 
---
 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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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, , 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, _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, , out.file, _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, , 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

[PATCH v6 5/7] net/core: support compiling out splice

2014-12-04 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith 
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd->pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 7/7] fs/splice: full support for compiling out splice

2014-12-04 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith 
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc *);
 
+#ifdef

[PATCH v6 6/7] fs/nfsd: support compiling out splice

2014-12-04 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith 
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp->rq_splice_ok = true;
+   rqstp->rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp->rq_usedeferral = true;
rqstp->rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 4/7] fs/fuse: support compiling out splice

2014-12-04 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith 
---
 fs/fuse/dev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..99f1ff4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,6 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1369,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/7] fs/splice: support compiling out splice-family syscalls

2014-12-04 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

The last change required before fs/splice can be comipled out is making fs/nfsd
aware of the lacking splice support in file-systems when CONFIG_SYSCALL_SPLICE
is undefined.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger

[PATCH v6 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-12-04 Thread Pieter Smith
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109


Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/nfsd: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   4 +
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 299 insertions(+), 192 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-12-04 Thread Pieter Smith
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109


Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/nfsd: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   4 +
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 299 insertions(+), 192 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/7] fs/splice: support compiling out splice-family syscalls

2014-12-04 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

The last change required before fs/splice can be comipled out is making fs/nfsd
aware of the lacking splice support in file-systems when CONFIG_SYSCALL_SPLICE
is undefined.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 pie...@boesman.nl
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info

[PATCH v6 4/7] fs/fuse: support compiling out splice

2014-12-04 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..99f1ff4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,6 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1369,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 7/7] fs/splice: full support for compiling out splice

2014-12-04 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc

[PATCH v6 6/7] fs/nfsd: support compiling out splice

2014-12-04 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp-rq_splice_ok = true;
+   rqstp-rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp-rq_usedeferral = true;
rqstp-rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 5/7] net/core: support compiling out splice

2014-12-04 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd-pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/7] fs: move sendfile syscall into fs/splice

2014-12-04 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith pie...@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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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

[PATCH v6 2/7] fs: moved kernel_write to fs/read_write

2014-12-04 Thread Pieter Smith
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 pie...@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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 12:49:16PM -0800, j...@joshtriplett.org wrote:
> On Tue, Nov 25, 2014 at 08:42:42PM +0100, Pieter Smith wrote:
> > On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
> > > [Trimming CC.  Please do the same for other patches.  I for one am not
> > > interested in the general tinification discussion]
> > > 
> > > On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
> > > > To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
> > > > This
> > > > struct is exported by fs/splice. The goal of the larger patch set is to
> > > > completely compile out fs/splice, so uses of the exported struct need 
> > > > to be
> > > > compiled out along with fs/splice.
> > > > 
> > > > This patch therefore compiles out splice support in fs/fuse when
> > > > CONFIG_SYSCALL_SPLICE is undefined.
> > > > 
> > > > Signed-off-by: Pieter Smith 
> > > > ---
> > > >  fs/fuse/dev.c | 9 +++--
> > > >  1 file changed, 7 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> > > > index ca88731..e984302 100644
> > > > --- a/fs/fuse/dev.c
> > > > +++ b/fs/fuse/dev.c
> > > > @@ -1191,8 +1191,9 @@ __releases(fc->lock)
> > > >   * request_end().  Otherwise add it to the processing list, and set
> > > >   * the 'sent' flag.
> > > >   */
> > > > -static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file 
> > > > *file,
> > > > -   struct fuse_copy_state *cs, size_t 
> > > > nbytes)
> > > > +static ssize_t __maybe_unused
> > > > +fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
> > > > +struct fuse_copy_state *cs, size_t nbytes)
> > > 
> > > fuse_dev_do_read() is definitely going to remain used.  So no point in 
> > > adding
> > > __maybe_unused.
> > 
> > Off course, but at least gcc now also is aware that this is intentional and
> > nicely refrains from nagging you with a warning.
> 
> GCC shouldn't be warning about an unused fuse_dev_do_read; please
> recheck.  It will always get used by fuse_dev_read, which
> unconditionally gets used in the .aio_read field of fuse_dev_operations.
> 
> - Josh Triplett

Thanks for pointing this out. I was too hasty in my response.

- Pieter Smith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 08:42:42PM +0100, Pieter Smith wrote:
> On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
> > [Trimming CC.  Please do the same for other patches.  I for one am not
> > interested in the general tinification discussion]
> > 
> > On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
> > > To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
> > > This
> > > struct is exported by fs/splice. The goal of the larger patch set is to
> > > completely compile out fs/splice, so uses of the exported struct need to 
> > > be
> > > compiled out along with fs/splice.
> > > 
> > > This patch therefore compiles out splice support in fs/fuse when
> > > CONFIG_SYSCALL_SPLICE is undefined.
> > > 
> > > Signed-off-by: Pieter Smith 
> > > ---
> > >  fs/fuse/dev.c | 9 +++--
> > >  1 file changed, 7 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> > > index ca88731..e984302 100644
> > > --- a/fs/fuse/dev.c
> > > +++ b/fs/fuse/dev.c
> > > @@ -1191,8 +1191,9 @@ __releases(fc->lock)
> > >   * request_end().  Otherwise add it to the processing list, and set
> > >   * the 'sent' flag.
> > >   */
> > > -static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
> > > - struct fuse_copy_state *cs, size_t nbytes)
> > > +static ssize_t __maybe_unused
> > > +fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
> > > +  struct fuse_copy_state *cs, size_t nbytes)
> > 
> > fuse_dev_do_read() is definitely going to remain used.  So no point in 
> > adding
> > __maybe_unused.
> 
> Off course, but at least gcc now also is aware that this is intentional and
> nicely refrains from nagging you with a warning.
> 
My apologies. My response was too hasty. You are right. This should not be
needed. I will revert this piece in v6 of this patch.
> > >  {
> > >   int err;
> > >   struct fuse_req *req;
> > > @@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
> > > const struct iovec *iov,
> > >   return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
> > >  }
> > >  
> > > +#ifdef CONFIG_SYSCALL_SPLICE
> > >  static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
> > >   struct pipe_inode_info *pipe,
> > >   size_t len, unsigned int flags)
> > > @@ -1368,6 +1370,9 @@ out:
> > >   kfree(bufs);
> > >   return ret;
> > >  }
> > > +#else /* CONFIG_SYSCALL_SPLICE */
> > > +#define fuse_dev_splice_read NULL
> > > +#endif
> > 
> > This looks fine.
> > 
> > Thanks,
> > Miklos
> > 
> > >  
> > >  static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
> > >   struct fuse_copy_state *cs)
> > > -- 
> > > 2.1.0
> > > 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 02:04:41PM -0500, David Miller wrote:
> From: j...@joshtriplett.org
> Date: Tue, 25 Nov 2014 10:53:10 -0800
> 
> > It's not a "slippery slope"; it's been our standard practice for ages.
> 
> We've never put an entire class of generic system calls behind
> a config option.

I would have loved to make them optional individually, but they all are
semantic variations of the same thing: Moving data between fd's without that
data passing through userspace. It therefore isn't surprising that these
syscalls share an underlying entanglement of code (which is where the bulk of
the space saving is to be had).

What a tiny product developer should be asking himself, is: "Do I really need
to efficiently move data between file descriptors?". If the answer no, he can
disable CONFIG_SYSCALL_SPLICE to squeeze an extra 8KB out of his kernel.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
> [Trimming CC.  Please do the same for other patches.  I for one am not
> interested in the general tinification discussion]
> 
> On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
> > To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
> > struct is exported by fs/splice. The goal of the larger patch set is to
> > completely compile out fs/splice, so uses of the exported struct need to be
> > compiled out along with fs/splice.
> > 
> > This patch therefore compiles out splice support in fs/fuse when
> > CONFIG_SYSCALL_SPLICE is undefined.
> > 
> > Signed-off-by: Pieter Smith 
> > ---
> >  fs/fuse/dev.c | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> > index ca88731..e984302 100644
> > --- a/fs/fuse/dev.c
> > +++ b/fs/fuse/dev.c
> > @@ -1191,8 +1191,9 @@ __releases(fc->lock)
> >   * request_end().  Otherwise add it to the processing list, and set
> >   * the 'sent' flag.
> >   */
> > -static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
> > -   struct fuse_copy_state *cs, size_t nbytes)
> > +static ssize_t __maybe_unused
> > +fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
> > +struct fuse_copy_state *cs, size_t nbytes)
> 
> fuse_dev_do_read() is definitely going to remain used.  So no point in adding
> __maybe_unused.

Off course, but at least gcc now also is aware that this is intentional and
nicely refrains from nagging you with a warning.

> >  {
> > int err;
> > struct fuse_req *req;
> > @@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
> > const struct iovec *iov,
> > return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
> >  }
> >  
> > +#ifdef CONFIG_SYSCALL_SPLICE
> >  static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
> > struct pipe_inode_info *pipe,
> > size_t len, unsigned int flags)
> > @@ -1368,6 +1370,9 @@ out:
> > kfree(bufs);
> > return ret;
> >  }
> > +#else /* CONFIG_SYSCALL_SPLICE */
> > +#define fuse_dev_splice_read NULL
> > +#endif
> 
> This looks fine.
> 
> Thanks,
> Miklos
> 
> >  
> >  static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
> > struct fuse_copy_state *cs)
> > -- 
> > 2.1.0
> > 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
 [Trimming CC.  Please do the same for other patches.  I for one am not
 interested in the general tinification discussion]
 
 On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
  To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
  struct is exported by fs/splice. The goal of the larger patch set is to
  completely compile out fs/splice, so uses of the exported struct need to be
  compiled out along with fs/splice.
  
  This patch therefore compiles out splice support in fs/fuse when
  CONFIG_SYSCALL_SPLICE is undefined.
  
  Signed-off-by: Pieter Smith pie...@boesman.nl
  ---
   fs/fuse/dev.c | 9 +++--
   1 file changed, 7 insertions(+), 2 deletions(-)
  
  diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
  index ca88731..e984302 100644
  --- a/fs/fuse/dev.c
  +++ b/fs/fuse/dev.c
  @@ -1191,8 +1191,9 @@ __releases(fc-lock)
* request_end().  Otherwise add it to the processing list, and set
* the 'sent' flag.
*/
  -static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
  -   struct fuse_copy_state *cs, size_t nbytes)
  +static ssize_t __maybe_unused
  +fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
  +struct fuse_copy_state *cs, size_t nbytes)
 
 fuse_dev_do_read() is definitely going to remain used.  So no point in adding
 __maybe_unused.

Off course, but at least gcc now also is aware that this is intentional and
nicely refrains from nagging you with a warning.

   {
  int err;
  struct fuse_req *req;
  @@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
  const struct iovec *iov,
  return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
   }
   
  +#ifdef CONFIG_SYSCALL_SPLICE
   static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
  struct pipe_inode_info *pipe,
  size_t len, unsigned int flags)
  @@ -1368,6 +1370,9 @@ out:
  kfree(bufs);
  return ret;
   }
  +#else /* CONFIG_SYSCALL_SPLICE */
  +#define fuse_dev_splice_read NULL
  +#endif
 
 This looks fine.
 
 Thanks,
 Miklos
 
   
   static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
  struct fuse_copy_state *cs)
  -- 
  2.1.0
  
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 02:04:41PM -0500, David Miller wrote:
 From: j...@joshtriplett.org
 Date: Tue, 25 Nov 2014 10:53:10 -0800
 
  It's not a slippery slope; it's been our standard practice for ages.
 
 We've never put an entire class of generic system calls behind
 a config option.

I would have loved to make them optional individually, but they all are
semantic variations of the same thing: Moving data between fd's without that
data passing through userspace. It therefore isn't surprising that these
syscalls share an underlying entanglement of code (which is where the bulk of
the space saving is to be had).

What a tiny product developer should be asking himself, is: Do I really need
to efficiently move data between file descriptors?. If the answer no, he can
disable CONFIG_SYSCALL_SPLICE to squeeze an extra 8KB out of his kernel.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 08:42:42PM +0100, Pieter Smith wrote:
 On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
  [Trimming CC.  Please do the same for other patches.  I for one am not
  interested in the general tinification discussion]
  
  On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
   To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
   This
   struct is exported by fs/splice. The goal of the larger patch set is to
   completely compile out fs/splice, so uses of the exported struct need to 
   be
   compiled out along with fs/splice.
   
   This patch therefore compiles out splice support in fs/fuse when
   CONFIG_SYSCALL_SPLICE is undefined.
   
   Signed-off-by: Pieter Smith pie...@boesman.nl
   ---
fs/fuse/dev.c | 9 +++--
1 file changed, 7 insertions(+), 2 deletions(-)
   
   diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
   index ca88731..e984302 100644
   --- a/fs/fuse/dev.c
   +++ b/fs/fuse/dev.c
   @@ -1191,8 +1191,9 @@ __releases(fc-lock)
 * request_end().  Otherwise add it to the processing list, and set
 * the 'sent' flag.
 */
   -static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
   - struct fuse_copy_state *cs, size_t nbytes)
   +static ssize_t __maybe_unused
   +fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
   +  struct fuse_copy_state *cs, size_t nbytes)
  
  fuse_dev_do_read() is definitely going to remain used.  So no point in 
  adding
  __maybe_unused.
 
 Off course, but at least gcc now also is aware that this is intentional and
 nicely refrains from nagging you with a warning.
 
My apologies. My response was too hasty. You are right. This should not be
needed. I will revert this piece in v6 of this patch.
{
 int err;
 struct fuse_req *req;
   @@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
   const struct iovec *iov,
 return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
}

   +#ifdef CONFIG_SYSCALL_SPLICE
static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
 struct pipe_inode_info *pipe,
 size_t len, unsigned int flags)
   @@ -1368,6 +1370,9 @@ out:
 kfree(bufs);
 return ret;
}
   +#else /* CONFIG_SYSCALL_SPLICE */
   +#define fuse_dev_splice_read NULL
   +#endif
  
  This looks fine.
  
  Thanks,
  Miklos
  

static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
 struct fuse_copy_state *cs)
   -- 
   2.1.0
   
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-25 Thread Pieter Smith
On Tue, Nov 25, 2014 at 12:49:16PM -0800, j...@joshtriplett.org wrote:
 On Tue, Nov 25, 2014 at 08:42:42PM +0100, Pieter Smith wrote:
  On Tue, Nov 25, 2014 at 03:17:13PM +0100, Miklos Szeredi wrote:
   [Trimming CC.  Please do the same for other patches.  I for one am not
   interested in the general tinification discussion]
   
   On Tue, Nov 25, 2014 at 08:19:39AM +0100, Pieter Smith wrote:
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need 
to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..e984302 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1191,8 +1191,9 @@ __releases(fc-lock)
  * request_end().  Otherwise add it to the processing list, and set
  * the 'sent' flag.
  */
-static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file 
*file,
-   struct fuse_copy_state *cs, size_t 
nbytes)
+static ssize_t __maybe_unused
+fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
+struct fuse_copy_state *cs, size_t nbytes)
   
   fuse_dev_do_read() is definitely going to remain used.  So no point in 
   adding
   __maybe_unused.
  
  Off course, but at least gcc now also is aware that this is intentional and
  nicely refrains from nagging you with a warning.
 
 GCC shouldn't be warning about an unused fuse_dev_do_read; please
 recheck.  It will always get used by fuse_dev_read, which
 unconditionally gets used in the .aio_read field of fuse_dev_operations.
 
 - Josh Triplett

Thanks for pointing this out. I was too hasty in my response.

- Pieter Smith
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/7] fs: moved kernel_write to fs/read_write

2014-11-24 Thread Pieter Smith
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 
---
 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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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, );
+   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, );
-   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)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/7] fs: move sendfile syscall into fs/splice

2014-11-24 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith 
---
 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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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, , 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, _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, , out.file, _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, , 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

[PATCH v5 5/7] net/core: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith 
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd->pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/7] fs/splice: support compiling out splice-family syscalls

2014-11-24 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

The last change required before fs/splice can be comipled out is making fs/nfsd
aware of the lacking splice support in file-systems when CONFIG_SYSCALL_SPLICE
is undefined.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger

[PATCH v5 7/7] fs/splice: full support for compiling out splice

2014-11-24 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith 
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc *);
 
+#ifdef

[PATCH v5 6/7] fs/nfsd: support compiling out splice

2014-11-24 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith 
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp->rq_splice_ok = true;
+   rqstp->rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp->rq_usedeferral = true;
rqstp->rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith 
---
 fs/fuse/dev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..e984302 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1191,8 +1191,9 @@ __releases(fc->lock)
  * request_end().  Otherwise add it to the processing list, and set
  * the 'sent' flag.
  */
-static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
-   struct fuse_copy_state *cs, size_t nbytes)
+static ssize_t __maybe_unused
+fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
+struct fuse_copy_state *cs, size_t nbytes)
 {
int err;
struct fuse_req *req;
@@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1370,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109


Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/nfsd: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   9 ++-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 302 insertions(+), 194 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/7] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith 
---
 fs/fuse/dev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..e984302 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1191,8 +1191,9 @@ __releases(fc->lock)
  * request_end().  Otherwise add it to the processing list, and set
  * the 'sent' flag.
  */
-static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
-   struct fuse_copy_state *cs, size_t nbytes)
+static ssize_t __maybe_unused
+fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
+struct fuse_copy_state *cs, size_t nbytes)
 {
int err;
struct fuse_req *req;
@@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1370,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/7] fs/splice: support compiling out splice-family syscalls

2014-11-24 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this. A macro is defined that will assist with NULL'ing out callbacks
when CONFIG_SYSCALL_SPLICE is undefined: __splice_p().

Once all exports are solved, fs/splice can be compiled out.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to major

[PATCH v4 6/7] net/core: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith 
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd->pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 5/7] fs/nfsd: support compiling out splice

2014-11-24 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith 
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp->rq_splice_ok = true;
+   rqstp->rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp->rq_usedeferral = true;
rqstp->rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 7/7] fs/splice: full support for compiling out splice

2014-11-24 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith 
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc *);
 
+#ifdef

[PATCH v4 2/7] fs: moved kernel_write to fs/read_write

2014-11-24 Thread Pieter Smith
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 
---
 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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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, );
+   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, );
-   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)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/7] fs: move sendfile syscall into fs/splice

2014-11-24 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith 
---
 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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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, , 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, _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, , out.file, _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, , 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

[PATCH v4 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  fs/nfsd: support compiling out splice
  net/core: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   9 ++-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 302 insertions(+), 194 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [fuse-devel] [PATCH 4/6] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
On Mon, Nov 24, 2014 at 12:22:14PM -0800, Greg KH wrote:
> On Mon, Nov 24, 2014 at 12:14:50PM -0800, j...@joshtriplett.org wrote:
> > > I would, again, argue that stuff like __splice_p() not be implemented at
> > > all please.  It will only cause a huge proliferation of stuff like this
> > > that will not make any sense, and only cause a trivial, if any, amount
> > > of code savings.
> > > 
> > > I thought you were going to not do this type of thing until you got the
> > > gcc optimizer working for function callbacks.
> > 
> > Compared to the previous patchset, there are now only two instances of
> > ifdefs outside of the splice code for this, and this is one of them.  In
> > this case, the issue is no longer about making the code for this
> > splice_read function disappear, but rather to eliminate a reference to a
> > bit of splice functionality (used *inside* the FUSE splice code) that
> > will not work without SPLICE_SYSCALL.
> > 
> > Would you prefer to see this specific case handled via an #ifdef in
> > fs/fuse/dev.c rather than introducing a __splice_p that people might be
> > inclined to propagate?  That'd be fine; the code could simply wrap
> > fuse_dev_splice_read in an #ifdef and have the #else define a NULL
> > fuse_dev_splice_read.
> 
> Yes, I would prefer that, but I'm not the fuse maintainer.
> 
> thanks,
> 
> greg k-h

Okay. I'll do my part to prevent the type of proliferation guaranteed to rate
high on the respected K-H icky-scale. __splice_p() goes the way of the dodo
in favor of the solution presented by Josh.

I pray that the Gods of fuse maintenance will look favorable upon the result.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
On Sun, Nov 23, 2014 at 04:32:51PM -0800, Josh Triplett wrote:
> On Sun, Nov 23, 2014 at 07:28:10PM -0500, Jeff Layton wrote:
> > On Sun, 23 Nov 2014 15:36:37 -0800
> > Josh Triplett  wrote:
> > 
> > > On Sun, Nov 23, 2014 at 09:30:40PM +0100, Pieter Smith wrote:
> > > > On Sun, Nov 23, 2014 at 11:43:26AM -0800, Josh Triplett wrote:
> > > > > On Sun, Nov 23, 2014 at 01:46:23PM -0500, David Miller wrote:
> > > > > > Truly removing sendfile/sendpage means that you can't even compile 
> > > > > > NFS
> > > > > > into the tree.
> > > > > 
> > > > > If you mean the in-kernel nfsd (CONFIG_NFSD), that already has a large
> > > > > stack of "select" and "depends on", both directly and indirectly; 
> > > > > adding
> > > > > a "select SPLICE_SYSCALL" to it seems fine.  (That select does need
> > > > > adding, though.  Pieter, you need to test-compile more than just
> > > > > tinyconfig and defconfig.  Try an allyesconfig with *just* splice 
> > > > > turned
> > > > > off, and make sure that compiles.)
> > > > 
> > > > Did exacly that. Took forever on my hardware, but no problems.
> > > 
> > > Ah, I see.  Looking more closely at nfsd, it looks like it already has a
> > > code path for filesystems that don't do splice.  I think, rather than
> > > making nfsd select SPLICE_SYSCALL, that it would suffice to change the
> > > "rqstp->rq_splice_ok = true;" in svc_process_common (net/sunrpc/svc.c)
> > > to:
> > > 
> > > rqstp->rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
> > > 
> > > Then nfsd should simply *always* fall back to its non-splice support.
> > > 
> > 
> > I'd probably prefer the above, actually. We have to keep supporting
> > non-splice enabled fs' for the forseeable future, so we may as well
> > allow people to run nfsd in such configurations. It could even be
> > useful for testing the non-splice-enabled codepaths.
> 
> Good point!
> 
> - Josh Triplett

I'll add this to svc_process_common. I can squash this into PATCH 3, which is
where the syscalls can be compiled out. The log entry may however get a little
crowded and multi-functional.

Should I keep this as a separate patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [fuse-devel] [PATCH 4/6] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
On Sun, Nov 23, 2014 at 03:23:02PM -0800, Josh Triplett wrote:
> On Sun, Nov 23, 2014 at 11:29:08PM +0100, Richard Weinberger wrote:
> > On Sun, Nov 23, 2014 at 3:20 PM, Pieter Smith  wrote:
> > > To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
> > > This
> > > struct is exported by fs/splice. The goal of the larger patch set is to
> > > completely compile out fs/splice, so uses of the exported struct need to 
> > > be
> > > compiled out along with fs/splice.
> > >
> > > This patch therefore compiles out splice support in fs/fuse when
> > > CONFIG_SYSCALL_SPLICE is undefined.
> > >
> > > Signed-off-by: Pieter Smith 
> > > ---
> > >  fs/fuse/dev.c  | 4 ++--
> > >  include/linux/fs.h | 6 ++
> > >  2 files changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> > > index ca88731..f8f92a4 100644
> > > --- a/fs/fuse/dev.c
> > > +++ b/fs/fuse/dev.c
> > > @@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
> > > const struct iovec *iov,
> > > return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
> > >  }
> > >
> > > -static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
> > > +static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, 
> > > loff_t *ppos,
> > > struct pipe_inode_info *pipe,
> > > size_t len, unsigned int flags)
> > >  {
> > > @@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
> > > .llseek = no_llseek,
> > > .read   = do_sync_read,
> > > .aio_read   = fuse_dev_read,
> > > -   .splice_read= fuse_dev_splice_read,
> > > +   .splice_read= __splice_p(fuse_dev_splice_read),
> > > .write  = do_sync_write,
> > > .aio_write  = fuse_dev_write,
> > > .splice_write   = fuse_dev_splice_write,
> > > diff --git a/include/linux/fs.h b/include/linux/fs.h
> > > index a957d43..04c0975 100644
> > > --- a/include/linux/fs.h
> > > +++ b/include/linux/fs.h
> > > @@ -2443,6 +2443,12 @@ 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
> > > +#define __splice_p(x) x
> > > +#else
> > > +#define __splice_p(x) NULL
> > > +#endif
> > > +
> > 
> > This needs to go into a different patch.
> > One logical change per patch please. :-)
> 
> Easy enough to merge this one into the patch introducing
> CONFIG_SYSCALL_SPLICE, then.
> 
> - Josh Triplett

The patch introducing CONFIG_SYSCALL_SPLICE (PATCH 3) only compiles out the
syscalls. PATCH 6 on the other hand, compiles out fs/splice.c. This patch
allows fs/fuse to be compiled when fs/splice.c is compiled out. If I am to
squash it, it would be logical to include it in PATCH 6, not 3.

Is this agreeable?

PATCH 5 does the same as this one for net/core. Should I still keep PATCH 5
separate from a maintainership perspective?

- Pieter Smith

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [fuse-devel] [PATCH 4/6] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
On Sun, Nov 23, 2014 at 03:23:02PM -0800, Josh Triplett wrote:
 On Sun, Nov 23, 2014 at 11:29:08PM +0100, Richard Weinberger wrote:
  On Sun, Nov 23, 2014 at 3:20 PM, Pieter Smith pie...@boesman.nl wrote:
   To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. 
   This
   struct is exported by fs/splice. The goal of the larger patch set is to
   completely compile out fs/splice, so uses of the exported struct need to 
   be
   compiled out along with fs/splice.
  
   This patch therefore compiles out splice support in fs/fuse when
   CONFIG_SYSCALL_SPLICE is undefined.
  
   Signed-off-by: Pieter Smith pie...@boesman.nl
   ---
fs/fuse/dev.c  | 4 ++--
include/linux/fs.h | 6 ++
2 files changed, 8 insertions(+), 2 deletions(-)
  
   diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
   index ca88731..f8f92a4 100644
   --- a/fs/fuse/dev.c
   +++ b/fs/fuse/dev.c
   @@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, 
   const struct iovec *iov,
   return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
}
  
   -static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
   +static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, 
   loff_t *ppos,
   struct pipe_inode_info *pipe,
   size_t len, unsigned int flags)
{
   @@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
   .llseek = no_llseek,
   .read   = do_sync_read,
   .aio_read   = fuse_dev_read,
   -   .splice_read= fuse_dev_splice_read,
   +   .splice_read= __splice_p(fuse_dev_splice_read),
   .write  = do_sync_write,
   .aio_write  = fuse_dev_write,
   .splice_write   = fuse_dev_splice_write,
   diff --git a/include/linux/fs.h b/include/linux/fs.h
   index a957d43..04c0975 100644
   --- a/include/linux/fs.h
   +++ b/include/linux/fs.h
   @@ -2443,6 +2443,12 @@ 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
   +#define __splice_p(x) x
   +#else
   +#define __splice_p(x) NULL
   +#endif
   +
  
  This needs to go into a different patch.
  One logical change per patch please. :-)
 
 Easy enough to merge this one into the patch introducing
 CONFIG_SYSCALL_SPLICE, then.
 
 - Josh Triplett

The patch introducing CONFIG_SYSCALL_SPLICE (PATCH 3) only compiles out the
syscalls. PATCH 6 on the other hand, compiles out fs/splice.c. This patch
allows fs/fuse to be compiled when fs/splice.c is compiled out. If I am to
squash it, it would be logical to include it in PATCH 6, not 3.

Is this agreeable?

PATCH 5 does the same as this one for net/core. Should I still keep PATCH 5
separate from a maintainership perspective?

- Pieter Smith

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
On Sun, Nov 23, 2014 at 04:32:51PM -0800, Josh Triplett wrote:
 On Sun, Nov 23, 2014 at 07:28:10PM -0500, Jeff Layton wrote:
  On Sun, 23 Nov 2014 15:36:37 -0800
  Josh Triplett j...@joshtriplett.org wrote:
  
   On Sun, Nov 23, 2014 at 09:30:40PM +0100, Pieter Smith wrote:
On Sun, Nov 23, 2014 at 11:43:26AM -0800, Josh Triplett wrote:
 On Sun, Nov 23, 2014 at 01:46:23PM -0500, David Miller wrote:
  Truly removing sendfile/sendpage means that you can't even compile 
  NFS
  into the tree.
 
 If you mean the in-kernel nfsd (CONFIG_NFSD), that already has a large
 stack of select and depends on, both directly and indirectly; 
 adding
 a select SPLICE_SYSCALL to it seems fine.  (That select does need
 adding, though.  Pieter, you need to test-compile more than just
 tinyconfig and defconfig.  Try an allyesconfig with *just* splice 
 turned
 off, and make sure that compiles.)

Did exacly that. Took forever on my hardware, but no problems.
   
   Ah, I see.  Looking more closely at nfsd, it looks like it already has a
   code path for filesystems that don't do splice.  I think, rather than
   making nfsd select SPLICE_SYSCALL, that it would suffice to change the
   rqstp-rq_splice_ok = true; in svc_process_common (net/sunrpc/svc.c)
   to:
   
   rqstp-rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
   
   Then nfsd should simply *always* fall back to its non-splice support.
   
  
  I'd probably prefer the above, actually. We have to keep supporting
  non-splice enabled fs' for the forseeable future, so we may as well
  allow people to run nfsd in such configurations. It could even be
  useful for testing the non-splice-enabled codepaths.
 
 Good point!
 
 - Josh Triplett

I'll add this to svc_process_common. I can squash this into PATCH 3, which is
where the syscalls can be compiled out. The log entry may however get a little
crowded and multi-functional.

Should I keep this as a separate patch?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [fuse-devel] [PATCH 4/6] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
On Mon, Nov 24, 2014 at 12:22:14PM -0800, Greg KH wrote:
 On Mon, Nov 24, 2014 at 12:14:50PM -0800, j...@joshtriplett.org wrote:
   I would, again, argue that stuff like __splice_p() not be implemented at
   all please.  It will only cause a huge proliferation of stuff like this
   that will not make any sense, and only cause a trivial, if any, amount
   of code savings.
   
   I thought you were going to not do this type of thing until you got the
   gcc optimizer working for function callbacks.
  
  Compared to the previous patchset, there are now only two instances of
  ifdefs outside of the splice code for this, and this is one of them.  In
  this case, the issue is no longer about making the code for this
  splice_read function disappear, but rather to eliminate a reference to a
  bit of splice functionality (used *inside* the FUSE splice code) that
  will not work without SPLICE_SYSCALL.
  
  Would you prefer to see this specific case handled via an #ifdef in
  fs/fuse/dev.c rather than introducing a __splice_p that people might be
  inclined to propagate?  That'd be fine; the code could simply wrap
  fuse_dev_splice_read in an #ifdef and have the #else define a NULL
  fuse_dev_splice_read.
 
 Yes, I would prefer that, but I'm not the fuse maintainer.
 
 thanks,
 
 greg k-h

Okay. I'll do my part to prevent the type of proliferation guaranteed to rate
high on the respected K-H icky-scale. __splice_p() goes the way of the dodo
in favor of the solution presented by Josh.

I pray that the Gods of fuse maintenance will look favorable upon the result.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  fs/nfsd: support compiling out splice
  net/core: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   9 ++-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 302 insertions(+), 194 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/7] fs: move sendfile syscall into fs/splice

2014-11-24 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith pie...@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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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

[PATCH v4 2/7] fs: moved kernel_write to fs/read_write

2014-11-24 Thread Pieter Smith
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 pie...@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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 5/7] fs/nfsd: support compiling out splice

2014-11-24 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp-rq_splice_ok = true;
+   rqstp-rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp-rq_usedeferral = true;
rqstp-rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 7/7] fs/splice: full support for compiling out splice

2014-11-24 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc

[PATCH v4 6/7] net/core: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd-pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/7] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..e984302 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1191,8 +1191,9 @@ __releases(fc-lock)
  * request_end().  Otherwise add it to the processing list, and set
  * the 'sent' flag.
  */
-static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
-   struct fuse_copy_state *cs, size_t nbytes)
+static ssize_t __maybe_unused
+fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
+struct fuse_copy_state *cs, size_t nbytes)
 {
int err;
struct fuse_req *req;
@@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1370,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/7] fs/splice: support compiling out splice-family syscalls

2014-11-24 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this. A macro is defined that will assist with NULL'ing out callbacks
when CONFIG_SYSCALL_SPLICE is undefined: __splice_p().

Once all exports are solved, fs/splice can be compiled out.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 pie...@boesman.nl
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo

[PATCH v5 0/7] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-24 Thread Pieter Smith
   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109


Pieter Smith (7):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/nfsd: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   9 ++-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  26 +++
 include/linux/skbuff.h |  10 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |  11 ++-
 net/sunrpc/svc.c   |   2 +-
 11 files changed, 302 insertions(+), 194 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 4/7] fs/fuse: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..e984302 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1191,8 +1191,9 @@ __releases(fc-lock)
  * request_end().  Otherwise add it to the processing list, and set
  * the 'sent' flag.
  */
-static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
-   struct fuse_copy_state *cs, size_t nbytes)
+static ssize_t __maybe_unused
+fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
+struct fuse_copy_state *cs, size_t nbytes)
 {
int err;
struct fuse_req *req;
@@ -1291,6 +1292,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
@@ -1368,6 +1370,9 @@ out:
kfree(bufs);
return ret;
 }
+#else /* CONFIG_SYSCALL_SPLICE */
+#define fuse_dev_splice_read NULL
+#endif
 
 static int fuse_notify_poll(struct fuse_conn *fc, unsigned int size,
struct fuse_copy_state *cs)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 6/7] fs/nfsd: support compiling out splice

2014-11-24 Thread Pieter Smith
The goal of the larger patch set is to completely compile out fs/splice, and
as a result, splice support for all file-systems. This patch ensures that
fs/nfsd falls back to non-splice fs support when CONFIG_SYSCALL_SPLICE is
undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 net/sunrpc/svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index ca8a795..6cacc37 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1084,7 +1084,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec 
*argv, struct kvec *resv)
goto err_short_len;
 
/* Will be turned off only in gss privacy case: */
-   rqstp-rq_splice_ok = true;
+   rqstp-rq_splice_ok = IS_ENABLED(CONFIG_SPLICE_SYSCALL);
/* Will be turned off only when NFSv4 Sessions are used */
rqstp-rq_usedeferral = true;
rqstp-rq_dropme = false;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 7/7] fs/splice: full support for compiling out splice

2014-11-24 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 a957d43..138107e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2444,6 +2444,7 @@ extern int blkdev_fsync(struct file *filp, loff_t start, 
loff_t end,
 extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
 extern ssize_t default_file_splice_read(struct file *, loff_t *,
@@ -2452,6 +2453,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..34570d8 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc

[PATCH v5 3/7] fs/splice: support compiling out splice-family syscalls

2014-11-24 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice along with the syscalls. To
achieve this, the remaining patch-set will deal with fs/splice exports. As far
as possible, the impact on other device drivers will be minimized so as to
reduce the overal maintenance burden of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Uses of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

The last change required before fs/splice can be comipled out is making fs/nfsd
aware of the lacking splice support in file-systems when CONFIG_SYSCALL_SPLICE
is undefined.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 pie...@boesman.nl
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info

[PATCH v5 5/7] net/core: support compiling out splice

2014-11-24 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 include/linux/skbuff.h | 10 ++
 net/core/skbuff.c  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..5cd636b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,19 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int
+skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..bb426d9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1678,7 +1678,8 @@ EXPORT_SYMBOL(skb_copy_bits);
  * Callback from splice_to_pipe(), if we need to release some pages
  * at the end of the spd in case we error'ed out in filling the pipe.
  */
-static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
+static void __maybe_unused sock_spd_release(struct splice_pipe_desc *spd,
+   unsigned int i)
 {
put_page(spd-pages[i]);
 }
@@ -1781,9 +1782,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1822,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1878,7 @@ done:
 
return ret;
 }
+#endif /* CONFIG_SYSCALL_SPLICE */
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/7] fs: move sendfile syscall into fs/splice

2014-11-24 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith pie...@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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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

[PATCH v5 2/7] fs: moved kernel_write to fs/read_write

2014-11-24 Thread Pieter Smith
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 pie...@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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-23 Thread Pieter Smith
On Sun, Nov 23, 2014 at 11:43:26AM -0800, Josh Triplett wrote:
> On Sun, Nov 23, 2014 at 01:46:23PM -0500, David Miller wrote:
> > Truly removing sendfile/sendpage means that you can't even compile NFS
> > into the tree.
> 
> If you mean the in-kernel nfsd (CONFIG_NFSD), that already has a large
> stack of "select" and "depends on", both directly and indirectly; adding
> a "select SPLICE_SYSCALL" to it seems fine.  (That select does need
> adding, though.  Pieter, you need to test-compile more than just
> tinyconfig and defconfig.  Try an allyesconfig with *just* splice turned
> off, and make sure that compiles.)

Did exacly that. Took forever on my hardware, but no problems.

> Given the requirements of running a file server in the kernel, I'd
> expect CONFIG_NFSD to end up with several more selects of optional
> functionality in the future.  It seems rather likely that the average
> embedded system will be compiling out NFS. :)
> 
> Also, this patch series compiles out splice and sendfile, including
> several *users* of sendpage; it doesn't compile out the sendpage
> support/infrastructure itself.
> 
> - Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] fs/splice: full support for compiling out splice

2014-11-23 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith 
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 04c0975..9b3054e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2449,6 +2449,7 @@ extern void block_sync_page(struct page *page);
 #define __splice_p(x) NULL
 #endif
 
+#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);
@@ -2458,6 +2459,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..5097a79 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc *);
 
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file

[PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-23 Thread Pieter Smith
   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Pieter Smith (6):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   4 +-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  32 
 include/linux/skbuff.h |   9 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |   9 ++-
 10 files changed, 300 insertions(+), 192 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] fs/splice: support compiling out splice-family syscalls

2014-11-23 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice. To achieve this, the remaining
patch-set will deal with fs/splice exports. As far as possible, the impact on
other device drivers will be minimized so as to reduce the maintenance burden
of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Use of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

Once all exports are solved, fs/splice can be compiled out.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] fs/fuse: support compiling out splice

2014-11-23 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith 
---
 fs/fuse/dev.c  | 4 ++--
 include/linux/fs.h | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..f8f92a4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
 }
 
-static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
+static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, loff_t 
*ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
 {
@@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
.llseek = no_llseek,
.read   = do_sync_read,
.aio_read   = fuse_dev_read,
-   .splice_read= fuse_dev_splice_read,
+   .splice_read= __splice_p(fuse_dev_splice_read),
.write  = do_sync_write,
.aio_write  = fuse_dev_write,
.splice_write   = fuse_dev_splice_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d43..04c0975 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2443,6 +2443,12 @@ 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
+#define __splice_p(x) x
+#else
+#define __splice_p(x) NULL
+#endif
+
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] net/core: support compiling out splice

2014-11-23 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith 
---
 include/linux/skbuff.h | 9 +
 net/core/skbuff.c  | 9 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..54a50c1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..74fad8a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1877,8 @@ done:
 
return ret;
 }
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] fs: moved kernel_write to fs/read_write

2014-11-23 Thread Pieter Smith
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 
---
 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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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, );
+   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, );
-   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)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] fs: move sendfile syscall into fs/splice

2014-11-23 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith 
---
 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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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, , 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, _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, , out.file, _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, , 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

[PATCH 1/6] fs: move sendfile syscall into fs/splice

2014-11-23 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith pie...@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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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

[PATCH 5/6] net/core: support compiling out splice

2014-11-23 Thread Pieter Smith
To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in net/core when
CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits
is transparently mocked out with a static inline. The greater patch set removes
userspace splice support so it cannot be called anyway.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 include/linux/skbuff.h | 9 +
 net/core/skbuff.c  | 9 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..54a50c1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else
+static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..74fad8a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1877,8 @@ done:
 
return ret;
 }
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] fs: moved kernel_write to fs/read_write

2014-11-23 Thread Pieter Smith
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 pie...@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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-23 Thread Pieter Smith
   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Pieter Smith (6):
  fs: move sendfile syscall into fs/splice
  fs: moved kernel_write to fs/read_write
  fs/splice: support compiling out splice-family syscalls
  fs/fuse: support compiling out splice
  net/core: support compiling out splice
  fs/splice: full support for compiling out splice

 fs/Makefile|   3 +-
 fs/fuse/dev.c  |   4 +-
 fs/read_write.c| 181 +++--
 fs/splice.c| 194 +
 include/linux/fs.h |  32 
 include/linux/skbuff.h |   9 +++
 include/linux/splice.h |  42 +++
 init/Kconfig   |  10 +++
 kernel/sys_ni.c|   8 ++
 net/core/skbuff.c  |   9 ++-
 10 files changed, 300 insertions(+), 192 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] fs/splice: support compiling out splice-family syscalls

2014-11-23 Thread Pieter Smith
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.

The goal is to completely compile out fs/splice. To achieve this, the remaining
patch-set will deal with fs/splice exports. As far as possible, the impact on
other device drivers will be minimized so as to reduce the maintenance burden
of CONFIG_SYSCALL_SPLICE.

The use of exported functions will be solved by transparently mocking them out
with static inlines. Use of the exported pipe_buf_operations struct however
require direct modification in fs/fuse and net/core. The next two patches will
deal with this.

Once all exports are solved, fs/splice can be compiled out.

The bloat benefit of this patch given a tinyconfig is:

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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 pie...@boesman.nl
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] fs/fuse: support compiling out splice

2014-11-23 Thread Pieter Smith
To implement splice support, fs/fuse makes use of nosteal_pipe_buf_ops. This
struct is exported by fs/splice. The goal of the larger patch set is to
completely compile out fs/splice, so uses of the exported struct need to be
compiled out along with fs/splice.

This patch therefore compiles out splice support in fs/fuse when
CONFIG_SYSCALL_SPLICE is undefined.

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c  | 4 ++--
 include/linux/fs.h | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..f8f92a4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
 }
 
-static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
+static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, loff_t 
*ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
 {
@@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
.llseek = no_llseek,
.read   = do_sync_read,
.aio_read   = fuse_dev_read,
-   .splice_read= fuse_dev_splice_read,
+   .splice_read= __splice_p(fuse_dev_splice_read),
.write  = do_sync_write,
.aio_write  = fuse_dev_write,
.splice_write   = fuse_dev_splice_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d43..04c0975 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2443,6 +2443,12 @@ 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
+#define __splice_p(x) x
+#else
+#define __splice_p(x) NULL
+#endif
+
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] fs/splice: full support for compiling out splice

2014-11-23 Thread Pieter Smith
 109   --109
page_cache_pipe_buf_steal114   --114
opipe_prep.part  119   --119
sys_sendfile 122   --122
generic_file_splice_read 131   8-123
sys_sendfile64   126   --126
sys_vmsplice 137   --137
do_splice_direct 148   --148
vmsplice_to_user 205   --205
__splice_from_pipe   246   --246
splice_direct_to_actor   348   --348
splice_to_pipe   371   --371
do_sendfile  492   --492
sys_tee  497   --497
vmsplice_to_pipe 558   --558
default_file_splice_read 688   --688
iter_file_splice_write   702   4-698
sys_splice  1075   -   -1075
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 42 ++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 04c0975..9b3054e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2449,6 +2449,7 @@ extern void block_sync_page(struct page *page);
 #define __splice_p(x) NULL
 #endif
 
+#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);
@@ -2458,6 +2459,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t iter_file_splice_write(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
+   struct file *out, loff_t *ppos, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+#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..5097a79 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -65,6 +65,7 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct 
pipe_buffer *,
 typedef int (splice_direct_actor)(struct pipe_inode_info *,
  struct splice_desc *);
 
+#ifdef CONFIG_SYSCALL_SPLICE
 extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file

Re: [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)

2014-11-23 Thread Pieter Smith
On Sun, Nov 23, 2014 at 11:43:26AM -0800, Josh Triplett wrote:
 On Sun, Nov 23, 2014 at 01:46:23PM -0500, David Miller wrote:
  Truly removing sendfile/sendpage means that you can't even compile NFS
  into the tree.
 
 If you mean the in-kernel nfsd (CONFIG_NFSD), that already has a large
 stack of select and depends on, both directly and indirectly; adding
 a select SPLICE_SYSCALL to it seems fine.  (That select does need
 adding, though.  Pieter, you need to test-compile more than just
 tinyconfig and defconfig.  Try an allyesconfig with *just* splice turned
 off, and make sure that compiles.)

Did exacly that. Took forever on my hardware, but no problems.

 Given the requirements of running a file server in the kernel, I'd
 expect CONFIG_NFSD to end up with several more selects of optional
 functionality in the future.  It seems rather likely that the average
 embedded system will be compiling out NFS. :)
 
 Also, this patch series compiles out splice and sendfile, including
 several *users* of sendpage; it doesn't compile out the sendpage
 support/infrastructure itself.
 
 - Josh Triplett
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] fs/splice: full support for compiling out splice

2014-11-22 Thread Pieter Smith
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/25 grow/shrink: 0/5 up/down: 0/-4845 (-4845)
function old new   delta
pipe_to_null   4   -  -4
generic_pipe_buf_nosteal   6   -  -6
spd_release_page  10   - -10
PageUptodate  22  11 -11
lock_page 36  24 -12
page_cache_pipe_buf_release   16   - -16
splice_write_null 24   4 -20
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_buf71   - -71
page_cache_pipe_buf_confirm   80   - -80
splice_grow_spd   87   - -87
splice_from_pipe  93   - -93
splice_from_pipe_next106   --106
pipe_to_sendpage 109   --109
page_cache_pipe_buf_steal114   --114
generic_file_splice_read 131   8-123
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   4-698
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith 
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 43 +++
 4 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 04c0975..9b3054e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2449,6 +2449,7 @@ extern void block_sync_page(struct page *page);
 #define __splice_p(x) NULL
 #endif
 
+#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);
@@ -2458,6 +2459,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe

[PATCH 4/6] fs/fuse: support compiling out splice

2014-11-22 Thread Pieter Smith
Compile out splice support from fuse when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/fuse/dev.c  | 4 ++--
 include/linux/fs.h | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..f8f92a4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, , iov_length(iov, nr_segs));
 }
 
-static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
+static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, loff_t 
*ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
 {
@@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
.llseek = no_llseek,
.read   = do_sync_read,
.aio_read   = fuse_dev_read,
-   .splice_read= fuse_dev_splice_read,
+   .splice_read= __splice_p(fuse_dev_splice_read),
.write  = do_sync_write,
.aio_write  = fuse_dev_write,
.splice_write   = fuse_dev_splice_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d43..04c0975 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2443,6 +2443,12 @@ 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
+#define __splice_p(x) x
+#else
+#define __splice_p(x) NULL
+#endif
+
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] net/core: support compiling out splice

2014-11-22 Thread Pieter Smith
Compile out splice support from networking core when the splice-family of
syscalls is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is
undefined).

Signed-off-by: Pieter Smith 
---
 include/linux/skbuff.h | 9 +
 net/core/skbuff.c  | 9 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..8c28524 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else /* #ifdef CONFIG_SYSCALL_SPLICE */
+static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..74fad8a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1877,8 @@ done:
 
return ret;
 }
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] fs: moved kernel_write to fs/read_write

2014-11-22 Thread Pieter Smith
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 
---
 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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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, );
+   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, );
-   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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] fs/splice: support compiling out splice-family syscalls

2014-11-22 Thread Pieter Smith
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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] fs: move sendfile syscall into fs/splice

2014-11-22 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith 
---
 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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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, , 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, _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, , out.file, _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, , 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

[PATCH 1/6] fs: move sendfile syscall into fs/splice

2014-11-22 Thread Pieter Smith
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_write29  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  10751020 -55

Signed-off-by: Pieter Smith pie...@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 7d9318c..d9451ba 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,178 +1191,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

[PATCH 2/6] fs: moved kernel_write to fs/read_write

2014-11-22 Thread Pieter Smith
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 pie...@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 d9451ba..f4c8d8b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1191,3 +1191,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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] fs/splice: support compiling out splice-family syscalls

2014-11-22 Thread Pieter Smith
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_next107 106  -1
fdput 11   - -11
signal_pending39  26 -13
fdget 56  42 -14
user_page_pipe_buf_ops20   - -20
user_page_pipe_buf_steal  25   - -25
file_end_write58  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 pie...@boesman.nl
---
 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 d811d5f..dec9819 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1571,6 +1571,16 @@ config NTP
  system clock to an NTP server, 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 d2f5b00..25d5551 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -170,6 +170,14 @@ cond_syscall(sys_fstat);
 cond_syscall(sys_stat);
 cond_syscall(sys_uname);
 cond_syscall(sys_olduname);
+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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] fs/splice: full support for compiling out splice

2014-11-22 Thread Pieter Smith
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/25 grow/shrink: 0/5 up/down: 0/-4845 (-4845)
function old new   delta
pipe_to_null   4   -  -4
generic_pipe_buf_nosteal   6   -  -6
spd_release_page  10   - -10
PageUptodate  22  11 -11
lock_page 36  24 -12
page_cache_pipe_buf_release   16   - -16
splice_write_null 24   4 -20
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_buf71   - -71
page_cache_pipe_buf_confirm   80   - -80
splice_grow_spd   87   - -87
splice_from_pipe  93   - -93
splice_from_pipe_next106   --106
pipe_to_sendpage 109   --109
page_cache_pipe_buf_steal114   --114
generic_file_splice_read 131   8-123
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   4-698
__generic_file_splice_read  1109   -   -1109

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/Makefile|  3 ++-
 fs/splice.c|  2 --
 include/linux/fs.h | 26 ++
 include/linux/splice.h | 43 +++
 4 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index fb7646e..9395622 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)
@@ -22,6 +22,7 @@ endif
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
 obj-$(CONFIG_FSNOTIFY) += notify/
+obj-$(CONFIG_SYSCALL_SPLICE)   += splice.o
 obj-$(CONFIG_EPOLL)+= eventpoll.o
 obj-$(CONFIG_ANON_INODES)  += anon_inodes.o
 obj-$(CONFIG_SIGNALFD) += signalfd.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 04c0975..9b3054e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2449,6 +2449,7 @@ extern void block_sync_page(struct page *page);
 #define __splice_p(x) NULL
 #endif
 
+#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);
@@ -2458,6 +2459,31 @@ 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);
+#else
+static inline ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
+   struct pipe_inode_info *pipe, size_t len, unsigned int flags)
+{
+   return -EPERM;
+}
+
+static inline ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
+   struct

[PATCH 4/6] fs/fuse: support compiling out splice

2014-11-22 Thread Pieter Smith
Compile out splice support from fuse when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 fs/fuse/dev.c  | 4 ++--
 include/linux/fs.h | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ca88731..f8f92a4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1291,7 +1291,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const 
struct iovec *iov,
return fuse_dev_do_read(fc, file, cs, iov_length(iov, nr_segs));
 }
 
-static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
+static ssize_t __maybe_unused fuse_dev_splice_read(struct file *in, loff_t 
*ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
 {
@@ -2144,7 +2144,7 @@ const struct file_operations fuse_dev_operations = {
.llseek = no_llseek,
.read   = do_sync_read,
.aio_read   = fuse_dev_read,
-   .splice_read= fuse_dev_splice_read,
+   .splice_read= __splice_p(fuse_dev_splice_read),
.write  = do_sync_write,
.aio_write  = fuse_dev_write,
.splice_write   = fuse_dev_splice_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d43..04c0975 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2443,6 +2443,12 @@ 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
+#define __splice_p(x) x
+#else
+#define __splice_p(x) NULL
+#endif
+
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] net/core: support compiling out splice

2014-11-22 Thread Pieter Smith
Compile out splice support from networking core when the splice-family of
syscalls is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is
undefined).

Signed-off-by: Pieter Smith pie...@boesman.nl
---
 include/linux/skbuff.h | 9 +
 net/core/skbuff.c  | 9 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d934..8c28524 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, 
void *to, int len);
 int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
 __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  int len, __wsum csum);
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
+#else /* #ifdef CONFIG_SYSCALL_SPLICE */
+static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
+   struct pipe_inode_info *pipe, unsigned int len,
+   unsigned int flags)
+{
+   return -EPERM;
+}
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 unsigned int skb_zerocopy_headlen(const struct sk_buff *from);
 int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a0..74fad8a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned 
int poff,
  * Map linear and fragment data from the skb to spd. It reports true if the
  * pipe is full or if we already spliced the requested length.
  */
-static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info 
*pipe,
- unsigned int *offset, unsigned int *len,
- struct splice_pipe_desc *spd, struct sock *sk)
+static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
+unsigned int *offset, unsigned int 
*len,
+struct splice_pipe_desc *spd, 
struct sock *sk)
 {
int seg;
 
@@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct 
pipe_inode_info *pipe,
  * the frag list, if such a thing exists. We'd probably need to recurse to
  * handle that cleanly.
  */
+#ifdef CONFIG_SYSCALL_SPLICE
 int skb_splice_bits(struct sk_buff *skb, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int tlen,
unsigned int flags)
@@ -1876,6 +1877,8 @@ done:
 
return ret;
 }
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
+
 
 /**
  * skb_store_bits - store bits from kernel buffer to skb
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/56] fs/adfs: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from adfs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/adfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/adfs/file.c b/fs/adfs/file.c
index 07c9edc..d7b19ab 100644
--- a/fs/adfs/file.c
+++ b/fs/adfs/file.c
@@ -29,7 +29,7 @@ const struct file_operations adfs_file_operations = {
.fsync  = generic_file_fsync,
.write  = new_sync_write,
.write_iter = generic_file_write_iter,
-   .splice_read= generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
 };
 
 const struct inode_operations adfs_file_inode_operations = {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/56] fs/affs: support compiling out splice

2014-11-13 Thread Pieter Smith
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 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/56] fs/lustre: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from lustre file-system when the splice-family of
syscalls is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is
undefined).

Signed-off-by: Pieter Smith 
---
 drivers/staging/lustre/lustre/llite/file.c   | 10 +++---
 drivers/staging/lustre/lustre/llite/llite_internal.h |  2 ++
 drivers/staging/lustre/lustre/llite/vvp_io.c |  2 ++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index fd1b75a3..98573da 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1126,10 +1126,12 @@ restart:
down_read(>lli_trunc_sem);
}
break;
+#ifdef CONFIG_SYSCALL_SPLICE
case IO_SPLICE:
vio->u.splice.cui_pipe = args->u.splice.via_pipe;
vio->u.splice.cui_flags = args->u.splice.via_flags;
break;
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
default:
CERROR("Unknown IO type - %u\n", vio->cui_io_subtype);
LBUG();
@@ -1223,6 +1225,7 @@ static ssize_t ll_file_write_iter(struct kiocb *iocb, 
struct iov_iter *from)
return result;
 }
 
+#ifdef CONFIG_SYSCALL_SPLICE
 /*
  * Send file content (through pagecache) somewhere with helper
  */
@@ -1247,6 +1250,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, 
loff_t *ppos,
cl_env_put(env, );
return result;
 }
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
 
 static int ll_lov_recreate(struct inode *inode, struct ost_id *oi,
   obd_count ost_idx)
@@ -3078,7 +3082,7 @@ struct file_operations ll_file_operations = {
.release= ll_file_release,
.mmap  = ll_file_mmap,
.llseek  = ll_file_seek,
-   .splice_read= ll_file_splice_read,
+   SPLICE_READ_INIT(ll_file_splice_read)
.fsync= ll_fsync,
.flush= ll_flush
 };
@@ -3093,7 +3097,7 @@ struct file_operations ll_file_operations_flock = {
.release= ll_file_release,
.mmap  = ll_file_mmap,
.llseek  = ll_file_seek,
-   .splice_read= ll_file_splice_read,
+   SPLICE_READ_INIT(ll_file_splice_read)
.fsync= ll_fsync,
.flush= ll_flush,
.flock= ll_file_flock,
@@ -3111,7 +3115,7 @@ struct file_operations ll_file_operations_noflock = {
.release= ll_file_release,
.mmap  = ll_file_mmap,
.llseek  = ll_file_seek,
-   .splice_read= ll_file_splice_read,
+   SPLICE_READ_INIT(ll_file_splice_read)
.fsync= ll_fsync,
.flush= ll_flush,
.flock= ll_file_noflock,
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 634ffa6..44fa32a 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -861,7 +861,9 @@ enum vvp_io_subtype {
/** normal IO */
IO_NORMAL,
/** io started from splice_{read|write} */
+#ifdef CONFIG_SYSCALL_SPLICE
IO_SPLICE
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
 };
 
 /* IO subtypes */
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c 
b/drivers/staging/lustre/lustre/llite/vvp_io.c
index a4117d6..2f4aa39 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -530,6 +530,7 @@ static int vvp_io_read_start(const struct lu_env *env,
LASSERT(cio->cui_iocb->ki_pos == pos);
result = generic_file_read_iter(cio->cui_iocb, cio->cui_iter);
break;
+#ifdef CONFIG_SYSCALL_SPLICE
case IO_SPLICE:
result = generic_file_splice_read(file, ,
vio->u.splice.cui_pipe, cnt,
@@ -539,6 +540,7 @@ static int vvp_io_read_start(const struct lu_env *env,
 * buffers. */
io->ci_continue = 0;
break;
+#endif /* #ifdef CONFIG_SYSCALL_SPLICE */
default:
CERROR("Wrong IO type %u\n", vio->cui_io_subtype);
LBUG();
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/56] fs/btrfs: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from btrfs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3afac2..68c2f0a 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2704,7 +2704,7 @@ const struct file_operations btrfs_file_operations = {
.read   = new_sync_read,
.write  = new_sync_write,
.read_iter  = generic_file_read_iter,
-   .splice_read= generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
.write_iter = btrfs_file_write_iter,
.mmap   = btrfs_file_mmap,
.open   = generic_file_open,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/56] fs/block_dev: support compiling out splice

2014-11-13 Thread Pieter Smith
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 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/56] fs/ceph: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from ceph when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/ceph/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 2eb02f8..c85396a 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1251,8 +1251,8 @@ const struct file_operations ceph_file_fops = {
.fsync = ceph_fsync,
.lock = ceph_lock,
.flock = ceph_flock,
-   .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)
.unlocked_ioctl = ceph_ioctl,
.compat_ioctl   = ceph_ioctl,
.fallocate  = ceph_fallocate,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/56] fs/cifs: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from cifs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/cifs/cifsfs.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index ac4f260..b2bd0a0 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -902,7 +902,7 @@ const struct file_operations cifs_file_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap  = cifs_file_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
.llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
@@ -921,7 +921,7 @@ const struct file_operations cifs_file_strict_ops = {
.fsync = cifs_strict_fsync,
.flush = cifs_flush,
.mmap = cifs_file_strict_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
.llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
@@ -941,7 +941,7 @@ const struct file_operations cifs_file_direct_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl  = cifs_ioctl,
 #endif /* CONFIG_CIFS_POSIX */
@@ -959,7 +959,7 @@ const struct file_operations cifs_file_nobrl_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap  = cifs_file_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
.llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
@@ -977,7 +977,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
.fsync = cifs_strict_fsync,
.flush = cifs_flush,
.mmap = cifs_file_strict_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
.llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
@@ -996,7 +996,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
-   .splice_read = generic_file_splice_read,
+   SPLICE_READ_INIT(generic_file_splice_read)
 #ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl  = cifs_ioctl,
 #endif /* CONFIG_CIFS_POSIX */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/56] fs/bfs: support compiling out splice

2014-11-13 Thread Pieter Smith
Compile out splice support from bfs when the splice-family of syscalls is not
supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined).

Signed-off-by: Pieter Smith 
---
 fs/bfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index e7f88ac..74ea687 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -28,7 +28,7 @@ const struct file_operations bfs_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)
 };
 
 static int bfs_move_block(unsigned long from, unsigned long to,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >