Il 19/11/2013 18:23, ronnie sahlberg ha scritto: > +#define SCSI_WRITE_SAME_MAX 524288 > ... > + data->iov.iov_len = MIN(data->nb_sectors * 512, SCSI_WRITE_SAME_MAX); > > I don't think you should just clamp the data to 512k, instead I think > you should report the 512k max write same size through > BlockLimitsVPD/MaximumWriteSameLength to the initiator. > Then instead of clamping the write to MIN() you return a check > condition if the initiator sends too much.
This would not work if the BlockDriverState has a large write_same_alignment (e.g. a qcow2 file with 1 MB cluster size). The only purpose of the above clamping is to avoid using too much memory when emulating WRITE SAME; there is no intrinsic limit in the length of a WRITE SAME command that QEMU supports. There is no particular need to have 1:1 mapping from guest to host, for two reasons: (1) even though this is not a fast path, every additional round trip hurts (2) the code in this patch ensures that the 512 kb writes are serialized. If the guest works around the maximum WRITE SAME length by sending many parallel requests, there will be no speed improvement, only a lot more stress on the storage. Paolo