summaryrefslogtreecommitdiff
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorFan Li <fanofcode.li@samsung.com>2015-08-05 15:52:16 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2015-08-05 22:15:42 -0700
commit759af1c9c16fec5323111b799ce25a3d8864df7e (patch)
treec92f1022dd58aaf20d51742da74b886e91e701fc /fs/f2fs/data.c
parente90c2d2850d9d034e814a328725a4b15878f0357 (diff)
f2fs: use extent cache to optimize f2fs_reserve_block
In some cases, we only need the block address when we call f2fs_reserve_block, other fields of struct dnode_of_data aren't necessary. We can try extent cache first for such cases in order to speed up the process. Signed-off-by: Fan li <fanofcode.li@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f8f93db437ce..4fabdd47490a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -263,6 +263,19 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
return err;
}
+int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
+{
+ struct extent_info ei;
+ struct inode *inode = dn->inode;
+
+ if (f2fs_lookup_extent_cache(inode, index, &ei)) {
+ dn->data_blkaddr = ei.blk + index - ei.fofs;
+ return 0;
+ }
+
+ return f2fs_reserve_block(dn, index);
+}
+
struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw)
{
struct address_space *mapping = inode->i_mapping;
@@ -1383,7 +1396,8 @@ repeat:
if (err)
goto put_fail;
}
- err = f2fs_reserve_block(&dn, index);
+
+ err = f2fs_get_block(&dn, index);
if (err)
goto put_fail;
put_next: