[LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE()
Petr Vorel
pvorel@suse.cz
Thu Apr 25 23:10:42 CEST 2024
This effectively increases the minimal used number of blocks to 256.
All {SAFE_,}MAKE_SWAPFILE_SIZE() calls which were creating swap used 10
blocks. While this is ok on 4kb page size, it's too low on systems with
64kb page size (e.g. on aarch64 with CONFIG_ARM64_64K_PAGES=y or on
ppc64le with CONFIG_PAGE_SIZE_64KB=y):
TWARN: Swapfile size is less than the system page size. Using page size
(65536 bytes) instead of block size (4096 bytes).
Obviously it would fail also on kernels with CONFIG_PAGE_SIZE_256KB.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
libs/libltpswap/libswap.c | 2 +-
testcases/kernel/syscalls/swapoff/swapoff02.c | 2 +-
testcases/kernel/syscalls/swapon/swapon02.c | 4 ++--
testcases/kernel/syscalls/swapon/swapon03.c | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c
index aed76dfe2..eb066df71 100644
--- a/libs/libltpswap/libswap.c
+++ b/libs/libltpswap/libswap.c
@@ -192,7 +192,7 @@ int make_swapfile(const char *file, const int lineno,
bool is_swap_supported(const char *filename)
{
int i, sw_support = 0;
- int ret = SAFE_MAKE_SWAPFILE_BLKS(filename, 10);
+ int ret = SAFE_MAKE_SMALL_SWAPFILE(filename);
int fi_contiguous = file_is_contiguous(filename);
long fs_type = tst_fs_type(filename);
const char *fstype = tst_fs_type_name(fs_type);
diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c
index 5a15826e4..0ab8338c5 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff02.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff02.c
@@ -87,7 +87,7 @@ static void setup(void)
nobody_uid = nobody->pw_uid;
is_swap_supported(TEST_FILE);
- SAFE_MAKE_SWAPFILE_BLKS(SWAP_FILE, 10);
+ SAFE_MAKE_SMALL_SWAPFILE(SWAP_FILE);
}
static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index e5e29b8e7..54796bdcc 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -50,8 +50,8 @@ static void setup(void)
is_swap_supported(TEST_FILE);
SAFE_TOUCH(NOTSWAP_FILE, 0777, NULL);
- MAKE_SWAPFILE_BLKS(SWAP_FILE, 10);
- MAKE_SWAPFILE_BLKS(USED_FILE, 10);
+ MAKE_SMALL_SWAPFILE(SWAP_FILE);
+ MAKE_SMALL_SWAPFILE(USED_FILE);
if (tst_syscall(__NR_swapon, USED_FILE, 0))
tst_res(TWARN | TERRNO, "swapon(alreadyused) failed");
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index 5295a6a73..ecce28bdc 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -49,7 +49,7 @@ static int setup_swap(void)
/* Create the swapfile */
snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, j + 2);
- MAKE_SWAPFILE_BLKS(filename, 10);
+ MAKE_SMALL_SWAPFILE(filename);
/* turn on the swap file */
TST_EXP_PASS_SILENT(swapon(filename, 0));
@@ -62,7 +62,7 @@ static int setup_swap(void)
tst_brk(TFAIL, "Failed to setup swap files");
tst_res(TINFO, "Successfully created %d swap files", swapfiles);
- MAKE_SWAPFILE_BLKS(TEST_FILE, 10);
+ MAKE_SMALL_SWAPFILE(TEST_FILE);
return 0;
}
--
2.43.0
More information about the ltp
mailing list