Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 87f9d26

Browse files
YeongjinGilgregkh
authored andcommitted
f2fs: Create COW inode from parent dentry for atomic write
[ Upstream commit 8c1b787 ] The i_pino in f2fs_inode_info has the previous parent's i_ino when inode was renamed, which may cause f2fs_ioc_start_atomic_write to fail. If file_wrong_pino is true and i_nlink is 1, then to find a valid pino, we should refer to the dentry from inode. To resolve this issue, let's get parent inode using parent dentry directly. Fixes: 3db1de0 ("f2fs: change the current atomic write way") Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com> Reviewed-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 67c3c46 commit 87f9d26

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

fs/f2fs/file.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
20972097
struct mnt_idmap *idmap = file_mnt_idmap(filp);
20982098
struct f2fs_inode_info *fi = F2FS_I(inode);
20992099
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
2100-
struct inode *pinode;
21012100
loff_t isize;
21022101
int ret;
21032102

@@ -2146,15 +2145,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
21462145
/* Check if the inode already has a COW inode */
21472146
if (fi->cow_inode == NULL) {
21482147
/* Create a COW inode for atomic write */
2149-
pinode = f2fs_iget(inode->i_sb, fi->i_pino);
2150-
if (IS_ERR(pinode)) {
2151-
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2152-
ret = PTR_ERR(pinode);
2153-
goto out;
2154-
}
2148+
struct dentry *dentry = file_dentry(filp);
2149+
struct inode *dir = d_inode(dentry->d_parent);
21552150

2156-
ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
2157-
iput(pinode);
2151+
ret = f2fs_get_tmpfile(idmap, dir, &fi->cow_inode);
21582152
if (ret) {
21592153
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
21602154
goto out;

0 commit comments

Comments
 (0)