.. | .. |
---|
18 | 18 | |
---|
19 | 19 | /* ===== constants ===== */ |
---|
20 | 20 | #define INCFS_NAME "incremental-fs" |
---|
21 | | -#define INCFS_MAGIC_NUMBER (0x5346434e49ul) |
---|
| 21 | + |
---|
| 22 | +/* |
---|
| 23 | + * Magic number used in file header and in memory superblock |
---|
| 24 | + * Note that it is a 5 byte unsigned long. Thus on 32 bit kernels, it is |
---|
| 25 | + * truncated to a 4 byte number |
---|
| 26 | + */ |
---|
| 27 | +#define INCFS_MAGIC_NUMBER (0x5346434e49ul & ULONG_MAX) |
---|
| 28 | + |
---|
22 | 29 | #define INCFS_DATA_FILE_BLOCK_SIZE 4096 |
---|
23 | 30 | #define INCFS_HEADER_VER 1 |
---|
24 | 31 | |
---|
.. | .. |
---|
28 | 35 | #define INCFS_MAX_HASH_SIZE 32 |
---|
29 | 36 | #define INCFS_MAX_FILE_ATTR_SIZE 512 |
---|
30 | 37 | |
---|
| 38 | +#define INCFS_INDEX_NAME ".index" |
---|
| 39 | +#define INCFS_INCOMPLETE_NAME ".incomplete" |
---|
31 | 40 | #define INCFS_PENDING_READS_FILENAME ".pending_reads" |
---|
32 | 41 | #define INCFS_LOG_FILENAME ".log" |
---|
| 42 | +#define INCFS_BLOCKS_WRITTEN_FILENAME ".blocks_written" |
---|
33 | 43 | #define INCFS_XATTR_ID_NAME (XATTR_USER_PREFIX "incfs.id") |
---|
34 | 44 | #define INCFS_XATTR_SIZE_NAME (XATTR_USER_PREFIX "incfs.size") |
---|
35 | 45 | #define INCFS_XATTR_METADATA_NAME (XATTR_USER_PREFIX "incfs.metadata") |
---|
| 46 | +#define INCFS_XATTR_VERITY_NAME (XATTR_USER_PREFIX "incfs.verity") |
---|
36 | 47 | |
---|
37 | 48 | #define INCFS_MAX_SIGNATURE_SIZE 8096 |
---|
38 | 49 | #define INCFS_SIGNATURE_VERSION 2 |
---|
.. | .. |
---|
42 | 53 | |
---|
43 | 54 | /* ===== ioctl requests on the command dir ===== */ |
---|
44 | 55 | |
---|
45 | | -/* Create a new file */ |
---|
| 56 | +/* |
---|
| 57 | + * Create a new file |
---|
| 58 | + * May only be called on .pending_reads file |
---|
| 59 | + */ |
---|
46 | 60 | #define INCFS_IOC_CREATE_FILE \ |
---|
47 | 61 | _IOWR(INCFS_IOCTL_BASE_CODE, 30, struct incfs_new_file_args) |
---|
48 | 62 | |
---|
.. | .. |
---|
92 | 106 | #define INCFS_IOC_GET_FILLED_BLOCKS \ |
---|
93 | 107 | _IOR(INCFS_IOCTL_BASE_CODE, 34, struct incfs_get_filled_blocks_args) |
---|
94 | 108 | |
---|
| 109 | +/* |
---|
| 110 | + * Creates a new mapped file |
---|
| 111 | + * May only be called on .pending_reads file |
---|
| 112 | + */ |
---|
| 113 | +#define INCFS_IOC_CREATE_MAPPED_FILE \ |
---|
| 114 | + _IOWR(INCFS_IOCTL_BASE_CODE, 35, struct incfs_create_mapped_file_args) |
---|
| 115 | + |
---|
| 116 | +/* |
---|
| 117 | + * Get number of blocks, total and filled |
---|
| 118 | + * May only be called on .pending_reads file |
---|
| 119 | + */ |
---|
| 120 | +#define INCFS_IOC_GET_BLOCK_COUNT \ |
---|
| 121 | + _IOR(INCFS_IOCTL_BASE_CODE, 36, struct incfs_get_block_count_args) |
---|
| 122 | + |
---|
| 123 | +/* |
---|
| 124 | + * Get per UID read timeouts |
---|
| 125 | + * May only be called on .pending_reads file |
---|
| 126 | + */ |
---|
| 127 | +#define INCFS_IOC_GET_READ_TIMEOUTS \ |
---|
| 128 | + _IOR(INCFS_IOCTL_BASE_CODE, 37, struct incfs_get_read_timeouts_args) |
---|
| 129 | + |
---|
| 130 | +/* |
---|
| 131 | + * Set per UID read timeouts |
---|
| 132 | + * May only be called on .pending_reads file |
---|
| 133 | + */ |
---|
| 134 | +#define INCFS_IOC_SET_READ_TIMEOUTS \ |
---|
| 135 | + _IOW(INCFS_IOCTL_BASE_CODE, 38, struct incfs_set_read_timeouts_args) |
---|
| 136 | + |
---|
| 137 | +/* |
---|
| 138 | + * Get last read error |
---|
| 139 | + * May only be called on .pending_reads file |
---|
| 140 | + */ |
---|
| 141 | +#define INCFS_IOC_GET_LAST_READ_ERROR \ |
---|
| 142 | + _IOW(INCFS_IOCTL_BASE_CODE, 39, struct incfs_get_last_read_error_args) |
---|
| 143 | + |
---|
| 144 | +/* ===== sysfs feature flags ===== */ |
---|
| 145 | +/* |
---|
| 146 | + * Each flag is represented by a file in /sys/fs/incremental-fs/features |
---|
| 147 | + * If the file exists the feature is supported |
---|
| 148 | + * Also the file contents will be the line "supported" |
---|
| 149 | + */ |
---|
| 150 | + |
---|
| 151 | +/* |
---|
| 152 | + * Basic flag stating that the core incfs file system is available |
---|
| 153 | + */ |
---|
| 154 | +#define INCFS_FEATURE_FLAG_COREFS "corefs" |
---|
| 155 | + |
---|
| 156 | +/* |
---|
| 157 | + * zstd compression support |
---|
| 158 | + */ |
---|
| 159 | +#define INCFS_FEATURE_FLAG_ZSTD "zstd" |
---|
| 160 | + |
---|
| 161 | +/* |
---|
| 162 | + * v2 feature set support. Covers: |
---|
| 163 | + * INCFS_IOC_CREATE_MAPPED_FILE |
---|
| 164 | + * INCFS_IOC_GET_BLOCK_COUNT |
---|
| 165 | + * INCFS_IOC_GET_READ_TIMEOUTS/INCFS_IOC_SET_READ_TIMEOUTS |
---|
| 166 | + * .blocks_written status file |
---|
| 167 | + * .incomplete folder |
---|
| 168 | + * report_uid mount option |
---|
| 169 | + */ |
---|
| 170 | +#define INCFS_FEATURE_FLAG_V2 "v2" |
---|
| 171 | + |
---|
95 | 172 | enum incfs_compression_alg { |
---|
96 | 173 | COMPRESSION_NONE = 0, |
---|
97 | | - COMPRESSION_LZ4 = 1 |
---|
| 174 | + COMPRESSION_LZ4 = 1, |
---|
| 175 | + COMPRESSION_ZSTD = 2, |
---|
98 | 176 | }; |
---|
99 | 177 | |
---|
100 | 178 | enum incfs_block_flags { |
---|
.. | .. |
---|
109 | 187 | /* |
---|
110 | 188 | * Description of a pending read. A pending read - a read call by |
---|
111 | 189 | * a userspace program for which the filesystem currently doesn't have data. |
---|
| 190 | + * |
---|
| 191 | + * Reads from .pending_reads and .log return an array of these structure |
---|
112 | 192 | */ |
---|
113 | 193 | struct incfs_pending_read_info { |
---|
114 | 194 | /* Id of a file that is being read from. */ |
---|
.. | .. |
---|
122 | 202 | |
---|
123 | 203 | /* A serial number of this pending read. */ |
---|
124 | 204 | __u32 serial_number; |
---|
| 205 | +}; |
---|
| 206 | + |
---|
| 207 | +/* |
---|
| 208 | + * Description of a pending read. A pending read - a read call by |
---|
| 209 | + * a userspace program for which the filesystem currently doesn't have data. |
---|
| 210 | + * |
---|
| 211 | + * This version of incfs_pending_read_info is used whenever the file system is |
---|
| 212 | + * mounted with the report_uid flag |
---|
| 213 | + */ |
---|
| 214 | +struct incfs_pending_read_info2 { |
---|
| 215 | + /* Id of a file that is being read from. */ |
---|
| 216 | + incfs_uuid_t file_id; |
---|
| 217 | + |
---|
| 218 | + /* A number of microseconds since system boot to the read. */ |
---|
| 219 | + __aligned_u64 timestamp_us; |
---|
| 220 | + |
---|
| 221 | + /* Index of a file block that is being read. */ |
---|
| 222 | + __u32 block_index; |
---|
| 223 | + |
---|
| 224 | + /* A serial number of this pending read. */ |
---|
| 225 | + __u32 serial_number; |
---|
| 226 | + |
---|
| 227 | + /* The UID of the reading process */ |
---|
| 228 | + __u32 uid; |
---|
| 229 | + |
---|
| 230 | + __u32 reserved; |
---|
125 | 231 | }; |
---|
126 | 232 | |
---|
127 | 233 | /* |
---|
.. | .. |
---|
331 | 437 | __u32 index_out; |
---|
332 | 438 | }; |
---|
333 | 439 | |
---|
| 440 | +/* |
---|
| 441 | + * Create a new mapped file |
---|
| 442 | + * Argument for INCFS_IOC_CREATE_MAPPED_FILE |
---|
| 443 | + */ |
---|
| 444 | +struct incfs_create_mapped_file_args { |
---|
| 445 | + /* |
---|
| 446 | + * Total size of the new file. |
---|
| 447 | + */ |
---|
| 448 | + __aligned_u64 size; |
---|
| 449 | + |
---|
| 450 | + /* |
---|
| 451 | + * File mode. Permissions and dir flag. |
---|
| 452 | + */ |
---|
| 453 | + __u16 mode; |
---|
| 454 | + |
---|
| 455 | + __u16 reserved1; |
---|
| 456 | + |
---|
| 457 | + __u32 reserved2; |
---|
| 458 | + |
---|
| 459 | + /* |
---|
| 460 | + * A pointer to a null-terminated relative path to the incfs mount |
---|
| 461 | + * point |
---|
| 462 | + * Max length: PATH_MAX |
---|
| 463 | + * |
---|
| 464 | + * Equivalent to: char *directory_path; |
---|
| 465 | + */ |
---|
| 466 | + __aligned_u64 directory_path; |
---|
| 467 | + |
---|
| 468 | + /* |
---|
| 469 | + * A pointer to a null-terminated file name. |
---|
| 470 | + * Max length: PATH_MAX |
---|
| 471 | + * |
---|
| 472 | + * Equivalent to: char *file_name; |
---|
| 473 | + */ |
---|
| 474 | + __aligned_u64 file_name; |
---|
| 475 | + |
---|
| 476 | + /* Id of source file to map. */ |
---|
| 477 | + incfs_uuid_t source_file_id; |
---|
| 478 | + |
---|
| 479 | + /* |
---|
| 480 | + * Offset in source file to start mapping. Must be a multiple of |
---|
| 481 | + * INCFS_DATA_FILE_BLOCK_SIZE |
---|
| 482 | + */ |
---|
| 483 | + __aligned_u64 source_offset; |
---|
| 484 | +}; |
---|
| 485 | + |
---|
| 486 | +/* |
---|
| 487 | + * Get information about the blocks in this file |
---|
| 488 | + * Argument for INCFS_IOC_GET_BLOCK_COUNT |
---|
| 489 | + */ |
---|
| 490 | +struct incfs_get_block_count_args { |
---|
| 491 | + /* Total number of data blocks in the file */ |
---|
| 492 | + __u32 total_data_blocks_out; |
---|
| 493 | + |
---|
| 494 | + /* Number of filled data blocks in the file */ |
---|
| 495 | + __u32 filled_data_blocks_out; |
---|
| 496 | + |
---|
| 497 | + /* Total number of hash blocks in the file */ |
---|
| 498 | + __u32 total_hash_blocks_out; |
---|
| 499 | + |
---|
| 500 | + /* Number of filled hash blocks in the file */ |
---|
| 501 | + __u32 filled_hash_blocks_out; |
---|
| 502 | +}; |
---|
| 503 | + |
---|
| 504 | +/* Description of timeouts for one UID */ |
---|
| 505 | +struct incfs_per_uid_read_timeouts { |
---|
| 506 | + /* UID to apply these timeouts to */ |
---|
| 507 | + __u32 uid; |
---|
| 508 | + |
---|
| 509 | + /* |
---|
| 510 | + * Min time in microseconds to read any block. Note that this doesn't |
---|
| 511 | + * apply to reads which are satisfied from the page cache. |
---|
| 512 | + */ |
---|
| 513 | + __u32 min_time_us; |
---|
| 514 | + |
---|
| 515 | + /* |
---|
| 516 | + * Min time in microseconds to satisfy a pending read. Any pending read |
---|
| 517 | + * which is filled before this time will be delayed so that the total |
---|
| 518 | + * read time >= this value. |
---|
| 519 | + */ |
---|
| 520 | + __u32 min_pending_time_us; |
---|
| 521 | + |
---|
| 522 | + /* |
---|
| 523 | + * Max time in microseconds to satisfy a pending read before the read |
---|
| 524 | + * times out. If set to U32_MAX, defaults to mount options |
---|
| 525 | + * read_timeout_ms * 1000. Must be >= min_pending_time_us |
---|
| 526 | + */ |
---|
| 527 | + __u32 max_pending_time_us; |
---|
| 528 | +}; |
---|
| 529 | + |
---|
| 530 | +/* |
---|
| 531 | + * Get the read timeouts array |
---|
| 532 | + * Argument for INCFS_IOC_GET_READ_TIMEOUTS |
---|
| 533 | + */ |
---|
| 534 | +struct incfs_get_read_timeouts_args { |
---|
| 535 | + /* |
---|
| 536 | + * A pointer to a buffer to fill with the current timeouts |
---|
| 537 | + * |
---|
| 538 | + * Equivalent to struct incfs_per_uid_read_timeouts * |
---|
| 539 | + */ |
---|
| 540 | + __aligned_u64 timeouts_array; |
---|
| 541 | + |
---|
| 542 | + /* Size of above buffer in bytes */ |
---|
| 543 | + __u32 timeouts_array_size; |
---|
| 544 | + |
---|
| 545 | + /* Size used in bytes, or size needed if -ENOMEM returned */ |
---|
| 546 | + __u32 timeouts_array_size_out; |
---|
| 547 | +}; |
---|
| 548 | + |
---|
| 549 | +/* |
---|
| 550 | + * Set the read timeouts array |
---|
| 551 | + * Arguments for INCFS_IOC_SET_READ_TIMEOUTS |
---|
| 552 | + */ |
---|
| 553 | +struct incfs_set_read_timeouts_args { |
---|
| 554 | + /* |
---|
| 555 | + * A pointer to an array containing the new timeouts |
---|
| 556 | + * This will replace any existing timeouts |
---|
| 557 | + * |
---|
| 558 | + * Equivalent to struct incfs_per_uid_read_timeouts * |
---|
| 559 | + */ |
---|
| 560 | + __aligned_u64 timeouts_array; |
---|
| 561 | + |
---|
| 562 | + /* Size of above array in bytes. Must be < 256 */ |
---|
| 563 | + __u32 timeouts_array_size; |
---|
| 564 | +}; |
---|
| 565 | + |
---|
| 566 | +/* |
---|
| 567 | + * Get last read error struct |
---|
| 568 | + * Arguments for INCFS_IOC_GET_LAST_READ_ERROR |
---|
| 569 | + */ |
---|
| 570 | +struct incfs_get_last_read_error_args { |
---|
| 571 | + /* File id of last file that had a read error */ |
---|
| 572 | + incfs_uuid_t file_id_out; |
---|
| 573 | + |
---|
| 574 | + /* Time of last read error, in us, from CLOCK_MONOTONIC */ |
---|
| 575 | + __u64 time_us_out; |
---|
| 576 | + |
---|
| 577 | + /* Index of page that was being read at last read error */ |
---|
| 578 | + __u32 page_out; |
---|
| 579 | + |
---|
| 580 | + /* errno of last read error */ |
---|
| 581 | + __u32 errno_out; |
---|
| 582 | + |
---|
| 583 | + /* uid of last read error */ |
---|
| 584 | + __u32 uid_out; |
---|
| 585 | + |
---|
| 586 | + __u32 reserved1; |
---|
| 587 | + __u64 reserved2; |
---|
| 588 | +}; |
---|
| 589 | + |
---|
334 | 590 | #endif /* _UAPI_LINUX_INCREMENTALFS_H */ |
---|