linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] f2fs: avoid looking up extents outside specified range
@ 2015-12-30  9:23 Fan Li
  0 siblings, 0 replies; only message in thread
From: Fan Li @ 2015-12-30  9:23 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-f2fs-devel

There are two advantages to update b_size in this way:
1. get_data_block tends to round down b_size to align with
   block size, if b_size isn't aligned already, it would take
   an extra loop to go through the range. So we round it up first.
2. unlike extent-based file, get_data_block could be time-consuming
    for indirect-based file, update b_size may avoid looking up blocks 
    outside the range.

Signed-off-by: Fan li <fanofcode.li@samsung.com>
---
 fs/f2fs/data.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f89cf07..29fec76 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -798,15 +798,15 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	isize = i_size_read(inode);
 
 	mutex_lock(&inode->i_mutex);
-	if (logical_to_blk(inode, len) == 0)
-		len = blk_to_logical(inode, 1);
 
 	start_blk = logical_to_blk(inode, start);
 	last_blk = logical_to_blk(inode, start + len - 1);
-
 next:
 	memset(&map_bh, 0, sizeof(struct buffer_head));
-	map_bh.b_size = len;
+	if (last_blk >= start_blk)
+		map_bh.b_size = blk_to_logical(inode, last_blk - start_blk + 1);
+	else
+		map_bh.b_size = blk_to_logical(inode, 1);
 
 	ret = get_data_block(inode, start_blk, &map_bh, 0,
 					F2FS_GET_BLOCK_FIEMAP);
-- 
1.7.9.5


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-30  9:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-30  9:23 [PATCH 3/3] f2fs: avoid looking up extents outside specified range Fan Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).