blkzoned.h 5.0 KB

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