From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] swapoff01.c: Adjust blocks size base on pagesize
Date: Thu, 22 Feb 2024 14:50:38 +0100 [thread overview]
Message-ID: <ZddRLm8zpX-wKBGe@yuki> (raw)
In-Reply-To: <ZddOKzhl1semChgB@wegao.166.144.58>
Hi!
> > Isn't this more about Btrfs though? Looking at the make_swapfile() we do
> > use statvfs to get filesystem block size and if that is Btrfs with 64k
> > blocks we end up with swapfile of a size of 4GB that sounds like a bit
> > too much I guess.
> >
>
> Sorry for confusing. It should caused by block size instead of page size.
> The code change should change like following, but i suppose you will not agree
> on this solution, correct?
>
> --- a/testcases/kernel/syscalls/swapoff/swapoff01.c
> +++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
> @@ -12,6 +12,7 @@
> #include <unistd.h>
> #include <errno.h>
> #include <stdlib.h>
> +#include <sys/statvfs.h>
>
> #include "tst_test.h"
> #include "lapi/syscalls.h"
> @@ -44,8 +45,21 @@ static void setup(void)
> {
> is_swap_supported(TEST_FILE);
>
> - if (make_swapfile(SWAP_FILE, 65536, 1))
> + struct statvfs fs_info;
> + unsigned long blk_size;
> + if (statvfs(".", &fs_info) == -1)
> + tst_brk(TBROK, "Failed to get statvfs info");
> +
> + blk_size = fs_info.f_bsize;
> +
> + int blocks = 65535;
> +
> + if (blk_size > 4096)
> + blocks = 65535 * 4096 / blk_size;
> +
> + if (make_swapfile(SWAP_FILE, blocks, 1))
> tst_brk(TBROK, "Failed to create file for swap");
> +
> }
It may be easier to change the make_swapfile() function to accept
megabytes instead of working around it like this.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-02-22 13:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 4:41 [LTP] [PATCH v1] swapoff01.c: Adjust blocks size base on pagesize Wei Gao via ltp
2024-02-22 7:57 ` Li Wang
2024-02-22 13:46 ` Wei Gao via ltp
2024-02-22 8:39 ` Cyril Hrubis
2024-02-22 13:37 ` Wei Gao via ltp
2024-02-22 13:50 ` Cyril Hrubis [this message]
2024-02-23 4:11 ` Li Wang
2024-02-23 8:32 ` 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=ZddRLm8zpX-wKBGe@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/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.