From 3474c32e764e75abb11a275874ac9cb52308696a Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Thu, 5 Jan 2017 17:10:42 +0100 Subject: [PATCH 1/2] torture/ioctl: test set_compression(format_none) This test case was overlooked in the previous bso#12144 update - set compression requests with format=COMPRESSION_FORMAT_NONE should succeed if the server / backing storage doesn't offer compression support. Confirm that Samba matches Windows Server 2016 ReFS behaviour here. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144 Reported-by: Nick Barrett Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison (cherry picked from commit 6fde123176409e261d955e24b3d28e5124f33bed) --- source4/torture/smb2/ioctl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c index 5fc03bccec0..43488626b9b 100644 --- a/source4/torture/smb2/ioctl.c +++ b/source4/torture/smb2/ioctl.c @@ -2608,7 +2608,16 @@ static bool test_ioctl_compress_notsup_set(struct torture_context *torture, COMPRESSION_FORMAT_DEFAULT); torture_assert_ntstatus_equal(torture, status, NT_STATUS_NOT_SUPPORTED, - "FSCTL_GET_COMPRESSION"); + "FSCTL_SET_COMPRESSION default"); + + /* + * Despite not supporting compression, we should get a successful + * response for set(COMPRESSION_FORMAT_NONE) - like WS2016 ReFS. + */ + status = test_ioctl_compress_set(torture, tmp_ctx, tree, fh, + COMPRESSION_FORMAT_NONE); + torture_assert_ntstatus_ok(torture, status, + "FSCTL_SET_COMPRESSION none"); smb2_util_close(tree, fh); talloc_free(tmp_ctx); -- 2.11.0.390.gc69c2f50cf-goog From da3d2b8435c5e7955304da2e26236a082017a559 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Thu, 5 Jan 2017 17:36:02 +0100 Subject: [PATCH 2/2] smbd/ioctl: match WS2016 ReFS set compression behaviour ReFS doesn't support compression, but responds to set-compression FSCTLs with NT_STATUS_OK if (and only if) the requested compression format is COMPRESSION_FORMAT_NONE. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144 Reported-by: Nick Barrett Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Jan 9 23:14:28 CET 2017 on sn-devel-144 (cherry picked from commit 28cc347876b97b7409d6efd377f031fc6df0c5f3) --- source3/smbd/smb2_ioctl_filesys.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c index 55ce3f24c01..34331b4e041 100644 --- a/source3/smbd/smb2_ioctl_filesys.c +++ b/source3/smbd/smb2_ioctl_filesys.c @@ -104,11 +104,6 @@ static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx, return status; } - if ((fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) == 0) { - DEBUG(4, ("FS does not advertise compression support\n")); - return NT_STATUS_NOT_SUPPORTED; - } - ndr_ret = ndr_pull_struct_blob(in_input, mem_ctx, &cmpr_state, (ndr_pull_flags_fn_t)ndr_pull_compression_state); if (ndr_ret != NDR_ERR_SUCCESS) { @@ -116,15 +111,22 @@ static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - status = SMB_VFS_SET_COMPRESSION(fsp->conn, - mem_ctx, - fsp, - cmpr_state.format); - if (!NT_STATUS_IS_OK(status)) { - return status; + status = NT_STATUS_NOT_SUPPORTED; + if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) { + status = SMB_VFS_SET_COMPRESSION(fsp->conn, + mem_ctx, + fsp, + cmpr_state.format); + } else if (cmpr_state.format == COMPRESSION_FORMAT_NONE) { + /* + * bso#12144: The underlying filesystem doesn't support + * compression. We should still accept set(FORMAT_NONE) requests + * (like WS2016 ReFS). + */ + status = NT_STATUS_OK; } - return NT_STATUS_OK; + return status; } static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx, -- 2.11.0.390.gc69c2f50cf-goog