summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2015-02-26 01:13:58 +0100
committerJeremy Allison <jra@samba.org>2015-03-09 21:27:08 +0100
commit27e19a81e6fae6ea072d865dcadebc9bb9db48c5 (patch)
tree6c3636c16edea0bd2c5893639ff1486b946c136d
parent2edb6ddc31e2a7382f8fcd8eaebde3392f85886f (diff)
downloadsamba-27e19a81e6fae6ea072d865dcadebc9bb9db48c5.tar.gz
samba-27e19a81e6fae6ea072d865dcadebc9bb9db48c5.tar.xz
samba-27e19a81e6fae6ea072d865dcadebc9bb9db48c5.zip
torture/ioctl: add multi-range QAR test
Write 10 x 64K ranges, with 64K holes punched in between. Afterwards, check that all ranges are present in the QAR response. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source4/torture/smb2/ioctl.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index 38b92a9590..5067d52016 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -4519,6 +4519,83 @@ static bool test_ioctl_sparse_qar_ob1(struct torture_context *torture,
return true;
}
+/* test QAR with multi-range responses */
+static bool test_ioctl_sparse_qar_multi(struct torture_context *torture,
+ struct smb2_tree *tree)
+{
+ struct smb2_handle fh;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ bool ok;
+ uint64_t dealloc_chunk_len = 64 * 1024; /* Windows 2012 */
+ uint64_t this_off;
+ int i;
+ struct file_alloced_range_buf *far_rsp = NULL;
+ uint64_t far_count = 0;
+
+ ok = test_setup_create_fill(torture, tree, tmp_ctx,
+ FNAME, &fh, dealloc_chunk_len * 2,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL);
+ torture_assert(torture, ok, "setup file");
+
+ status = test_ioctl_sparse_fs_supported(torture, tree, tmp_ctx, &fh,
+ &ok);
+ torture_assert_ntstatus_ok(torture, status, "SMB2_GETINFO_FS");
+ if (!ok) {
+ torture_skip(torture, "Sparse files not supported\n");
+ smb2_util_close(tree, fh);
+ }
+
+ status = test_ioctl_sparse_req(torture, tmp_ctx, tree, fh, true);
+ torture_assert_ntstatus_ok(torture, status, "FSCTL_SET_SPARSE");
+
+ /* each loop, write out two chunks and punch the first out */
+ for (i = 0; i < 10; i++) {
+ this_off = i * dealloc_chunk_len * 2;
+
+ ok = write_pattern(torture, tree, tmp_ctx, fh,
+ this_off, /* off */
+ dealloc_chunk_len * 2, /* len */
+ this_off); /* pattern offset */
+ torture_assert(torture, ok, "write pattern");
+
+ status = test_ioctl_zdata_req(torture, tmp_ctx, tree, fh,
+ this_off, /* off */
+ this_off + dealloc_chunk_len);
+ torture_assert_ntstatus_ok(torture, status, "zero_data");
+ }
+
+ /* should now have one separate region for each iteration */
+ status = test_ioctl_qar_req(torture, tmp_ctx, tree, fh,
+ 0,
+ 10 * dealloc_chunk_len * 2,
+ &far_rsp, &far_count);
+ torture_assert_ntstatus_ok(torture, status,
+ "FSCTL_QUERY_ALLOCATED_RANGES req failed");
+ if (far_count == 1) {
+ torture_comment(torture, "this FS doesn't deallocate 64K"
+ "zeroed ranges in sparse files\n");
+ return true; /* FS specific, not a failure */
+ }
+ torture_assert_u64_equal(torture, far_count, 10,
+ "unexpected response len");
+ for (i = 0; i < 10; i++) {
+ this_off = i * dealloc_chunk_len * 2;
+
+ torture_assert_u64_equal(torture, far_rsp[i].file_off,
+ this_off + dealloc_chunk_len,
+ "unexpected allocation");
+ torture_assert_u64_equal(torture, far_rsp[i].len,
+ dealloc_chunk_len,
+ "unexpected far len");
+ }
+
+ smb2_util_close(tree, fh);
+ talloc_free(tmp_ctx);
+ return true;
+}
+
/*
* basic testing of SMB2 ioctls
*/
@@ -4616,6 +4693,8 @@ struct torture_suite *torture_smb2_ioctl_init(void)
test_ioctl_sparse_lck);
torture_suite_add_1smb2_test(suite, "sparse_qar_ob1",
test_ioctl_sparse_qar_ob1);
+ torture_suite_add_1smb2_test(suite, "sparse_qar_multi",
+ test_ioctl_sparse_qar_multi);
suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");