From: Fan Li <fanofcode.li@samsung.com>
To: 'Jaegeuk Kim' <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 3/3] f2fs: avoid looking up extents outside specified range
Date: Wed, 30 Dec 2015 17:23:33 +0800 [thread overview]
Message-ID: <000e01d142e3$d6dea560$849bf020$@samsung.com> (raw)
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
------------------------------------------------------------------------------
reply other threads:[~2015-12-30 9:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000e01d142e3$d6dea560$849bf020$@samsung.com' \
--to=fanofcode.li@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).