Problem with VirtIO TRIM/DISCARD?

From: Jeppe Øland
Date: Fri Sep 24 2021 - 17:21:54 EST


I'm experimenting with running VMs on a 4Kn sector array, but I'm
having some issues.
Specifically it seems VirtIO TRIM/DISCARD support may be broken for
non 512B sector sizes.

I started digging, and landed on this commit:
https://github.com/torvalds/linux/commit/af822aa68fbdf0a480a17462ed70232998127453

On line 143 the TRIM/DISCARD size is converted to a sector count - but
it's using a hardcoded sector size of 512.
Shouldn't that be using the actual block size gotten earlier?

Did that code just wipe out a ton of data following the TRIM/DISCARD area?

Regards,
-Jeppe