f2fs: fix writecount false positive in releasing compress blocks

In current condition check, if it detects writecount, it return -EBUSY
regardless of f_mode of the file. Fixed it.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Daeho Jeong 2020-10-12 13:59:47 +09:00 committed by Jaegeuk Kim
parent af4b6b8edf
commit 8c8cf26ae3
1 changed files with 2 additions and 1 deletions

View File

@ -3511,7 +3511,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
inode_lock(inode);
writecount = atomic_read(&inode->i_writecount);
if ((filp->f_mode & FMODE_WRITE && writecount != 1) || writecount) {
if ((filp->f_mode & FMODE_WRITE && writecount != 1) ||
(!(filp->f_mode & FMODE_WRITE) && writecount)) {
ret = -EBUSY;
goto out;
}