All of lore.kernel.org
 help / color / mirror / Atom feed
* [rados] Asynchronous operations
@ 2012-06-27  7:32 Rutger ter Borg
  2012-06-27 15:22 ` Sage Weil
  0 siblings, 1 reply; 4+ messages in thread
From: Rutger ter Borg @ 2012-06-27  7:32 UTC (permalink / raw)
  To: ceph-devel


Dear list,

I'm currently writing a Boost.Asio-like interface to librados.hpp. Most 
things are working like expected, and some things I couldn't figure out 
from the available docs and code. I have itemized a couple of questions 
below.

* to avoid allocations done by rados, I'm currently using 
buffer::create_static() for both reads and writes. I suppose this is ok?

* suppose you have the following code example

boost::asio::io_service ios;
pool pool( "some pool", ios );

std::string some_data( "this is an example string of data" );
pool.async_write_object_at( "hello", 0, boost::asio::buffer( some_data 
), &done );

ios.run();

with respect to this interface, I have the following questions:

a) the IoCtx's synchronous read() and write() functions return the 
number of bytes read and written; is there a way to get to this number 
from AioCompletion? I would like to define the function signature for 
the callback handler (see 'done' in the example above) something like

void( const boost::system::error_code&, std::size_t )

where the second argument would be the number of bytes transferred.

b) is it possible to cancel outstanding asynchronous operations? I.e., 
have the possibility to implement something like

pool.cancel();

?

TIA,
Regards,

Rutger




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rados] Asynchronous operations
  2012-06-27  7:32 [rados] Asynchronous operations Rutger ter Borg
@ 2012-06-27 15:22 ` Sage Weil
  2012-07-23 15:59   ` Rutger ter Borg
  0 siblings, 1 reply; 4+ messages in thread
From: Sage Weil @ 2012-06-27 15:22 UTC (permalink / raw)
  To: Rutger ter Borg; +Cc: ceph-devel

On Wed, 27 Jun 2012, Rutger ter Borg wrote:
> 
> Dear list,
> 
> I'm currently writing a Boost.Asio-like interface to librados.hpp. Most things
> are working like expected, and some things I couldn't figure out from the
> available docs and code. I have itemized a couple of questions below.
> 
> * to avoid allocations done by rados, I'm currently using
> buffer::create_static() for both reads and writes. I suppose this is ok?
> 
> * suppose you have the following code example
> 
> boost::asio::io_service ios;
> pool pool( "some pool", ios );
> 
> std::string some_data( "this is an example string of data" );
> pool.async_write_object_at( "hello", 0, boost::asio::buffer( some_data ),
> &done );
> 
> ios.run();
> 
> with respect to this interface, I have the following questions:
> 
> a) the IoCtx's synchronous read() and write() functions return the number of
> bytes read and written; is there a way to get to this number from
> AioCompletion? I would like to define the function signature for the callback
> handler (see 'done' in the example above) something like
> 
> void( const boost::system::error_code&, std::size_t )
> 
> where the second argument would be the number of bytes transferred.

There is a get_return_value() method on the AioCompletion that gives you 
bytes read (for reads).  For write operations, it is always 0 (success) or 
an error code.

> b) is it possible to cancel outstanding asynchronous operations? I.e., have
> the possibility to implement something like
> 
> pool.cancel();

Not currently.  This is probably something we should add.

sage

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rados] Asynchronous operations
  2012-06-27 15:22 ` Sage Weil
@ 2012-07-23 15:59   ` Rutger ter Borg
  2012-07-23 16:07     ` Josh Durgin
  0 siblings, 1 reply; 4+ messages in thread
From: Rutger ter Borg @ 2012-07-23 15:59 UTC (permalink / raw)
  To: ceph-devel

On 06/27/2012 05:22 PM, Sage Weil wrote:
>
> There is a get_return_value() method on the AioCompletion that gives you
> bytes read (for reads).  For write operations, it is always 0 (success) or
> an error code.
>

Thanks for the info. Maybe a bit of a newbie question, but in that case, 
how do I detect a read error, given an AioCompletion object?

Thanks,

Rutger



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rados] Asynchronous operations
  2012-07-23 15:59   ` Rutger ter Borg
@ 2012-07-23 16:07     ` Josh Durgin
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Durgin @ 2012-07-23 16:07 UTC (permalink / raw)
  To: Rutger ter Borg; +Cc: ceph-devel

On 07/23/2012 08:59 AM, Rutger ter Borg wrote:
> On 06/27/2012 05:22 PM, Sage Weil wrote:
>>
>> There is a get_return_value() method on the AioCompletion that gives you
>> bytes read (for reads).  For write operations, it is always 0
>> (success) or
>> an error code.
>>
>
> Thanks for the info. Maybe a bit of a newbie question, but in that case,
> how do I detect a read error, given an AioCompletion object?

It's the same as with writes - if there's an error, get_return_value
will give you the negative error code (i.e. -ENOENT, -EPERM, etc).


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-23 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27  7:32 [rados] Asynchronous operations Rutger ter Borg
2012-06-27 15:22 ` Sage Weil
2012-07-23 15:59   ` Rutger ter Borg
2012-07-23 16:07     ` Josh Durgin

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.