Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2008, Christoph Hellwig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include "xfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include "xfs_shared.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "xfs_format.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "xfs_log_format.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "xfs_trans_resv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "xfs_mount.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "xfs_inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "xfs_quota.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "xfs_trans.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "xfs_icache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "xfs_qm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) xfs_qm_fill_state(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct qc_type_state	*tstate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct xfs_mount	*mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct xfs_inode	*ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	xfs_ino_t		ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct xfs_def_quota	*defq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	bool			tempqip = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	tstate->ino = ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	if (!ip && ino == NULLFSINO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	if (!ip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		if (xfs_iget(mp, NULL, ino, 0, 0, &ip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		tempqip = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	tstate->flags |= QCI_SYSFILE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	tstate->blocks = ip->i_d.di_nblocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	tstate->nextents = ip->i_df.if_nextents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	tstate->spc_timelimit = (u32)defq->blk.time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	tstate->ino_timelimit = (u32)defq->ino.time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	tstate->rt_spc_timelimit = (u32)defq->rtb.time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	tstate->spc_warnlimit = defq->blk.warn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	tstate->ino_warnlimit = defq->ino.warn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	tstate->rt_spc_warnlimit = defq->rtb.warn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (tempqip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		xfs_irele(ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * Return quota status information, such as enforcements, quota file inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * numbers etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) xfs_fs_get_quota_state(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct qc_state		*state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct xfs_mount *mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct xfs_quotainfo *q = mp->m_quotainfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	memset(state, 0, sizeof(*state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	state->s_incoredqs = q->qi_dquots;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (XFS_IS_UQUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		state->s_state[USRQUOTA].flags |= QCI_ACCT_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (XFS_IS_UQUOTA_ENFORCED(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		state->s_state[USRQUOTA].flags |= QCI_LIMITS_ENFORCED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (XFS_IS_GQUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		state->s_state[GRPQUOTA].flags |= QCI_ACCT_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (XFS_IS_GQUOTA_ENFORCED(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		state->s_state[GRPQUOTA].flags |= QCI_LIMITS_ENFORCED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (XFS_IS_PQUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		state->s_state[PRJQUOTA].flags |= QCI_ACCT_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (XFS_IS_PQUOTA_ENFORCED(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	xfs_qm_fill_state(&state->s_state[USRQUOTA], mp, q->qi_uquotaip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			  mp->m_sb.sb_uquotino, &q->qi_usr_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	xfs_qm_fill_state(&state->s_state[GRPQUOTA], mp, q->qi_gquotaip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			  mp->m_sb.sb_gquotino, &q->qi_grp_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	xfs_qm_fill_state(&state->s_state[PRJQUOTA], mp, q->qi_pquotaip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			  mp->m_sb.sb_pquotino, &q->qi_prj_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) STATIC xfs_dqtype_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) xfs_quota_type(int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	case USRQUOTA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return XFS_DQTYPE_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	case GRPQUOTA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		return XFS_DQTYPE_GROUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		return XFS_DQTYPE_PROJ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define XFS_QC_SETINFO_MASK (QC_TIMER_MASK | QC_WARNS_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Adjust quota timers & warnings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) xfs_fs_set_info(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	int			type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct qc_info		*info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct qc_dqblk		newlim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	if (!XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (info->i_fieldmask & ~XFS_QC_SETINFO_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if ((info->i_fieldmask & XFS_QC_SETINFO_MASK) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	newlim.d_fieldmask = info->i_fieldmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	newlim.d_spc_timer = info->i_spc_timelimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	newlim.d_ino_timer = info->i_ino_timelimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	newlim.d_rt_spc_timer = info->i_rt_spc_timelimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	newlim.d_ino_warns = info->i_ino_warnlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	newlim.d_spc_warns = info->i_spc_warnlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	newlim.d_rt_spc_warns = info->i_rt_spc_warnlimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return xfs_qm_scall_setqlim(mp, 0, xfs_quota_type(type), &newlim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) xfs_quota_flags(unsigned int uflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	unsigned int flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (uflags & FS_QUOTA_UDQ_ACCT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		flags |= XFS_UQUOTA_ACCT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (uflags & FS_QUOTA_PDQ_ACCT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		flags |= XFS_PQUOTA_ACCT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	if (uflags & FS_QUOTA_GDQ_ACCT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		flags |= XFS_GQUOTA_ACCT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (uflags & FS_QUOTA_UDQ_ENFD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		flags |= XFS_UQUOTA_ENFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	if (uflags & FS_QUOTA_GDQ_ENFD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		flags |= XFS_GQUOTA_ENFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (uflags & FS_QUOTA_PDQ_ENFD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		flags |= XFS_PQUOTA_ENFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) xfs_quota_enable(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	unsigned int		uflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	return xfs_qm_scall_quotaon(mp, xfs_quota_flags(uflags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) xfs_quota_disable(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	unsigned int		uflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if (sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (!XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	return xfs_qm_scall_quotaoff(mp, xfs_quota_flags(uflags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) xfs_fs_rm_xquota(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	unsigned int		uflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	unsigned int		flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if (sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (uflags & FS_USER_QUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		flags |= XFS_QMOPT_UQUOTA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	if (uflags & FS_GROUP_QUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		flags |= XFS_QMOPT_GQUOTA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (uflags & FS_PROJ_QUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		flags |= XFS_QMOPT_PQUOTA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return xfs_qm_scall_trunc_qfiles(mp, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) xfs_fs_get_dqblk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct kqid		qid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	struct qc_dqblk		*qdq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	xfs_dqid_t		id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (!XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		return -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	id = from_kqid(&init_user_ns, qid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return xfs_qm_scall_getquota(mp, id, xfs_quota_type(qid.type), qdq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /* Return quota info for active quota >= this qid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) xfs_fs_get_nextdqblk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	struct kqid		*qid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct qc_dqblk		*qdq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	int			ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	xfs_dqid_t		id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	if (!XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		return -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	id = from_kqid(&init_user_ns, *qid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	ret = xfs_qm_scall_getquota_next(mp, &id, xfs_quota_type(qid->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			qdq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	/* ID may be different, so convert back what we got */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	*qid = make_kqid(current_user_ns(), qid->type, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) xfs_fs_set_dqblk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	struct super_block	*sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct kqid		qid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	struct qc_dqblk		*qdq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	struct xfs_mount	*mp = XFS_M(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if (sb_rdonly(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	if (!XFS_IS_QUOTA_RUNNING(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	if (!XFS_IS_QUOTA_ON(mp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		return -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	return xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 				     xfs_quota_type(qid.type), qdq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) const struct quotactl_ops xfs_quotactl_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	.get_state		= xfs_fs_get_quota_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	.set_info		= xfs_fs_set_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	.quota_enable		= xfs_quota_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	.quota_disable		= xfs_quota_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	.rm_xquota		= xfs_fs_rm_xquota,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	.get_dqblk		= xfs_fs_get_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	.get_nextdqblk		= xfs_fs_get_nextdqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	.set_dqblk		= xfs_fs_set_dqblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) };