diff mbox series

[6/9] btrfs: remove redundant i_size check in __extent_writepage_io()

Message ID 365cd6fdadd6a91c22ccf61fcb1deb688763a176.1575336816.git.osandov@fb.com (mailing list archive)
State New, archived
Headers show
Series btrfs: miscellaneous cleanups | expand

Commit Message

Omar Sandoval Dec. 3, 2019, 1:34 a.m. UTC
From: Omar Sandoval <osandov@fb.com>

In __extent_writepage_io(), we check whether
i_size <= page_offset(page).

Note that if i_size < page_offset(page), then
i_size >> PAGE_SHIFT < page->index. If i_size == page_offset(page), then
i_size >> PAGE_SHIFT == page->index && offset_in_page(i_size) == 0.

__extent_writepage() already has a check for these cases that
returns without calling __extent_writepage_io():

  end_index = i_size >> PAGE_SHIFT
  pg_offset = offset_in_page(i_size);
  if (page->index > end_index ||
     (page->index == end_index && !pg_offset)) {
          page->mapping->a_ops->invalidatepage(page, 0, PAGE_SIZE);
          unlock_page(page);
          return 0;
  }

Get rid of the one in __extent_writepage_io(), which was obsoleted in
211c17f51f46 ("Fix corners in writepage and btrfs_truncate_page").

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/btrfs/extent_io.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

David Sterba Dec. 10, 2019, 5:45 p.m. UTC | #1
On Mon, Dec 02, 2019 at 05:34:22PM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> In __extent_writepage_io(), we check whether
> i_size <= page_offset(page).
> 
> Note that if i_size < page_offset(page), then
> i_size >> PAGE_SHIFT < page->index. If i_size == page_offset(page), then
> i_size >> PAGE_SHIFT == page->index && offset_in_page(i_size) == 0.
> 
> __extent_writepage() already has a check for these cases that
> returns without calling __extent_writepage_io():
> 
>   end_index = i_size >> PAGE_SHIFT
>   pg_offset = offset_in_page(i_size);
>   if (page->index > end_index ||
>      (page->index == end_index && !pg_offset)) {
>           page->mapping->a_ops->invalidatepage(page, 0, PAGE_SIZE);
>           unlock_page(page);
>           return 0;
>   }
> 
> Get rid of the one in __extent_writepage_io(), which was obsoleted in
> 211c17f51f46 ("Fix corners in writepage and btrfs_truncate_page").
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Reviewed-by: David Sterba <dsterba@suse.com>
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8622282db31e..635f5d2954a4 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3455,11 +3455,6 @@  static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 	update_nr_written(wbc, nr_written + 1);
 
 	end = page_end;
-	if (i_size <= start) {
-		btrfs_writepage_endio_finish_ordered(page, start, page_end, 1);
-		goto done;
-	}
-
 	blocksize = inode->i_sb->s_blocksize;
 
 	while (cur <= end) {
@@ -3540,7 +3535,6 @@  static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 		pg_offset += iosize;
 		nr++;
 	}
-done:
 	*nr_ret = nr;
 	return ret;
 }