Skip to content

Commit

Permalink
splice: simplify a conditional in copy_splice_read
Browse files Browse the repository at this point in the history
Check for -EFAULT instead of wrapping the check in an ret < 0 block.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20230614140341.521331-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 16, 2023
1 parent 0b24be4 commit 2e82f6c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,
if (ret > 0) {
keep = DIV_ROUND_UP(ret, PAGE_SIZE);
*ppos = kiocb.ki_pos;
} else if (ret < 0) {
/*
* callers of ->splice_read() expect -EAGAIN on
* "can't put anything in there", rather than -EFAULT.
*/
if (ret == -EFAULT)
ret = -EAGAIN;
}

/*
* Callers of ->splice_read() expect -EAGAIN on "can't put anything in
* there", rather than -EFAULT.
*/
if (ret == -EFAULT)
ret = -EAGAIN;

/* Free any pages that didn't get touched at all. */
if (keep < npages)
release_pages(pages + keep, npages - keep);
Expand Down

0 comments on commit 2e82f6c

Please sign in to comment.