All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/4] libswap: add known swap supported fs check
Date: Mon, 22 Jan 2024 11:57:34 +0100	[thread overview]
Message-ID: <20240122105734.GA95077@pevik> (raw)
In-Reply-To: <CAEemH2c7_pvi1imV3pb2oc3g_ZGSTvBsKd=OYE=mSW2g=Z-BEA@mail.gmail.com>

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

> > Hi Li, Cyril,

> > > This introduce an enhancement to the library's is_swap_supported
> > > function to check for filesystem compatibility before attempting
> > > to create and enable a swap file.  A list of supported filesystems
> > > is added (ext2, ext3, ext4, xfs, vfat, exfat, ntfs), and a check
> > > against this list is performed to ensure that the swap operations
> > > are only attempted on known compatible filesystems.

> > > If the make_swapfile function fails, the error handling is now
> > > more descriptive: it distinguishes between failures due to the
> > > filesystem not supporting swap files and other types of failures.
> > > Similarly, when attempting to enable the swap file with swapon,
> > > the patch ensures that clearer error messages are provided in
> > > cases where the operation is not supported by the filesystem.

> > > Signed-off-by: Li Wang <liwang@redhat.com>
> > > ---
> > >  libs/libltpswap/libswap.c | 33 ++++++++++++++++++++++++++-------
> > >  1 file changed, 26 insertions(+), 7 deletions(-)

> > > diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c
> > > index 13610709e..623f2fb3c 100644
> > > --- a/libs/libltpswap/libswap.c
> > > +++ b/libs/libltpswap/libswap.c
> > > @@ -12,6 +12,17 @@
> > >  #include "libswap.h"
> > >  #include "lapi/syscalls.h"

> > > +static const char *const swap_supported_fs[] = {
> > > +     "ext2",
> > > +     "ext3",
> > > +     "ext4",
> > > +     "xfs",
> > > +     "vfat",
> > > +     "exfat",
> > > +     "ntfs",
> > > +     NULL
> > > +};
> > > +
> > >  /*
> > >   * Make a swap file
> > >   */
> > > @@ -40,23 +51,31 @@ int make_swapfile(const char *swapfile, int safe)
> > >   */
> > >  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


> Interesting, can you try with the below command manually to see if swapfile
> is supported correctly on the BTRFS?
> "cut from man 5 btrfs"

>           # truncate -s 0 swapfile
>           # chattr +C swapfile
>           # fallocate -l 2G swapfile
>           # chmod 0600 swapfile
>           # mkswap swapfile
>           # swapon swapfile

It works (tested on openSUSE Tumbleweed with 6.6.11 which also reported FIBMAP
ioctl is NOT supported), on file created with:

dd if=/dev/zero of=swapfile bs=400M count=1

# swapon -s
Filename				Type		Size		Used		Priority
/dev/vda3                               partition	2098152		34148		-2
/root/swapfile                          file		2097148		0		-3

# df -hT .
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/vda2      btrfs   28G   21G  1.4G  95% /root

Kind regards,
Petr

> > Am I wrong or could it be solved with FIEMAP (<linux/fiemap.h>)?
> > If yes, I wonder if we should fallback on btrfs when FIBMAP is missing

> > https://www.kernel.org/doc/Documentation/filesystems/fiemap.txt

> > https://unix.stackexchange.com/questions/623859/how-do-you-find-the-physical-offset-for-a-file-in-btrfs

> > Kind regards,
> > Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-01-22 10:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22  7:29 [LTP] [PATCH 1/4] libswap: add known swap supported fs check Li Wang
2024-01-22  7:29 ` [LTP] [PATCH 2/4] swapon01: Test on all filesystems Li Wang
2024-01-22  7:29 ` [LTP] [PATCH 3/4] swapon01: Improving test with memory limits and swap reporting Li Wang
2024-01-22  9:08   ` Petr Vorel
2024-01-22  7:29 ` [LTP] [PATCH 4/4] libswap: add Btrfs noCOW attribute setting for swap files Li Wang
2024-01-22  8:40   ` Petr Vorel
2024-01-22  8:47     ` Petr Vorel
2024-01-22  9:20       ` Li Wang
2024-01-22  9:04     ` Li Wang
2024-01-22  9:03 ` [LTP] [PATCH 1/4] libswap: add known swap supported fs check Petr Vorel
2024-01-22  9:12   ` Li Wang
2024-01-22 10:57     ` Petr Vorel [this message]
2024-01-22  9:41   ` Petr Vorel
2024-01-22 10:22     ` Li Wang
2024-01-22  9:13 ` Petr Vorel
2024-01-22  9:32   ` Li Wang
2024-01-22 11:03     ` Petr Vorel
2024-01-22 14:23       ` Li Wang
2024-01-22 20:23         ` Petr Vorel
2024-01-23  5:55           ` Li Wang
2024-01-23  7:30             ` Li Wang
2024-01-23  7:48               ` Petr Vorel
2024-01-23 12:04                 ` Li Wang
2024-01-23 12:31                   ` Petr Vorel
2024-01-23 13:10                     ` Li Wang
2024-01-23 15:45                       ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240122105734.GA95077@pevik \
    --to=pvorel@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.