Commit 3f5f4959 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to commit bio cache after flushing node pages

In sync_node_pages, we won't check and commit last merged pages in private
bio cache of f2fs, as these pages were taged as writeback, someone who is
waiting for writebacking of the page will be blocked until the cache was
committed by someone else.

We need to commit node type bio cache to avoid potential deadlock or long
delay of waiting writeback.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent fc0065ad
...@@ -1312,6 +1312,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1312,6 +1312,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
struct page *last_page = NULL; struct page *last_page = NULL;
bool marked = false; bool marked = false;
nid_t ino = inode->i_ino; nid_t ino = inode->i_ino;
int nwritten = 0;
if (atomic) { if (atomic) {
last_page = last_fsync_dnode(sbi, ino); last_page = last_fsync_dnode(sbi, ino);
...@@ -1385,7 +1386,10 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1385,7 +1386,10 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
unlock_page(page); unlock_page(page);
f2fs_put_page(last_page, 0); f2fs_put_page(last_page, 0);
break; break;
} else {
nwritten++;
} }
if (page == last_page) { if (page == last_page) {
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
marked = true; marked = true;
...@@ -1407,6 +1411,9 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1407,6 +1411,9 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
unlock_page(last_page); unlock_page(last_page);
goto retry; goto retry;
} }
if (nwritten)
f2fs_submit_merged_bio_cond(sbi, NULL, NULL, ino, NODE, WRITE);
return ret ? -EIO: 0; return ret ? -EIO: 0;
} }
...@@ -1416,6 +1423,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc) ...@@ -1416,6 +1423,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
struct pagevec pvec; struct pagevec pvec;
int step = 0; int step = 0;
int nwritten = 0; int nwritten = 0;
int ret = 0;
pagevec_init(&pvec, 0); pagevec_init(&pvec, 0);
...@@ -1436,7 +1444,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc) ...@@ -1436,7 +1444,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
if (unlikely(f2fs_cp_error(sbi))) { if (unlikely(f2fs_cp_error(sbi))) {
pagevec_release(&pvec); pagevec_release(&pvec);
return -EIO; ret = -EIO;
goto out;
} }
/* /*
...@@ -1487,6 +1496,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc) ...@@ -1487,6 +1496,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc)) if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc))
unlock_page(page); unlock_page(page);
else
nwritten++;
if (--wbc->nr_to_write == 0) if (--wbc->nr_to_write == 0)
break; break;
...@@ -1504,7 +1515,10 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc) ...@@ -1504,7 +1515,10 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
step++; step++;
goto next_step; goto next_step;
} }
return nwritten; out:
if (nwritten)
f2fs_submit_merged_bio(sbi, NODE, WRITE);
return ret;
} }
int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino) int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment