public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <guaneryu@gmail.com>
To: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Cc: fstests@vger.kernel.org, "Darrick J. Wong" <darrick.wong@oracle.com>
Subject: Re: [PATCH v2] fsx: add more check for copy_file_range
Date: Sun, 6 Oct 2019 03:07:44 +0800	[thread overview]
Message-ID: <20191005190741.GF2622@desktop> (raw)
In-Reply-To: <1569549234-13096-1-git-send-email-suyj.fnst@cn.fujitsu.com>

On Fri, Sep 27, 2019 at 09:53:54AM +0800, Su Yanjun wrote:
> On some linux distros(RHEL7, centos 7) copy_file_range uses
> general implementation (splice interface). splice interace
> uses pipe_to_file. pipe_to_file only work for different page.
> The userspace cant's be  aware of such error because copy_file_range
> returns ok too.
> So for such case when copy_file_range return we read back data
> then check it.
> 
> Also add check for do_clone_range following Eryu's advice.
> 
> Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
> ---
> v2:
> - Use check_buffers instead memcmp code
> - Add check for do_clone_range
> - Fix return unique error number for the check code

I just noticed that fsx already has an option (-X) to control check file
content or not after each test, which calls check_buffers().

Would you please check if adding '-X' option to fsx could reproduce the
copy_file_range bug on RHEL7? If so, perhaps we should add a new test
which is similar to generic/522 but does content check. Or just add '-X'
to generic/52[12]?

/me copies Darrick and hopes he could share his thoughts.

Thanks,
Eryu

> ---
>  ltp/fsx.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index 06d08e4..714bebc 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -1378,6 +1378,7 @@ test_clone_range(void)
>  void
>  do_clone_range(unsigned offset, unsigned length, unsigned dest)
>  {
> +	int ret = 0;
>  	struct file_clone_range	fcr = {
>  		.src_fd = fd,
>  		.src_offset = offset,
> @@ -1429,6 +1430,23 @@ do_clone_range(unsigned offset, unsigned length, unsigned dest)
>  		memset(good_buf + file_size, '\0', dest - file_size);
>  	if (dest + length > file_size)
>  		file_size = dest + length;
> +
> +	ret = lseek(fd, (off_t)dest, SEEK_SET);
> +	if (ret == (off_t)-1) {
> +		prterr("do_clone_range: lseek");
> +		report_failure(162);
> +	}
> +	ret = fsxread(fd, temp_buf, length, dest);
> +	if (ret != length) {
> +		if (ret == -1)
> +			prterr("do_clone_range: read");
> +		else
> +			prt("short read: 0x%x bytes instead of 0x%x\n",
> +				ret, length);
> +		report_failure(163);
> +	}
> +	check_buffers(temp_buf, dest, length);
> +
>  }
>  
>  #else
> @@ -1602,6 +1620,7 @@ do_copy_range(unsigned offset, unsigned length, unsigned dest)
>  	size_t olen;
>  	ssize_t nr;
>  	int tries = 0;
> +	int ret = 0;
>  
>  	if (length == 0) {
>  		if (!quiet && testcalls > simulatedopcount)
> @@ -1665,6 +1684,22 @@ do_copy_range(unsigned offset, unsigned length, unsigned dest)
>  		memset(good_buf + file_size, '\0', dest - file_size);
>  	if (dest + length > file_size)
>  		file_size = dest + length;
> +
> +	ret = lseek(fd, (off_t)dest, SEEK_SET);
> +	if (ret == (off_t)-1) {
> +		prterr("do_copy_range: lseek");
> +		report_failure(162);
> +	}
> +	ret = fsxread(fd, temp_buf, length, dest);
> +	if (ret != length) {
> +		if (ret == -1)
> +			prterr("do_copy_range: read");
> +		else
> +			prt("short read: 0x%x bytes instead of 0x%x\n",
> +				ret, length);
> +		report_failure(163);
> +	}
> +	check_buffers(temp_buf, dest, length);
>  }
>  
>  #else
> -- 
> 2.7.4
> 
> 
> 

      parent reply	other threads:[~2019-10-05 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27  1:53 [PATCH v2] fsx: add more check for copy_file_range Su Yanjun
2019-09-27  1:53 ` Su Yanjun
2019-10-05 19:07 ` Eryu Guan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191005190741.GF2622@desktop \
    --to=guaneryu@gmail.com \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=suyj.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox