From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@freelists.org>
Subject: Re: [PATCH] lib/core/coio_file: Use eio_sendfile_sync instead of a chunk mode
Date: Fri, 12 Apr 2019 16:43:23 +0300 [thread overview]
Message-ID: <20190412134323.ebqjjxaqgpbu4dt5@esperanza> (raw)
In-Reply-To: <20190410193624.12510-1-gorcunov@gmail.com>
On Wed, Apr 10, 2019 at 10:36:24PM +0300, Cyrill Gorcunov wrote:
> eio library provides a portable version of sendfile syscall
> which works a way more efficient than explicit copying file
> by 4K chunks.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>
> Test app/fio.test.lua which uses this helper passed.
>
> src/lib/core/coio_file.c | 22 +++++++---------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/src/lib/core/coio_file.c b/src/lib/core/coio_file.c
> index c5b2db781..27806d7d5 100644
> --- a/src/lib/core/coio_file.c
> +++ b/src/lib/core/coio_file.c
> @@ -588,22 +588,14 @@ coio_do_copyfile(eio_req *req)
> goto error_dest;
> }
>
> - enum { COPY_FILE_BUF_SIZE = 4096 };
> -
> - char buf[COPY_FILE_BUF_SIZE];
> -
> - while (true) {
> - ssize_t nread = fio_read(source_fd, buf, sizeof(buf));
> - if (nread < 0)
> - goto error_copy;
> -
> - if (nread == 0)
> - break; /* eof */
> -
> - ssize_t nwritten = fio_writen(dest_fd, buf, nread);
> - if (nwritten < 0)
> - goto error_copy;
> + ssize_t nwritten = eio_sendfile_sync(dest_fd, source_fd, 0, st.st_size);
> + if (nwritten != st.st_size) {
> + say_syserror("sendfile, [%s -> %s]",
> + fio_filename(source_fd),
> + fio_filename(dest_fd));
Other coio/fio methods don't log errors so I don't think this one
should, either.
An extract from the sendfile manual page:
} sendfile() will transfer at most 0x7ffff000 (2,147,479,552) bytes,
} returning the number of bytes actually transferred. (This is true on
} both 32-bit and 64-bit systems.)
So I don't think using sendfile is equivalent to read+write...
> + goto error_copy;
> }
> +
> req->result = 0;
> close(source_fd);
> close(dest_fd);
next prev parent reply other threads:[~2019-04-12 13:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-10 19:36 Cyrill Gorcunov
2019-04-12 13:43 ` Vladimir Davydov [this message]
2019-04-12 14:05 ` Cyrill Gorcunov
2019-04-12 14:19 ` Vladimir Davydov
2019-04-12 14:42 ` Cyrill Gorcunov
2019-04-12 14:53 ` Vladimir Davydov
2019-04-12 14:59 ` Cyrill Gorcunov
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=20190412134323.ebqjjxaqgpbu4dt5@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH] lib/core/coio_file: Use eio_sendfile_sync instead of a chunk mode' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox