fs/xfs/libxfs/xfs_rtgroup.c

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

File Facts

System
Linux kernel
Corpus path
fs/xfs/libxfs/xfs_rtgroup.c
Extension
.c
Size
17870 bytes
Lines
752
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

struct xfs_rtginode_ops {
	const char		*name;	/* short name */

	enum xfs_metafile_type	metafile_type;

	unsigned int		sick;	/* rtgroup sickness flag */

	unsigned int		fmt_mask; /* all valid data fork formats */

	/* Does the fs have this feature? */
	bool			(*enabled)(const struct xfs_mount *mp);

	/* Create this rtgroup metadata inode and initialize it. */
	int			(*create)(struct xfs_rtgroup *rtg,
					  struct xfs_inode *ip,
					  struct xfs_trans *tp,
					  bool init);
};

static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTGI_MAX] = {
	[XFS_RTGI_BITMAP] = {
		.name		= "bitmap",
		.metafile_type	= XFS_METAFILE_RTBITMAP,
		.sick		= XFS_SICK_RG_BITMAP,
		.fmt_mask	= (1U << XFS_DINODE_FMT_EXTENTS) |
				  (1U << XFS_DINODE_FMT_BTREE),
		.enabled	= xfs_has_nonzoned,
		.create		= xfs_rtbitmap_create,
	},
	[XFS_RTGI_SUMMARY] = {
		.name		= "summary",
		.metafile_type	= XFS_METAFILE_RTSUMMARY,
		.sick		= XFS_SICK_RG_SUMMARY,
		.fmt_mask	= (1U << XFS_DINODE_FMT_EXTENTS) |
				  (1U << XFS_DINODE_FMT_BTREE),
		.enabled	= xfs_has_nonzoned,
		.create		= xfs_rtsummary_create,
	},
	[XFS_RTGI_RMAP] = {
		.name		= "rmap",
		.metafile_type	= XFS_METAFILE_RTRMAP,
		.sick		= XFS_SICK_RG_RMAPBT,
		.fmt_mask	= 1U << XFS_DINODE_FMT_META_BTREE,
		/*
		 * growfs must create the rtrmap inodes before adding a
		 * realtime volume to the filesystem, so we cannot use the
		 * rtrmapbt predicate here.
		 */
		.enabled	= xfs_has_rmapbt,
		.create		= xfs_rtrmapbt_create,
	},
	[XFS_RTGI_REFCOUNT] = {
		.name		= "refcount",
		.metafile_type	= XFS_METAFILE_RTREFCOUNT,
		.sick		= XFS_SICK_RG_REFCNTBT,
		.fmt_mask	= 1U << XFS_DINODE_FMT_META_BTREE,
		/* same comment about growfs and rmap inodes applies here */
		.enabled	= xfs_has_reflink,
		.create		= xfs_rtrefcountbt_create,
	},
};

/* Return the shortname of this rtgroup inode. */
const char *
xfs_rtginode_name(
	enum xfs_rtg_inodes	type)
{
	return xfs_rtginode_ops[type].name;
}

/* Return the metafile type of this rtgroup inode. */
enum xfs_metafile_type
xfs_rtginode_metafile_type(
	enum xfs_rtg_inodes	type)
{
	return xfs_rtginode_ops[type].metafile_type;
}

/* Should this rtgroup inode be present? */
bool
xfs_rtginode_enabled(
	struct xfs_rtgroup	*rtg,
	enum xfs_rtg_inodes	type)
{
	const struct xfs_rtginode_ops *ops = &xfs_rtginode_ops[type];

	if (!ops->enabled)
		return true;
	return ops->enabled(rtg_mount(rtg));
}

Annotation

Implementation Notes