2018-06-06 02:42:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2009-02-09 07:47:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008, Christoph Hellwig
|
|
|
|
* All Rights Reserved.
|
|
|
|
*/
|
|
|
|
#include "xfs.h"
|
2019-06-29 02:25:35 +00:00
|
|
|
#include "xfs_shared.h"
|
2013-08-12 10:49:26 +00:00
|
|
|
#include "xfs_format.h"
|
2013-10-22 23:50:10 +00:00
|
|
|
#include "xfs_log_format.h"
|
2013-08-12 10:49:32 +00:00
|
|
|
#include "xfs_trans_resv.h"
|
2009-02-09 07:47:34 +00:00
|
|
|
#include "xfs_mount.h"
|
2013-10-22 23:51:50 +00:00
|
|
|
#include "xfs_inode.h"
|
2009-02-09 07:47:34 +00:00
|
|
|
#include "xfs_quota.h"
|
|
|
|
#include "xfs_trans.h"
|
2014-11-19 11:03:59 +00:00
|
|
|
#include "xfs_icache.h"
|
2011-08-12 18:57:55 +00:00
|
|
|
#include "xfs_qm.h"
|
2009-02-09 07:47:34 +00:00
|
|
|
|
|
|
|
|
2024-08-30 22:37:17 +00:00
|
|
|
static int
|
2014-11-19 11:03:59 +00:00
|
|
|
xfs_qm_fill_state(
|
|
|
|
struct qc_type_state *tstate,
|
|
|
|
struct xfs_mount *mp,
|
2024-08-30 22:37:17 +00:00
|
|
|
xfs_dqtype_t type)
|
2009-02-09 07:47:34 +00:00
|
|
|
{
|
2024-08-30 22:37:17 +00:00
|
|
|
struct xfs_inode *ip;
|
|
|
|
struct xfs_def_quota *defq;
|
|
|
|
int error;
|
2014-11-19 11:03:59 +00:00
|
|
|
|
2024-08-30 22:37:17 +00:00
|
|
|
error = xfs_qm_qino_load(mp, type, &ip);
|
|
|
|
if (error) {
|
|
|
|
tstate->ino = NULLFSINO;
|
|
|
|
return error != -ENOENT ? error : 0;
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
2024-08-30 22:37:17 +00:00
|
|
|
|
|
|
|
defq = xfs_get_defquota(mp->m_quotainfo, type);
|
|
|
|
|
|
|
|
tstate->ino = ip->i_ino;
|
2014-11-19 11:03:59 +00:00
|
|
|
tstate->flags |= QCI_SYSFILE;
|
2021-03-29 18:11:40 +00:00
|
|
|
tstate->blocks = ip->i_nblocks;
|
2020-05-18 17:27:22 +00:00
|
|
|
tstate->nextents = ip->i_df.if_nextents;
|
2020-07-14 17:37:32 +00:00
|
|
|
tstate->spc_timelimit = (u32)defq->blk.time;
|
|
|
|
tstate->ino_timelimit = (u32)defq->ino.time;
|
|
|
|
tstate->rt_spc_timelimit = (u32)defq->rtb.time;
|
2022-05-10 20:27:58 +00:00
|
|
|
tstate->spc_warnlimit = 0;
|
|
|
|
tstate->ino_warnlimit = 0;
|
|
|
|
tstate->rt_spc_warnlimit = 0;
|
2024-08-30 22:37:17 +00:00
|
|
|
xfs_irele(ip);
|
|
|
|
|
|
|
|
return 0;
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
2014-11-19 11:03:59 +00:00
|
|
|
/*
|
|
|
|
* Return quota status information, such as enforcements, quota file inode
|
|
|
|
* numbers etc.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
xfs_fs_get_quota_state(
|
2009-02-09 07:47:34 +00:00
|
|
|
struct super_block *sb,
|
2014-11-19 11:03:59 +00:00
|
|
|
struct qc_state *state)
|
2009-02-09 07:47:34 +00:00
|
|
|
{
|
2024-08-30 22:37:17 +00:00
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
struct xfs_quotainfo *q = mp->m_quotainfo;
|
|
|
|
int error;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2014-11-19 11:03:59 +00:00
|
|
|
memset(state, 0, sizeof(*state));
|
2021-08-06 18:05:37 +00:00
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2014-11-19 11:03:59 +00:00
|
|
|
return 0;
|
|
|
|
state->s_incoredqs = q->qi_dquots;
|
2021-08-06 18:05:37 +00:00
|
|
|
if (XFS_IS_UQUOTA_ON(mp))
|
2014-11-19 11:03:59 +00:00
|
|
|
state->s_state[USRQUOTA].flags |= QCI_ACCT_ENABLED;
|
|
|
|
if (XFS_IS_UQUOTA_ENFORCED(mp))
|
|
|
|
state->s_state[USRQUOTA].flags |= QCI_LIMITS_ENFORCED;
|
2021-08-06 18:05:37 +00:00
|
|
|
if (XFS_IS_GQUOTA_ON(mp))
|
2014-11-19 11:03:59 +00:00
|
|
|
state->s_state[GRPQUOTA].flags |= QCI_ACCT_ENABLED;
|
|
|
|
if (XFS_IS_GQUOTA_ENFORCED(mp))
|
|
|
|
state->s_state[GRPQUOTA].flags |= QCI_LIMITS_ENFORCED;
|
2021-08-06 18:05:37 +00:00
|
|
|
if (XFS_IS_PQUOTA_ON(mp))
|
2014-11-19 11:03:59 +00:00
|
|
|
state->s_state[PRJQUOTA].flags |= QCI_ACCT_ENABLED;
|
|
|
|
if (XFS_IS_PQUOTA_ENFORCED(mp))
|
|
|
|
state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;
|
|
|
|
|
2024-08-30 22:37:17 +00:00
|
|
|
error = xfs_qm_fill_state(&state->s_state[USRQUOTA], mp,
|
|
|
|
XFS_DQTYPE_USER);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
error = xfs_qm_fill_state(&state->s_state[GRPQUOTA], mp,
|
|
|
|
XFS_DQTYPE_GROUP);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
error = xfs_qm_fill_state(&state->s_state[PRJQUOTA], mp,
|
|
|
|
XFS_DQTYPE_PROJ);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2014-11-19 11:03:59 +00:00
|
|
|
return 0;
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 00:53:43 +00:00
|
|
|
STATIC xfs_dqtype_t
|
2014-11-19 11:03:59 +00:00
|
|
|
xfs_quota_type(int type)
|
2013-08-06 22:27:08 +00:00
|
|
|
{
|
2014-11-19 11:03:59 +00:00
|
|
|
switch (type) {
|
|
|
|
case USRQUOTA:
|
2020-07-16 00:42:36 +00:00
|
|
|
return XFS_DQTYPE_USER;
|
2014-11-19 11:03:59 +00:00
|
|
|
case GRPQUOTA:
|
2020-07-16 00:42:36 +00:00
|
|
|
return XFS_DQTYPE_GROUP;
|
2014-11-19 11:03:59 +00:00
|
|
|
default:
|
2020-07-16 00:42:36 +00:00
|
|
|
return XFS_DQTYPE_PROJ;
|
2014-11-19 11:03:59 +00:00
|
|
|
}
|
2013-08-06 22:27:08 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 20:28:00 +00:00
|
|
|
#define XFS_QC_SETINFO_MASK (QC_TIMER_MASK)
|
2014-12-16 12:07:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Adjust quota timers & warnings
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
xfs_fs_set_info(
|
|
|
|
struct super_block *sb,
|
|
|
|
int type,
|
|
|
|
struct qc_info *info)
|
|
|
|
{
|
2020-05-21 20:07:00 +00:00
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
struct qc_dqblk newlim;
|
2014-12-16 12:07:45 +00:00
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
2014-12-16 12:07:45 +00:00
|
|
|
return -EROFS;
|
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2021-08-06 18:05:37 +00:00
|
|
|
return -ENOSYS;
|
2014-12-16 12:07:45 +00:00
|
|
|
if (info->i_fieldmask & ~XFS_QC_SETINFO_MASK)
|
|
|
|
return -EINVAL;
|
|
|
|
if ((info->i_fieldmask & XFS_QC_SETINFO_MASK) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
newlim.d_fieldmask = info->i_fieldmask;
|
|
|
|
newlim.d_spc_timer = info->i_spc_timelimit;
|
|
|
|
newlim.d_ino_timer = info->i_ino_timelimit;
|
|
|
|
newlim.d_rt_spc_timer = info->i_rt_spc_timelimit;
|
|
|
|
newlim.d_ino_warns = info->i_ino_warnlimit;
|
|
|
|
newlim.d_spc_warns = info->i_spc_warnlimit;
|
|
|
|
newlim.d_rt_spc_warns = info->i_rt_spc_warnlimit;
|
|
|
|
|
|
|
|
return xfs_qm_scall_setqlim(mp, 0, xfs_quota_type(type), &newlim);
|
|
|
|
}
|
|
|
|
|
2014-10-08 13:56:21 +00:00
|
|
|
static unsigned int
|
|
|
|
xfs_quota_flags(unsigned int uflags)
|
2009-02-09 07:47:34 +00:00
|
|
|
{
|
2014-10-08 13:56:21 +00:00
|
|
|
unsigned int flags = 0;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2010-06-04 08:56:01 +00:00
|
|
|
if (uflags & FS_QUOTA_UDQ_ACCT)
|
2009-02-09 07:47:34 +00:00
|
|
|
flags |= XFS_UQUOTA_ACCT;
|
2010-06-04 08:56:01 +00:00
|
|
|
if (uflags & FS_QUOTA_PDQ_ACCT)
|
2009-02-09 07:47:34 +00:00
|
|
|
flags |= XFS_PQUOTA_ACCT;
|
2010-06-04 08:56:01 +00:00
|
|
|
if (uflags & FS_QUOTA_GDQ_ACCT)
|
2009-02-09 07:47:34 +00:00
|
|
|
flags |= XFS_GQUOTA_ACCT;
|
2010-06-04 08:56:01 +00:00
|
|
|
if (uflags & FS_QUOTA_UDQ_ENFD)
|
2009-02-09 07:47:34 +00:00
|
|
|
flags |= XFS_UQUOTA_ENFD;
|
2013-06-27 22:25:10 +00:00
|
|
|
if (uflags & FS_QUOTA_GDQ_ENFD)
|
|
|
|
flags |= XFS_GQUOTA_ENFD;
|
|
|
|
if (uflags & FS_QUOTA_PDQ_ENFD)
|
|
|
|
flags |= XFS_PQUOTA_ENFD;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2014-10-08 13:56:21 +00:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC int
|
|
|
|
xfs_quota_enable(
|
|
|
|
struct super_block *sb,
|
|
|
|
unsigned int uflags)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
2014-10-08 13:56:21 +00:00
|
|
|
return -EROFS;
|
2021-08-06 18:05:37 +00:00
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2014-10-08 13:56:21 +00:00
|
|
|
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);
|
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
2014-10-08 13:56:21 +00:00
|
|
|
return -EROFS;
|
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2021-08-06 18:05:37 +00:00
|
|
|
return -ENOSYS;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2014-10-08 13:56:21 +00:00
|
|
|
return xfs_qm_scall_quotaoff(mp, xfs_quota_flags(uflags));
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
STATIC int
|
|
|
|
xfs_fs_rm_xquota(
|
|
|
|
struct super_block *sb,
|
|
|
|
unsigned int uflags)
|
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
unsigned int flags = 0;
|
2014-06-25 04:58:08 +00:00
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
return -EROFS;
|
|
|
|
|
|
|
|
if (XFS_IS_QUOTA_ON(mp))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-10-24 00:00:45 +00:00
|
|
|
if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA))
|
|
|
|
return -EINVAL;
|
|
|
|
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
if (uflags & FS_USER_QUOTA)
|
2020-07-14 17:36:09 +00:00
|
|
|
flags |= XFS_QMOPT_UQUOTA;
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
if (uflags & FS_GROUP_QUOTA)
|
2020-07-14 17:36:09 +00:00
|
|
|
flags |= XFS_QMOPT_GQUOTA;
|
2014-07-24 11:27:17 +00:00
|
|
|
if (uflags & FS_PROJ_QUOTA)
|
2020-07-14 17:36:09 +00:00
|
|
|
flags |= XFS_QMOPT_PQUOTA;
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
|
2014-06-25 04:58:08 +00:00
|
|
|
return xfs_qm_scall_trunc_qfiles(mp, flags);
|
|
|
|
}
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
|
2009-02-09 07:47:34 +00:00
|
|
|
STATIC int
|
2010-05-06 21:04:58 +00:00
|
|
|
xfs_fs_get_dqblk(
|
2009-02-09 07:47:34 +00:00
|
|
|
struct super_block *sb,
|
2012-09-16 09:07:49 +00:00
|
|
|
struct kqid qid,
|
2014-10-09 14:03:13 +00:00
|
|
|
struct qc_dqblk *qdq)
|
2009-02-09 07:47:34 +00:00
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
2016-02-08 00:27:38 +00:00
|
|
|
xfs_dqid_t id;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2021-08-06 18:05:37 +00:00
|
|
|
return -ENOSYS;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2016-02-08 00:27:38 +00:00
|
|
|
id = from_kqid(&init_user_ns, qid);
|
2018-05-04 22:30:20 +00:00
|
|
|
return xfs_qm_scall_getquota(mp, id, xfs_quota_type(qid.type), qdq);
|
2016-02-08 00:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return quota info for active quota >= this qid */
|
|
|
|
STATIC int
|
|
|
|
xfs_fs_get_nextdqblk(
|
|
|
|
struct super_block *sb,
|
|
|
|
struct kqid *qid,
|
|
|
|
struct qc_dqblk *qdq)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
xfs_dqid_t id;
|
|
|
|
|
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2021-08-06 18:05:37 +00:00
|
|
|
return -ENOSYS;
|
2016-02-08 00:27:38 +00:00
|
|
|
|
|
|
|
id = from_kqid(&init_user_ns, *qid);
|
2018-05-04 22:30:20 +00:00
|
|
|
ret = xfs_qm_scall_getquota_next(mp, &id, xfs_quota_type(qid->type),
|
|
|
|
qdq);
|
2016-02-08 00:27:38 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ID may be different, so convert back what we got */
|
|
|
|
*qid = make_kqid(current_user_ns(), qid->type, id);
|
|
|
|
return 0;
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STATIC int
|
2010-05-06 21:05:17 +00:00
|
|
|
xfs_fs_set_dqblk(
|
2009-02-09 07:47:34 +00:00
|
|
|
struct super_block *sb,
|
2012-09-16 09:07:49 +00:00
|
|
|
struct kqid qid,
|
2014-10-09 14:03:13 +00:00
|
|
|
struct qc_dqblk *qdq)
|
2009-02-09 07:47:34 +00:00
|
|
|
{
|
|
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
|
2017-07-17 07:45:34 +00:00
|
|
|
if (sb_rdonly(sb))
|
2009-02-09 07:47:34 +00:00
|
|
|
return -EROFS;
|
|
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
2021-08-06 18:05:37 +00:00
|
|
|
return -ENOSYS;
|
2009-02-09 07:47:34 +00:00
|
|
|
|
2014-06-25 04:58:08 +00:00
|
|
|
return xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
|
2014-10-09 14:03:13 +00:00
|
|
|
xfs_quota_type(qid.type), qdq);
|
2009-02-09 07:47:34 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 00:01:09 +00:00
|
|
|
const struct quotactl_ops xfs_quotactl_operations = {
|
2014-11-19 11:03:59 +00:00
|
|
|
.get_state = xfs_fs_get_quota_state,
|
2014-12-16 12:07:45 +00:00
|
|
|
.set_info = xfs_fs_set_info,
|
2014-10-08 13:56:21 +00:00
|
|
|
.quota_enable = xfs_quota_enable,
|
|
|
|
.quota_disable = xfs_quota_disable,
|
xfs: fix Q_XQUOTARM ioctl
The Q_XQUOTARM quotactl was not working properly, because
we weren't passing around proper flags. The xfs_fs_set_xstate()
ioctl handler used the same flags for Q_XQUOTAON/OFF as
well as for Q_XQUOTARM, but Q_XQUOTAON/OFF look for
XFS_UQUOTA_ACCT, XFS_UQUOTA_ENFD, XFS_GQUOTA_ACCT etc,
i.e. quota type + state, while Q_XQUOTARM looks only for
the type of quota, i.e. XFS_DQ_USER, XFS_DQ_GROUP etc.
Unfortunately these flag spaces overlap a bit, so we
got semi-random results for Q_XQUOTARM; i.e. the value
for XFS_DQ_USER == XFS_UQUOTA_ACCT, etc. yeargh.
Add a new quotactl op vector specifically for the QUOTARM
operation, since it operates with a different flag space.
This has been broken more or less forever, AFAICT.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-05-05 07:25:50 +00:00
|
|
|
.rm_xquota = xfs_fs_rm_xquota,
|
2010-05-06 21:04:58 +00:00
|
|
|
.get_dqblk = xfs_fs_get_dqblk,
|
2016-02-08 00:27:38 +00:00
|
|
|
.get_nextdqblk = xfs_fs_get_nextdqblk,
|
2010-05-06 21:05:17 +00:00
|
|
|
.set_dqblk = xfs_fs_set_dqblk,
|
2009-02-09 07:47:34 +00:00
|
|
|
};
|