From 650accfb3f32c23635bbd10868101b4268ebf9b4 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 --- 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 01cc150..5e102bc 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_DEFAULT) - 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.10.2 From 1615ff5203b056cca512021e2c94dc1de6214ac9 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 --- 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 f2a0554..64b5454 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.10.2