aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2017-02-03 17:44:04 -0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:34:51 +0200
commit1d55f970406805f0168477febab0031a9e34e2e9 (patch)
treea2584db95a2123479353aac2ad7b34954061dd47
parentc8daba9109cfadbd6d594a2e3d196000f9cbfdfa (diff)
f2fs: check io submission more precisely
This patch check IO submission more precisely than previous rough check. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/data.c23
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/node.c27
3 files changed, 37 insertions, 14 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index e1c8746fc..ee8177e27 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -380,6 +380,9 @@ int f2fs_submit_page_mbio(struct f2fs_io_info *fio)
bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
+ /* set submitted = 1 as a return value */
+ fio->submitted = 1;
+
if (!is_read)
inc_page_count(sbi, WB_DATA_TYPE(bio_page));
@@ -1341,8 +1344,8 @@ out_writepage:
return err;
}
-static int __write_data_page(struct page *page,
- struct writeback_control *wbc)
+static int __write_data_page(struct page *page, bool *submitted,
+ struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -1360,6 +1363,7 @@ static int __write_data_page(struct page *page,
.op_flags = wbc_to_write_flags(wbc),
.page = page,
.encrypted_page = NULL,
+ .submitted = false,
};
trace_f2fs_writepage(page, DATA);
@@ -1425,13 +1429,19 @@ out:
if (wbc->for_reclaim) {
f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, DATA, WRITE);
remove_dirty_inode(inode);
+ submitted = NULL;
}
unlock_page(page);
f2fs_balance_fs(sbi, need_balance_fs);
- if (unlikely(f2fs_cp_error(sbi)))
+ if (unlikely(f2fs_cp_error(sbi))) {
f2fs_submit_merged_bio(sbi, DATA, WRITE);
+ submitted = NULL;
+ }
+
+ if (submitted)
+ *submitted = fio.submitted;
return 0;
@@ -1446,7 +1456,7 @@ redirty_out:
static int f2fs_write_data_page(struct page *page,
struct writeback_control *wbc)
{
- return __write_data_page(page, wbc);
+ return __write_data_page(page, NULL, wbc);
}
/*
@@ -1505,6 +1515,7 @@ retry:
for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i];
+ bool submitted = false;
if (page->index > end) {
done = 1;
@@ -1538,7 +1549,7 @@ continue_unlock:
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
- ret = __write_data_page(page, wbc);
+ ret = __write_data_page(page, &submitted, wbc);
if (unlikely(ret)) {
/*
* keep nr_to_write, since vfs uses this to
@@ -1552,7 +1563,7 @@ continue_unlock:
done_index = page->index + 1;
done = 1;
break;
- } else {
+ } else if (submitted) {
nwritten++;
}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6f2c2b479..dd211e1cd 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -828,6 +828,7 @@ struct f2fs_io_info {
block_t old_blkaddr; /* old block address before Cow */
struct page *page; /* page to be written */
struct page *encrypted_page; /* encrypted page */
+ bool submitted; /* indicate IO submission */
};
#define is_read_io(rw) (rw == READ)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index e44a28719..d832babc3 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1335,7 +1335,7 @@ continue_unlock:
return last_page;
}
-static int __write_node_page(struct page *page, bool atomic,
+static int __write_node_page(struct page *page, bool atomic, bool *submitted,
struct writeback_control *wbc)
{
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
@@ -1348,6 +1348,7 @@ static int __write_node_page(struct page *page, bool atomic,
.op_flags = wbc_to_write_flags(wbc),
.page = page,
.encrypted_page = NULL,
+ .submitted = false,
};
trace_f2fs_writepage(page, NODE);
@@ -1389,13 +1390,19 @@ static int __write_node_page(struct page *page, bool atomic,
dec_page_count(sbi, F2FS_DIRTY_NODES);
up_read(&sbi->node_write);
- if (wbc->for_reclaim)
+ if (wbc->for_reclaim) {
f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, NODE, WRITE);
+ submitted = NULL;
+ }
unlock_page(page);
- if (unlikely(f2fs_cp_error(sbi)))
+ if (unlikely(f2fs_cp_error(sbi))) {
f2fs_submit_merged_bio(sbi, NODE, WRITE);
+ submitted = NULL;
+ }
+ if (submitted)
+ *submitted = fio.submitted;
return 0;
@@ -1407,7 +1414,7 @@ redirty_out:
static int f2fs_write_node_page(struct page *page,
struct writeback_control *wbc)
{
- return __write_node_page(page, false, wbc);
+ return __write_node_page(page, false, NULL, wbc);
}
int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
@@ -1441,6 +1448,7 @@ retry:
for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i];
+ bool submitted = false;
if (unlikely(f2fs_cp_error(sbi))) {
f2fs_put_page(last_page, 0);
@@ -1490,12 +1498,13 @@ continue_unlock:
goto continue_unlock;
ret = __write_node_page(page, atomic &&
- page == last_page, wbc);
+ page == last_page,
+ &submitted, wbc);
if (ret) {
unlock_page(page);
f2fs_put_page(last_page, 0);
break;
- } else {
+ } else if (submitted) {
nwritten++;
}
@@ -1551,6 +1560,7 @@ next_step:
for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i];
+ bool submitted = false;
if (unlikely(f2fs_cp_error(sbi))) {
pagevec_release(&pvec);
@@ -1604,9 +1614,10 @@ continue_unlock:
set_fsync_mark(page, 0);
set_dentry_mark(page, 0);
- if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc))
+ ret = __write_node_page(page, false, &submitted, wbc);
+ if (ret)
unlock_page(page);
- else
+ else if (submitted)
nwritten++;
if (--wbc->nr_to_write == 0)