Commit c2c2620d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: clean up the XFS_IOC_FSCOUNTS handler

Split XFS_IOC_FSCOUNTS out of the main xfs_file_ioctl function, and
merge the xfs_fs_counts helper into the ioctl handler.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent 64f08b15
...@@ -343,22 +343,6 @@ xfs_growfs_log( ...@@ -343,22 +343,6 @@ xfs_growfs_log(
return error; return error;
} }
/*
* exported through ioctl XFS_IOC_FSCOUNTS
*/
void
xfs_fs_counts(
xfs_mount_t *mp,
xfs_fsop_counts_t *cnt)
{
cnt->allocino = percpu_counter_read_positive(&mp->m_icount);
cnt->freeino = percpu_counter_read_positive(&mp->m_ifree);
cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) -
xfs_fdblocks_unavailable(mp);
cnt->freertx = percpu_counter_read_positive(&mp->m_frextents);
}
/* /*
* exported through ioctl XFS_IOC_SET_RESBLKS & XFS_IOC_GET_RESBLKS * exported through ioctl XFS_IOC_SET_RESBLKS & XFS_IOC_GET_RESBLKS
* *
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
extern int xfs_growfs_data(struct xfs_mount *mp, struct xfs_growfs_data *in); extern int xfs_growfs_data(struct xfs_mount *mp, struct xfs_growfs_data *in);
extern int xfs_growfs_log(struct xfs_mount *mp, struct xfs_growfs_log *in); extern int xfs_growfs_log(struct xfs_mount *mp, struct xfs_growfs_log *in);
extern void xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
extern int xfs_reserve_blocks(xfs_mount_t *mp, uint64_t *inval, extern int xfs_reserve_blocks(xfs_mount_t *mp, uint64_t *inval,
xfs_fsop_resblks_t *outval); xfs_fsop_resblks_t *outval);
extern int xfs_fs_goingdown(xfs_mount_t *mp, uint32_t inflags); extern int xfs_fs_goingdown(xfs_mount_t *mp, uint32_t inflags);
......
...@@ -1912,6 +1912,24 @@ xfs_ioctl_getset_resblocks( ...@@ -1912,6 +1912,24 @@ xfs_ioctl_getset_resblocks(
return 0; return 0;
} }
static int
xfs_ioctl_fs_counts(
struct xfs_mount *mp,
struct xfs_fsop_counts __user *uarg)
{
struct xfs_fsop_counts out = {
.allocino = percpu_counter_read_positive(&mp->m_icount),
.freeino = percpu_counter_read_positive(&mp->m_ifree),
.freedata = percpu_counter_read_positive(&mp->m_fdblocks) -
xfs_fdblocks_unavailable(mp),
.freertx = percpu_counter_read_positive(&mp->m_frextents),
};
if (copy_to_user(uarg, &out, sizeof(out)))
return -EFAULT;
return 0;
}
/* /*
* These long-unused ioctls were removed from the official ioctl API in 5.17, * These long-unused ioctls were removed from the official ioctl API in 5.17,
* but retain these definitions so that we can log warnings about them. * but retain these definitions so that we can log warnings about them.
...@@ -2048,15 +2066,8 @@ xfs_file_ioctl( ...@@ -2048,15 +2066,8 @@ xfs_file_ioctl(
return error; return error;
} }
case XFS_IOC_FSCOUNTS: { case XFS_IOC_FSCOUNTS:
xfs_fsop_counts_t out; return xfs_ioctl_fs_counts(mp, arg);
xfs_fs_counts(mp, &out);
if (copy_to_user(arg, &out, sizeof(out)))
return -EFAULT;
return 0;
}
case XFS_IOC_SET_RESBLKS: case XFS_IOC_SET_RESBLKS:
case XFS_IOC_GET_RESBLKS: case XFS_IOC_GET_RESBLKS:
......
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