Fix cli_splice() fallback code when splicing less than a complete file.

Jeremy Allison jra at samba.org
Fri Jul 13 15:29:03 UTC 2018


On Fri, Jul 13, 2018 at 02:39:47PM +0200, David Disseldorp via samba-technical wrote:
> On Fri, 13 Jul 2018 13:00:24 +0200, David Disseldorp via samba-technical wrote:
> 
> > On Thu, 12 Jul 2018 13:08:19 -0700, Jeremy Allison wrote:
> > 
> > > Bailey Berro <baileyberro at google.com> found bug:
> > > 
> > > https://bugzilla.samba.org/show_bug.cgi?id=13527
> > > 
> > > where the fallback code for cli_splice() is always
> > > asking for SPLICE_BLOCK_SIZE even when the
> > > remaining bytes we need were smaller than that. This works
> > > when using cli_splice() on a complete file, as the cli_read()
> > > terminated the read at the right place.
> > > 
> > > Includes regression test and fix. Passes local
> > > make test, and is in gitlab-CI:
> > > 
> > > https://gitlab.com/samba-team/devel/samba/pipelines/25667214
> > > 
> > > Please review and push if happy !  
> > 
> > Looks good, thanks for adding test coverage. Pushed to autobuild.
> 
> One thing I noticed after pushing is that there's a typo in the
> regression test (which doesn't affect the result):
>   size_t splice_size = 13*1024*0124 + 713;
> 
> Please consider pushing the attached change.

Thanks. I noticed after sending for review but realized
it doesn't affect the test :-).

I'll push your followup and squash when doing the back-ports
for release branches.

Thanks !

Jeremy

> From f2df3cb51080ff83c1f5a4bf5012117265e568a6 Mon Sep 17 00:00:00 2001
> From: David Disseldorp <ddiss at samba.org>
> Date: Fri, 13 Jul 2018 13:58:04 +0200
> Subject: [PATCH] s3: torture: adjust SMB1 cli_splice() test sizes
> 
> The test writes 20M and then splices just over 1M (13M is intended,
> but there's a 1024*0124 typo). Fix the type and reduce the size of the
> dataset to make it run faster - cli_splice works with 1M chunks
> (SPLICE_BLOCK_SIZE), and the reproducer only requires that the splice
> size is not chunk-aligned.
> 
> Signed-off-by: David Disseldorp <ddiss at samba.org>
> ---
>  source3/torture/torture.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/source3/torture/torture.c b/source3/torture/torture.c
> index be763343659..098560968dd 100644
> --- a/source3/torture/torture.c
> +++ b/source3/torture/torture.c
> @@ -9256,8 +9256,8 @@ static bool run_cli_splice(int dummy)
>  	NTSTATUS status;
>  	uint16_t fnum1 = UINT16_MAX;
>  	uint16_t fnum2 = UINT16_MAX;
> -	size_t file_size = 20*1024*1024;
> -	size_t splice_size = 13*1024*0124 + 713;
> +	size_t file_size = 2*1024*1024;
> +	size_t splice_size = 1*1024*1024 + 713;
>  	MD5_CTX md5_ctx;
>  	uint8_t digest1[16], digest2[16];
>  	off_t written = 0;
> @@ -9295,7 +9295,7 @@ static bool run_cli_splice(int dummy)
>  	/* Fill it with random numbers. */
>  	generate_random_buffer(buf, file_size);
>  
> -	/* MD5 the first 13MB + 713 bytes. */
> +	/* MD5 the first 1MB + 713 bytes. */
>  	MD5Init(&md5_ctx);
>  	MD5Update(&md5_ctx, buf, splice_size);
>  	MD5Final(digest1, &md5_ctx);
> @@ -9321,7 +9321,7 @@ static bool run_cli_splice(int dummy)
>  		goto out;
>  	}
>  
> -	/* Now splice 13MB + 713 bytes. */
> +	/* Now splice 1MB + 713 bytes. */
>  	status = cli_splice(cli1,
>  				cli1,
>  				fnum1,
> @@ -9354,7 +9354,7 @@ static bool run_cli_splice(int dummy)
>  		goto out;
>  	}
>  
> -	/* MD5 the first 13MB + 713 bytes. */
> +	/* MD5 the first 1MB + 713 bytes. */
>  	MD5Init(&md5_ctx);
>  	MD5Update(&md5_ctx, buf, splice_size);
>  	MD5Final(digest2, &md5_ctx);
> -- 
> 2.13.7
> 




More information about the samba-technical mailing list