summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorSheng Yong <shengyong@oppo.com>2023-06-12 11:01:19 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2023-06-26 06:07:10 -0700
commitac1ee161dec5801d9bbd874ef69cd0ff1e8053b6 (patch)
treef9f1b8f7f2f54808ba13d28d0cffe26e2beda272 /fs/f2fs/file.c
parentdde38c03b351749f682db087df5202b55c7c1b40 (diff)
downloadlinux-stable-ac1ee161dec5801d9bbd874ef69cd0ff1e8053b6.tar.gz
linux-stable-ac1ee161dec5801d9bbd874ef69cd0ff1e8053b6.tar.bz2
linux-stable-ac1ee161dec5801d9bbd874ef69cd0ff1e8053b6.zip
f2fs: add f2fs_ioc_get_compress_blocks
This patch adds f2fs_ioc_get_compress_blocks() to provide a common f2fs_get_compress_blocks(). Signed-off-by: Sheng Yong <shengyong@oppo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b8a6267d9800..95b92a6ca19f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3377,18 +3377,29 @@ out:
return err;
}
-static int f2fs_get_compress_blocks(struct file *filp, unsigned long arg)
+static int f2fs_get_compress_blocks(struct inode *inode, __u64 *blocks)
{
- struct inode *inode = file_inode(filp);
- __u64 blocks;
-
if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
return -EOPNOTSUPP;
if (!f2fs_compressed_file(inode))
return -EINVAL;
- blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks);
+ *blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks);
+
+ return 0;
+}
+
+static int f2fs_ioc_get_compress_blocks(struct file *filp, unsigned long arg)
+{
+ struct inode *inode = file_inode(filp);
+ __u64 blocks;
+ int ret;
+
+ ret = f2fs_get_compress_blocks(inode, &blocks);
+ if (ret < 0)
+ return ret;
+
return put_user(blocks, (u64 __user *)arg);
}
@@ -4240,7 +4251,7 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case FS_IOC_SETFSLABEL:
return f2fs_ioc_setfslabel(filp, arg);
case F2FS_IOC_GET_COMPRESS_BLOCKS:
- return f2fs_get_compress_blocks(filp, arg);
+ return f2fs_ioc_get_compress_blocks(filp, arg);
case F2FS_IOC_RELEASE_COMPRESS_BLOCKS:
return f2fs_release_compress_blocks(filp, arg);
case F2FS_IOC_RESERVE_COMPRESS_BLOCKS: