diff mbox

[3/7] btrfs: subpagesize-blocksize: Handle small extent maps properly

Message ID 1386805122-23972-4-git-send-email-sekharan@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chandra Seetharaman Dec. 11, 2013, 11:38 p.m. UTC
This patch makes sure that the size extent maps handles are at
least PAGE_CACHE_SIZE for the subpagesize-blocksize case.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
---
 fs/btrfs/inode.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c79c9cd..c0c18ca 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6036,7 +6036,11 @@  next:
 	if (found_type == BTRFS_FILE_EXTENT_REG ||
 	    found_type == BTRFS_FILE_EXTENT_PREALLOC) {
 		em->start = extent_start;
-		em->len = extent_end - extent_start;
+		if (inode->i_sb->s_blocksize < PAGE_CACHE_SIZE &&
+				em->len < PAGE_CACHE_SIZE)
+			em->len = PAGE_CACHE_SIZE;
+		else
+			em->len = extent_end - extent_start;
 		em->orig_start = extent_start -
 				 btrfs_file_extent_offset(leaf, item);
 		em->orig_block_len = btrfs_file_extent_disk_num_bytes(leaf,
@@ -6077,6 +6081,8 @@  next:
 		extent_offset = page_offset(page) + pg_offset - extent_start;
 		copy_size = min_t(u64, PAGE_CACHE_SIZE - pg_offset,
 				size - extent_offset);
+		if (inode->i_sb->s_blocksize < PAGE_CACHE_SIZE)
+			copy_size = max_t(u64, copy_size, PAGE_CACHE_SIZE);
 		em->start = extent_start + extent_offset;
 		em->len = ALIGN(copy_size, btrfs_align_size(inode));
 		em->orig_block_len = em->len;