[2/3] fs: remove the buffer_unwritten check in page_seek_hole_data

Message ID 20180530100208.31490-3-hch@lst.de
State Not Applicable, archived
Headers show
Series
  • [1/3] fs: move page_cache_seek_hole_data to iomap.c
Related show

Commit Message

Christoph Hellwig May 30, 2018, 10:02 a.m.
We only call into this function through the iomap iterators, so we already
know the buffer is unwritten.  In addition to that we always require the
uptodate flag that is ORed with the result anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Dave Chinner May 30, 2018, 10:47 p.m. | #1
On Wed, May 30, 2018 at 12:02:07PM +0200, Christoph Hellwig wrote:
> We only call into this function through the iomap iterators, so we already
> know the buffer is unwritten.  In addition to that we always require the
> uptodate flag that is ORed with the result anyway.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/iomap.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

Makes sense to me.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

Patch

diff --git a/fs/iomap.c b/fs/iomap.c
index c2d4fd551fed..e75153f52748 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -816,14 +816,9 @@  page_seek_hole_data(struct page *page, loff_t lastoff, int whence)
 			continue;
 
 		/*
-		 * Unwritten extents that have data in the page cache covering
-		 * them can be identified by the BH_Unwritten state flag.
-		 * Pages with multiple buffers might have a mix of holes, data
-		 * and unwritten extents - any buffer with valid data in it
-		 * should have BH_Uptodate flag set on it.
+		 * Any buffer with valid data in it should have BH_Uptodate set.
 		 */
-
-		if ((buffer_unwritten(bh) || buffer_uptodate(bh)) == seek_data)
+		if (buffer_uptodate(bh) == seek_data)
 			return lastoff;
 
 		lastoff = offset;
@@ -835,8 +830,8 @@  page_seek_hole_data(struct page *page, loff_t lastoff, int whence)
  * Seek for SEEK_DATA / SEEK_HOLE in the page cache.
  *
  * Within unwritten extents, the page cache determines which parts are holes
- * and which are data: unwritten and uptodate buffer heads count as data;
- * everything else counts as a hole.
+ * and which are data: uptodate buffer heads count as data; everything else
+ * counts as a hole.
  *
  * Returns the resulting offset on successs, and -ENOENT otherwise.
  */