From: Bart Van Assche Date: Thu, 8 Mar 2018 20:57:41 +0000 (-0800) Subject: Linux: Add support for the zoned block device ioctls X-Git-Tag: VALGRIND_3_14_0~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a05d86e562006c4823d7187d9cd5806324ee8d36;p=thirdparty%2Fvalgrind.git Linux: Add support for the zoned block device ioctls 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. --- diff --git a/NEWS b/NEWS index 375751b3e2..4b9824e558 100644 --- 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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index beb9dff6b1..b103d13d48 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -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 */ diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index cfec2350b5..ae3ad7019a 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -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 ---*/ /*--------------------------------------------------------------------*/