All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: use iosize while reading compressed pages
@ 2020-09-15 15:41 Goldwyn Rodrigues
  2020-09-28 18:07 ` Josef Bacik
  2020-10-14 14:12 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Goldwyn Rodrigues @ 2020-09-15 15:41 UTC (permalink / raw)
  To: linux-btrfs

While using compression, a submitted bio is mapped with a compressed bio
which performs the read from disk, decompresses and returns uncompressed
data to original bio. The original bio must reflect the uncompressed
size (iosize) of the I/O to be performed, or else the page just gets the
decompressed I/O length of data (disk_io_size). The compressed bio
checks the extent map and get the correct length while performing the
I/O from disk.

This came up in subpage work when only compressed length of the original
bio was filled in the page. This worked correctly for pagesize ==
sectorsize because both compressed and uncompressed data are at pagesize
boundaries, and would end up filling the requested page.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/extent_io.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index afac70ef0cc5..98173580a948 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3158,7 +3158,6 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
 	int nr = 0;
 	size_t pg_offset = 0;
 	size_t iosize;
-	size_t disk_io_size;
 	size_t blocksize = inode->i_sb->s_blocksize;
 	unsigned long this_bio_flag = 0;
 	struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
@@ -3224,13 +3223,10 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
 		iosize = min(extent_map_end(em) - cur, end - cur + 1);
 		cur_end = min(extent_map_end(em) - 1, end);
 		iosize = ALIGN(iosize, blocksize);
-		if (this_bio_flag & EXTENT_BIO_COMPRESSED) {
-			disk_io_size = em->block_len;
+		if (this_bio_flag & EXTENT_BIO_COMPRESSED)
 			offset = em->block_start;
-		} else {
+		else
 			offset = em->block_start + extent_offset;
-			disk_io_size = iosize;
-		}
 		block_start = em->block_start;
 		if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags))
 			block_start = EXTENT_MAP_HOLE;
@@ -3319,7 +3315,7 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
 		}
 
 		ret = submit_extent_page(REQ_OP_READ | read_flags, NULL,
-					 page, offset, disk_io_size,
+					 page, offset, iosize,
 					 pg_offset, bio,
 					 end_bio_extent_readpage, 0,
 					 *bio_flags,
-- 
2.26.2


-- 
Goldwyn

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: use iosize while reading compressed pages
  2020-09-15 15:41 [PATCH] btrfs: use iosize while reading compressed pages Goldwyn Rodrigues
@ 2020-09-28 18:07 ` Josef Bacik
  2020-10-14 14:12 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-09-28 18:07 UTC (permalink / raw)
  To: Goldwyn Rodrigues, linux-btrfs

On 9/15/20 11:41 AM, Goldwyn Rodrigues wrote:
> While using compression, a submitted bio is mapped with a compressed bio
> which performs the read from disk, decompresses and returns uncompressed
> data to original bio. The original bio must reflect the uncompressed
> size (iosize) of the I/O to be performed, or else the page just gets the
> decompressed I/O length of data (disk_io_size). The compressed bio
> checks the extent map and get the correct length while performing the
> I/O from disk.
> 
> This came up in subpage work when only compressed length of the original
> bio was filled in the page. This worked correctly for pagesize ==
> sectorsize because both compressed and uncompressed data are at pagesize
> boundaries, and would end up filling the requested page.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: use iosize while reading compressed pages
  2020-09-15 15:41 [PATCH] btrfs: use iosize while reading compressed pages Goldwyn Rodrigues
  2020-09-28 18:07 ` Josef Bacik
@ 2020-10-14 14:12 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-10-14 14:12 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: linux-btrfs

On Tue, Sep 15, 2020 at 10:41:40AM -0500, Goldwyn Rodrigues wrote:
> While using compression, a submitted bio is mapped with a compressed bio
> which performs the read from disk, decompresses and returns uncompressed
> data to original bio. The original bio must reflect the uncompressed
> size (iosize) of the I/O to be performed, or else the page just gets the
> decompressed I/O length of data (disk_io_size). The compressed bio
> checks the extent map and get the correct length while performing the
> I/O from disk.
> 
> This came up in subpage work when only compressed length of the original
> bio was filled in the page. This worked correctly for pagesize ==
> sectorsize because both compressed and uncompressed data are at pagesize
> boundaries, and would end up filling the requested page.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-14 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 15:41 [PATCH] btrfs: use iosize while reading compressed pages Goldwyn Rodrigues
2020-09-28 18:07 ` Josef Bacik
2020-10-14 14:12 ` David Sterba

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.