aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2016-09-29 06:50:10 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2016-09-30 20:34:38 -0400
commit3f5f4959b144d9ba6657ccc0ab9edcc78fcc1d8a (patch)
tree139debf9e15b1556e179b241b77db7975b84ce6d
parentfc0065adb202518e25fb929cda7d5887a456f774 (diff)
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: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/node.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 9faddcd068d9..883103593f33 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1312,6 +1312,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
1312 struct page *last_page = NULL; 1312 struct page *last_page = NULL;
1313 bool marked = false; 1313 bool marked = false;
1314 nid_t ino = inode->i_ino; 1314 nid_t ino = inode->i_ino;
1315 int nwritten = 0;
1315 1316
1316 if (atomic) { 1317 if (atomic) {
1317 last_page = last_fsync_dnode(sbi, ino); 1318 last_page = last_fsync_dnode(sbi, ino);
@@ -1385,7 +1386,10 @@ continue_unlock:
1385 unlock_page(page); 1386 unlock_page(page);
1386 f2fs_put_page(last_page, 0); 1387 f2fs_put_page(last_page, 0);
1387 break; 1388 break;
1389 } else {
1390 nwritten++;
1388 } 1391 }
1392
1389 if (page == last_page) { 1393 if (page == last_page) {
1390 f2fs_put_page(page, 0); 1394 f2fs_put_page(page, 0);
1391 marked = true; 1395 marked = true;
@@ -1407,6 +1411,9 @@ continue_unlock:
1407 unlock_page(last_page); 1411 unlock_page(last_page);
1408 goto retry; 1412 goto retry;
1409 } 1413 }
1414
1415 if (nwritten)
1416 f2fs_submit_merged_bio_cond(sbi, NULL, NULL, ino, NODE, WRITE);
1410 return ret ? -EIO: 0; 1417 return ret ? -EIO: 0;
1411} 1418}
1412 1419
@@ -1416,6 +1423,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
1416 struct pagevec pvec; 1423 struct pagevec pvec;
1417 int step = 0; 1424 int step = 0;
1418 int nwritten = 0; 1425 int nwritten = 0;
1426 int ret = 0;
1419 1427
1420 pagevec_init(&pvec, 0); 1428 pagevec_init(&pvec, 0);
1421 1429
@@ -1436,7 +1444,8 @@ next_step:
1436 1444
1437 if (unlikely(f2fs_cp_error(sbi))) { 1445 if (unlikely(f2fs_cp_error(sbi))) {
1438 pagevec_release(&pvec); 1446 pagevec_release(&pvec);
1439 return -EIO; 1447 ret = -EIO;
1448 goto out;
1440 } 1449 }
1441 1450
1442 /* 1451 /*
@@ -1487,6 +1496,8 @@ continue_unlock:
1487 1496
1488 if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc)) 1497 if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc))
1489 unlock_page(page); 1498 unlock_page(page);
1499 else
1500 nwritten++;
1490 1501
1491 if (--wbc->nr_to_write == 0) 1502 if (--wbc->nr_to_write == 0)
1492 break; 1503 break;
@@ -1504,7 +1515,10 @@ continue_unlock:
1504 step++; 1515 step++;
1505 goto next_step; 1516 goto next_step;
1506 } 1517 }
1507 return nwritten; 1518out:
1519 if (nwritten)
1520 f2fs_submit_merged_bio(sbi, NODE, WRITE);
1521 return ret;
1508} 1522}
1509 1523
1510int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino) 1524int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)