fs/xfs/xfs_quotaops.c

Source file repositories/reference/linux-study-clean/fs/xfs/xfs_quotaops.c

File Facts

System
Linux kernel
Corpus path
fs/xfs/xfs_quotaops.c
Extension
.c
Size
6456 bytes
Lines
290
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2008, Christoph Hellwig
 * All Rights Reserved.
 */
#include "xfs_platform.h"
#include "xfs_shared.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_icache.h"
#include "xfs_qm.h"


static int
xfs_qm_fill_state(
	struct qc_type_state	*tstate,
	struct xfs_mount	*mp,
	xfs_dqtype_t		type)
{
	struct xfs_inode	*ip;
	struct xfs_def_quota	*defq;
	int			error;

	error = xfs_qm_qino_load(mp, type, &ip);
	if (error) {
		tstate->ino = NULLFSINO;
		return error != -ENOENT ? error : 0;
	}

	defq = xfs_get_defquota(mp->m_quotainfo, type);

	tstate->ino = I_INO(ip);
	tstate->flags |= QCI_SYSFILE;
	tstate->blocks = ip->i_nblocks;
	tstate->nextents = ip->i_df.if_nextents;
	tstate->spc_timelimit = (u32)defq->blk.time;
	tstate->ino_timelimit = (u32)defq->ino.time;
	tstate->rt_spc_timelimit = (u32)defq->rtb.time;
	tstate->spc_warnlimit = 0;
	tstate->ino_warnlimit = 0;
	tstate->rt_spc_warnlimit = 0;
	xfs_irele(ip);

	return 0;
}

/*
 * 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;
	int			error;

	memset(state, 0, sizeof(*state));
	if (!XFS_IS_QUOTA_ON(mp))
		return 0;
	state->s_incoredqs = min_t(uint64_t, q->qi_dquots, UINT_MAX);
	if (XFS_IS_UQUOTA_ON(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_ON(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_ON(mp))
		state->s_state[PRJQUOTA].flags |= QCI_ACCT_ENABLED;
	if (XFS_IS_PQUOTA_ENFORCED(mp))
		state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;

	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,

Annotation

Implementation Notes