On Mon, Jan 24, 2022 at 06:05:07AM -0800, Christoph Hellwig wrote: > 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. [ CC linux-unionfs, Miklos ] This should work well for overlayfs too. I see it just passes the query to underlying filesystem and that should report optimal I/O size. On my overlayfs instance, I see. # stat -c '%o' foo.txt 4096 Vivek