summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2015-02-23 20:03:19 +0100
committerJeremy Allison <jra@samba.org>2015-03-09 21:27:07 +0100
commit6729557c2788f232dcc1e8b5f14ec1cadc962a35 (patch)
tree12bed470249fd24ccd291c6091e405273d1787d4
parent4dec434f7151e0ef222aa72531f3353ee2651c74 (diff)
downloadsamba-6729557c2788f232dcc1e8b5f14ec1cadc962a35.tar.gz
samba-6729557c2788f232dcc1e8b5f14ec1cadc962a35.tar.xz
samba-6729557c2788f232dcc1e8b5f14ec1cadc962a35.zip
torture/ioctl: rework and reduce pattern helper IO sizes
check_pattern() currently attempts to read all data in one go. Fix it to use a 64K maximum IO size so that it works against Windows Server 2008. Additionally, rework write_pattern() so that it only allocates a buffer for the largest IO size (now 64K), rather than for the full write length. Finally, assert that callers are correctly performing pattern IO in 8-byte increments - copy_chunk_tiny was not, so fix it. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source4/torture/smb2/ioctl.c83
1 files changed, 46 insertions, 37 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index b14ec3a430..c7b870c863 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -127,31 +127,33 @@ static bool write_pattern(struct torture_context *torture,
NTSTATUS status;
uint64_t i;
uint8_t *buf;
- uint64_t buf_off = 0;
+ uint64_t io_sz = MIN(1024 * 64, len);
if (len == 0) {
return true;
}
- buf = talloc_zero_size(mem_ctx, len);
- torture_assert(torture, (buf != NULL), "no memory for file data buf");
+ torture_assert(torture, (len % 8) == 0, "invalid write len");
- for (i = 0; i <= len - 8; i += 8) {
- SBVAL(buf, i, patt_hash(patt_off));
- patt_off += 8;
- }
+ buf = talloc_zero_size(mem_ctx, io_sz);
+ torture_assert(torture, (buf != NULL), "no memory for file data buf");
while (len > 0) {
- uint64_t io_sz = MIN(1024 * 1024, len);
+ for (i = 0; i <= io_sz - 8; i += 8) {
+ SBVAL(buf, i, patt_hash(patt_off));
+ patt_off += 8;
+ }
+
status = smb2_util_write(tree, h,
- buf + buf_off, off, io_sz);
+ buf, off, io_sz);
torture_assert_ntstatus_ok(torture, status, "file write");
len -= io_sz;
- buf_off += io_sz;
off += io_sz;
}
+ talloc_free(buf);
+
return true;
}
@@ -160,33 +162,40 @@ static bool check_pattern(struct torture_context *torture,
struct smb2_handle h, uint64_t off, uint64_t len,
uint64_t patt_off)
{
- uint64_t i;
- struct smb2_read r;
- NTSTATUS status;
-
if (len == 0) {
return true;
}
- ZERO_STRUCT(r);
- r.in.file.handle = h;
- r.in.length = len;
- r.in.offset = off;
- status = smb2_read(tree, mem_ctx, &r);
- torture_assert_ntstatus_ok(torture, status, "read");
+ torture_assert(torture, (len % 8) == 0, "invalid read len");
- torture_assert_u64_equal(torture, r.out.data.length, len,
- "read data len mismatch");
-
- for (i = 0; i <= len - 8; i += 8, patt_off += 8) {
- uint64_t data = BVAL(r.out.data.data, i);
- torture_assert_u64_equal(torture, data, patt_hash(patt_off),
- talloc_asprintf(torture, "read data "
- "pattern bad at %llu\n",
- (unsigned long long)i));
+ while (len > 0) {
+ uint64_t i;
+ struct smb2_read r;
+ NTSTATUS status;
+ uint64_t io_sz = MIN(1024 * 64, len);
+
+ ZERO_STRUCT(r);
+ r.in.file.handle = h;
+ r.in.length = io_sz;
+ r.in.offset = off;
+ status = smb2_read(tree, mem_ctx, &r);
+ torture_assert_ntstatus_ok(torture, status, "read");
+
+ torture_assert_u64_equal(torture, r.out.data.length, io_sz,
+ "read data len mismatch");
+
+ for (i = 0; i <= io_sz - 8; i += 8, patt_off += 8) {
+ uint64_t data = BVAL(r.out.data.data, i);
+ torture_assert_u64_equal(torture, data, patt_hash(patt_off),
+ talloc_asprintf(torture, "read data "
+ "pattern bad at %llu\n",
+ (unsigned long long)off + i));
+ }
+ talloc_free(r.out.data.data);
+ len -= io_sz;
+ off += io_sz;
}
- talloc_free(r.out.data.data);
return true;
}
@@ -500,7 +509,7 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture,
ok = test_setup_copy_chunk(torture, tree, tmp_ctx,
2, /* chunks */
- &src_h, 100, /* src file */
+ &src_h, 96, /* src file */
SEC_RIGHTS_FILE_ALL,
&dest_h, 0, /* dest file */
SEC_RIGHTS_FILE_ALL,
@@ -513,11 +522,11 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture,
/* copy all src file data via two chunks, sub block size chunks */
cc_copy.chunks[0].source_off = 0;
cc_copy.chunks[0].target_off = 0;
- cc_copy.chunks[0].length = 50;
+ cc_copy.chunks[0].length = 48;
- cc_copy.chunks[1].source_off = 50;
- cc_copy.chunks[1].target_off = 50;
- cc_copy.chunks[1].length = 50;
+ cc_copy.chunks[1].source_off = 48;
+ cc_copy.chunks[1].target_off = 48;
+ cc_copy.chunks[1].length = 48;
ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx,
&cc_copy,
@@ -537,12 +546,12 @@ static bool test_ioctl_copy_chunk_tiny(struct torture_context *torture,
ok = check_copy_chunk_rsp(torture, &cc_rsp,
2, /* chunks written */
0, /* chunk bytes unsuccessfully written */
- 100); /* total bytes written */
+ 96); /* total bytes written */
if (!ok) {
torture_fail(torture, "bad copy chunk response data");
}
- ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 100, 0);
+ ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 96, 0);
if (!ok) {
torture_fail(torture, "inconsistent file data");
}