summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorHou Pengyang <houpengyang@huawei.com>2017-04-25 15:45:13 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2017-05-03 07:19:47 +0300
commite959c8f543e11dadf7f6923427fb3acb452a0de6 (patch)
tree79ae2172c8d1d45231a6e3eea23aacf22be00a84 /fs/f2fs
parent7eab0c0df8d1a8c460f7d660d3ffd06fd448e590 (diff)
downloadlinux-e959c8f543e11dadf7f6923427fb3acb452a0de6.tar.xz
f2fs: lookup extent cache first under IPU scenario
If a page is cold, NOT atomit written and need_ipu now, there is a high probability that IPU should be adapted. For IPU, we try to check extent tree to get the block index first, instead of reading the dnode page, where may lead to an useless dnode IO, since no need to update the dnode index for IPU. Signed-off-by: Hou Pengyang <houpengyang@huawei.com> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c16
-rw-r--r--fs/f2fs/gc.c1
-rw-r--r--fs/f2fs/segment.c1
3 files changed, 16 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index dfc974c95dd2..ca21ecbd6bbd 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1350,9 +1350,20 @@ int do_write_data_page(struct f2fs_io_info *fio)
struct page *page = fio->page;
struct inode *inode = page->mapping->host;
struct dnode_of_data dn;
+ struct extent_info ei = {0,0,0};
+ bool ipu_force = false;
int err = 0;
set_new_dnode(&dn, inode, NULL, NULL, 0);
+ if (need_inplace_update(fio) &&
+ f2fs_lookup_extent_cache(inode, page->index, &ei)) {
+ fio->old_blkaddr = ei.blk + page->index - ei.fofs;
+ if (fio->old_blkaddr != NULL_ADDR &&
+ fio->old_blkaddr != NEW_ADDR) {
+ ipu_force = true;
+ goto got_it;
+ }
+ }
err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
if (err)
return err;
@@ -1364,7 +1375,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
ClearPageUptodate(page);
goto out_writepage;
}
-
+got_it:
err = encrypt_one_page(fio);
if (err)
goto out_writepage;
@@ -1375,7 +1386,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
* If current allocation needs SSR,
* it had better in-place writes for updated data.
*/
- if (need_inplace_update(fio)) {
+ if (ipu_force || need_inplace_update(fio)) {
f2fs_bug_on(fio->sbi, !fio->cp_rwsem_locked);
f2fs_unlock_op(fio->sbi);
fio->cp_rwsem_locked = false;
@@ -1412,6 +1423,7 @@ static int __write_data_page(struct page *page, bool *submitted,
.type = DATA,
.op = REQ_OP_WRITE,
.op_flags = wbc_to_write_flags(wbc),
+ .old_blkaddr = NULL_ADDR,
.page = page,
.encrypted_page = NULL,
.submitted = false,
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 84db41ca27c1..c2a9ae8397d3 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -714,6 +714,7 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
.type = DATA,
.op = REQ_OP_WRITE,
.op_flags = REQ_SYNC,
+ .old_blkaddr = NULL_ADDR,
.page = page,
.encrypted_page = NULL,
};
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 35d5d49e7614..38b97ad6bceb 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -311,6 +311,7 @@ static int __commit_inmem_pages(struct inode *inode,
}
fio.page = page;
+ fio.old_blkaddr = NULL_ADDR;
err = do_write_data_page(&fio);
if (err) {
unlock_page(page);