f2fs: fix potential deadlock due to unpaired node_write lock use
authorChao Yu <chao@kernel.org>
Sun, 14 May 2023 08:07:23 +0000 (16:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:21:55 +0000 (16:21 +0200)
commit15c073e752d22934b9763016679cbe2850020d6a
tree76b332747155757690d8607391ba53412a0d464b
parent2e980eb9550d01d8d86b7bb29ab16a12fc57c6fa
f2fs: fix potential deadlock due to unpaired node_write lock use

[ Upstream commit f082c6b205a06953f26c40bdc7621cc5a58ceb7c ]

If S_NOQUOTA is cleared from inode during data page writeback of quota
file, it may miss to unlock node_write lock, result in potential
deadlock, fix to use the lock in paired.

Kworker Thread
- writepage
 if (IS_NOQUOTA())
   f2fs_down_read(&sbi->node_write);
- vfs_cleanup_quota_inode
 - inode->i_flags &= ~S_NOQUOTA;
 if (IS_NOQUOTA())
   f2fs_up_read(&sbi->node_write);

Fixes: 79963d967b49 ("f2fs: shrink node_write lock coverage")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/compress.c
fs/f2fs/data.c