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...@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


------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to