]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: fix writecount false positive in releasing compress blocks
authorDaeho Jeong <daehojeong@google.com>
Mon, 12 Oct 2020 04:59:47 +0000 (13:59 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 14 Oct 2020 06:23:34 +0000 (23:23 -0700)
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>
fs/f2fs/file.c

index 62efbf1b2b62c56d076b85cbf50c66ce8e7ff0d7..7ceb6e30fc8c2584ab1f85b708a3e16337cde7b5 100644 (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;
        }