From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "Jianhong.Yin" <yin-jianhong@163.com>
Cc: linux-xfs@vger.kernel.org, jiyin@redhat.com
Subject: Re: [PATCH v2] xfsprogs: copy_range don't truncate dstfile
Date: Wed, 4 Sep 2019 17:14:57 -0700 [thread overview]
Message-ID: <20190905001457.GF5354@magnolia> (raw)
In-Reply-To: <20190904233634.12261-1-yin-jianhong@163.com>
On Thu, Sep 05, 2019 at 07:36:34AM +0800, Jianhong.Yin wrote:
> now if we do copy_range from srcfile to dstfile without any option
> will truncate the dstfile, and not any document indicate this default
> action. that's unexpected and confuse people.
Needs manpage update.
Also, did you check that xfstests doesn't somehow use this? There are
several cfr tests now...
generic/430 generic/431 generic/432 generic/433 generic/434 generic/553
generic/554 generic/564 generic/565 generic/716
--D
> '''
> $ ./xfs_io -f -c 'copy_range copy_file_range.c' testfile
> $ ll testfile
> -rw-rw-r--. 1 yjh yjh 3534 Sep 5 07:15 testfile
> $ ./xfs_io -c 'copy_range testfile' testfile
> $ ll testfile
> -rw-rw-r--. 1 yjh yjh 3534 Sep 5 07:16 testfile
> $ ./xfs_io -c 'copy_range testfile -l 3534 -d 3534' testfile
> $ ll testfile
> -rw-rw-r--. 1 yjh yjh 7068 Sep 5 07:17 testfile
> $ ./xfs_io -c 'copy_range copy_file_range.c' testfile
> $ ll testfile
> -rw-rw-r--. 1 yjh yjh 7068 Sep 5 07:18 testfile
> $ cmp -n 3534 copy_file_range.c testfile
> $ cmp -i 0:3534 copy_file_range.c testfile
> '''
>
> Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> ---
> io/copy_file_range.c | 15 ---------------
> 1 file changed, 15 deletions(-)
>
> diff --git a/io/copy_file_range.c b/io/copy_file_range.c
> index b7b9fd88..283f5094 100644
> --- a/io/copy_file_range.c
> +++ b/io/copy_file_range.c
> @@ -66,15 +66,6 @@ copy_src_filesize(int fd)
> return st.st_size;
> }
>
> -static int
> -copy_dst_truncate(void)
> -{
> - int ret = ftruncate(file->fd, 0);
> - if (ret < 0)
> - perror("ftruncate");
> - return ret;
> -}
> -
> static int
> copy_range_f(int argc, char **argv)
> {
> @@ -146,12 +137,6 @@ copy_range_f(int argc, char **argv)
> goto out;
> }
> len = sz;
> -
> - ret = copy_dst_truncate();
> - if (ret < 0) {
> - ret = 1;
> - goto out;
> - }
> }
>
> ret = copy_file_range_cmd(fd, &src, &dst, len);
> --
> 2.21.0
>
next prev parent reply other threads:[~2019-09-05 0:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-04 23:36 [PATCH v2] xfsprogs: copy_range don't truncate dstfile Jianhong.Yin
2019-09-05 0:14 ` Darrick J. Wong [this message]
2019-09-05 1:08 ` Jianhong Yin
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=20190905001457.GF5354@magnolia \
--to=darrick.wong@oracle.com \
--cc=jiyin@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=yin-jianhong@163.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