]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Allow WRITE SAME with NDOB bit set but without UNMAP.
authormav <mav@FreeBSD.org>
Thu, 24 Sep 2015 15:59:08 +0000 (15:59 +0000)
committermav <mav@FreeBSD.org>
Thu, 24 Sep 2015 15:59:08 +0000 (15:59 +0000)
This combination was originally forbidden, but allowed at spc4r3.

sys/cam/ctl/ctl.c
sys/cam/ctl/ctl_backend_block.c

index 88337523946ac43851180109273c3ebe2dfac772..8d85bc55a6a493769eb7274954ce53fbf206eb73 100644 (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);
index 2ef5598de6f95100860391649d5e569580145f7c..a37ac7bd05bfb91e26a3be789c23c2ccdbe3dd57 100644 (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++;