Received: by 10.213.65.68 with SMTP id h4csp144766imn; Thu, 15 Mar 2018 12:12:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELvng1lMe3yXKc4UTRAuHMRjKgHUvV+qHlRK9+z3cvuEE2R3O0L33/gvVl0HDlr6tlJ76hFK X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr9045489pld.231.1521141170548; Thu, 15 Mar 2018 12:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521141170; cv=none; d=google.com; s=arc-20160816; b=dFjMJyRBPYMJcrJuDFab3KVPu3v9WnvVZ4dcdMSFBPVFCVY3mnx4o6DEXb7DdueqbN 9V5SkuNfc8V+Q9yNTjrA0PJiV4lUapxiSimIhVC58mCBmmMJll0KvAQSI+Bp9tzptb7G izG9tyjVmTWQqXvKRH5/C34mSwXm6fkH4yMZ2XnnyBHIRTf4e/zj/ljhHmdTLr64CoNF L9Jcp1C1GtxF5b7qopIR9lO/sHXujxf82jKzjzlLXRgKH7wHwYFZ1Ht4Rph9JYTaMwYg 2SumcELFrYSZsAIgF22d35kqzq30xAaa5+FbX5mT0mjwoHCSdBsOE31+2UH4gKXE3hzr Wf5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=R/gSCsekvH34+5U+V7Eek3kRsKNiIAPLrNovxgg26NU=; b=lPOe+l8b56lQ/7LEcghDFrtdt+RHfsASDr+l9pIP+QmE194Z/TWFobxh/vN/elXkFH /bWqWB6I3yNT406MvNIr+bIpRG+bXVbLQdnWhQtLnGu4XRQMfcMeeIyWH6FjItv1EUsk onfwiPaqaWff+oL9RH1hPL6acLyFtcmThNzVLHOl5MVZF+4dJedDcAoXdBq33LjIs2he KrOXOBylZDbrfHEyIgZlqDAhINa0aK4oVKl8aNfwKuAHYNXZqmli1UgdMnJyaJjuneDL 6Cs7vynYv1fIoOb+lFOKs5zvQnKPRNMwPflDUrn8lq9+3obHcHHNpN/jnDEDgStY4e8z VZ7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13si997417pgs.482.2018.03.15.12.12.35; Thu, 15 Mar 2018 12:12:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932772AbeCOTJ1 (ORCPT + 99 others); Thu, 15 Mar 2018 15:09:27 -0400 Received: from isilmar-4.linta.de ([136.243.71.142]:36262 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932668AbeCOTGX (ORCPT ); Thu, 15 Mar 2018 15:06:23 -0400 Received: from light.dominikbrodowski.net (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTPS id A03EC20091C; Thu, 15 Mar 2018 19:06:18 +0000 (UTC) Received: by light.dominikbrodowski.net (Postfix, from userid 1000) id 8448B206AD; Thu, 15 Mar 2018 20:05:39 +0100 (CET) From: Dominik Brodowski To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk Cc: luto@kernel.org, mingo@kernel.org, akpm@linux-foundation.org, arnd@arndb.de Subject: [PATCH v2 23/36] fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscall Date: Thu, 15 Mar 2018 20:05:16 +0100 Message-Id: <20180315190529.20943-24-linux@dominikbrodowski.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315190529.20943-1-linux@dominikbrodowski.net> References: <20180315190529.20943-1-linux@dominikbrodowski.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using this helper allows us to avoid the in-kernel calls to the sys_sync_file_range() syscall. Cc: Al Viro Cc: Andrew Morton Signed-off-by: Dominik Brodowski --- arch/mips/kernel/linux32.c | 2 +- arch/parisc/kernel/sys_parisc.c | 2 +- arch/powerpc/kernel/sys_ppc32.c | 2 +- arch/s390/kernel/compat_linux.c | 2 +- arch/sparc/kernel/sys_sparc32.c | 2 +- arch/x86/ia32/sys_ia32.c | 6 +++--- fs/sync.c | 12 +++++++++--- include/linux/syscalls.h | 2 ++ 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 0ce4f7240f69..db895771ab06 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c @@ -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); } diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 572feeea834c..0b0e1cfb4bd9 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c @@ -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); } diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c index 93df264ab76c..3871aa9267e6 100644 --- a/arch/powerpc/kernel/sys_ppc32.c +++ b/arch/powerpc/kernel/sys_ppc32.c @@ -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); } diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index a47995a5174c..82e99bf3b00e 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c @@ -510,7 +510,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); } diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c index 08261bc15d30..c56f43893283 100644 --- a/arch/sparc/kernel/sys_sparc32.c +++ b/arch/sparc/kernel/sys_sparc32.c @@ -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); diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c index ca28ee07a191..e5b053252a01 100644 --- a/arch/x86/ia32/sys_ia32.c +++ b/arch/x86/ia32/sys_ia32.c @@ -214,9 +214,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, diff --git a/fs/sync.c b/fs/sync.c index 6e0a2cbaf6de..ff947c30a6c0 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -280,8 +280,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; @@ -359,10 +359,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); } diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 923a4d056137..8f0f99702e7a 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -968,5 +968,7 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff); int ksys_chdir(const char __user *filename); +int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, + unsigned int flags); #endif -- 2.16.2