blkzoned.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 _UAPI_BLKZONED_H
  17. #define _UAPI_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_EMPTY
  52. * - ZC2: Implicit Open | BLK_ZONE_COND_IMP_OPEN
  53. * - ZC3: Explicit Open | BLK_ZONE_COND_EXP_OPEN
  54. * - ZC4: Closed | BLK_ZONE_CLOSED
  55. * - ZC5: Full | BLK_ZONE_FULL
  56. * - ZC6: Read Only | BLK_ZONE_READONLY
  57. * - ZC7: Offline | BLK_ZONE_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. * struct blk_zone - Zone descriptor for BLKREPORTZONE ioctl.
  74. *
  75. * @start: Zone start in 512 B sector units
  76. * @len: Zone length in 512 B sector units
  77. * @wp: Zone write pointer location in 512 B sector units
  78. * @type: see enum blk_zone_type for possible values
  79. * @cond: see enum blk_zone_cond for possible values
  80. * @non_seq: Flag indicating that the zone is using non-sequential resources
  81. * (for host-aware zoned block devices only).
  82. * @reset: Flag indicating that a zone reset is recommended.
  83. * @reserved: Padding to 64 B to match the ZBC/ZAC defined zone descriptor size.
  84. *
  85. * start, len and wp use the regular 512 B sector unit, regardless of the
  86. * device logical block size. The overall structure size is 64 B to match the
  87. * ZBC/ZAC defined zone descriptor and allow support for future additional
  88. * zone information.
  89. */
  90. struct blk_zone {
  91. __u64 start; /* Zone start sector */
  92. __u64 len; /* Zone length in number of sectors */
  93. __u64 wp; /* Zone write pointer position */
  94. __u8 type; /* Zone type */
  95. __u8 cond; /* Zone condition */
  96. __u8 non_seq; /* Non-sequential write resources active */
  97. __u8 reset; /* Reset write pointer recommended */
  98. __u8 reserved[36];
  99. };
  100. /**
  101. * struct blk_zone_report - BLKREPORTZONE ioctl request/reply
  102. *
  103. * @sector: starting sector of report
  104. * @nr_zones: IN maximum / OUT actual
  105. * @reserved: padding to 16 byte alignment
  106. * @zones: Space to hold @nr_zones @zones entries on reply.
  107. *
  108. * The array of at most @nr_zones must follow this structure in memory.
  109. */
  110. struct blk_zone_report {
  111. __u64 sector;
  112. __u32 nr_zones;
  113. __u8 reserved[4];
  114. struct blk_zone zones[0];
  115. };
  116. /**
  117. * struct blk_zone_range - BLKRESETZONE ioctl request
  118. * @sector: starting sector of the first zone to issue reset write pointer
  119. * @nr_sectors: Total number of sectors of 1 or more zones to reset
  120. */
  121. struct blk_zone_range {
  122. __u64 sector;
  123. __u64 nr_sectors;
  124. };
  125. /**
  126. * Zoned block device ioctl's:
  127. *
  128. * @BLKREPORTZONE: Get zone information. Takes a zone report as argument.
  129. * The zone report will start from the zone containing the
  130. * sector specified in the report request structure.
  131. * @BLKRESETZONE: Reset the write pointer of the zones in the specified
  132. * sector range. The sector range must be zone aligned.
  133. */
  134. #define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report)
  135. #define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range)
  136. #endif /* _UAPI_BLKZONED_H */