mm/filemap: rename generic_file_buffered_read to filemap_read

Rename generic_file_buffered_read to match the naming of filemap_fault,
also update the written parameter to a more descriptive name and improve
the kerneldoc comment.

Link: https://lkml.kernel.org/r/20210122160140.223228-18-willy@infradead.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Christoph Hellwig 2021-02-24 12:02:42 -08:00 committed by Linus Torvalds
parent aa1ec2f697
commit 87fa0f3eb2
3 changed files with 19 additions and 22 deletions

View File

@ -3634,7 +3634,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
return ret; return ret;
} }
return generic_file_buffered_read(iocb, to, ret); return filemap_read(iocb, to, ret);
} }
const struct file_operations btrfs_file_operations = { const struct file_operations btrfs_file_operations = {

View File

@ -3080,8 +3080,8 @@ extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
extern int generic_write_check_limits(struct file *file, loff_t pos, extern int generic_write_check_limits(struct file *file, loff_t pos,
loff_t *count); loff_t *count);
extern int generic_file_rw_checks(struct file *file_in, struct file *file_out); extern int generic_file_rw_checks(struct file *file_in, struct file *file_out);
extern ssize_t generic_file_buffered_read(struct kiocb *iocb, ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *to,
struct iov_iter *to, ssize_t already_read); ssize_t already_read);
extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);

View File

@ -2394,23 +2394,20 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
} }
/** /**
* generic_file_buffered_read - generic file read routine * filemap_read - Read data from the page cache.
* @iocb: the iocb to read * @iocb: The iocb to read.
* @iter: data destination * @iter: Destination for the data.
* @written: already copied * @already_read: Number of bytes already read by the caller.
* *
* This is a generic file read routine, and uses the * Copies data from the page cache. If the data is not currently present,
* mapping->a_ops->readpage() function for the actual low-level stuff. * uses the readahead and readpage address_space operations to fetch it.
* *
* This is really ugly. But the goto's actually try to clarify some * Return: Total number of bytes copied, including those already read by
* of the logic when it comes to error handling etc. * the caller. If an error happens before any bytes are copied, returns
* * a negative error number.
* Return:
* * total number of bytes copied, including those the were already @written
* * negative error code if nothing was copied
*/ */
ssize_t generic_file_buffered_read(struct kiocb *iocb, ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
struct iov_iter *iter, ssize_t written) ssize_t already_read)
{ {
struct file *filp = iocb->ki_filp; struct file *filp = iocb->ki_filp;
struct file_ra_state *ra = &filp->f_ra; struct file_ra_state *ra = &filp->f_ra;
@ -2437,7 +2434,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
* can no longer safely return -EIOCBQUEUED. Hence mark * can no longer safely return -EIOCBQUEUED. Hence mark
* an async read NOWAIT at that point. * an async read NOWAIT at that point.
*/ */
if ((iocb->ki_flags & IOCB_WAITQ) && written) if ((iocb->ki_flags & IOCB_WAITQ) && already_read)
iocb->ki_flags |= IOCB_NOWAIT; iocb->ki_flags |= IOCB_NOWAIT;
error = filemap_get_pages(iocb, iter, &pvec); error = filemap_get_pages(iocb, iter, &pvec);
@ -2497,7 +2494,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
copied = copy_page_to_iter(page, offset, bytes, iter); copied = copy_page_to_iter(page, offset, bytes, iter);
written += copied; already_read += copied;
iocb->ki_pos += copied; iocb->ki_pos += copied;
ra->prev_pos = iocb->ki_pos; ra->prev_pos = iocb->ki_pos;
@ -2514,9 +2511,9 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
file_accessed(filp); file_accessed(filp);
return written ? written : error; return already_read ? already_read : error;
} }
EXPORT_SYMBOL_GPL(generic_file_buffered_read); EXPORT_SYMBOL_GPL(filemap_read);
/** /**
* generic_file_read_iter - generic filesystem read routine * generic_file_read_iter - generic filesystem read routine
@ -2591,7 +2588,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
goto out; goto out;
} }
retval = generic_file_buffered_read(iocb, iter, retval); retval = filemap_read(iocb, iter, retval);
out: out:
return retval; return retval;
} }