Skip to contentSkip to conversation

f2fs: update inode page under cp_rwsem lock

PATCH Superseded Chao Yu 1 participant 1 message Feb 25, 2016 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 2/2 f2fs: update inode page under cp_rwsem lock

We should update inode page under protection of cp_rwsem lock, otherwise new dirty inode pages will generated by ->fsync or ->write_inode during checkpoint, which should not be allowed.

---
 fs/f2fs/inode.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +6 -1
index cb269c4..cdfe114 100644
@@ -295,6 +295,7 @@ retry:
 int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+	bool updated;
 
 	if (inode->i_ino == F2FS_NODE_INO(sbi) ||
 			inode->i_ino == F2FS_META_INO(sbi))
@@ -307,7 +308,11 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
 	 * We need to balance fs here to prevent from producing dirty node pages
 	 * during the urgent cleaning time when runing out of free sections.
 	 */
-	if (update_inode_page(inode))
+	f2fs_lock_op(sbi);
+	updated = update_inode_page(inode);
+	f2fs_unlock_op(sbi);
+
+	if (updated)
 		f2fs_balance_fs(sbi, true);
 	return 0;
 }
Signature · 1 line
2.7.0