Re: [PATCH V3] block: loop:use kstatfs.f_bsize of backing file to set discard granularity
From: Ming Lei <hidden>
Date: 2022-02-08 03:22:56
From: Ming Lei <hidden>
Date: 2022-02-08 03:22:56
On Wed, Jan 26, 2022 at 11:58:30AM +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. Christoph suggested to pass kstatfs.f_bsize as discard granularity, and this way is fine because kstatfs.f_bsize means 'Optimal transfer block size', which still matches with definition of discard granularity. So fix the issue by setting discard_granularity as kstatfs.f_bsize if it is available, otherwise claims discard isn't supported. Cc: Christoph Hellwig <hch@lst.de> Cc: Vivek Goyal <vgoyal@redhat.com> Reported-by: Pei Zhang <redacted> Signed-off-by: Ming Lei <redacted> --- V3: - following Christoph's suggestion to not claim discard support if vfs_statfs() fails
Hi Jens, Any chance to merge it to v5.17? Thanks, Ming