Skip to contentSkip to conversation

f2fs: don't drop dentry pages after fs shutdown

PATCH New Chao Yu 1 participant 2 messages May 28, 2018 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/2 f2fs: don't drop dentry pages after fs shutdown

As description in commit "f2fs: don't drop any page on f2fs_cp_error() case":

"We still provide readdir() after shtudown, so we should keep pages to avoid additional IOs."

In order to provider lastest directory structure, let's keep dentry pages in cache after fs shutdown.

---
 fs/f2fs/data.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/data.c +6 -0
index 9d3e2e1c1e33..31c2edb217ec 100644
@@ -1801,6 +1801,12 @@ static int __write_data_page(struct page *page, bool *submitted,
 	/* we should bypass data pages to proceed the kworkder jobs */
 	if (unlikely(f2fs_cp_error(sbi))) {
 		mapping_set_error(page->mapping, -EIO);
+		/*
+		 * don't drop any dirty dentry pages for keeping lastest
+		 * directory structure.
+		 */
+		if (S_ISDIR(inode->i_mode))
+			goto redirty_out;
 		goto out;
 	}
 
Signature · 1 line
2.17.0.391.g1f1cddd558b5
author
#1 lore raw

PATCH 2/2 f2fs: fix error path of move_data_page

This patch fixes error path of move_data_page:
- clear cold data flag if it fails to write page.
- redirty page for non-ENOMEM case.

---
 fs/f2fs/gc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
fs/f2fs/gc.c +8 -3
index 50bb8fc25275..885032fc3a61 100644
@@ -780,9 +780,14 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
 		set_cold_data(page);
 
 		err = do_write_data_page(&fio);
-		if (err == -ENOMEM && is_dirty) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			goto retry;
+		if (err) {
+			clear_cold_data(page);
+			if (err == -ENOMEM) {
+				congestion_wait(BLK_RW_ASYNC, HZ/50);
+				goto retry;
+			}
+			if (is_dirty)
+				set_page_dirty(page);
 		}
 	}
 out:
Signature · 1 line
2.17.0.391.g1f1cddd558b5