Allow WRITE SAME with NDOB bit set but without UNMAP.

This combination was originally forbidden, but allowed at spc4r3.
This commit is contained in:
Alexander Motin 2015-09-24 15:59:08 +00:00
parent 4ef0129a46
commit 6c2acea564
2 changed files with 8 additions and 4 deletions

View File

@ -5808,9 +5808,8 @@ ctl_write_same(struct ctl_scsiio *ctsio)
break; /* NOTREACHED */
}
/* NDOB and ANCHOR flags can be used only together with UNMAP */
if ((byte2 & SWS_UNMAP) == 0 &&
(byte2 & (SWS_NDOB | SWS_ANCHOR)) != 0) {
/* ANCHOR flag can be used only together with UNMAP */
if ((byte2 & SWS_UNMAP) == 0 && (byte2 & SWS_ANCHOR) != 0) {
ctl_set_invalid_field(ctsio, /*sks_valid*/ 1,
/*command*/ 1, /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0);
ctl_done((union ctl_io *)ctsio);

View File

@ -1357,7 +1357,12 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *be_lun,
buf = beio->sg_segs[i].addr;
end = buf + seglen;
for (; buf < end; buf += cbe_lun->blocksize) {
memcpy(buf, io->scsiio.kern_data_ptr, cbe_lun->blocksize);
if (lbalen->flags & SWS_NDOB) {
memset(buf, 0, cbe_lun->blocksize);
} else {
memcpy(buf, io->scsiio.kern_data_ptr,
cbe_lun->blocksize);
}
if (lbalen->flags & SWS_LBDATA)
scsi_ulto4b(lbalen->lba + lba, buf);
lba++;