Commit ac1ee161 authored by Sheng Yong's avatar Sheng Yong Committed by Jaegeuk Kim

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: default avatarSheng Yong <shengyong@oppo.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent dde38c03
...@@ -3377,18 +3377,29 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg) ...@@ -3377,18 +3377,29 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg)
return err; 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))) if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (!f2fs_compressed_file(inode)) if (!f2fs_compressed_file(inode))
return -EINVAL; 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); return put_user(blocks, (u64 __user *)arg);
} }
...@@ -4240,7 +4251,7 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -4240,7 +4251,7 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case FS_IOC_SETFSLABEL: case FS_IOC_SETFSLABEL:
return f2fs_ioc_setfslabel(filp, arg); return f2fs_ioc_setfslabel(filp, arg);
case F2FS_IOC_GET_COMPRESS_BLOCKS: 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: case F2FS_IOC_RELEASE_COMPRESS_BLOCKS:
return f2fs_release_compress_blocks(filp, arg); return f2fs_release_compress_blocks(filp, arg);
case F2FS_IOC_RESERVE_COMPRESS_BLOCKS: case F2FS_IOC_RESERVE_COMPRESS_BLOCKS:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment