Re: [LTP] [PATCH 1/4] libswap: add known swap supported fs check

Li Wang
2024-01-22T10:23:11Z

On Mon, Jan 22, 2024 at 5:41 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li, Cyril,
>
> > Hi Li, Cyril,
> ...
> > > void is_swap_supported(const char *filename)
> > > {
> > > + int i, sw_support = 0;
> > > int fibmap = tst_fibmap(filename);
> > Just a note unrelated to this patchset. When testing on SLES kernel
> based on
> > 5.3.18 we still get TCONF due missing FIBMAP ioctl support:
>
> > tst_test.c:1669: TINFO: === Testing on btrfs ===
> > tst_test.c:1118: TINFO: Formatting /dev/loop0 with btrfs opts='' extra
> opts=''
> > tst_test.c:1132: TINFO: Mounting /dev/loop0 to
> /tmp/LTP_swazaqF1L/mntpoint fstyp=btrfs flags=0
> > tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
> > libswap.c:45: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01
>
> > libswap.c:114: TCONF: Swapfile on btrfs not implemented
>
> Hm, what makes me wonder is that btrfs does not support FIBMAP even on
> current
> openSUSE Tumbleweed with 6.7.0 kernel:
>

What we made use of FIBMAP is just to determine the
file's blocks are contiguous on the disk then we can assume
the swapfile support or not with that filesystem.

As you mentioned, maybe FIEMAP is an additional way
to check if a file's blocks are contiguous, I guess we might
need to improve the check in a simple function with both
FIEMAP and FIBMAP to guarantee we get the necessary info.

And yes, it can be achieved in a separate patch.

>
> # TMPDIR=/var/tmp/ LTP_SINGLE_FS_TYPE=btrfs ./swapon01
> ...
> tst_test.c:1669: TINFO: === Testing on btrfs ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with btrfs opts='' extra
> opts=''
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to
> /var/tmp/LTP_swaMBctpq/mntpoint fstyp=btrfs flags=0
> tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
> libswap.c:45: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01
>
> libswap.c:114: TCONF: Swapfile on btrfs not implemented
>
> $ df -hT /var/tmp
> Filesystem Type Size Used Avail Use% Mounted on
> /dev/vda2 btrfs 28G 19G 3.3G 86% /var
>
> $ uname -r
> 6.7.0-9.gaedda80-default
>
> I thought the problem is that underlying fs is btrfs, but testing on Debian
> on 6.6.x with TMPDIR on ext4 does not bring FIBMAP support:
>
> # TMPDIR=/var/tmp LTP_SINGLE_FS_TYPE=btrfs /opt/ltp/testcases/bin/swapon01
>
> tst_test.c:1669: TINFO: === Testing on btrfs ===
> tst_test.c:1117: TINFO: Formatting /dev/loop0 with btrfs opts='' extra
> opts=''
> tst_test.c:1131: TINFO: Mounting /dev/loop0 to
> /var/tmp/LTP_swaZf8FN6/mntpoint fstyp=btrfs flags=0
> tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
> libswap.c:45: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01
>
> libswap.c:114: TCONF: Swapfile on btrfs not implemented
>
> ...
>
> Kind regards,
> Petr
>
>

--
Regards,
Li Wang