From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@freelists.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH 2/3] core/coio_file: Add ERRINJ_COIO_SENDFILE_CHUNK error injection
Date: Tue, 16 Apr 2019 23:08:57 +0300 [thread overview]
Message-ID: <20190416200858.19473-3-gorcunov@gmail.com> (raw)
In-Reply-To: <20190416200858.19473-1-gorcunov@gmail.com>
This allows us to test sendfile in a cycle.
---
src/lib/core/coio_file.c | 11 +++++++++--
src/lib/core/errinj.h | 1 +
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/lib/core/coio_file.c b/src/lib/core/coio_file.c
index 20053558e..3caf185a5 100644
--- a/src/lib/core/coio_file.c
+++ b/src/lib/core/coio_file.c
@@ -33,6 +33,7 @@
#include "fiber.h"
#include "say.h"
#include "fio.h"
+#include "errinj.h"
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
@@ -570,8 +571,9 @@ coio_readdir(const char *dir_path, char **buf)
static void
coio_do_copyfile(eio_req *req)
{
+ struct errinj *inj = errinj(ERRINJ_COIO_SENDFILE_CHUNK, ERRINJ_INT);
struct coio_file_task *eio = (struct coio_file_task *)req->data;
- off_t pos, ret, left;
+ off_t pos, ret, left, chunk;
struct stat st;
if (stat(eio->copyfile.source, &st) < 0) {
goto error;
@@ -588,8 +590,13 @@ coio_do_copyfile(eio_req *req)
goto error_dest;
}
+ if (inj != NULL && inj->iparam > 0)
+ chunk = (off_t)inj->iparam;
+ else
+ chunk = st.st_size;
+
for (left = st.st_size, pos = 0; left > 0;) {
- ret = eio_sendfile_sync(dest_fd, source_fd, pos, left);
+ ret = eio_sendfile_sync(dest_fd, source_fd, pos, chunk);
if (ret < 0) {
say_syserror("sendfile, [%s -> %s]",
fio_filename(source_fd),
diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h
index 4bca81caf..462c98464 100644
--- a/src/lib/core/errinj.h
+++ b/src/lib/core/errinj.h
@@ -129,6 +129,7 @@ struct errinj {
_(ERRINJ_MEMTX_DELAY_GC, ERRINJ_BOOL, {.bparam = false}) \
_(ERRINJ_SIO_READ_MAX, ERRINJ_INT, {.iparam = -1}) \
_(ERRINJ_SQL_NAME_NORMALIZATION, ERRINJ_BOOL, {.bparam = false}) \
+ _(ERRINJ_COIO_SENDFILE_CHUNK, ERRINJ_INT, {.iparam = -1}) \
ENUM0(errinj_id, ERRINJ_LIST);
extern struct errinj errinjs[];
--
2.20.1
next prev parent reply other threads:[~2019-04-16 20:08 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
2019-04-18 18:50 ` Cyrill Gorcunov
2019-04-16 20:08 ` Cyrill Gorcunov [this message]
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=20190416200858.19473-3-gorcunov@gmail.com \
--to=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH 2/3] core/coio_file: Add ERRINJ_COIO_SENDFILE_CHUNK error injection' \
/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