From: Rutger ter Borg <rutger@terborg.net>
To: ceph-devel@vger.kernel.org
Subject: [PATCH] fix librados aio read buffer handling
Date: Mon, 30 Sep 2013 12:13:11 +0200 [thread overview]
Message-ID: <l2bire$iue$1@ger.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
Dear all,
please find attached a patch that enables a user to pass user-owned
buffers into librados' aio_read. The patch (against dumpling) removes
the buf and pbl data members in AioCompletionImpl.
* The 'buf' argument to read() used to be passed into AioCompletionImpl,
and the results would be copied back after reading. This is replaced
with the creation of a static buffer of that buf.
* The pbl argument in AioCompletionImpl is removed.
The patch is tested against an application using librados. I've assumed
that 'pbl' in
aio_read( ...., pbl, )
is allocated by the user. It may even speed things up: a buffer copy is
prevented.
Thanks,
Rutger
[-- Attachment #2: aio_read_patch.diff --]
[-- Type: text/x-patch, Size: 2503 bytes --]
diff -u -p ceph-0.67.3/src/librados/AioCompletionImpl.h ceph-0.67.3-patched/src/librados/AioCompletionImpl.h
--- ceph-0.67.3/src/librados/AioCompletionImpl.h 2013-09-09 21:47:34.000000000 +0200
+++ ceph-0.67.3-patched/src/librados/AioCompletionImpl.h 2013-09-30 11:14:17.946802146 +0200
@@ -39,8 +39,7 @@ struct librados::AioCompletionImpl {
// for read
bool is_read;
- bufferlist bl, *pbl;
- char *buf;
+ bufferlist bl;
unsigned maxlen;
IoCtxImpl *io;
@@ -50,7 +49,7 @@ struct librados::AioCompletionImpl {
AioCompletionImpl() : lock("AioCompletionImpl lock", false, false),
ref(1), rval(0), released(false), ack(false), safe(false),
callback_complete(0), callback_safe(0), callback_arg(0),
- is_read(false), pbl(0), buf(0), maxlen(0),
+ is_read(false), maxlen(0),
io(NULL), aio_write_seq(0), aio_write_list_item(this) { }
int set_complete_callback(void *cb_arg, rados_callback_t cb) {
diff -u -p ceph-0.67.3/src/librados/IoCtxImpl.cc ceph-0.67.3-patched/src/librados/IoCtxImpl.cc
--- ceph-0.67.3/src/librados/IoCtxImpl.cc 2013-09-09 21:47:34.000000000 +0200
+++ ceph-0.67.3-patched/src/librados/IoCtxImpl.cc 2013-09-30 11:14:23.622824966 +0200
@@ -570,7 +570,6 @@ int librados::IoCtxImpl::aio_operate_rea
c->is_read = true;
c->io = this;
- c->pbl = pbl;
Mutex::Locker l(*lock);
objecter->read(oid, oloc,
@@ -613,11 +612,10 @@ int librados::IoCtxImpl::aio_read(const
c->is_read = true;
c->io = this;
- c->pbl = pbl;
Mutex::Locker l(*lock);
objecter->read(oid, oloc,
- off, len, snapid, &c->bl, 0,
+ off, len, snapid, pbl, 0,
onack, &c->objver);
return 0;
}
@@ -633,8 +631,9 @@ int librados::IoCtxImpl::aio_read(const
c->is_read = true;
c->io = this;
- c->buf = buf;
c->maxlen = len;
+ c->bl.clear();
+ c->bl.push_back( buffer::create_static( len, buf ) );
Mutex::Locker l(*lock);
objecter->read(oid, oloc,
@@ -669,7 +668,6 @@ int librados::IoCtxImpl::aio_sparse_read
c->is_read = true;
c->io = this;
- c->pbl = NULL;
onack->m_ops.sparse_read(off, len, m, data_bl, NULL);
@@ -1180,15 +1178,6 @@ void librados::IoCtxImpl::C_aio_Ack::fin
c->safe = true;
c->cond.Signal();
- if (c->buf && c->bl.length() > 0) {
- unsigned l = MIN(c->bl.length(), c->maxlen);
- c->bl.copy(0, l, c->buf);
- c->rval = c->bl.length();
- }
- if (c->pbl) {
- *c->pbl = c->bl;
- }
-
if (c->callback_complete) {
c->io->client->finisher.queue(new C_AioComplete(c));
}
next reply other threads:[~2013-09-30 10:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 10:13 Rutger ter Borg [this message]
2013-09-30 15:38 ` [PATCH] fix librados aio read buffer handling Sage Weil
2013-09-30 22:52 ` Josh Durgin
2013-09-30 23:14 ` Sage Weil
2013-11-27 8:49 ` Rutger ter Borg
2013-12-30 20:00 ` Josh Durgin
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='l2bire$iue$1@ger.gmane.org' \
--to=rutger@terborg.net \
--cc=ceph-devel@vger.kernel.org \
/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