ANDROID: scsi: sd_zbc: Work around non-compliance

ZBC requires that every LBA is associated with a zone. Some zoned
devices do not associate a zone with the last LBA. Let the kernel use
these devices instead of rejecting them as follows:

sd 0:0:0:4: [sde] 59552768 4096-byte logical blocks: (244 GB/227 GiB)
sde: detected capacity change from 0 to 476422144
sd 0:0:0:4: [sde] REPORT ZONES report invalid length 0
sde: failed to revalidate zones
sde: detected capacity change from 476422144 to 0

This patch will be reverted after the firmware bug has been fixed.

Bug: 258289823
Change-Id: Ic7f13d1742bdd144fd4df2d37a3ed3dd93e65a2e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Bart Van Assche
2023-01-13 11:32:06 -08:00
parent 31f50e8abc
commit bbac37faad

View File

@@ -274,6 +274,17 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
while (zone_idx < nr_zones && lba < sdkp->capacity) { while (zone_idx < nr_zones && lba < sdkp->capacity) {
ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true); ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true);
if (ret && zone_idx) {
sd_printk(KERN_WARNING, sdkp,
"ZBC violation: %llu LBAs are not associated with a zone (zone length %llu)\n",
sdkp->capacity - lba, zone_length);
sdkp->capacity = lba;
set_capacity_and_notify(disk,
logical_to_sectors(sdkp->device,
sdkp->capacity));
ret = 0;
break;
}
if (ret) if (ret)
goto out; goto out;