mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
Fix UNMAP stuck if the last block descriptor in the list is empty.
MFC after: 3 days
This commit is contained in:
parent
9fd573c39d
commit
4a6d9c740a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271949
@ -6059,7 +6059,7 @@ ctl_unmap(struct ctl_scsiio *ctsio)
|
||||
struct scsi_unmap *cdb;
|
||||
struct ctl_ptr_len_flags *ptrlen;
|
||||
struct scsi_unmap_header *hdr;
|
||||
struct scsi_unmap_desc *buf, *end, *range;
|
||||
struct scsi_unmap_desc *buf, *end, *endnz, *range;
|
||||
uint64_t lba;
|
||||
uint32_t num_blocks;
|
||||
int len, retval;
|
||||
@ -6112,6 +6112,7 @@ ctl_unmap(struct ctl_scsiio *ctsio)
|
||||
buf = (struct scsi_unmap_desc *)(hdr + 1);
|
||||
end = buf + len / sizeof(*buf);
|
||||
|
||||
endnz = buf;
|
||||
for (range = buf; range < end; range++) {
|
||||
lba = scsi_8btou64(range->lba);
|
||||
num_blocks = scsi_4btoul(range->length);
|
||||
@ -6121,6 +6122,19 @@ ctl_unmap(struct ctl_scsiio *ctsio)
|
||||
ctl_done((union ctl_io *)ctsio);
|
||||
return (CTL_RETVAL_COMPLETE);
|
||||
}
|
||||
if (num_blocks != 0)
|
||||
endnz = range + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Block backend can not handle zero last range.
|
||||
* Filter it out and return if there is nothing left.
|
||||
*/
|
||||
len = (uint8_t *)endnz - (uint8_t *)buf;
|
||||
if (len == 0) {
|
||||
ctl_set_success(ctsio);
|
||||
ctl_done((union ctl_io *)ctsio);
|
||||
return (CTL_RETVAL_COMPLETE);
|
||||
}
|
||||
|
||||
mtx_lock(&lun->lun_lock);
|
||||
|
Loading…
Reference in New Issue
Block a user