From: Rutger ter Borg <rutger@terborg.net>
To: ceph-devel@vger.kernel.org
Subject: Re: Rados and user-provided buffers
Date: Thu, 19 Sep 2013 11:28:55 +0200 [thread overview]
Message-ID: <l1eg4e$uom$1@ger.gmane.org> (raw)
In-Reply-To: <alpine.DEB.2.00.1309181347570.30792@cobra.newdream.net>
On 2013-09-18 22:52, Sage Weil wrote:
> Hmm, looking at the code, I'm surprised that this isn't working. The C
> aio_read call is just doing
>
> bufferlist bl;
> bufferptr bp = buffer::create_static(len, buf);
> bl.push_back(bp);
>
> ret = ctx->read(oid, bl, len, off);
> if (ret >= 0) {
> if (bl.length() > len)
> return -ERANGE;
> if (bl.c_str() != buf)
> bl.copy(0, bl.length(), buf);
Hey Sage,
thanks for the hints. You're citing the synchronous version of
rados_read, not rados_aio_read. The difference between rados_read and
rados_aio_read (the C-versions) is that rados_read uses a bufferlist,
and rados_aio_read uses an overload with a char* buf. Both are delegated
to IoCtxImpl. IoCtxImpl has two overloads for aio_read, one accepting a
bufferlist and a char*, but only one overload for read, accepting a
bufferlist only.
IoCtxImpl's overloads for aio_read are almost identical, the difference
is that the buflist overload sets a bufferlist on AioCompletionImpl* c,
c->pbl = pbl;
and the char* buffer-overload sets a buffer
c->buf = buf;
AioCompletionImpl contains multiple data members: a bufferlist (bl), a
pointer to a bufferlist (pbl), and a pointer to a character array buf.
The following calls (in IoCtxImpl's aio_read overloads) to the objecter
are identical:
objecter->read(oid, oloc,
off, len, snapid, &c->bl, 0,
onack, &c->objver);
Looking at the Objecter read and deeper in the call chain, it seems that
information about data member pbl in AioCompletionImpl* is lost. The
objecter only knows about a Context, not about AioCompletionImpl. The
user-provided buffer is not passed on.
My preliminary conclusion is that my problem is caused by information
lost in IoCtxImpl's aio_read overloads. Maybe it can be solved by
modifying IoCtxImpl.cc:
* removing line 615. Not sure why the AioCompletionImpl needs to know
anything about buffers?
* replacing '&c->bl' with 'pbl' on line 619 of IoCtxImpl.cc, making
the call to the objecter
objecter->read(oid, oloc,
off, len, snapid, pbl, 0,
onack, &c->objver);
In that way, the bufferlist is passed through, and not thrown away.
Thanks,
Rutger
next prev parent reply other threads:[~2013-09-19 9:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-18 19:57 Rados and user-provided buffers Rutger ter Borg
2013-09-18 20:01 ` Sage Weil
2013-09-18 20:31 ` Rutger ter Borg
2013-09-18 20:52 ` Sage Weil
2013-09-19 9:28 ` Rutger ter Borg [this message]
2013-09-19 12:39 ` Rutger ter Borg
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='l1eg4e$uom$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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.