diff options
author | Eric Biggers <ebiggers@google.com> | 2020-05-05 21:41:11 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-05-12 06:36:46 +0300 |
commit | 84c9c2de0626567c0d964ee5fa1ae3310911ddf8 (patch) | |
tree | 27e4f37bc61b46f10ceb404683814307025364f4 /fs/f2fs/file.c | |
parent | 43c780ba26244e4caf3f9986beb6c4ae5eb54f50 (diff) | |
download | linux-84c9c2de0626567c0d964ee5fa1ae3310911ddf8.tar.xz |
f2fs: correctly fix the parent inode number during fsync()
fsync() may be called on a deleted file that's still open. So when
fsync() tries to set the parent inode number when the inode has
LOST_PINO and i_nlink == 1 (to avoid later checkpoints), it needs to
make sure to get the parent directory via a non-deleted alias.
Also remove the unnecessary igrab() and iput(), as the caller already
holds a reference to the inode.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 175c66190087..81bfc5b44fa1 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -169,9 +169,11 @@ static int get_parent_ino(struct inode *inode, nid_t *pino) { struct dentry *dentry; - inode = igrab(inode); - dentry = d_find_any_alias(inode); - iput(inode); + /* + * Make sure to get the non-deleted alias. The alias associated with + * the open file descriptor being fsync()'ed may be deleted already. + */ + dentry = d_find_alias(inode); if (!dentry) return 0; |