All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 12/13] mm: rename generic_file_buffered_read to filemap_read
Date: Sat, 31 Oct 2020 10:00:03 +0100	[thread overview]
Message-ID: <20201031090004.452516-13-hch@lst.de> (raw)
In-Reply-To: <20201031090004.452516-1-hch@lst.de>

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/file.c    |  2 +-
 include/linux/fs.h |  4 ++--
 mm/filemap.c       | 34 ++++++++++++++++------------------
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 87355a38a65470..1a4913e1fd1289 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -3633,7 +3633,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 			return ret;
 	}
 
-	return generic_file_buffered_read(iocb, to, ret);
+	return filemap_read(iocb, to, ret);
 }
 
 const struct file_operations btrfs_file_operations = {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8d559d43f2af92..a79f65607236ae 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2948,8 +2948,8 @@ extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
 extern int generic_write_check_limits(struct file *file, loff_t pos,
 		loff_t *count);
 extern int generic_file_rw_checks(struct file *file_in, struct file *file_out);
-extern ssize_t generic_file_buffered_read(struct kiocb *iocb,
-		struct iov_iter *to, ssize_t already_read);
+ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *to,
+		ssize_t already_read);
 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 *);
diff --git a/mm/filemap.c b/mm/filemap.c
index 904b0a4fb9e008..743d764f3eab1c 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2372,23 +2372,21 @@ static int filemap_read_pages(struct kiocb *iocb, struct iov_iter *iter,
 }
 
 /**
- * generic_file_buffered_read - generic file read routine
- * @iocb:	the iocb to read
- * @iter:	data destination
- * @written:	already copied
+ * filemap_read - read data from the page cache
+ * @iocb:		the iocb to read
+ * @iter:		data destination
+ * @already_read:	number of bytes already read by the caller
  *
- * This is a generic file read routine, and uses the
- * mapping->a_ops->readpage() function for the actual low-level stuff.
- *
- * This is really ugly. But the goto's actually try to clarify some
- * of the logic when it comes to error handling etc.
+ * Read data from the pagecache using the ->readpage address space
+ * operation.
  *
  * Return:
- * * total number of bytes copied, including those the were already @written
- * * negative error code if nothing was copied
+ *  Total number of bytes copied, including those already read by the caller as
+ *  passed in the @already_read argument.  Negative error code if an error
+ *  happened before any bytes were copied.
  */
-ssize_t generic_file_buffered_read(struct kiocb *iocb,
-		struct iov_iter *iter, ssize_t written)
+ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
+		ssize_t already_read)
 {
 	struct file *filp = iocb->ki_filp;
 	struct file_ra_state *ra = &filp->f_ra;
@@ -2422,7 +2420,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
 		 * can no longer safely return -EIOCBQUEUED. Hence mark
 		 * 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;
 
 		i = 0;
@@ -2482,7 +2480,7 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
 
 			copied = copy_page_to_iter(pages[i], offset, bytes, iter);
 
-			written += copied;
+			already_read += copied;
 			iocb->ki_pos += copied;
 			ra->prev_pos = iocb->ki_pos;
 
@@ -2501,9 +2499,9 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb,
 	if (pages != pages_onstack)
 		kfree(pages);
 
-	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
@@ -2577,7 +2575,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 			goto out;
 	}
 
-	retval = generic_file_buffered_read(iocb, iter, retval);
+	retval = filemap_read(iocb, iter, retval);
 out:
 	return retval;
 }
-- 
2.28.0


  parent reply	other threads:[~2020-10-31  9:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31  8:59 clean up the generic pagecache read helpers Christoph Hellwig
2020-10-31  8:59 ` [PATCH 01/13] mm: simplify generic_file_buffered_read_readpage Christoph Hellwig
2020-10-31  8:59 ` [PATCH 02/13] mm: simplify generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31  8:59 ` [PATCH 03/13] mm: lift the nowait checks into generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31  8:59 ` [PATCH 04/13] mm: handle readahead in generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31 17:06   ` Matthew Wilcox
2020-11-01 10:31     ` Christoph Hellwig
2020-11-01 10:49       ` Matthew Wilcox
2020-11-01 10:51         ` Christoph Hellwig
2020-11-01 10:51           ` Christoph Hellwig
2020-11-01 11:04             ` Matthew Wilcox
2020-11-01 11:52               ` Christoph Hellwig
2020-11-01 14:55                 ` Matthew Wilcox
2020-11-02  8:18                   ` Christoph Hellwig
2020-10-31  8:59 ` [PATCH 05/13] mm: simplify generic_file_buffered_read_no_cached_page Christoph Hellwig
2020-10-31 16:20   ` Matthew Wilcox
2020-10-31 16:28   ` Matthew Wilcox
2020-11-01 10:29     ` Christoph Hellwig
2020-10-31  8:59 ` [PATCH 06/13] mm: factor out a filemap_find_get_pages helper Christoph Hellwig
2020-10-31  8:59 ` [PATCH 07/13] mm: refactor generic_file_buffered_read_get_pages Christoph Hellwig
2020-11-01 11:18   ` Matthew Wilcox
2020-10-31  8:59 ` [PATCH 08/13] mm: move putting the page on error out of filemap_readpage Christoph Hellwig
2020-10-31  9:00 ` [PATCH 09/13] mm: move putting the page on error out of filemap_make_page_uptodate Christoph Hellwig
2020-10-31  9:00 ` [PATCH 10/13] mm: open code readahead in filemap_new_page Christoph Hellwig
2020-11-01 11:20   ` Matthew Wilcox
2020-10-31  9:00 ` [PATCH 11/13] mm: streamline the partially uptodate checks in filemap_make_page_uptodate Christoph Hellwig
2020-11-01 11:23   ` Matthew Wilcox
2020-10-31  9:00 ` Christoph Hellwig [this message]
2020-10-31  9:00 ` [PATCH 13/13] mm: simplify generic_file_read_iter Christoph Hellwig
2020-10-31 15:42 ` clean up the generic pagecache read helpers Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201031090004.452516-13-hch@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.