Release 4.10 fs/xfs/xfs_quotaops.c
/*
* Copyright (c) 2008, Christoph Hellwig
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xfs.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_quota.h"
#include "xfs_trans.h"
#include "xfs_trace.h"
#include "xfs_icache.h"
#include "xfs_qm.h"
#include <linux/quota.h>
static void
xfs_qm_fill_state(
struct qc_type_state *tstate,
struct xfs_mount *mp,
struct xfs_inode *ip,
xfs_ino_t ino)
{
struct xfs_quotainfo *q = mp->m_quotainfo;
bool tempqip = false;
tstate->ino = ino;
if (!ip && ino == NULLFSINO)
return;
if (!ip) {
if (xfs_iget(mp, NULL, ino, 0, 0, &ip))
return;
tempqip = true;
}
tstate->flags |= QCI_SYSFILE;
tstate->blocks = ip->i_d.di_nblocks;
tstate->nextents = ip->i_d.di_nextents;
tstate->spc_timelimit = q->qi_btimelimit;
tstate->ino_timelimit = q->qi_itimelimit;
tstate->rt_spc_timelimit = q->qi_rtbtimelimit;
tstate->spc_warnlimit = q->qi_bwarnlimit;
tstate->ino_warnlimit = q->qi_iwarnlimit;
tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
if (tempqip)
IRELE(ip);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 144 | 86.23% | 1 | 50.00% |
christoph hellwig | christoph hellwig | 23 | 13.77% | 1 | 50.00% |
| Total | 167 | 100.00% | 2 | 100.00% |
/*
* Return quota status information, such as enforcements, quota file inode
* numbers etc.
*/
static int
xfs_fs_get_quota_state(
struct super_block *sb,
struct qc_state *state)
{
struct xfs_mount *mp = XFS_M(sb);
struct xfs_quotainfo *q = mp->m_quotainfo;
memset(state, 0, sizeof(*state));
if (!XFS_IS_QUOTA_RUNNING(mp))
return 0;
state->s_incoredqs = q->qi_dquots;
if (XFS_IS_UQUOTA_RUNNING(mp))
state->s_state[USRQUOTA].flags |= QCI_ACCT_ENABLED;
if (XFS_IS_UQUOTA_ENFORCED(mp))
state->s_state[USRQUOTA].flags |= QCI_LIMITS_ENFORCED;
if (XFS_IS_GQUOTA_RUNNING(mp))
state->s_state[GRPQUOTA].flags |= QCI_ACCT_ENABLED;
if (XFS_IS_GQUOTA_ENFORCED(mp))
state->s_state[GRPQUOTA].flags |= QCI_LIMITS_ENFORCED;
if (XFS_IS_PQUOTA_RUNNING(mp))
state->s_state[PRJQUOTA].flags |= QCI_ACCT_ENABLED;
if (XFS_IS_PQUOTA_ENFORCED(mp))
state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;
xfs_qm_fill_state(&state->s_state[USRQUOTA], mp, q->qi_uquotaip,
mp->m_sb.sb_uquotino);
xfs_qm_fill_state(&state->s_state[GRPQUOTA], mp, q->qi_gquotaip,
mp->m_sb.sb_gquotino);
xfs_qm_fill_state(&state->s_state[PRJQUOTA], mp, q->qi_pquotaip,
mp->m_sb.sb_pquotino);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 212 | 85.83% | 1 | 33.33% |
chandra seetharaman | chandra seetharaman | 34 | 13.77% | 1 | 33.33% |
christoph hellwig | christoph hellwig | 1 | 0.40% | 1 | 33.33% |
| Total | 247 | 100.00% | 3 | 100.00% |
STATIC int
xfs_quota_type(int type)
{
switch (type) {
case USRQUOTA:
return XFS_DQ_USER;
case GRPQUOTA:
return XFS_DQ_GROUP;
default:
return XFS_DQ_PROJ;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 29 | 93.55% | 1 | 50.00% |
chandra seetharaman | chandra seetharaman | 2 | 6.45% | 1 | 50.00% |
| Total | 31 | 100.00% | 2 | 100.00% |
#define XFS_QC_SETINFO_MASK (QC_TIMER_MASK | QC_WARNS_MASK)
/*
* Adjust quota timers & warnings
*/
static int
xfs_fs_set_info(
struct super_block *sb,
int type,
struct qc_info *info)
{
struct xfs_mount *mp = XFS_M(sb);
struct qc_dqblk newlim;
if (sb->s_flags & MS_RDONLY)
return -EROFS;
if (!XFS_IS_QUOTA_RUNNING(mp))
return -ENOSYS;
if (!XFS_IS_QUOTA_ON(mp))
return -ESRCH;
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);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 169 | 100.00% | 1 | 100.00% |
| Total | 169 | 100.00% | 1 | 100.00% |
static unsigned int
xfs_quota_flags(unsigned int uflags)
{
unsigned int flags = 0;
if (uflags & FS_QUOTA_UDQ_ACCT)
flags |= XFS_UQUOTA_ACCT;
if (uflags & FS_QUOTA_PDQ_ACCT)
flags |= XFS_PQUOTA_ACCT;
if (uflags & FS_QUOTA_GDQ_ACCT)
flags |= XFS_GQUOTA_ACCT;
if (uflags & FS_QUOTA_UDQ_ENFD)
flags |= XFS_UQUOTA_ENFD;
if (uflags & FS_QUOTA_GDQ_ENFD)
flags |= XFS_GQUOTA_ENFD;
if (uflags & FS_QUOTA_PDQ_ENFD)
flags |= XFS_PQUOTA_ENFD;
return flags;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 61 | 76.25% | 2 | 40.00% |
chandra seetharaman | chandra seetharaman | 12 | 15.00% | 2 | 40.00% |
jan kara | jan kara | 7 | 8.75% | 1 | 20.00% |
| Total | 80 | 100.00% | 5 | 100.00% |
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));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 51 | 85.00% | 1 | 50.00% |
christoph hellwig | christoph hellwig | 9 | 15.00% | 1 | 50.00% |
| Total | 60 | 100.00% | 2 | 100.00% |
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));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 52 | 72.22% | 1 | 33.33% |
christoph hellwig | christoph hellwig | 18 | 25.00% | 1 | 33.33% |
eric sandeen | eric sandeen | 2 | 2.78% | 1 | 33.33% |
| Total | 72 | 100.00% | 3 | 100.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;
if (sb->s_flags & MS_RDONLY)
return -EROFS;
if (XFS_IS_QUOTA_ON(mp))
return -EINVAL;
if (uflags & FS_USER_QUOTA)
flags |= XFS_DQ_USER;
if (uflags & FS_GROUP_QUOTA)
flags |= XFS_DQ_GROUP;
if (uflags & FS_PROJ_QUOTA)
flags |= XFS_DQ_PROJ;
return xfs_qm_scall_trunc_qfiles(mp, flags);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
eric sandeen | eric sandeen | 71 | 77.17% | 1 | 33.33% |
christoph hellwig | christoph hellwig | 20 | 21.74% | 1 | 33.33% |
jeff liu | jeff liu | 1 | 1.09% | 1 | 33.33% |
| Total | 92 | 100.00% | 3 | 100.00% |
STATIC int
xfs_fs_get_dqblk(
struct super_block *sb,
struct kqid qid,
struct qc_dqblk *qdq)
{
struct xfs_mount *mp = XFS_M(sb);
xfs_dqid_t id;
if (!XFS_IS_QUOTA_RUNNING(mp))
return -ENOSYS;
if (!XFS_IS_QUOTA_ON(mp))
return -ESRCH;
id = from_kqid(&init_user_ns, qid);
return xfs_qm_scall_getquota(mp, &id,
xfs_quota_type(qid.type), qdq, 0);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 53 | 60.92% | 2 | 40.00% |
eric sandeen | eric sandeen | 29 | 33.33% | 1 | 20.00% |
eric w. biederman | eric w. biederman | 3 | 3.45% | 1 | 20.00% |
jan kara | jan kara | 2 | 2.30% | 1 | 20.00% |
| Total | 87 | 100.00% | 5 | 100.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_RUNNING(mp))
return -ENOSYS;
if (!XFS_IS_QUOTA_ON(mp))
return -ESRCH;
id = from_kqid(&init_user_ns, *qid);
ret = xfs_qm_scall_getquota(mp, &id,
xfs_quota_type(qid->type), qdq,
XFS_QMOPT_DQNEXT);
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;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
eric sandeen | eric sandeen | 101 | 84.87% | 1 | 25.00% |
christoph hellwig | christoph hellwig | 9 | 7.56% | 1 | 25.00% |
eric w. biederman | eric w. biederman | 8 | 6.72% | 1 | 25.00% |
jan kara | jan kara | 1 | 0.84% | 1 | 25.00% |
| Total | 119 | 100.00% | 4 | 100.00% |
STATIC int
xfs_fs_set_dqblk(
struct super_block *sb,
struct kqid qid,
struct qc_dqblk *qdq)
{
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 -ESRCH;
return xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
xfs_quota_type(qid.type), qdq);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
christoph hellwig | christoph hellwig | 74 | 83.15% | 2 | 50.00% |
eric w. biederman | eric w. biederman | 12 | 13.48% | 1 | 25.00% |
jan kara | jan kara | 3 | 3.37% | 1 | 25.00% |
| Total | 89 | 100.00% | 4 | 100.00% |
const struct quotactl_ops xfs_quotactl_operations = {
.get_state = xfs_fs_get_quota_state,
.set_info = xfs_fs_set_info,
.quota_enable = xfs_quota_enable,
.quota_disable = xfs_quota_disable,
.rm_xquota = xfs_fs_rm_xquota,
.get_dqblk = xfs_fs_get_dqblk,
.get_nextdqblk = xfs_fs_get_nextdqblk,
.set_dqblk = xfs_fs_set_dqblk,
};
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan kara | jan kara | 696 | 53.37% | 4 | 20.00% |
christoph hellwig | christoph hellwig | 310 | 23.77% | 4 | 20.00% |
eric sandeen | eric sandeen | 214 | 16.41% | 2 | 10.00% |
chandra seetharaman | chandra seetharaman | 48 | 3.68% | 2 | 10.00% |
eric w. biederman | eric w. biederman | 23 | 1.76% | 1 | 5.00% |
dave chinner | dave chinner | 8 | 0.61% | 3 | 15.00% |
david chinner | david chinner | 2 | 0.15% | 1 | 5.00% |
alex elder | alex elder | 1 | 0.08% | 1 | 5.00% |
alexey dobriyan | alexey dobriyan | 1 | 0.08% | 1 | 5.00% |
jeff liu | jeff liu | 1 | 0.08% | 1 | 5.00% |
| Total | 1304 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.