]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscall
authorDominik Brodowski <linux@dominikbrodowski.net>
Sun, 11 Mar 2018 10:34:47 +0000 (11:34 +0100)
committerDominik Brodowski <linux@dominikbrodowski.net>
Mon, 2 Apr 2018 18:16:07 +0000 (20:16 +0200)
Using this helper allows us to avoid the in-kernel calls to the
sys_sync_file_range() syscall. The ksys_ prefix denotes that this function
is meant as a drop-in replacement for the syscall. In particular, it uses
the same calling convention as sys_sync_file_range().

This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
arch/mips/kernel/linux32.c
arch/parisc/kernel/sys_parisc.c
arch/powerpc/kernel/sys_ppc32.c
arch/s390/kernel/compat_linux.c
arch/sparc/kernel/sys_sparc32.c
arch/x86/ia32/sys_ia32.c
fs/sync.c
include/linux/syscalls.h

index 3c90449742a0b485d6e342ea6199f9f8e73b6007..57b3310873f00c1ef2f2a77680e8a84173214635 100644 (file)
@@ -139,7 +139,7 @@ asmlinkage long sys32_sync_file_range(int fd, int __pad,
        unsigned long a4, unsigned long a5,
        int flags)
 {
-       return sys_sync_file_range(fd,
+       return ksys_sync_file_range(fd,
                        merge_64(a2, a3), merge_64(a4, a5),
                        flags);
 }
index 6d2a64859c22bda036060d4cf4013abe00865af3..ef995b5d97ef66f39c77baf9fb9c0c9f39d162d4 100644 (file)
@@ -360,7 +360,7 @@ asmlinkage long parisc_sync_file_range(int fd,
                        u32 hi_off, u32 lo_off, u32 hi_nbytes, u32 lo_nbytes,
                        unsigned int flags)
 {
-       return sys_sync_file_range(fd, (loff_t)hi_off << 32 | lo_off,
+       return ksys_sync_file_range(fd, (loff_t)hi_off << 32 | lo_off,
                        (loff_t)hi_nbytes << 32 | lo_nbytes, flags);
 }
 
index e0c9b7f1bf380c63f27c45234efbd6ab42deeb21..664e4c5b5855813faf303f876f81bd9b28515fdd 100644 (file)
@@ -124,5 +124,5 @@ asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
        loff_t offset = ((loff_t)offset_hi << 32) | offset_lo;
        loff_t nbytes = ((loff_t)nbytes_hi << 32) | nbytes_lo;
 
-       return sys_sync_file_range(fd, offset, nbytes, flags);
+       return ksys_sync_file_range(fd, offset, nbytes, flags);
 }
index af0469f204fdfd0cf92836e5d6612dd159665b1b..605f6f026e447132f964b5c9c5b7a34b65141703 100644 (file)
@@ -509,7 +509,7 @@ COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, arg
 COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,
                       u32, nhigh, u32, nlow, unsigned int, flags)
 {
-       return sys_sync_file_range(fd, ((loff_t)offhigh << 32) + offlow,
+       return ksys_sync_file_range(fd, ((loff_t)offhigh << 32) + offlow,
                                   ((u64)nhigh << 32) + nlow, flags);
 }
 
index d64b425fff931cd2e46a87a3daabeb79a5218458..af18b9ff86be53fb7c9f9048e66668e8049adc18 100644 (file)
@@ -241,7 +241,7 @@ long compat_sys_fadvise64_64(int fd,
 
 long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned long off_low, unsigned long nb_high, unsigned long nb_low, unsigned int flags)
 {
-       return sys_sync_file_range(fd,
+       return ksys_sync_file_range(fd,
                                   (off_high << 32) | off_low,
                                   (nb_high << 32) | nb_low,
                                   flags);
index 1979e5b4ad9a1271d49f251b556bc3feb4a4d99f..0c5f8932c136b188ab30c313a847cc147dcd519e 100644 (file)
@@ -209,9 +209,9 @@ COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
                       unsigned int, off_hi, unsigned int, n_low,
                       unsigned int, n_hi, int, flags)
 {
-       return sys_sync_file_range(fd,
-                                  ((u64)off_hi << 32) | off_low,
-                                  ((u64)n_hi << 32) | n_low, flags);
+       return ksys_sync_file_range(fd,
+                                   ((u64)off_hi << 32) | off_low,
+                                   ((u64)n_hi << 32) | n_low, flags);
 }
 
 COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
index 602ae94bb67e4fe83a3d3750b700b69e1fd6889e..9908a114d5060af797257f48ca57c91d7465d760 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -285,8 +285,8 @@ SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
  * already-instantiated disk blocks, there are no guarantees here that the data
  * will be available after a crash.
  */
-SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
-                               unsigned int, flags)
+int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
+                        unsigned int flags)
 {
        int ret;
        struct fd f;
@@ -364,10 +364,16 @@ SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
        return ret;
 }
 
+SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
+                               unsigned int, flags)
+{
+       return ksys_sync_file_range(fd, offset, nbytes, flags);
+}
+
 /* It would be nice if people remember that not all the world's an i386
    when they introduce new system calls */
 SYSCALL_DEFINE4(sync_file_range2, int, fd, unsigned int, flags,
                                 loff_t, offset, loff_t, nbytes)
 {
-       return sys_sync_file_range(fd, offset, nbytes, flags);
+       return ksys_sync_file_range(fd, offset, nbytes, flags);
 }
index 4dd685ee425dac6aed90597e88f343d105e41e4d..331da76f66e2955820439bb9205891de2d5c3145 100644 (file)
@@ -963,6 +963,8 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
 void ksys_sync(void);
 int ksys_unshare(unsigned long unshare_flags);
 int ksys_setsid(void);
+int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
+                        unsigned int flags);
 
 /*
  * The following kernel syscall equivalents are just wrappers to fs-internal