On Mon, Jan 24, 2022 at 06:06:28PM +0800, Ming Lei wrote: > If backing file's filesystem has implemented ->fallocate(), we think the > loop device can support discard, then pass sb->s_blocksize as > discard_granularity. However, some underlying FS, such as overlayfs, > doesn't set sb->s_blocksize, and causes discard_granularity to be set as > zero, then the warning in __blkdev_issue_discard() is triggered. > > Fix the issue by setting discard_granularity as PAGE_SIZE in this case > since PAGE_SIZE is the most common data unit for FS. sb->s_blocksize really does not mean anything. kstat.blksize might be a better choice, even if it someimes errs on the too large side.