From f5c472ea47b2b45f8303e62772a21b77644ed5dc Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Thu, 19 Feb 2015 16:09:02 +0100 Subject: torture/ioctl: remove 64K chunk size assumptions These tests assumed that 4K chunks remain allocated following write at a subsequent offset. This is not the case for other filesystems (E.g. XFS, Btrfs, Etc.), which may deallocate the chunk. Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source4/torture/smb2/ioctl.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c index d04fb4962e..9e152c727d 100644 --- a/source4/torture/smb2/ioctl.c +++ b/source4/torture/smb2/ioctl.c @@ -3009,7 +3009,11 @@ static bool test_ioctl_sparse_qar(struct torture_context *torture, 4096); /* pattern offset */ torture_assert(torture, ok, "write pattern"); - /* query range before write off, it should be alloced */ + /* + * Query range before write off. Whether it's allocated or not is FS + * dependent. NTFS deallocates chunks in 64K increments, but others + * (e.g. XFS, Btrfs, etc.) may deallocate 4K chunks. + */ status = test_ioctl_qar_req(torture, tmp_ctx, tree, fh, 0, /* off */ 4096, /* len */ @@ -3017,10 +3021,15 @@ static bool test_ioctl_sparse_qar(struct torture_context *torture, &far_count); torture_assert_ntstatus_ok(torture, status, "FSCTL_QUERY_ALLOCATED_RANGES req failed"); - torture_assert_u64_equal(torture, far_count, 1, - "unexpected response len"); - torture_assert_u64_equal(torture, far_rsp[0].file_off, 0, "far offset"); - torture_assert_u64_equal(torture, far_rsp[0].len, 4096, "far len"); + if (far_count == 0) { + torture_comment(torture, "FS deallocated 4K chunk\n"); + } else { + /* expect fully allocated */ + torture_assert_u64_equal(torture, far_count, 1, + "unexpected response len"); + torture_assert_u64_equal(torture, far_rsp[0].file_off, 0, "far offset"); + torture_assert_u64_equal(torture, far_rsp[0].len, 4096, "far len"); + } /* * Query range before and past write, it should be allocated up to the @@ -3035,8 +3044,16 @@ static bool test_ioctl_sparse_qar(struct torture_context *torture, "FSCTL_QUERY_ALLOCATED_RANGES req failed"); torture_assert_u64_equal(torture, far_count, 1, "unexpected response len"); - torture_assert_u64_equal(torture, far_rsp[0].file_off, 0, "far offset"); - torture_assert_u64_equal(torture, far_rsp[0].len, 5120, "far len"); + /* FS dependent */ + if (far_rsp[0].file_off == 4096) { + /* 4K chunk unallocated */ + torture_assert_u64_equal(torture, far_rsp[0].file_off, 4096, "far offset"); + torture_assert_u64_equal(torture, far_rsp[0].len, 1024, "far len"); + } else { + /* expect fully allocated */ + torture_assert_u64_equal(torture, far_rsp[0].file_off, 0, "far offset"); + torture_assert_u64_equal(torture, far_rsp[0].len, 5120, "far len"); + } smb2_util_close(tree, fh); talloc_free(tmp_ctx); -- cgit