Skip to content

Commit

Permalink
WRITE SAME 10/16 with TL=0 means write x upto the end; this is also
Browse files Browse the repository at this point in the history
limited to MAX_WS_LEN
  • Loading branch information
folkertvanheusden committed Oct 10, 2024
1 parent 68986e9 commit a9ff96a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,20 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
if (ok) {
scsi::scsi_rw_result rc = rw_ok;

const uint64_t size_in_blocks = b->get_size_in_blocks();

if (transfer_length == 0) {
for(uint64_t i=lba; i<b->get_size_in_blocks() && rc == rw_ok; i++) {
rc = response.r2t.write_same_is_unmap ?
trim(i, 1) :
write(i, 1, data.first);
if (size_in_blocks - lba > MAX_WS_LEN) {
DOLOG(logging::ll_debug, "scsi::validate_request", "-", "WRITE_SAME maximum number of blocks for TL=0");
response.sense_data = error_invalid_field();
ok = false;
}
else {
for(uint64_t i=lba; i<b->get_size_in_blocks() && rc == rw_ok; i++) {
rc = response.r2t.write_same_is_unmap ?
trim(i, 1) :
write(i, 1, data.first);
}
}
}
else {
Expand Down

0 comments on commit a9ff96a

Please sign in to comment.