From d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 02:45:28 +0000 Subject: [PATCH] add boot partition size --- kernel/include/uapi/linux/incrementalfs.h | 262 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 259 insertions(+), 3 deletions(-) diff --git a/kernel/include/uapi/linux/incrementalfs.h b/kernel/include/uapi/linux/incrementalfs.h index 13c3d51..f8338af 100644 --- a/kernel/include/uapi/linux/incrementalfs.h +++ b/kernel/include/uapi/linux/incrementalfs.h @@ -18,7 +18,14 @@ /* ===== constants ===== */ #define INCFS_NAME "incremental-fs" -#define INCFS_MAGIC_NUMBER (0x5346434e49ul) + +/* + * Magic number used in file header and in memory superblock + * Note that it is a 5 byte unsigned long. Thus on 32 bit kernels, it is + * truncated to a 4 byte number + */ +#define INCFS_MAGIC_NUMBER (0x5346434e49ul & ULONG_MAX) + #define INCFS_DATA_FILE_BLOCK_SIZE 4096 #define INCFS_HEADER_VER 1 @@ -28,11 +35,15 @@ #define INCFS_MAX_HASH_SIZE 32 #define INCFS_MAX_FILE_ATTR_SIZE 512 +#define INCFS_INDEX_NAME ".index" +#define INCFS_INCOMPLETE_NAME ".incomplete" #define INCFS_PENDING_READS_FILENAME ".pending_reads" #define INCFS_LOG_FILENAME ".log" +#define INCFS_BLOCKS_WRITTEN_FILENAME ".blocks_written" #define INCFS_XATTR_ID_NAME (XATTR_USER_PREFIX "incfs.id") #define INCFS_XATTR_SIZE_NAME (XATTR_USER_PREFIX "incfs.size") #define INCFS_XATTR_METADATA_NAME (XATTR_USER_PREFIX "incfs.metadata") +#define INCFS_XATTR_VERITY_NAME (XATTR_USER_PREFIX "incfs.verity") #define INCFS_MAX_SIGNATURE_SIZE 8096 #define INCFS_SIGNATURE_VERSION 2 @@ -42,7 +53,10 @@ /* ===== ioctl requests on the command dir ===== */ -/* Create a new file */ +/* + * Create a new file + * May only be called on .pending_reads file + */ #define INCFS_IOC_CREATE_FILE \ _IOWR(INCFS_IOCTL_BASE_CODE, 30, struct incfs_new_file_args) @@ -92,9 +106,73 @@ #define INCFS_IOC_GET_FILLED_BLOCKS \ _IOR(INCFS_IOCTL_BASE_CODE, 34, struct incfs_get_filled_blocks_args) +/* + * Creates a new mapped file + * May only be called on .pending_reads file + */ +#define INCFS_IOC_CREATE_MAPPED_FILE \ + _IOWR(INCFS_IOCTL_BASE_CODE, 35, struct incfs_create_mapped_file_args) + +/* + * Get number of blocks, total and filled + * May only be called on .pending_reads file + */ +#define INCFS_IOC_GET_BLOCK_COUNT \ + _IOR(INCFS_IOCTL_BASE_CODE, 36, struct incfs_get_block_count_args) + +/* + * Get per UID read timeouts + * May only be called on .pending_reads file + */ +#define INCFS_IOC_GET_READ_TIMEOUTS \ + _IOR(INCFS_IOCTL_BASE_CODE, 37, struct incfs_get_read_timeouts_args) + +/* + * Set per UID read timeouts + * May only be called on .pending_reads file + */ +#define INCFS_IOC_SET_READ_TIMEOUTS \ + _IOW(INCFS_IOCTL_BASE_CODE, 38, struct incfs_set_read_timeouts_args) + +/* + * Get last read error + * May only be called on .pending_reads file + */ +#define INCFS_IOC_GET_LAST_READ_ERROR \ + _IOW(INCFS_IOCTL_BASE_CODE, 39, struct incfs_get_last_read_error_args) + +/* ===== sysfs feature flags ===== */ +/* + * Each flag is represented by a file in /sys/fs/incremental-fs/features + * If the file exists the feature is supported + * Also the file contents will be the line "supported" + */ + +/* + * Basic flag stating that the core incfs file system is available + */ +#define INCFS_FEATURE_FLAG_COREFS "corefs" + +/* + * zstd compression support + */ +#define INCFS_FEATURE_FLAG_ZSTD "zstd" + +/* + * v2 feature set support. Covers: + * INCFS_IOC_CREATE_MAPPED_FILE + * INCFS_IOC_GET_BLOCK_COUNT + * INCFS_IOC_GET_READ_TIMEOUTS/INCFS_IOC_SET_READ_TIMEOUTS + * .blocks_written status file + * .incomplete folder + * report_uid mount option + */ +#define INCFS_FEATURE_FLAG_V2 "v2" + enum incfs_compression_alg { COMPRESSION_NONE = 0, - COMPRESSION_LZ4 = 1 + COMPRESSION_LZ4 = 1, + COMPRESSION_ZSTD = 2, }; enum incfs_block_flags { @@ -109,6 +187,8 @@ /* * Description of a pending read. A pending read - a read call by * a userspace program for which the filesystem currently doesn't have data. + * + * Reads from .pending_reads and .log return an array of these structure */ struct incfs_pending_read_info { /* Id of a file that is being read from. */ @@ -122,6 +202,32 @@ /* A serial number of this pending read. */ __u32 serial_number; +}; + +/* + * Description of a pending read. A pending read - a read call by + * a userspace program for which the filesystem currently doesn't have data. + * + * This version of incfs_pending_read_info is used whenever the file system is + * mounted with the report_uid flag + */ +struct incfs_pending_read_info2 { + /* Id of a file that is being read from. */ + incfs_uuid_t file_id; + + /* A number of microseconds since system boot to the read. */ + __aligned_u64 timestamp_us; + + /* Index of a file block that is being read. */ + __u32 block_index; + + /* A serial number of this pending read. */ + __u32 serial_number; + + /* The UID of the reading process */ + __u32 uid; + + __u32 reserved; }; /* @@ -331,4 +437,154 @@ __u32 index_out; }; +/* + * Create a new mapped file + * Argument for INCFS_IOC_CREATE_MAPPED_FILE + */ +struct incfs_create_mapped_file_args { + /* + * Total size of the new file. + */ + __aligned_u64 size; + + /* + * File mode. Permissions and dir flag. + */ + __u16 mode; + + __u16 reserved1; + + __u32 reserved2; + + /* + * A pointer to a null-terminated relative path to the incfs mount + * point + * Max length: PATH_MAX + * + * Equivalent to: char *directory_path; + */ + __aligned_u64 directory_path; + + /* + * A pointer to a null-terminated file name. + * Max length: PATH_MAX + * + * Equivalent to: char *file_name; + */ + __aligned_u64 file_name; + + /* Id of source file to map. */ + incfs_uuid_t source_file_id; + + /* + * Offset in source file to start mapping. Must be a multiple of + * INCFS_DATA_FILE_BLOCK_SIZE + */ + __aligned_u64 source_offset; +}; + +/* + * Get information about the blocks in this file + * Argument for INCFS_IOC_GET_BLOCK_COUNT + */ +struct incfs_get_block_count_args { + /* Total number of data blocks in the file */ + __u32 total_data_blocks_out; + + /* Number of filled data blocks in the file */ + __u32 filled_data_blocks_out; + + /* Total number of hash blocks in the file */ + __u32 total_hash_blocks_out; + + /* Number of filled hash blocks in the file */ + __u32 filled_hash_blocks_out; +}; + +/* Description of timeouts for one UID */ +struct incfs_per_uid_read_timeouts { + /* UID to apply these timeouts to */ + __u32 uid; + + /* + * Min time in microseconds to read any block. Note that this doesn't + * apply to reads which are satisfied from the page cache. + */ + __u32 min_time_us; + + /* + * Min time in microseconds to satisfy a pending read. Any pending read + * which is filled before this time will be delayed so that the total + * read time >= this value. + */ + __u32 min_pending_time_us; + + /* + * Max time in microseconds to satisfy a pending read before the read + * times out. If set to U32_MAX, defaults to mount options + * read_timeout_ms * 1000. Must be >= min_pending_time_us + */ + __u32 max_pending_time_us; +}; + +/* + * Get the read timeouts array + * Argument for INCFS_IOC_GET_READ_TIMEOUTS + */ +struct incfs_get_read_timeouts_args { + /* + * A pointer to a buffer to fill with the current timeouts + * + * Equivalent to struct incfs_per_uid_read_timeouts * + */ + __aligned_u64 timeouts_array; + + /* Size of above buffer in bytes */ + __u32 timeouts_array_size; + + /* Size used in bytes, or size needed if -ENOMEM returned */ + __u32 timeouts_array_size_out; +}; + +/* + * Set the read timeouts array + * Arguments for INCFS_IOC_SET_READ_TIMEOUTS + */ +struct incfs_set_read_timeouts_args { + /* + * A pointer to an array containing the new timeouts + * This will replace any existing timeouts + * + * Equivalent to struct incfs_per_uid_read_timeouts * + */ + __aligned_u64 timeouts_array; + + /* Size of above array in bytes. Must be < 256 */ + __u32 timeouts_array_size; +}; + +/* + * Get last read error struct + * Arguments for INCFS_IOC_GET_LAST_READ_ERROR + */ +struct incfs_get_last_read_error_args { + /* File id of last file that had a read error */ + incfs_uuid_t file_id_out; + + /* Time of last read error, in us, from CLOCK_MONOTONIC */ + __u64 time_us_out; + + /* Index of page that was being read at last read error */ + __u32 page_out; + + /* errno of last read error */ + __u32 errno_out; + + /* uid of last read error */ + __u32 uid_out; + + __u32 reserved1; + __u64 reserved2; +}; + #endif /* _UAPI_LINUX_INCREMENTALFS_H */ -- Gitblit v1.6.2