Skip to contentSkip to conversation

f2fs: fix to clear FI_NO_PREALLOC

PATCH New Chao Yu 1 participant 2 messages Nov 13, 2017 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/2 f2fs: fix to clear FI_NO_PREALLOC

We need to clear FI_NO_PREALLOC flag in error path of f2fs_file_write_iter, otherwise we will lose the chance to preallocate blocks in latter write() at one time.

Fixes dc91de78e5e1 ("f2fs: do not preallocate blocks which has wrong buffer")
---
 fs/f2fs/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/file.c +1 -0
index 8742c028acc6..41a6f1f70416 100644
@@ -2750,6 +2750,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 		err = f2fs_preallocate_blocks(iocb, from);
 		if (err) {
+			clear_inode_flag(inode, FI_NO_PREALLOC);
 			inode_unlock(inode);
 			return err;
 		}
Signature · 6 lines
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
author
#1 lore raw

PATCH 2/2 f2fs: inject fault in inc_valid_node_count

This patch adds missing fault injection in inc_valid_node_count.

---
 fs/f2fs/f2fs.h | 7 +++++++
 1 file changed, 7 insertions(+)
fs/f2fs/f2fs.h +7 -0
index 5c379a8ea075..22b81bbb056f 100644
@@ -1765,6 +1765,13 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
 			return ret;
 	}
 
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+	if (time_to_inject(sbi, FAULT_BLOCK)) {
+		f2fs_show_injection_info(FAULT_BLOCK);
+		goto enospc;
+	}
+#endif
+
 	spin_lock(&sbi->stat_lock);
 
 	valid_block_count = sbi->total_valid_block_count + 1;
Signature · 6 lines
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot