f2fs: enforce fsync_mode=strict for renamed directory
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 25 Apr 2018 04:43:01 +0000 (22:43 -0600)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 31 May 2018 18:31:48 +0000 (11:31 -0700)
This is to give a option for user to be able to recover B/foo in the below
case.

mkdir A
sync()
rename(A, B)
creat (B/foo)
fsync (B/foo)
---crash---

Sugessted-by: Velayudhan Pillai <vijay@cs.utexas.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/namei.c

index b5f404674cadd27ab65aabab8a874fad5dc2b6c2..fef6e3ab213566ffaeb1908b8fa16de6d21f75ff 100644 (file)
@@ -973,8 +973,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        f2fs_put_page(old_dir_page, 0);
                f2fs_i_links_write(old_dir, false);
        }
-       if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
+       if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) {
                add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO);
+               if (S_ISDIR(old_inode->i_mode))
+                       add_ino_entry(sbi, old_inode->i_ino, TRANS_DIR_INO);
+       }
 
        f2fs_unlock_op(sbi);