summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/quotacheck.h
blob: 415f7a63418fd8f245eea09c33d923446c4f3ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2021 Oracle.  All Rights Reserved.
 * Author: Darrick J. Wong <djwong@kernel.org>
 */
#ifndef __XFS_SCRUB_QUOTACHECK_H__
#define __XFS_SCRUB_QUOTACHECK_H__

/* Quota counters for live quotacheck. */
struct xqcheck_dquot {
	/* block usage count */
	int64_t			bcount;

	/* inode usage count */
	int64_t			icount;

	/* realtime block usage count */
	int64_t			rtbcount;

	/* Record state */
	unsigned int		flags;
};

/* Already checked this dquot */
#define XQCHECK_DQUOT_COMPARE_SCANNED	(1U << 0)

/* Live quotacheck control structure. */
struct xqcheck {
	struct xfs_scrub	*sc;

	/* Shadow dquot counter data. */
	struct xfarray		*ucounts;
	struct xfarray		*gcounts;
	struct xfarray		*pcounts;

	/* Lock protecting quotacheck count observations */
	struct mutex		lock;

	struct xchk_iscan	iscan;
};

/* Return the incore counter array for a given quota type. */
static inline struct xfarray *
xqcheck_counters_for(
	struct xqcheck		*xqc,
	xfs_dqtype_t		dqtype)
{
	switch (dqtype) {
	case XFS_DQTYPE_USER:
		return xqc->ucounts;
	case XFS_DQTYPE_GROUP:
		return xqc->gcounts;
	case XFS_DQTYPE_PROJ:
		return xqc->pcounts;
	}

	ASSERT(0);
	return NULL;
}

#endif /* __XFS_SCRUB_QUOTACHECK_H__ */