1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 2 /* 3 * Zoned block devices handling. 3 * Zoned block devices handling. 4 * 4 * 5 * Copyright (C) 2015 Seagate Technology PLC 5 * Copyright (C) 2015 Seagate Technology PLC 6 * 6 * 7 * Written by: Shaun Tancheff <shaun.tancheff@ 7 * Written by: Shaun Tancheff <shaun.tancheff@seagate.com> 8 * 8 * 9 * Modified by: Damien Le Moal <damien.lemoal@ 9 * Modified by: Damien Le Moal <damien.lemoal@hgst.com> 10 * Copyright (C) 2016 Western Digital 10 * Copyright (C) 2016 Western Digital 11 * 11 * 12 * This file is licensed under the terms of t 12 * This file is licensed under the terms of the GNU General Public 13 * License version 2. This program is licensed 13 * License version 2. This program is licensed "as is" without any 14 * warranty of any kind, whether express or im 14 * warranty of any kind, whether express or implied. 15 */ 15 */ 16 #ifndef _UAPI_BLKZONED_H 16 #ifndef _UAPI_BLKZONED_H 17 #define _UAPI_BLKZONED_H 17 #define _UAPI_BLKZONED_H 18 18 19 #include <linux/types.h> 19 #include <linux/types.h> 20 #include <linux/ioctl.h> 20 #include <linux/ioctl.h> 21 21 22 /** 22 /** 23 * enum blk_zone_type - Types of zones allowed 23 * enum blk_zone_type - Types of zones allowed in a zoned device. 24 * 24 * 25 * @BLK_ZONE_TYPE_CONVENTIONAL: The zone has n 25 * @BLK_ZONE_TYPE_CONVENTIONAL: The zone has no write pointer and can be writen 26 * randomly. Zone 26 * randomly. Zone reset has no effect on the zone. 27 * @BLK_ZONE_TYPE_SEQWRITE_REQ: The zone must 27 * @BLK_ZONE_TYPE_SEQWRITE_REQ: The zone must be written sequentially 28 * @BLK_ZONE_TYPE_SEQWRITE_PREF: The zone can 28 * @BLK_ZONE_TYPE_SEQWRITE_PREF: The zone can be written non-sequentially 29 * 29 * 30 * Any other value not defined is reserved and 30 * Any other value not defined is reserved and must be considered as invalid. 31 */ 31 */ 32 enum blk_zone_type { 32 enum blk_zone_type { 33 BLK_ZONE_TYPE_CONVENTIONAL = 0x1, 33 BLK_ZONE_TYPE_CONVENTIONAL = 0x1, 34 BLK_ZONE_TYPE_SEQWRITE_REQ = 0x2, 34 BLK_ZONE_TYPE_SEQWRITE_REQ = 0x2, 35 BLK_ZONE_TYPE_SEQWRITE_PREF = 0x3, 35 BLK_ZONE_TYPE_SEQWRITE_PREF = 0x3, 36 }; 36 }; 37 37 38 /** 38 /** 39 * enum blk_zone_cond - Condition [state] of a 39 * enum blk_zone_cond - Condition [state] of a zone in a zoned device. 40 * 40 * 41 * @BLK_ZONE_COND_NOT_WP: The zone has no writ 41 * @BLK_ZONE_COND_NOT_WP: The zone has no write pointer, it is conventional. 42 * @BLK_ZONE_COND_EMPTY: The zone is empty. 42 * @BLK_ZONE_COND_EMPTY: The zone is empty. 43 * @BLK_ZONE_COND_IMP_OPEN: The zone is open, 43 * @BLK_ZONE_COND_IMP_OPEN: The zone is open, but not explicitly opened. 44 * @BLK_ZONE_COND_EXP_OPEN: The zones was expl 44 * @BLK_ZONE_COND_EXP_OPEN: The zones was explicitly opened by an 45 * OPEN ZONE command. 45 * OPEN ZONE command. 46 * @BLK_ZONE_COND_CLOSED: The zone was [explic 46 * @BLK_ZONE_COND_CLOSED: The zone was [explicitly] closed after writing. 47 * @BLK_ZONE_COND_FULL: The zone is marked as 47 * @BLK_ZONE_COND_FULL: The zone is marked as full, possibly by a zone 48 * FINISH ZONE command. 48 * FINISH ZONE command. 49 * @BLK_ZONE_COND_READONLY: The zone is read-o 49 * @BLK_ZONE_COND_READONLY: The zone is read-only. 50 * @BLK_ZONE_COND_OFFLINE: The zone is offline 50 * @BLK_ZONE_COND_OFFLINE: The zone is offline (sectors cannot be read/written). 51 * 51 * 52 * The Zone Condition state machine in the ZBC 52 * The Zone Condition state machine in the ZBC/ZAC standards maps the above 53 * deinitions as: 53 * deinitions as: 54 * - ZC1: Empty | BLK_ZONE_COND_EMPT !! 54 * - ZC1: Empty | BLK_ZONE_EMPTY 55 * - ZC2: Implicit Open | BLK_ZONE_COND_IMP_ 55 * - ZC2: Implicit Open | BLK_ZONE_COND_IMP_OPEN 56 * - ZC3: Explicit Open | BLK_ZONE_COND_EXP_ 56 * - ZC3: Explicit Open | BLK_ZONE_COND_EXP_OPEN 57 * - ZC4: Closed | BLK_ZONE_COND_CLOS !! 57 * - ZC4: Closed | BLK_ZONE_CLOSED 58 * - ZC5: Full | BLK_ZONE_COND_FULL !! 58 * - ZC5: Full | BLK_ZONE_FULL 59 * - ZC6: Read Only | BLK_ZONE_COND_READ !! 59 * - ZC6: Read Only | BLK_ZONE_READONLY 60 * - ZC7: Offline | BLK_ZONE_COND_OFFL !! 60 * - ZC7: Offline | BLK_ZONE_OFFLINE 61 * 61 * 62 * Conditions 0x5 to 0xC are reserved by the c 62 * Conditions 0x5 to 0xC are reserved by the current ZBC/ZAC spec and should 63 * be considered invalid. 63 * be considered invalid. 64 */ 64 */ 65 enum blk_zone_cond { 65 enum blk_zone_cond { 66 BLK_ZONE_COND_NOT_WP = 0x0, 66 BLK_ZONE_COND_NOT_WP = 0x0, 67 BLK_ZONE_COND_EMPTY = 0x1, 67 BLK_ZONE_COND_EMPTY = 0x1, 68 BLK_ZONE_COND_IMP_OPEN = 0x2, 68 BLK_ZONE_COND_IMP_OPEN = 0x2, 69 BLK_ZONE_COND_EXP_OPEN = 0x3, 69 BLK_ZONE_COND_EXP_OPEN = 0x3, 70 BLK_ZONE_COND_CLOSED = 0x4, 70 BLK_ZONE_COND_CLOSED = 0x4, 71 BLK_ZONE_COND_READONLY = 0xD, 71 BLK_ZONE_COND_READONLY = 0xD, 72 BLK_ZONE_COND_FULL = 0xE, 72 BLK_ZONE_COND_FULL = 0xE, 73 BLK_ZONE_COND_OFFLINE = 0xF, 73 BLK_ZONE_COND_OFFLINE = 0xF, 74 }; 74 }; 75 75 76 /** 76 /** 77 * enum blk_zone_report_flags - Feature flags 77 * enum blk_zone_report_flags - Feature flags of reported zone descriptors. 78 * 78 * 79 * @BLK_ZONE_REP_CAPACITY: Zone descriptor has 79 * @BLK_ZONE_REP_CAPACITY: Zone descriptor has capacity field. 80 */ 80 */ 81 enum blk_zone_report_flags { 81 enum blk_zone_report_flags { 82 BLK_ZONE_REP_CAPACITY = (1 << 0), 82 BLK_ZONE_REP_CAPACITY = (1 << 0), 83 }; 83 }; 84 84 85 /** 85 /** 86 * struct blk_zone - Zone descriptor for BLKRE 86 * struct blk_zone - Zone descriptor for BLKREPORTZONE ioctl. 87 * 87 * 88 * @start: Zone start in 512 B sector units 88 * @start: Zone start in 512 B sector units 89 * @len: Zone length in 512 B sector units 89 * @len: Zone length in 512 B sector units 90 * @wp: Zone write pointer location in 512 B s 90 * @wp: Zone write pointer location in 512 B sector units 91 * @type: see enum blk_zone_type for possible 91 * @type: see enum blk_zone_type for possible values 92 * @cond: see enum blk_zone_cond for possible 92 * @cond: see enum blk_zone_cond for possible values 93 * @non_seq: Flag indicating that the zone is 93 * @non_seq: Flag indicating that the zone is using non-sequential resources 94 * (for host-aware zoned block devic 94 * (for host-aware zoned block devices only). 95 * @reset: Flag indicating that a zone reset i 95 * @reset: Flag indicating that a zone reset is recommended. 96 * @resv: Padding for 8B alignment. 96 * @resv: Padding for 8B alignment. 97 * @capacity: Zone usable capacity in 512 B se 97 * @capacity: Zone usable capacity in 512 B sector units 98 * @reserved: Padding to 64 B to match the ZBC 98 * @reserved: Padding to 64 B to match the ZBC, ZAC and ZNS defined zone 99 * descriptor size. 99 * descriptor size. 100 * 100 * 101 * start, len, capacity and wp use the regular 101 * start, len, capacity and wp use the regular 512 B sector unit, regardless 102 * of the device logical block size. The overa 102 * of the device logical block size. The overall structure size is 64 B to 103 * match the ZBC, ZAC and ZNS defined zone des 103 * match the ZBC, ZAC and ZNS defined zone descriptor and allow support for 104 * future additional zone information. 104 * future additional zone information. 105 */ 105 */ 106 struct blk_zone { 106 struct blk_zone { 107 __u64 start; /* Zone start 107 __u64 start; /* Zone start sector */ 108 __u64 len; /* Zone length 108 __u64 len; /* Zone length in number of sectors */ 109 __u64 wp; /* Zone write 109 __u64 wp; /* Zone write pointer position */ 110 __u8 type; /* Zone type * 110 __u8 type; /* Zone type */ 111 __u8 cond; /* Zone condit 111 __u8 cond; /* Zone condition */ 112 __u8 non_seq; /* Non-sequent 112 __u8 non_seq; /* Non-sequential write resources active */ 113 __u8 reset; /* Reset write 113 __u8 reset; /* Reset write pointer recommended */ 114 __u8 resv[4]; 114 __u8 resv[4]; 115 __u64 capacity; /* Zone capaci 115 __u64 capacity; /* Zone capacity in number of sectors */ 116 __u8 reserved[24]; 116 __u8 reserved[24]; 117 }; 117 }; 118 118 119 /** 119 /** 120 * struct blk_zone_report - BLKREPORTZONE ioct 120 * struct blk_zone_report - BLKREPORTZONE ioctl request/reply 121 * 121 * 122 * @sector: starting sector of report 122 * @sector: starting sector of report 123 * @nr_zones: IN maximum / OUT actual 123 * @nr_zones: IN maximum / OUT actual 124 * @flags: one or more flags as defined by enu 124 * @flags: one or more flags as defined by enum blk_zone_report_flags. 125 * @zones: Space to hold @nr_zones @zones entr 125 * @zones: Space to hold @nr_zones @zones entries on reply. 126 * 126 * 127 * The array of at most @nr_zones must follow 127 * The array of at most @nr_zones must follow this structure in memory. 128 */ 128 */ 129 struct blk_zone_report { 129 struct blk_zone_report { 130 __u64 sector; 130 __u64 sector; 131 __u32 nr_zones; 131 __u32 nr_zones; 132 __u32 flags; 132 __u32 flags; 133 struct blk_zone zones[]; !! 133 struct blk_zone zones[0]; 134 }; 134 }; 135 135 136 /** 136 /** 137 * struct blk_zone_range - BLKRESETZONE/BLKOPE 137 * struct blk_zone_range - BLKRESETZONE/BLKOPENZONE/ 138 * BLKCLOSEZONE/BLKFIN 138 * BLKCLOSEZONE/BLKFINISHZONE ioctl 139 * requests 139 * requests 140 * @sector: Starting sector of the first zone 140 * @sector: Starting sector of the first zone to operate on. 141 * @nr_sectors: Total number of sectors of all 141 * @nr_sectors: Total number of sectors of all zones to operate on. 142 */ 142 */ 143 struct blk_zone_range { 143 struct blk_zone_range { 144 __u64 sector; 144 __u64 sector; 145 __u64 nr_sectors; 145 __u64 nr_sectors; 146 }; 146 }; 147 147 148 /** 148 /** 149 * Zoned block device ioctl's: 149 * Zoned block device ioctl's: 150 * 150 * 151 * @BLKREPORTZONE: Get zone information. Takes 151 * @BLKREPORTZONE: Get zone information. Takes a zone report as argument. 152 * The zone report will start 152 * The zone report will start from the zone containing the 153 * sector specified in the rep 153 * sector specified in the report request structure. 154 * @BLKRESETZONE: Reset the write pointer of t 154 * @BLKRESETZONE: Reset the write pointer of the zones in the specified 155 * sector range. The sector ran 155 * sector range. The sector range must be zone aligned. 156 * @BLKGETZONESZ: Get the device zone size in 156 * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors. 157 * @BLKGETNRZONES: Get the total number of zon 157 * @BLKGETNRZONES: Get the total number of zones of the device. 158 * @BLKOPENZONE: Open the zones in the specifi 158 * @BLKOPENZONE: Open the zones in the specified sector range. 159 * The 512 B sector range must b 159 * The 512 B sector range must be zone aligned. 160 * @BLKCLOSEZONE: Close the zones in the speci 160 * @BLKCLOSEZONE: Close the zones in the specified sector range. 161 * The 512 B sector range must 161 * The 512 B sector range must be zone aligned. 162 * @BLKFINISHZONE: Mark the zones as full in t 162 * @BLKFINISHZONE: Mark the zones as full in the specified sector range. 163 * The 512 B sector range must 163 * The 512 B sector range must be zone aligned. 164 */ 164 */ 165 #define BLKREPORTZONE _IOWR(0x12, 130, struc 165 #define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) 166 #define BLKRESETZONE _IOW(0x12, 131, struct 166 #define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range) 167 #define BLKGETZONESZ _IOR(0x12, 132, __u32) 167 #define BLKGETZONESZ _IOR(0x12, 132, __u32) 168 #define BLKGETNRZONES _IOR(0x12, 133, __u32) 168 #define BLKGETNRZONES _IOR(0x12, 133, __u32) 169 #define BLKOPENZONE _IOW(0x12, 134, struct 169 #define BLKOPENZONE _IOW(0x12, 134, struct blk_zone_range) 170 #define BLKCLOSEZONE _IOW(0x12, 135, struct 170 #define BLKCLOSEZONE _IOW(0x12, 135, struct blk_zone_range) 171 #define BLKFINISHZONE _IOW(0x12, 136, struct 171 #define BLKFINISHZONE _IOW(0x12, 136, struct blk_zone_range) 172 172 173 #endif /* _UAPI_BLKZONED_H */ 173 #endif /* _UAPI_BLKZONED_H */ 174 174
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.