[LTP] [PATCH v2] ioctl_loop06: update loopback block size validation

Li Wang liwang@redhat.com
Fri Mar 14 07:47:41 CET 2025


On Fri, Mar 14, 2025 at 1:52 PM Luis Chamberlain <mcgrof@kernel.org> wrote:

> On Fri, Mar 14, 2025 at 10:24:52AM +0800, Li Wang wrote:
> > Hi Luis,
> >
> > On Fri, Mar 14, 2025 at 6:59 AM Luis Chamberlain <mcgrof@kernel.org>
> wrote:
> >
> > > On Thu, Mar 13, 2025 at 05:24:45PM +0800, Li Wang wrote:
> > > > The kernel commit 47dd6753 ("block/bdev: lift block size
> restrictions to
> > > 64k")
> > > > now supports block sizes larger than PAGE_SIZE, with a new upper
> limit of
> > > > BLK_MAX_BLOCK_SIZE (64K). But ioctl_loop06 still assumes that
> PAGE_SIZE
> > > is the
> > > > maximum allowed block size, causing failures on newer kernels(>=
> 6.14):
> > >
> >
> > Well, this sounds like we need to go back to patch v1:
> >   https://lists.linux.it/pipermail/ltp/2025-March/042599.html
> >
> > Note: LTP has a function tst_kvercmp() for comparing kernel versions.
>
> Close.
>
> BLK_MAX_BLOCK_SIZE may change in the future so the only real way to
> test for an invalid block size is having a check for linux/blkdev.h.
>

Good point.


> I see commit 7c84fa710f75 ("ioprio: use ioprio.h kernel header if it
> exists") is an example of using a kernel header file. I think similar
> thing can be done to use linux/blkdev.h and if you don't have
> HAVE_LINUX_BLKDEV_H then you can define BLK_MAX_BLOCK_SIZE to 64k for
> for older kernels.
>

To precise, if BLK_MAX_BLOCK_SIZE is undefined (in blkdev.h) in older
kernel (e.g. kernel-6.12)  then we define it to 64k.



>
> A more appropriate invalid value would be BLK_MAX_BLOCK_SIZE * 2 as
> non power of 2 values will be outright disallowed.
>

Agreed. Thanks for reviewing.


-- 
Regards,
Li Wang


More information about the ltp mailing list