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>
This commit is contained in:
Eric Biggers 2020-05-05 11:41:11 -07:00 коммит произвёл Jaegeuk Kim
Родитель 43c780ba26
Коммит 84c9c2de06
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -169,9 +169,11 @@ static int get_parent_ino(struct inode *inode, nid_t *pino)
{ {
struct dentry *dentry; struct dentry *dentry;
inode = igrab(inode); /*
dentry = d_find_any_alias(inode); * Make sure to get the non-deleted alias. The alias associated with
iput(inode); * the open file descriptor being fsync()'ed may be deleted already.
*/
dentry = d_find_alias(inode);
if (!dentry) if (!dentry)
return 0; return 0;