Commit ca597bdd authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to dirty inode for i_mode recovery

As Seulbae Kim reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=202637

We didn't recover permission field correctly after sudden power-cut,
the reason is in setattr we didn't add inode into global dirty list
once i_mode is changed, so latter checkpoint triggered by fsync will
not flush last i_mode into disk, result in this problem, fix it.
Reported-by: default avatarSeulbae Kim <seulbae@gatech.edu>
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 428e3bcf
...@@ -766,7 +766,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -766,7 +766,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
int err; int err;
bool size_changed = false;
if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
return -EIO; return -EIO;
...@@ -841,8 +840,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -841,8 +840,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
down_write(&F2FS_I(inode)->i_sem); down_write(&F2FS_I(inode)->i_sem);
F2FS_I(inode)->last_disk_size = i_size_read(inode); F2FS_I(inode)->last_disk_size = i_size_read(inode);
up_write(&F2FS_I(inode)->i_sem); up_write(&F2FS_I(inode)->i_sem);
size_changed = true;
} }
__setattr_copy(inode, attr); __setattr_copy(inode, attr);
...@@ -856,7 +853,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -856,7 +853,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
} }
/* file size may changed here */ /* file size may changed here */
f2fs_mark_inode_dirty_sync(inode, size_changed); f2fs_mark_inode_dirty_sync(inode, true);
/* inode change will produce dirty node pages flushed by checkpoint */ /* inode change will produce dirty node pages flushed by checkpoint */
f2fs_balance_fs(F2FS_I_SB(inode), true); f2fs_balance_fs(F2FS_I_SB(inode), true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment