[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [virtio-comment] Block Device VIRTIO_BLK_F_RO clarification needed.
On Mon, Jan 20, 2020 at 11:21:36AM -0500, Michael S. Tsirkin wrote: > On Mon, Jan 20, 2020 at 11:45:05AM +0000, Damir Shaikhutdinov wrote: > > Hello! > > > > While reading section 5.2 of the spec, I found that VIRTIO_BLK_F_RO feature could use > > some additional clarification regarding handling requests when it was offered. > > > > This RO feature is described as "Device is read only" (Section 5.2.3). There are some explicit requirements for this feature, but they only describe a "write request". > > > > 5.2.5 p3 says "If the VIRTIO_BLK_F_RO feature is set by the device, any write requests will fail." > > > > 5.2.6 says "The type of the request is either a read (VIRTIO_BLK_T_IN), a write (VIRTIO_BLK_T_OUT) ...", so "write request" mentioned in 5.2.5 p3 is VIRTIO_BLK_T_OUT. > > > > 126.96.36.199 says "A device MUST set the status byte to VIRTIO_BLK_S_IOERR for a write request if the VIRTIO_BLK_F_RO > > feature if offered, and MUST NOT write any data." > > > > What is missing here is a requirement for features and other types of requests in case of VIRTIO_BLK_F_RO: > > > > * config.writeback field (guarded by VIRTIO_BLK_F_CONFIG_WCE feature) > > * VIRTIO_BLK_T_ FLUSH (guarded by VIRTIO_BLK_F_FLUSH feature) > > * VIRTIO_BLK_T_DISCARD (guarded by VIRTIO_BLK_F_DISCARD feature) > > * VIRTIO_BLK_T_WRITE_ZEROES (guarded by VIRTIO_BLK_F_WRITE_ZEROES feature) > > > > Configuration field, requests and features described above make no sense in presence of VIRTIO_BLK_F_RO. > > > > This can be clarified in several ways, for example: > > > > 1. Device should not offer CONFIG_WCE, FLUSH, DISCARD and WRITE_ZEROES features if it offers RO feature (partially contradicts 188.8.131.52 "Device SHOULD always offer VIRTIO_BLK_F_FLUSH") > > 2. Device must set the status byte to IOERR for FLUSH, DISCARD and WRITE_ZEROES requests if it offers RO feature. > > > > > > What do you think about that? > > I guess flush can even be allowed, it's harmless if nothing is written, > right? I agree. There seems to be no benefit in failing it and there's a small chance that some drivers could get upset if it fails (typically when a common code path submits a flush request and expects it to succeed). > I agree DISCARD and WRITE_ZEROES must fail. And set VIRTIO_BLK_S_IOERR > I guess? Yes. > It's too late to disallow configurations such as a combination of VIRTIO_BLK_F_CONFIG_WCE > and VIRTIO_BLK_F_RO, devices out there might be setting this combination. Yes. Stefan
Description: PGP signature