]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
f2fs: fix lost xattrs of directories
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 30 Aug 2016 01:23:45 +0000 (18:23 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 8 Sep 2016 00:27:39 +0000 (17:27 -0700)
This patch enhances the xattr consistency of dirs from suddern power-cuts.

Possible scenario would be:
1. dir->setxattr used by per-file encryption
2. file->setxattr goes into inline_xattr
3. file->fsync

In that case, we should do checkpoint for #1.
Otherwise we'd lose dir's key information for the file given #2.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/xattr.c

index 64a685d5c11b8fc787d0c19b1f4ecaa706fddb5f..727e97edf7580ff5eb359927af3b6fa39756e171 100644 (file)
@@ -1152,6 +1152,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        clear_prefree_segments(sbi, cpc);
        clear_sbi_flag(sbi, SBI_IS_DIRTY);
+       clear_sbi_flag(sbi, SBI_NEED_CP);
 
        return 0;
 }
index c2478a19bfaa45291dc82732a2d50cdf021cbe37..b9611d4cb49ce0df6a61714aae338d9b521b1bed 100644 (file)
@@ -756,6 +756,7 @@ enum {
        SBI_NEED_FSCK,                          /* need fsck.f2fs to fix */
        SBI_POR_DOING,                          /* recovery is doing or not */
        SBI_NEED_SB_WRITE,                      /* need to recover superblock */
+       SBI_NEED_CP,                            /* need to checkpoint */
 };
 
 enum {
index 7c6ee7ec88f2d058a044b785b7cfa409f0f9ec8f..21aa99b220d7f82ea7a9f23d442baa85bf10a35a 100644 (file)
@@ -135,6 +135,8 @@ static inline bool need_do_checkpoint(struct inode *inode)
 
        if (!S_ISREG(inode->i_mode) || inode->i_nlink != 1)
                need_cp = true;
+       else if (is_sbi_flag_set(sbi, SBI_NEED_CP))
+               need_cp = true;
        else if (file_enc_name(inode) && need_dentry_mark(sbi, inode->i_ino))
                need_cp = true;
        else if (file_wrong_pino(inode))
index c8898b5148eb62134db2467d579d5401f8efdcfd..d39a7923de423bdf5f599851566f24e54302e011 100644 (file)
@@ -548,6 +548,8 @@ static int __f2fs_setxattr(struct inode *inode, int index,
                        !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT))
                f2fs_set_encrypted_inode(inode);
        f2fs_mark_inode_dirty_sync(inode);
+       if (!error && S_ISDIR(inode->i_mode))
+               set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP);
 exit:
        kzfree(base_addr);
        return error;