From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@freelists.org>
Subject: Re: [PATCH 1/3] core/coio_file: Use eio_sendfile_sync instead of a chunk mode
Date: Thu, 18 Apr 2019 21:41:55 +0300 [thread overview]
Message-ID: <20190418184155.2junklpawlvucyjh@esperanza> (raw)
In-Reply-To: <20190416200858.19473-2-gorcunov@gmail.com>
On Tue, Apr 16, 2019 at 11:08:56PM +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>
> ---
> src/lib/core/coio_file.c | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
The patch looks fine, but we typically don't split tests from the code
when submitting a patch, i.e. I'd squash all the three patches in one.
Also, after having added a new error injection, you have to update
box/errinj.result. Please do.
Also, please check that app/fio.test.lua works fine when Tarantool is
built in Release mode. The thing is we typically disable tests using
error injections for Release builds, because they don't work there
(see suite.ini:release_disabled). I assume the test case you submitted
should pass even without the error injection, nevertheless better check
that.
>
> diff --git a/src/lib/core/coio_file.c b/src/lib/core/coio_file.c
> index c5b2db781..20053558e 100644
> --- a/src/lib/core/coio_file.c
> +++ b/src/lib/core/coio_file.c
> @@ -571,7 +571,7 @@ static void
> coio_do_copyfile(eio_req *req)
> {
> struct coio_file_task *eio = (struct coio_file_task *)req->data;
> -
> + off_t pos, ret, left;
Nit: We don't have a requirement to define all variables in the
beginning of a code block. I'd define these variables right before
the 'for' loop where they are used.
> struct stat st;
> if (stat(eio->copyfile.source, &st) < 0) {
> goto error;
> @@ -588,22 +588,18 @@ 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)
> + for (left = st.st_size, pos = 0; left > 0;) {
> + ret = eio_sendfile_sync(dest_fd, source_fd, pos, left);
> + if (ret < 0) {
> + say_syserror("sendfile, [%s -> %s]",
> + fio_filename(source_fd),
> + fio_filename(dest_fd));
> goto error_copy;
> + }
> + pos += ret;
> + left -= ret;
> }
> +
> req->result = 0;
> close(source_fd);
> close(dest_fd);
next prev parent reply other threads:[~2019-04-18 18:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 20:08 [PATCH v3 0/3] core/coio_file: Use eio_sendfile_sync for file copying Cyrill Gorcunov
2019-04-16 20:08 ` [PATCH 1/3] core/coio_file: Use eio_sendfile_sync instead of a chunk mode Cyrill Gorcunov
2019-04-18 18:41 ` Vladimir Davydov [this message]
2019-04-18 18:50 ` Cyrill Gorcunov
2019-04-16 20:08 ` [PATCH 2/3] core/coio_file: Add ERRINJ_COIO_SENDFILE_CHUNK error injection Cyrill Gorcunov
2019-04-16 20:08 ` [PATCH 3/3] test: app/fio -- Add ERRINJ_COIO_SENDFILE_CHUNK Cyrill Gorcunov
2019-04-16 21:40 ` [PATCH v4 " 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=20190418184155.2junklpawlvucyjh@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 1/3] 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