Skip to contentSkip to conversation

Add test for misaligned fallocate()

PATCH Superseded Martin Doucha 2 participants 2 messages Jan 16, 2020 – Jan 21, 2020

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add test for misaligned fallocate()

Make sure that space allocation and deallocation works (or fails) correctly even when the requested file range does not align with filesystem blocks.

Test on:
- empty file system
- full file system
- also test with and without copy-on-write when supported

---

Note for reviewers: Feel free to ignore this patch until next week.

This patch is a follow-up to the fallocate05 fix. The original fallocate05 test accidentally tested some misaligned allocation and deallocation on platforms with block size bigger than 8k but it didn't validate the results correctly. Test calling fallocate() on misaligned file range and this time validate the results properly, taking into account advanced FS features like copy-on-write.

Changes since v1:
- Fix compilation with --std=c89
- Misalign by at most 512 bytes, otherwise the test may miss an XFS bug on PPC

 runtest/syscalls                              |   1 +
 .../kernel/syscalls/fallocate/fallocate06.c   | 253 ++++++++++++++++++
 2 files changed, 254 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fallocate/fallocate06.c
runtest/syscalls +1 -0
index fa87ef63f..ec522e8fa 100644
@@ -184,6 +184,7 @@ fallocate02 fallocate02
 fallocate03 fallocate03
 fallocate04 fallocate04
 fallocate05 fallocate05
+fallocate06 fallocate06
 
 fsetxattr01 fsetxattr01
 fsetxattr02 fsetxattr02
testcases/kernel/syscalls/fallocate/fallocate06.c new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/1 Add test for misaligned fallocate()

Hi!

Review

Quoted 2 lines
(quoted diff) +2 -0
+	SAFE_CLOSE(fd);
+	tst_system("rm -r " MNTPOINT "/*");

Just FYI, we already have something like this implemented but not exported outside of the test library. We basically need a public wrapper around the rmobj() function from the tst_tmpdir.c

Quoted 25 lines
testcases/kernel/syscalls/fallocate/fallocate06.c new file +19 -0
+}
+
+static void cleanup(void)
+{
+	free(wbuf);
+	free(rbuf);
+}
+
+static struct tst_test test = {
+	.test = run,
+	.tcnt = ARRAY_SIZE(testcase_list),
+	.needs_root = 1,
+	.mount_device = 1,
+	.dev_min_size = 512,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+};
Signature · 5 lines
2.24.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]