Re: 5.2.x kernel: WD 8TB USB Drives: Unaligned partial completion (resid=78, sector_sz=512)

From: Damien Le Moal
Date: Mon Aug 12 2019 - 23:47:14 EST

On 2019/08/12 19:12, Martin K. Petersen wrote:
> Justin,
>>> Attached 2 x brand new Western Digital 8TB USB 3.0 drives awhile back
>>> and ran some file copy tests and was getting these warnings-- is
>>> there any way to avoid these warnings? I did confirm with parted
>>> that the partition was aligned but this appears to be something
>>> related to the firmware on the device according to [1] and [2]?
>> sg_vpd_bdc.txt
>> Block device characteristics VPD page (SBC):
>> Nominal rotation rate: 5400 rpm
>> Product type: Not specified
>> Nominal form factor: 3.5 inch
>> ZONED=0
> Damien: What can we do to limit the messages in cases like this? Would
> it make sense to make the residual warning conditional on sd_is_zoned()?

These WD drives are regular disks, not SMR. Making the warning conditional on
sd_is_zoned() will not reduce the amount of messages. REPORT ZONES is the only
command that could result in a resid not being aligned to the block size since
by definition the command reply is composed of 64B zone descriptors. But that
command is now processed through a device method and is not a REQ_OP_XXX
anymore, so as an internal req, it does not go through sd_done() for completion
right ? All other zone commands either have no buffer, or the exact same
requirement as regular disks, expecting a block aligned resid. So I think that
using sd_is_zoned() is not relevant to this problem.

Bottom line: this USB adapter is weird and likely triggers all the unaligned
resid. I do get regularly reports of similar problem with SAS HBAs, all always
fixed with HBA FW updates. Not sure if there is a FW available for these drives.
I will ask internally.

In the mean time, rate limiting or removing the sd_printk() call may be the only
option. Failing all commands with an invalid resid would be safer I guess, but
will at best likely cause a lot of retry on these buggy devices, and break the
drive operation/perfomance completely in the worst case.

Or the usb mass storage device driver could add some silent forced resid
alignment too.

Best regards.

Damien Le Moal
Western Digital Research