]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Linux: Add support for the zoned block device ioctls
authorBart Van Assche <bart.vanassche@wdc.com>
Thu, 8 Mar 2018 20:57:41 +0000 (12:57 -0800)
committerBart Van Assche <bart.vanassche@wdc.com>
Mon, 12 Mar 2018 17:46:15 +0000 (10:46 -0700)
Shingled magnetic recording drives support a command set called ZBC
(Zoned Block Commands). Two new ioctls have been added to the Linux
kernel to support such drives, namely VKI_BLKREPORTZONE and
VKI_BLKRESETZONE. Add support to Valgrind for these ioctls.

NEWS
coregrind/m_syswrap/syswrap-linux.c
include/vki/vki-linux.h

diff --git a/NEWS b/NEWS
index 375751b3e2560d3a3f0151a39aa69bd7f762c5b1..4b9824e558e27d7184e6b323e83404f8c282cbe5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -97,6 +97,7 @@ where XXXXXX is the bug number as listed below.
 n-i-bz  Fix missing workq_ops operations (macOS)
 n-i-bz  fix bug in strspn replacement
 n-i-bz  Add support for the Linux BLKFLSBUF ioctl
+n-i-bz  Add support for the Linux BLKREPORTZONE and BLKRESETZONE ioctls
 
 Release 3.13.0 (15 June 2017)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index beb9dff6b1ab47c32b2ccbbe829cf85156582bc5..b103d13d4829754ee3b05e90cbdc83b10c2e4b1c 100644 (file)
@@ -6919,6 +6919,14 @@ PRE(sys_ioctl)
    case VKI_BLKDISCARDZEROES:
       PRE_MEM_WRITE( "ioctl(BLKDISCARDZEROES)", ARG3, sizeof(vki_uint));
       break;
+   case VKI_BLKREPORTZONE:
+      PRE_MEM_READ("ioctl(BLKREPORTZONE)", ARG3,
+                  sizeof(struct vki_blk_zone_report));
+      break;
+   case VKI_BLKRESETZONE:
+      PRE_MEM_READ("ioctl(BLKRESETZONE)", ARG3,
+                  sizeof(struct vki_blk_zone_range));
+      break;
 
       /* Hard disks */
    case VKI_HDIO_GETGEO: /* 0x0301 */
@@ -9672,6 +9680,14 @@ POST(sys_ioctl)
    case VKI_BLKDISCARDZEROES:
       POST_MEM_WRITE(ARG3, sizeof(vki_uint));
       break;
+   case VKI_BLKREPORTZONE: {
+      const struct vki_blk_zone_report *zr = (void *)ARG3;
+
+      POST_MEM_WRITE(ARG3, sizeof(*zr) + zr->nr_zones * sizeof(zr->zones[0]));
+      break;
+   }
+   case VKI_BLKRESETZONE:
+      break;
 
       /* Hard disks */
    case VKI_HDIO_GETGEO: /* 0x0301 */
index cfec2350b590c716ca96ed45dda308237c819c28..ae3ad7019a82ef6a4e144aa3fe07fd0e7de9daf7 100644 (file)
@@ -4760,6 +4760,36 @@ struct vki_serial_struct {
 
 #endif // __VKI_LINUX_H
 
+//----------------------------------------------------------------------
+// From linux-4.10/include/uapi/linux/blkzoned.h
+//----------------------------------------------------------------------
+
+struct vki_blk_zone {
+       __vki_u64       start;
+       __vki_u64       len;
+       __vki_u64       wp;
+       __vki_u8        type;
+       __vki_u8        cond;
+       __vki_u8        non_seq;
+       __vki_u8        reset;
+       __vki_u8        reserved[36];
+};
+
+struct vki_blk_zone_report {
+       __vki_u64               sector;
+       __vki_u32               nr_zones;
+       __vki_u8                reserved[4];
+       struct vki_blk_zone     zones[0];
+};
+
+struct vki_blk_zone_range {
+       __vki_u64               sector;
+       __vki_u64               nr_sectors;
+};
+
+#define VKI_BLKREPORTZONE      _VKI_IOWR(0x12, 130, struct vki_blk_zone_report)
+#define VKI_BLKRESETZONE       _VKI_IOW(0x12, 131, struct vki_blk_zone_range)
+
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/