Skip to content

Commit ac1ee16

Browse files
Sheng YongJaegeuk Kim
authored andcommitted
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>
1 parent dde38c0 commit ac1ee16

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

fs/f2fs/file.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,18 +3377,29 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg)
33773377
return err;
33783378
}
33793379

3380-
static int f2fs_get_compress_blocks(struct file *filp, unsigned long arg)
3380+
static int f2fs_get_compress_blocks(struct inode *inode, __u64 *blocks)
33813381
{
3382-
struct inode *inode = file_inode(filp);
3383-
__u64 blocks;
3384-
33853382
if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
33863383
return -EOPNOTSUPP;
33873384

33883385
if (!f2fs_compressed_file(inode))
33893386
return -EINVAL;
33903387

3391-
blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks);
3388+
*blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks);
3389+
3390+
return 0;
3391+
}
3392+
3393+
static int f2fs_ioc_get_compress_blocks(struct file *filp, unsigned long arg)
3394+
{
3395+
struct inode *inode = file_inode(filp);
3396+
__u64 blocks;
3397+
int ret;
3398+
3399+
ret = f2fs_get_compress_blocks(inode, &blocks);
3400+
if (ret < 0)
3401+
return ret;
3402+
33923403
return put_user(blocks, (u64 __user *)arg);
33933404
}
33943405

@@ -4240,7 +4251,7 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42404251
case FS_IOC_SETFSLABEL:
42414252
return f2fs_ioc_setfslabel(filp, arg);
42424253
case F2FS_IOC_GET_COMPRESS_BLOCKS:
4243-
return f2fs_get_compress_blocks(filp, arg);
4254+
return f2fs_ioc_get_compress_blocks(filp, arg);
42444255
case F2FS_IOC_RELEASE_COMPRESS_BLOCKS:
42454256
return f2fs_release_compress_blocks(filp, arg);
42464257
case F2FS_IOC_RESERVE_COMPRESS_BLOCKS:

0 commit comments

Comments
 (0)