Skip to content

Commit

Permalink
Fix ioctl_ficlone on XFS without reflink support
Browse files Browse the repository at this point in the history
reflink has been introduced in XFS by kernel 4.9 and mkfs.xfs enabled
by default in 5.1.0. Check the mkfs.xfs version in order to make sure
that mkfs.xfs supports reflink and verify kernel is at least 4.9 when
we run the ioctl_ficlone tests on XFS.

Signed-off-by: Andrea Cervesato <[email protected]>
  • Loading branch information
acerv committed Sep 24, 2024
1 parent 8934711 commit f871e79
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
9 changes: 8 additions & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ static void run(void)
SAFE_UNLINK(DSTPATH);
}

static void setup(void)
{
if (!strcmp(tst_device->fs_type, "xfs") && tst_kvercmp(4, 9, 0) < 0)
tst_brk(TCONF, "XFS doesn't support reflink");
}

static void cleanup(void)
{
if (src_fd != -1)
Expand All @@ -106,6 +112,7 @@ static void cleanup(void)

static struct tst_test test = {
.test_all = run,
.setup = setup,
.cleanup = cleanup,
.min_kver = "4.5",
.needs_root = 1,
Expand All @@ -115,7 +122,7 @@ static struct tst_test test = {
{.type = "bcachefs"},
{.type = "btrfs"},
{
.type = "xfs",
.type = "xfs >= 5.1.0",
.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
},
{}
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ static void setup(void)
int attr;
struct stat sb;

if (!strcmp(tst_device->fs_type, "xfs") && tst_kvercmp(4, 9, 0) < 0)
tst_brk(TCONF, "XFS doesn't support reflink");

rw_file = SAFE_OPEN("ok_only", O_CREAT | O_RDWR, 0640);
ro_file = SAFE_OPEN("rd_only", O_CREAT | O_RDONLY, 0640);
wo_file = SAFE_OPEN("rw_only", O_CREAT | O_WRONLY, 0640);
Expand Down Expand Up @@ -113,7 +116,7 @@ static struct tst_test test = {
{.type = "bcachefs"},
{.type = "btrfs"},
{
.type = "xfs",
.type = "xfs >= 5.1.0",
.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
},
{}
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ static void setup(void)
{
struct stat sb;

if (!strcmp(tst_device->fs_type, "xfs") && tst_kvercmp(4, 9, 0) < 0)
tst_brk(TCONF, "XFS doesn't support reflink");

SAFE_STAT(MNTPOINT, &sb);

filesize = sb.st_blksize * CHUNKS;
Expand Down Expand Up @@ -148,7 +151,7 @@ static struct tst_test test = {
{.type = "bcachefs"},
{.type = "btrfs"},
{
.type = "xfs",
.type = "xfs >= 5.1.0",
.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
},
{}
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ static void setup(void)
{
struct stat sb;

if (!strcmp(tst_device->fs_type, "xfs") && tst_kvercmp(4, 9, 0) < 0)
tst_brk(TCONF, "XFS doesn't support reflink");

SAFE_STAT(MNTPOINT, &sb);

alignment = sb.st_blksize;
Expand All @@ -85,7 +88,7 @@ static struct tst_test test = {
{.type = "bcachefs"},
{.type = "btrfs"},
{
.type = "xfs",
.type = "xfs >= 5.1.0",
.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
},
{}
Expand Down

0 comments on commit f871e79

Please sign in to comment.