logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

blkzoned.h (6492B)


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