mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
[PATCH] splice: unlikely() optimizations
Also corrects a few comments. Patch mainly from Ingo, changes by me. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Jens Axboe <axboe@suse.de>
This commit is contained in:
parent
6f767b0425
commit
49570e9b29
2 changed files with 8 additions and 9 deletions
|
@ -202,7 +202,7 @@ int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count
|
||||||
goto Einval;
|
goto Einval;
|
||||||
|
|
||||||
inode = file->f_dentry->d_inode;
|
inode = file->f_dentry->d_inode;
|
||||||
if (inode->i_flock && MANDATORY_LOCK(inode)) {
|
if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
|
||||||
int retval = locks_mandatory_area(
|
int retval = locks_mandatory_area(
|
||||||
read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
|
read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,
|
||||||
inode, file, pos, count);
|
inode, file, pos, count);
|
||||||
|
|
13
fs/splice.c
13
fs/splice.c
|
@ -346,7 +346,6 @@ __generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
|
||||||
* @flags: splice modifier flags
|
* @flags: splice modifier flags
|
||||||
*
|
*
|
||||||
* Will read pages from given file and fill them into a pipe.
|
* Will read pages from given file and fill them into a pipe.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
ssize_t generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
|
ssize_t generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
|
||||||
size_t len, unsigned int flags)
|
size_t len, unsigned int flags)
|
||||||
|
@ -730,10 +729,10 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
|
||||||
loff_t pos;
|
loff_t pos;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!out->f_op || !out->f_op->splice_write)
|
if (unlikely(!out->f_op || !out->f_op->splice_write))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!(out->f_mode & FMODE_WRITE))
|
if (unlikely(!(out->f_mode & FMODE_WRITE)))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
pos = out->f_pos;
|
pos = out->f_pos;
|
||||||
|
@ -754,10 +753,10 @@ static long do_splice_to(struct file *in, struct pipe_inode_info *pipe,
|
||||||
loff_t pos, isize, left;
|
loff_t pos, isize, left;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!in->f_op || !in->f_op->splice_read)
|
if (unlikely(!in->f_op || !in->f_op->splice_read))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!(in->f_mode & FMODE_READ))
|
if (unlikely(!(in->f_mode & FMODE_READ)))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
pos = in->f_pos;
|
pos = in->f_pos;
|
||||||
|
@ -771,7 +770,7 @@ static long do_splice_to(struct file *in, struct pipe_inode_info *pipe,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
left = isize - in->f_pos;
|
left = isize - in->f_pos;
|
||||||
if (left < len)
|
if (unlikely(left < len))
|
||||||
len = left;
|
len = left;
|
||||||
|
|
||||||
return in->f_op->splice_read(in, pipe, len, flags);
|
return in->f_op->splice_read(in, pipe, len, flags);
|
||||||
|
@ -799,7 +798,7 @@ long do_splice_direct(struct file *in, struct file *out, size_t len,
|
||||||
* 'out' and transfer the wanted data from 'in' to 'out' through that
|
* 'out' and transfer the wanted data from 'in' to 'out' through that
|
||||||
*/
|
*/
|
||||||
pipe = current->splice_pipe;
|
pipe = current->splice_pipe;
|
||||||
if (!pipe) {
|
if (unlikely(!pipe)) {
|
||||||
pipe = alloc_pipe_info(NULL);
|
pipe = alloc_pipe_info(NULL);
|
||||||
if (!pipe)
|
if (!pipe)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Reference in a new issue