aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjin Gil <[email protected]>2024-08-13 16:32:44 +0900
committerJaegeuk Kim <[email protected]>2024-08-21 00:56:27 +0000
commit8c1b787938fd86bab27a1492fa887408c75fec2b (patch)
treef3476141dc69e05fca1032a13c1d1c55b70254a2
parent4f5a100f87f32cb65d4bb1ad282a08c92f6f591e (diff)
f2fs: Create COW inode from parent dentry for atomic write
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: 3db1de0e582c ("f2fs: change the current atomic write way") Reviewed-by: Sungjong Seo <[email protected]> Reviewed-by: Sunmin Jeong <[email protected]> Signed-off-by: Yeongjin Gil <[email protected]> Reviewed-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
-rw-r--r--fs/f2fs/file.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 2c591fbc75a9..082e81ba09b9 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2127,7 +2127,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
struct mnt_idmap *idmap = file_mnt_idmap(filp);
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
- struct inode *pinode;
loff_t isize;
int ret;
@@ -2180,15 +2179,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
/* Check if the inode already has a COW inode */
if (fi->cow_inode == NULL) {
/* Create a COW inode for atomic write */
- pinode = f2fs_iget(inode->i_sb, fi->i_pino);
- if (IS_ERR(pinode)) {
- f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
- ret = PTR_ERR(pinode);
- goto out;
- }
+ struct dentry *dentry = file_dentry(filp);
+ struct inode *dir = d_inode(dentry->d_parent);
- ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
- iput(pinode);
+ ret = f2fs_get_tmpfile(idmap, dir, &fi->cow_inode);
if (ret) {
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
goto out;