From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Cyrill Gorcunov <gorcunov@gmail.com>, tml <tarantool-patches@dev.tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] fio/coio: handle partial writes Date: Wed, 10 Jun 2020 00:55:04 +0200 [thread overview] Message-ID: <cba903ec-3032-fae2-21da-41a39468a16e@tarantool.org> (raw) In-Reply-To: <20200421213930.28713-1-gorcunov@gmail.com> Hi! Thanks for the patch! See 4 comments below. On 21/04/2020 23:39, Cyrill Gorcunov wrote: > Writting less bytes than requested is perfectly fine. 1. 'Writting' -> 'Writing'. > In turn our fio.write/pwrite api simply returns 'true' > even if only some part of a buffer has been written. > > Thus make coio_write and coio_pwrite to write the > whole data in a cycle. Note in most situations there > will be only one pass, partial writes are really the > rare cases. > > Fixes #4651 > > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> > --- > issue https://github.com/tarantool/tarantool/issues/4651 > branch gorcunov/gh-4651-partial-write > > src/lib/core/coio_file.c | 62 ++++++++++++++++++++++++++++------ > src/lib/core/errinj.h | 1 + > test/app/fio.result | 73 ++++++++++++++++++++++++++++++++++++++++ > test/app/fio.test.lua | 21 ++++++++++++ > test/box/errinj.result | 1 + > 5 files changed, 147 insertions(+), 11 deletions(-) > > diff --git a/src/lib/core/coio_file.c b/src/lib/core/coio_file.c > index e2345567c..e290214bc 100644 > --- a/src/lib/core/coio_file.c > +++ b/src/lib/core/coio_file.c > @@ -164,10 +164,30 @@ coio_file_close(int fd) > ssize_t > coio_pwrite(int fd, const void *buf, size_t count, off_t offset) > { > - INIT_COEIO_FILE(eio); > - eio_req *req = eio_write(fd, (void *) buf, count, offset, > - 0, coio_complete, &eio); > - return coio_wait_done(req, &eio); > + ssize_t left = count, pos = 0, res, chunk; > + eio_req *req; > + > + while (left > 0) { > + INIT_COEIO_FILE(eio); > + chunk = left; > + > + ERROR_INJECT(ERRINJ_COIO_WRITE_CHUNK, { > + chunk = 1; > + }); > + > + req = eio_write(fd, (void *)buf + pos, chunk, 2. As it was fairly noticed by Timur in one of my patches for lsregion - lets better avoid 'void' pointer arithmetic. And use uint8_t * or char *. > + offset + pos, EIO_PRI_DEFAULT, > + coio_complete, &eio); > + res = coio_wait_done(req, &eio); > + if (res < 0) { > + pos = -1; 3. What if eio_write() returns EAGAIN/EINTR/WOULDBLOCK? Can it happen at all? Can it happen, if the descriptor is not blocking? Can it happen if the underlying FS is a network file system, like sshfs via FUSE? Coio socket library handles these errors and retries them. > + break; > + } else { > + left -= res; > + pos += res; > + } > + } > + return pos; > } > diff --git a/test/app/fio.result b/test/app/fio.result > index 783fa4fab..73fbd29e5 100644 > --- a/test/app/fio.result > +++ b/test/app/fio.result > @@ -865,6 +871,73 @@ fh6:close() > --- > - true > ... > +-- test partial write/pwrite via one byte transfer 4. Please - Add the issue reference, like this: -- -- gh-4651: ... -- - Start sentences from a capital letter, and finish with dot.
next prev parent reply other threads:[~2020-06-09 22:55 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-21 21:39 Cyrill Gorcunov 2020-05-06 17:08 ` Alexander Turenko 2020-05-15 9:00 ` Cyrill Gorcunov 2020-06-09 16:55 ` Alexander Turenko 2020-06-09 22:55 ` Vladislav Shpilevoy 2020-06-09 22:55 ` Vladislav Shpilevoy [this message] 2020-06-10 7:52 ` Cyrill Gorcunov 2020-06-11 19:36 ` Vladislav Shpilevoy 2020-06-11 19:43 ` Cyrill Gorcunov 2020-06-11 19:56 ` Vladislav Shpilevoy 2020-06-11 20:12 ` Cyrill Gorcunov 2020-06-11 19:56 ` Vladislav Shpilevoy -- strict thread matches above, loose matches on Subject: below -- 2019-11-26 18:05 [Tarantool-patches] [PATCH] fio/coio: Handle " Cyrill Gorcunov 2019-12-04 9:44 ` 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=cba903ec-3032-fae2-21da-41a39468a16e@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] fio/coio: handle partial writes' \ /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