Skip to content

Commit edf292c

Browse files
author
Dominik Brodowski
committed
fs: add ksys_fallocate() wrapper; remove in-kernel calls to sys_fallocate()
Using the ksys_fallocate() wrapper allows us to get rid of in-kernel calls to the sys_fallocate() 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_fallocate(). 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>
1 parent 36028d5 commit edf292c

8 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎arch/mips/kernel/linux32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
157157
asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
158158
unsigned offset_a3, unsigned len_a4, unsigned len_a5)
159159
{
160-
return sys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
161-
merge_64(len_a4, len_a5));
160+
return ksys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
161+
merge_64(len_a4, len_a5));
162162
}

‎arch/parisc/kernel/sys_parisc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ asmlinkage long parisc_sync_file_range(int fd,
367367
asmlinkage long parisc_fallocate(int fd, int mode, u32 offhi, u32 offlo,
368368
u32 lenhi, u32 lenlo)
369369
{
370-
return sys_fallocate(fd, mode, ((u64)offhi << 32) | offlo,
371-
((u64)lenhi << 32) | lenlo);
370+
return ksys_fallocate(fd, mode, ((u64)offhi << 32) | offlo,
371+
((u64)lenhi << 32) | lenlo);
372372
}
373373

374374
long parisc_personality(unsigned long personality)

‎arch/powerpc/kernel/sys_ppc32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
100100
asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
101101
u32 lenhi, u32 lenlo)
102102
{
103-
return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
103+
return ksys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
104104
((loff_t)lenhi << 32) | lenlo);
105105
}
106106

‎arch/s390/kernel/compat_linux.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,6 @@ COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,
516516
COMPAT_SYSCALL_DEFINE6(s390_fallocate, int, fd, int, mode, u32, offhigh, u32, offlow,
517517
u32, lenhigh, u32, lenlow)
518518
{
519-
return sys_fallocate(fd, mode, ((loff_t)offhigh << 32) + offlow,
520-
((u64)lenhigh << 32) + lenlow);
519+
return ksys_fallocate(fd, mode, ((loff_t)offhigh << 32) + offlow,
520+
((u64)lenhigh << 32) + lenlow);
521521
}

‎arch/sparc/kernel/sys_sparc32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,6 @@ long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned lon
250250
asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
251251
u32 lenhi, u32 lenlo)
252252
{
253-
return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
254-
((loff_t)lenhi << 32) | lenlo);
253+
return ksys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
254+
((loff_t)lenhi << 32) | lenlo);
255255
}

‎arch/x86/ia32/sys_ia32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
226226
unsigned int, offset_lo, unsigned int, offset_hi,
227227
unsigned int, len_lo, unsigned int, len_hi)
228228
{
229-
return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
230-
((u64)len_hi << 32) | len_lo);
229+
return ksys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
230+
((u64)len_hi << 32) | len_lo);
231231
}
232232

233233
/*

‎fs/open.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
333333
}
334334
EXPORT_SYMBOL_GPL(vfs_fallocate);
335335

336-
SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
336+
int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len)
337337
{
338338
struct fd f = fdget(fd);
339339
int error = -EBADF;
@@ -345,6 +345,11 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
345345
return error;
346346
}
347347

348+
SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
349+
{
350+
return ksys_fallocate(fd, mode, offset, len);
351+
}
352+
348353
/*
349354
* access() needs to use the real uid/gid, not the effective uid/gid.
350355
* We do this by temporarily clearing all FS-related capabilities and

‎include/linux/syscalls.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count,
969969
loff_t pos);
970970
ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf,
971971
size_t count, loff_t pos);
972+
int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len);
972973

973974
/*
974975
* The following kernel syscall equivalents are just wrappers to fs-internal

0 commit comments

Comments
 (0)