quota: Split ->set_xstate callback into two
Split ->set_xstate callback into two callbacks - one for turning quotas on (->quota_enable) and one for turning quotas off (->quota_disable). That way we don't have to pass quotactl command into the callback which seems cleaner. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
@@ -64,19 +64,10 @@ xfs_fs_get_xstatev(
|
||||
return xfs_qm_scall_getqstatv(mp, fqs);
|
||||
}
|
||||
|
||||
STATIC int
|
||||
xfs_fs_set_xstate(
|
||||
struct super_block *sb,
|
||||
unsigned int uflags,
|
||||
int op)
|
||||
static unsigned int
|
||||
xfs_quota_flags(unsigned int uflags)
|
||||
{
|
||||
struct xfs_mount *mp = XFS_M(sb);
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
if (!XFS_IS_QUOTA_RUNNING(mp))
|
||||
return -ENOSYS;
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (uflags & FS_QUOTA_UDQ_ACCT)
|
||||
flags |= XFS_UQUOTA_ACCT;
|
||||
@@ -91,16 +82,39 @@ xfs_fs_set_xstate(
|
||||
if (uflags & FS_QUOTA_PDQ_ENFD)
|
||||
flags |= XFS_PQUOTA_ENFD;
|
||||
|
||||
switch (op) {
|
||||
case Q_XQUOTAON:
|
||||
return xfs_qm_scall_quotaon(mp, flags);
|
||||
case Q_XQUOTAOFF:
|
||||
if (!XFS_IS_QUOTA_ON(mp))
|
||||
return -EINVAL;
|
||||
return xfs_qm_scall_quotaoff(mp, flags);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
STATIC int
|
||||
xfs_quota_enable(
|
||||
struct super_block *sb,
|
||||
unsigned int uflags)
|
||||
{
|
||||
struct xfs_mount *mp = XFS_M(sb);
|
||||
|
||||
if (sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
if (!XFS_IS_QUOTA_RUNNING(mp))
|
||||
return -ENOSYS;
|
||||
|
||||
return xfs_qm_scall_quotaon(mp, xfs_quota_flags(uflags));
|
||||
}
|
||||
|
||||
STATIC int
|
||||
xfs_quota_disable(
|
||||
struct super_block *sb,
|
||||
unsigned int uflags)
|
||||
{
|
||||
struct xfs_mount *mp = XFS_M(sb);
|
||||
|
||||
if (sb->s_flags & MS_RDONLY)
|
||||
return -EROFS;
|
||||
if (!XFS_IS_QUOTA_RUNNING(mp))
|
||||
return -ENOSYS;
|
||||
if (!XFS_IS_QUOTA_ON(mp))
|
||||
return -EINVAL;
|
||||
|
||||
return xfs_qm_scall_quotaoff(mp, xfs_quota_flags(uflags));
|
||||
}
|
||||
|
||||
STATIC int
|
||||
@@ -166,7 +180,8 @@ xfs_fs_set_dqblk(
|
||||
const struct quotactl_ops xfs_quotactl_operations = {
|
||||
.get_xstatev = xfs_fs_get_xstatev,
|
||||
.get_xstate = xfs_fs_get_xstate,
|
||||
.set_xstate = xfs_fs_set_xstate,
|
||||
.quota_enable = xfs_quota_enable,
|
||||
.quota_disable = xfs_quota_disable,
|
||||
.rm_xquota = xfs_fs_rm_xquota,
|
||||
.get_dqblk = xfs_fs_get_dqblk,
|
||||
.set_dqblk = xfs_fs_set_dqblk,
|
||||
|
||||
Reference in New Issue
Block a user