]> xenbits.xensource.com Git - xen.git/commit
public/io/blkif.h: try to fix the semantics of sector based quantities
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 4 Apr 2019 11:40:02 +0000 (12:40 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 4 Apr 2019 13:11:34 +0000 (14:11 +0100)
commit67e1c050e36b2c9900cca83618e56189effbad98
treeeabc932ab5b4555235260cb744069a3478139189
parent0763cd2687897b55e7a87ff6e77f785136bcc2de
public/io/blkif.h: try to fix the semantics of sector based quantities

The semantics of sector based quantities, such as first_sect and last_sect
in blkif_request_segment, and the value of "sectors" in the backend info
in xenstore have become confused. Some comments in the header suggest they
should be supplied/interpreted strictly in terms of 512-byte units, others
suggest they should be scaled by the value of "sector-size" i.e. the
logical block size of the underlying backend storage.
This confusion has caused mixed semantics to become ingrained in frontend
implementations. For instance Linux xen-blkfront.c contains code such as:

    fsect = offset >> 9;
    lsect = fsect + (len >> 9) - 1;

whereas the Windows XENVBD frontend contains the following equivalent code:

    Segment->FirstSector = (UCHAR)((Offset + SectorSize - 1) / SectorSize);
    *SectorsNow = __min(SectorsLeft, SectorsPerPage - Segment->FirstSector);
    Segment->LastSector = (UCHAR)(Segment->FirstSector + *SectorsNow - 1);

(where SectorSize is the "sector-size" value advertized in xenstore).

Thus it has become unsafe for a backend to set "sector-size" to anything
other than 512 as it does not know which way the frontend is coded.

This patch is intended to clarify the situation and also introduce a
mechanism to allow logical block sizes of more than 512 to be supported...

A new frontend feature node is specified: 'feature-large-sector-size'.
If this node is present and set to "1" then it means that frontend is
coded to supply and interpret all sector based quantities in terms of the
the advertized "sector-size" value rather than a hardcoded size of 512.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
xen/include/public/io/blkif.h