162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2017 Oracle.  All Rights Reserved.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Author: Darrick J. Wong <darrick.wong@oracle.com>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef __EXT4_FSMAP_H__
862306a36Sopenharmony_ci#define	__EXT4_FSMAP_H__
962306a36Sopenharmony_ci
1062306a36Sopenharmony_cistruct fsmap;
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/* internal fsmap representation */
1362306a36Sopenharmony_cistruct ext4_fsmap {
1462306a36Sopenharmony_ci	struct list_head	fmr_list;
1562306a36Sopenharmony_ci	dev_t		fmr_device;	/* device id */
1662306a36Sopenharmony_ci	uint32_t	fmr_flags;	/* mapping flags */
1762306a36Sopenharmony_ci	uint64_t	fmr_physical;	/* device offset of segment */
1862306a36Sopenharmony_ci	uint64_t	fmr_owner;	/* owner id */
1962306a36Sopenharmony_ci	uint64_t	fmr_length;	/* length of segment, blocks */
2062306a36Sopenharmony_ci};
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cistruct ext4_fsmap_head {
2362306a36Sopenharmony_ci	uint32_t	fmh_iflags;	/* control flags */
2462306a36Sopenharmony_ci	uint32_t	fmh_oflags;	/* output flags */
2562306a36Sopenharmony_ci	unsigned int	fmh_count;	/* # of entries in array incl. input */
2662306a36Sopenharmony_ci	unsigned int	fmh_entries;	/* # of entries filled in (output). */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	struct ext4_fsmap fmh_keys[2];	/* low and high keys */
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_civoid ext4_fsmap_from_internal(struct super_block *sb, struct fsmap *dest,
3262306a36Sopenharmony_ci		struct ext4_fsmap *src);
3362306a36Sopenharmony_civoid ext4_fsmap_to_internal(struct super_block *sb, struct ext4_fsmap *dest,
3462306a36Sopenharmony_ci		struct fsmap *src);
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci/* fsmap to userspace formatter - copy to user & advance pointer */
3762306a36Sopenharmony_citypedef int (*ext4_fsmap_format_t)(struct ext4_fsmap *, void *);
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciint ext4_getfsmap(struct super_block *sb, struct ext4_fsmap_head *head,
4062306a36Sopenharmony_ci		ext4_fsmap_format_t formatter, void *arg);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define EXT4_QUERY_RANGE_ABORT		1
4362306a36Sopenharmony_ci#define EXT4_QUERY_RANGE_CONTINUE	0
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/*	fmr_owner special values for FS_IOC_GETFSMAP; some share w/ XFS */
4662306a36Sopenharmony_ci#define EXT4_FMR_OWN_FREE	FMR_OWN_FREE      /* free space */
4762306a36Sopenharmony_ci#define EXT4_FMR_OWN_UNKNOWN	FMR_OWN_UNKNOWN   /* unknown owner */
4862306a36Sopenharmony_ci#define EXT4_FMR_OWN_FS		FMR_OWNER('X', 1) /* static fs metadata */
4962306a36Sopenharmony_ci#define EXT4_FMR_OWN_LOG	FMR_OWNER('X', 2) /* journalling log */
5062306a36Sopenharmony_ci#define EXT4_FMR_OWN_INODES	FMR_OWNER('X', 5) /* inodes */
5162306a36Sopenharmony_ci#define EXT4_FMR_OWN_GDT	FMR_OWNER('f', 1) /* group descriptors */
5262306a36Sopenharmony_ci#define EXT4_FMR_OWN_RESV_GDT	FMR_OWNER('f', 2) /* reserved gdt blocks */
5362306a36Sopenharmony_ci#define EXT4_FMR_OWN_BLKBM	FMR_OWNER('f', 3) /* block bitmap */
5462306a36Sopenharmony_ci#define EXT4_FMR_OWN_INOBM	FMR_OWNER('f', 4) /* inode bitmap */
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#endif /* __EXT4_FSMAP_H__ */
57