* [PATCH] implement librados aio_stat @ 2012-12-14 11:18 Filippos Giannakos 2012-12-14 12:19 ` Giannakos Filippos 2012-12-15 7:49 ` Yehuda Sadeh 0 siblings, 2 replies; 14+ messages in thread From: Filippos Giannakos @ 2012-12-14 11:18 UTC (permalink / raw) To: ceph-devel; +Cc: synefo-devel, philipgian --- src/include/rados/librados.h | 14 ++++++++++++++ src/include/rados/librados.hpp | 15 +++++++++++++- src/librados/IoCtxImpl.cc | 42 ++++++++++++++++++++++++++++++++++++++++ src/librados/IoCtxImpl.h | 9 +++++++++ src/librados/librados.cc | 10 ++++++++++ 5 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 44d6f71..7f4b5c0 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char *oid, */ int rados_aio_flush(rados_ioctx_t io); + +/** + * Asynchronously get object stats (size/mtime) + * + * @param io ioctx + * @param o object name + * @param psize where to store object size + * @param pmtime where to store modification time + * @returns 0 on success, negative error code on failure + */ +int rados_aio_stat(rados_ioctx_t io, const char *o, + rados_completion_t completion, + uint64_t *psize, time_t *pmtime); + /** @} Asynchronous I/O */ /** diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index e50acdb..96bfc15 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -473,9 +473,22 @@ namespace librados * other than CEPH_NOSNAP */ int aio_remove(const std::string& oid, AioCompletion *c); - + int aio_flush(); + /** + * Asynchronously get object stats (size/mtime) + * + * @param io ioctx + * @param o object name + * @param psize where to store object size + * @param pmtime where to store modification time + * @returns 0 on success, negative error code on failure + */ + int rados_aio_stat(rados_ioctx_t io, const char *o, + rados_completion_t completion, + uint64_t *psize, time_t *pmtime); + int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method, bufferlist& inbl, bufferlist *outbl); diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 01b4a94..50aab1e 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c) return 0; } + +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, + uint64_t *psize, time_t *pmtime) +{ + c->io = this; + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); + + Mutex::Locker l(*lock); + objecter->stat(oid, oloc, + snap_seq, psize, &onack->mtime, 0, + onack, &c->objver); + + return 0; +} + int librados::IoCtxImpl::remove(const object_t& oid) { utime_t ut = ceph_clock_now(client->cct); @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) c->put_unlock(); } +///////////////////////////// C_aio_stat_Ack //////////////////////////// + +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl *_c, + time_t *pm) + : c(_c), pmtime(pm) +{ + c->get(); +} + +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) +{ + c->lock.Lock(); + c->rval = r; + c->ack = true; + c->cond.Signal(); + + if (r >= 0 && pmtime) { + *pmtime = mtime.sec(); + } + + if (c->callback_complete) { + c->io->client->finisher.queue(new C_AioComplete(c)); + } + + c->put_unlock(); +} + /////////////////////// C_aio_sparse_read_Ack ////////////////////////// librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl *_c, diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index feea0e8..55b07ee 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { C_aio_Ack(AioCompletionImpl *_c); void finish(int r); }; + + struct C_aio_stat_Ack : public Context { + librados::AioCompletionImpl *c; + time_t *pmtime; + utime_t mtime; + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); + void finish(int r); + }; struct C_aio_sparse_read_Ack : public Context { AioCompletionImpl *c; @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { int aio_remove(const object_t &oid, AioCompletionImpl *c); int aio_exec(const object_t& oid, AioCompletionImpl *c, const char *cls, const char *method, bufferlist& inbl, bufferlist *outbl); + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); int pool_change_auid(unsigned long long auid); int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 274119c..af36b38 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) return 0; } +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, + rados_completion_t completion, + uint64_t *psize, time_t *pmtime) +{ + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; + object_t oid(o); + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, + psize, pmtime); +} + struct C_WatchCB : public librados::WatchCtx { rados_watchcb_t wcb; void *arg; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] implement librados aio_stat 2012-12-14 11:18 [PATCH] implement librados aio_stat Filippos Giannakos @ 2012-12-14 12:19 ` Giannakos Filippos 2012-12-15 7:49 ` Yehuda Sadeh 1 sibling, 0 replies; 14+ messages in thread From: Giannakos Filippos @ 2012-12-14 12:19 UTC (permalink / raw) To: ceph-devel; +Cc: synnefo-devel Hi team, I forgot to include a description (also cc-ing correctly the synnefo-devel list). I am a member of the Synnefo team, where we are experimenting with RADOS as a storage backend to host blocks for our volume block storage named "archipelago". In this patch I implement aio stat and also export this functionality to the C API. On 12/14/2012 01:18 PM, Filippos Giannakos wrote: > --- > src/include/rados/librados.h | 14 ++++++++++++++ > src/include/rados/librados.hpp | 15 +++++++++++++- > src/librados/IoCtxImpl.cc | 42 ++++++++++++++++++++++++++++++++++++++++ > src/librados/IoCtxImpl.h | 9 +++++++++ > src/librados/librados.cc | 10 ++++++++++ > 5 files changed, 89 insertions(+), 1 deletion(-) > > diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h > index 44d6f71..7f4b5c0 100644 > --- a/src/include/rados/librados.h > +++ b/src/include/rados/librados.h > @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char *oid, > */ > int rados_aio_flush(rados_ioctx_t io); > > + > +/** > + * Asynchronously get object stats (size/mtime) > + * > + * @param io ioctx > + * @param o object name > + * @param psize where to store object size > + * @param pmtime where to store modification time > + * @returns 0 on success, negative error code on failure > + */ > +int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime); > + > /** @} Asynchronous I/O */ > > /** > diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp > index e50acdb..96bfc15 100644 > --- a/src/include/rados/librados.hpp > +++ b/src/include/rados/librados.hpp > @@ -473,9 +473,22 @@ namespace librados > * other than CEPH_NOSNAP > */ > int aio_remove(const std::string& oid, AioCompletion *c); > - > + > int aio_flush(); > > + /** > + * Asynchronously get object stats (size/mtime) > + * > + * @param io ioctx > + * @param o object name > + * @param psize where to store object size > + * @param pmtime where to store modification time > + * @returns 0 on success, negative error code on failure > + */ > + int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime); > + > int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method, > bufferlist& inbl, bufferlist *outbl); > > diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc > index 01b4a94..50aab1e 100644 > --- a/src/librados/IoCtxImpl.cc > +++ b/src/librados/IoCtxImpl.cc > @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const object_t&oid, AioCompletionImpl *c) > return 0; > } > > + > +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, > + uint64_t *psize, time_t *pmtime) > +{ > + c->io = this; > + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); > + > + Mutex::Locker l(*lock); > + objecter->stat(oid, oloc, > + snap_seq, psize,&onack->mtime, 0, > + onack,&c->objver); > + > + return 0; > +} > + > int librados::IoCtxImpl::remove(const object_t& oid) > { > utime_t ut = ceph_clock_now(client->cct); > @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) > c->put_unlock(); > } > > +///////////////////////////// C_aio_stat_Ack //////////////////////////// > + > +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl *_c, > + time_t *pm) > + : c(_c), pmtime(pm) > +{ > + c->get(); > +} > + > +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) > +{ > + c->lock.Lock(); > + c->rval = r; > + c->ack = true; > + c->cond.Signal(); > + > + if (r>= 0&& pmtime) { > + *pmtime = mtime.sec(); > + } > + > + if (c->callback_complete) { > + c->io->client->finisher.queue(new C_AioComplete(c)); > + } > + > + c->put_unlock(); > +} > + > /////////////////////// C_aio_sparse_read_Ack ////////////////////////// > > librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl *_c, > diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h > index feea0e8..55b07ee 100644 > --- a/src/librados/IoCtxImpl.h > +++ b/src/librados/IoCtxImpl.h > @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { > C_aio_Ack(AioCompletionImpl *_c); > void finish(int r); > }; > + > + struct C_aio_stat_Ack : public Context { > + librados::AioCompletionImpl *c; > + time_t *pmtime; > + utime_t mtime; > + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); > + void finish(int r); > + }; > > struct C_aio_sparse_read_Ack : public Context { > AioCompletionImpl *c; > @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { > int aio_remove(const object_t&oid, AioCompletionImpl *c); > int aio_exec(const object_t& oid, AioCompletionImpl *c, const char *cls, > const char *method, bufferlist& inbl, bufferlist *outbl); > + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); > > int pool_change_auid(unsigned long long auid); > int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); > diff --git a/src/librados/librados.cc b/src/librados/librados.cc > index 274119c..af36b38 100644 > --- a/src/librados/librados.cc > +++ b/src/librados/librados.cc > @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) > return 0; > } > > +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime) > +{ > + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; > + object_t oid(o); > + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, > + psize, pmtime); > +} > + > struct C_WatchCB : public librados::WatchCtx { > rados_watchcb_t wcb; > void *arg; > -- > 1.7.10.4 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] implement librados aio_stat 2012-12-14 11:18 [PATCH] implement librados aio_stat Filippos Giannakos 2012-12-14 12:19 ` Giannakos Filippos @ 2012-12-15 7:49 ` Yehuda Sadeh 2012-12-19 9:13 ` Filippos Giannakos 1 sibling, 1 reply; 14+ messages in thread From: Yehuda Sadeh @ 2012-12-15 7:49 UTC (permalink / raw) To: Filippos Giannakos; +Cc: ceph-devel, synefo-devel Went through it briefly, looks fine, though I'd like to go over it some more before picking this up. Note that LIBRADOS_VER_MINOR needs to be bumped up too. Thanks, Yehuda On Fri, Dec 14, 2012 at 3:18 AM, Filippos Giannakos <philipgian@grnet.gr> wrote: > --- > src/include/rados/librados.h | 14 ++++++++++++++ > src/include/rados/librados.hpp | 15 +++++++++++++- > src/librados/IoCtxImpl.cc | 42 ++++++++++++++++++++++++++++++++++++++++ > src/librados/IoCtxImpl.h | 9 +++++++++ > src/librados/librados.cc | 10 ++++++++++ > 5 files changed, 89 insertions(+), 1 deletion(-) > > diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h > index 44d6f71..7f4b5c0 100644 > --- a/src/include/rados/librados.h > +++ b/src/include/rados/librados.h > @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char *oid, > */ > int rados_aio_flush(rados_ioctx_t io); > > + > +/** > + * Asynchronously get object stats (size/mtime) > + * > + * @param io ioctx > + * @param o object name > + * @param psize where to store object size > + * @param pmtime where to store modification time > + * @returns 0 on success, negative error code on failure > + */ > +int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime); > + > /** @} Asynchronous I/O */ > > /** > diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp > index e50acdb..96bfc15 100644 > --- a/src/include/rados/librados.hpp > +++ b/src/include/rados/librados.hpp > @@ -473,9 +473,22 @@ namespace librados > * other than CEPH_NOSNAP > */ > int aio_remove(const std::string& oid, AioCompletion *c); > - > + > int aio_flush(); > > + /** > + * Asynchronously get object stats (size/mtime) > + * > + * @param io ioctx > + * @param o object name > + * @param psize where to store object size > + * @param pmtime where to store modification time > + * @returns 0 on success, negative error code on failure > + */ > + int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime); > + > int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method, > bufferlist& inbl, bufferlist *outbl); > > diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc > index 01b4a94..50aab1e 100644 > --- a/src/librados/IoCtxImpl.cc > +++ b/src/librados/IoCtxImpl.cc > @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c) > return 0; > } > > + > +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, > + uint64_t *psize, time_t *pmtime) > +{ > + c->io = this; > + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); > + > + Mutex::Locker l(*lock); > + objecter->stat(oid, oloc, > + snap_seq, psize, &onack->mtime, 0, > + onack, &c->objver); > + > + return 0; > +} > + > int librados::IoCtxImpl::remove(const object_t& oid) > { > utime_t ut = ceph_clock_now(client->cct); > @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) > c->put_unlock(); > } > > +///////////////////////////// C_aio_stat_Ack //////////////////////////// > + > +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl *_c, > + time_t *pm) > + : c(_c), pmtime(pm) > +{ > + c->get(); > +} > + > +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) > +{ > + c->lock.Lock(); > + c->rval = r; > + c->ack = true; > + c->cond.Signal(); > + > + if (r >= 0 && pmtime) { > + *pmtime = mtime.sec(); > + } > + > + if (c->callback_complete) { > + c->io->client->finisher.queue(new C_AioComplete(c)); > + } > + > + c->put_unlock(); > +} > + > /////////////////////// C_aio_sparse_read_Ack ////////////////////////// > > librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl *_c, > diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h > index feea0e8..55b07ee 100644 > --- a/src/librados/IoCtxImpl.h > +++ b/src/librados/IoCtxImpl.h > @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { > C_aio_Ack(AioCompletionImpl *_c); > void finish(int r); > }; > + > + struct C_aio_stat_Ack : public Context { > + librados::AioCompletionImpl *c; > + time_t *pmtime; > + utime_t mtime; > + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); > + void finish(int r); > + }; > > struct C_aio_sparse_read_Ack : public Context { > AioCompletionImpl *c; > @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { > int aio_remove(const object_t &oid, AioCompletionImpl *c); > int aio_exec(const object_t& oid, AioCompletionImpl *c, const char *cls, > const char *method, bufferlist& inbl, bufferlist *outbl); > + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); > > int pool_change_auid(unsigned long long auid); > int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); > diff --git a/src/librados/librados.cc b/src/librados/librados.cc > index 274119c..af36b38 100644 > --- a/src/librados/librados.cc > +++ b/src/librados/librados.cc > @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) > return 0; > } > > +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, > + rados_completion_t completion, > + uint64_t *psize, time_t *pmtime) > +{ > + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; > + object_t oid(o); > + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, > + psize, pmtime); > +} > + > struct C_WatchCB : public librados::WatchCtx { > rados_watchcb_t wcb; > void *arg; > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] implement librados aio_stat 2012-12-15 7:49 ` Yehuda Sadeh @ 2012-12-19 9:13 ` Filippos Giannakos 2012-12-19 15:43 ` Sage Weil 0 siblings, 1 reply; 14+ messages in thread From: Filippos Giannakos @ 2012-12-19 9:13 UTC (permalink / raw) To: Yehuda Sadeh; +Cc: ceph-devel, synnefo-devel OK. About the LIBRADOS_VER_MINOR, do you want me to bump it and submit a new patch? Best regards, Filippos On 12/15/2012 09:49 AM, Yehuda Sadeh wrote: > Went through it briefly, looks fine, though I'd like to go over it > some more before picking this up. Note that LIBRADOS_VER_MINOR needs > to be bumped up too. > > Thanks, > Yehuda > > On Fri, Dec 14, 2012 at 3:18 AM, Filippos Giannakos<philipgian@grnet.gr> wrote: >> --- >> src/include/rados/librados.h | 14 ++++++++++++++ >> src/include/rados/librados.hpp | 15 +++++++++++++- >> src/librados/IoCtxImpl.cc | 42 ++++++++++++++++++++++++++++++++++++++++ >> src/librados/IoCtxImpl.h | 9 +++++++++ >> src/librados/librados.cc | 10 ++++++++++ >> 5 files changed, 89 insertions(+), 1 deletion(-) >> >> diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h >> index 44d6f71..7f4b5c0 100644 >> --- a/src/include/rados/librados.h >> +++ b/src/include/rados/librados.h >> @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char *oid, >> */ >> int rados_aio_flush(rados_ioctx_t io); >> >> + >> +/** >> + * Asynchronously get object stats (size/mtime) >> + * >> + * @param io ioctx >> + * @param o object name >> + * @param psize where to store object size >> + * @param pmtime where to store modification time >> + * @returns 0 on success, negative error code on failure >> + */ >> +int rados_aio_stat(rados_ioctx_t io, const char *o, >> + rados_completion_t completion, >> + uint64_t *psize, time_t *pmtime); >> + >> /** @} Asynchronous I/O */ >> >> /** >> diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp >> index e50acdb..96bfc15 100644 >> --- a/src/include/rados/librados.hpp >> +++ b/src/include/rados/librados.hpp >> @@ -473,9 +473,22 @@ namespace librados >> * other than CEPH_NOSNAP >> */ >> int aio_remove(const std::string& oid, AioCompletion *c); >> - >> + >> int aio_flush(); >> >> + /** >> + * Asynchronously get object stats (size/mtime) >> + * >> + * @param io ioctx >> + * @param o object name >> + * @param psize where to store object size >> + * @param pmtime where to store modification time >> + * @returns 0 on success, negative error code on failure >> + */ >> + int rados_aio_stat(rados_ioctx_t io, const char *o, >> + rados_completion_t completion, >> + uint64_t *psize, time_t *pmtime); >> + >> int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method, >> bufferlist& inbl, bufferlist *outbl); >> >> diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc >> index 01b4a94..50aab1e 100644 >> --- a/src/librados/IoCtxImpl.cc >> +++ b/src/librados/IoCtxImpl.cc >> @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const object_t&oid, AioCompletionImpl *c) >> return 0; >> } >> >> + >> +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, >> + uint64_t *psize, time_t *pmtime) >> +{ >> + c->io = this; >> + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); >> + >> + Mutex::Locker l(*lock); >> + objecter->stat(oid, oloc, >> + snap_seq, psize,&onack->mtime, 0, >> + onack,&c->objver); >> + >> + return 0; >> +} >> + >> int librados::IoCtxImpl::remove(const object_t& oid) >> { >> utime_t ut = ceph_clock_now(client->cct); >> @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) >> c->put_unlock(); >> } >> >> +///////////////////////////// C_aio_stat_Ack //////////////////////////// >> + >> +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl *_c, >> + time_t *pm) >> + : c(_c), pmtime(pm) >> +{ >> + c->get(); >> +} >> + >> +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) >> +{ >> + c->lock.Lock(); >> + c->rval = r; >> + c->ack = true; >> + c->cond.Signal(); >> + >> + if (r>= 0&& pmtime) { >> + *pmtime = mtime.sec(); >> + } >> + >> + if (c->callback_complete) { >> + c->io->client->finisher.queue(new C_AioComplete(c)); >> + } >> + >> + c->put_unlock(); >> +} >> + >> /////////////////////// C_aio_sparse_read_Ack ////////////////////////// >> >> librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl *_c, >> diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h >> index feea0e8..55b07ee 100644 >> --- a/src/librados/IoCtxImpl.h >> +++ b/src/librados/IoCtxImpl.h >> @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { >> C_aio_Ack(AioCompletionImpl *_c); >> void finish(int r); >> }; >> + >> + struct C_aio_stat_Ack : public Context { >> + librados::AioCompletionImpl *c; >> + time_t *pmtime; >> + utime_t mtime; >> + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); >> + void finish(int r); >> + }; >> >> struct C_aio_sparse_read_Ack : public Context { >> AioCompletionImpl *c; >> @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { >> int aio_remove(const object_t&oid, AioCompletionImpl *c); >> int aio_exec(const object_t& oid, AioCompletionImpl *c, const char *cls, >> const char *method, bufferlist& inbl, bufferlist *outbl); >> + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); >> >> int pool_change_auid(unsigned long long auid); >> int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); >> diff --git a/src/librados/librados.cc b/src/librados/librados.cc >> index 274119c..af36b38 100644 >> --- a/src/librados/librados.cc >> +++ b/src/librados/librados.cc >> @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) >> return 0; >> } >> >> +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, >> + rados_completion_t completion, >> + uint64_t *psize, time_t *pmtime) >> +{ >> + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; >> + object_t oid(o); >> + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, >> + psize, pmtime); >> +} >> + >> struct C_WatchCB : public librados::WatchCtx { >> rados_watchcb_t wcb; >> void *arg; >> -- >> 1.7.10.4 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] implement librados aio_stat 2012-12-19 9:13 ` Filippos Giannakos @ 2012-12-19 15:43 ` Sage Weil 2012-12-19 15:53 ` Josh Durgin 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 0 siblings, 2 replies; 14+ messages in thread From: Sage Weil @ 2012-12-19 15:43 UTC (permalink / raw) To: Filippos Giannakos; +Cc: Yehuda Sadeh, ceph-devel, synnefo-devel On Wed, 19 Dec 2012, Filippos Giannakos wrote: > OK. About the LIBRADOS_VER_MINOR, do you want me to bump it and submit a > new patch? Yes, please. Also, one other thing: can you add a functional test to ceph.git/src/test/librados/aio.cc so that all of the the regular testing and test suites will exercise the new code? Thanks! sage > > Best regards, > Filippos > > On 12/15/2012 09:49 AM, Yehuda Sadeh wrote: > > Went through it briefly, looks fine, though I'd like to go over it > > some more before picking this up. Note that LIBRADOS_VER_MINOR needs > > to be bumped up too. > > > > Thanks, > > Yehuda > > > > On Fri, Dec 14, 2012 at 3:18 AM, Filippos Giannakos<philipgian@grnet.gr> > > wrote: > > > --- > > > src/include/rados/librados.h | 14 ++++++++++++++ > > > src/include/rados/librados.hpp | 15 +++++++++++++- > > > src/librados/IoCtxImpl.cc | 42 > > > ++++++++++++++++++++++++++++++++++++++++ > > > src/librados/IoCtxImpl.h | 9 +++++++++ > > > src/librados/librados.cc | 10 ++++++++++ > > > 5 files changed, 89 insertions(+), 1 deletion(-) > > > > > > diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h > > > index 44d6f71..7f4b5c0 100644 > > > --- a/src/include/rados/librados.h > > > +++ b/src/include/rados/librados.h > > > @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char > > > *oid, > > > */ > > > int rados_aio_flush(rados_ioctx_t io); > > > > > > + > > > +/** > > > + * Asynchronously get object stats (size/mtime) > > > + * > > > + * @param io ioctx > > > + * @param o object name > > > + * @param psize where to store object size > > > + * @param pmtime where to store modification time > > > + * @returns 0 on success, negative error code on failure > > > + */ > > > +int rados_aio_stat(rados_ioctx_t io, const char *o, > > > + rados_completion_t completion, > > > + uint64_t *psize, time_t *pmtime); > > > + > > > /** @} Asynchronous I/O */ > > > > > > /** > > > diff --git a/src/include/rados/librados.hpp > > > b/src/include/rados/librados.hpp > > > index e50acdb..96bfc15 100644 > > > --- a/src/include/rados/librados.hpp > > > +++ b/src/include/rados/librados.hpp > > > @@ -473,9 +473,22 @@ namespace librados > > > * other than CEPH_NOSNAP > > > */ > > > int aio_remove(const std::string& oid, AioCompletion *c); > > > - > > > + > > > int aio_flush(); > > > > > > + /** > > > + * Asynchronously get object stats (size/mtime) > > > + * > > > + * @param io ioctx > > > + * @param o object name > > > + * @param psize where to store object size > > > + * @param pmtime where to store modification time > > > + * @returns 0 on success, negative error code on failure > > > + */ > > > + int rados_aio_stat(rados_ioctx_t io, const char *o, > > > + rados_completion_t completion, > > > + uint64_t *psize, time_t *pmtime); > > > + > > > int aio_exec(const std::string& oid, AioCompletion *c, const char > > > *cls, const char *method, > > > bufferlist& inbl, bufferlist *outbl); > > > > > > diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc > > > index 01b4a94..50aab1e 100644 > > > --- a/src/librados/IoCtxImpl.cc > > > +++ b/src/librados/IoCtxImpl.cc > > > @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const > > > object_t&oid, AioCompletionImpl *c) > > > return 0; > > > } > > > > > > + > > > +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl > > > *c, > > > + uint64_t *psize, time_t *pmtime) > > > +{ > > > + c->io = this; > > > + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); > > > + > > > + Mutex::Locker l(*lock); > > > + objecter->stat(oid, oloc, > > > + snap_seq, psize,&onack->mtime, 0, > > > + onack,&c->objver); > > > + > > > + return 0; > > > +} > > > + > > > int librados::IoCtxImpl::remove(const object_t& oid) > > > { > > > utime_t ut = ceph_clock_now(client->cct); > > > @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) > > > c->put_unlock(); > > > } > > > > > > +///////////////////////////// C_aio_stat_Ack //////////////////////////// > > > + > > > +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl > > > *_c, > > > + time_t *pm) > > > + : c(_c), pmtime(pm) > > > +{ > > > + c->get(); > > > +} > > > + > > > +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) > > > +{ > > > + c->lock.Lock(); > > > + c->rval = r; > > > + c->ack = true; > > > + c->cond.Signal(); > > > + > > > + if (r>= 0&& pmtime) { > > > + *pmtime = mtime.sec(); > > > + } > > > + > > > + if (c->callback_complete) { > > > + c->io->client->finisher.queue(new C_AioComplete(c)); > > > + } > > > + > > > + c->put_unlock(); > > > +} > > > + > > > /////////////////////// C_aio_sparse_read_Ack ////////////////////////// > > > > > > librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl > > > *_c, > > > diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h > > > index feea0e8..55b07ee 100644 > > > --- a/src/librados/IoCtxImpl.h > > > +++ b/src/librados/IoCtxImpl.h > > > @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { > > > C_aio_Ack(AioCompletionImpl *_c); > > > void finish(int r); > > > }; > > > + > > > + struct C_aio_stat_Ack : public Context { > > > + librados::AioCompletionImpl *c; > > > + time_t *pmtime; > > > + utime_t mtime; > > > + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); > > > + void finish(int r); > > > + }; > > > > > > struct C_aio_sparse_read_Ack : public Context { > > > AioCompletionImpl *c; > > > @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { > > > int aio_remove(const object_t&oid, AioCompletionImpl *c); > > > int aio_exec(const object_t& oid, AioCompletionImpl *c, const char > > > *cls, > > > const char *method, bufferlist& inbl, bufferlist *outbl); > > > + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t > > > *psize, time_t *pmtime); > > > > > > int pool_change_auid(unsigned long long auid); > > > int pool_change_auid_async(unsigned long long auid, > > > PoolAsyncCompletionImpl *c); > > > diff --git a/src/librados/librados.cc b/src/librados/librados.cc > > > index 274119c..af36b38 100644 > > > --- a/src/librados/librados.cc > > > +++ b/src/librados/librados.cc > > > @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) > > > return 0; > > > } > > > > > > +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, > > > + rados_completion_t completion, > > > + uint64_t *psize, time_t *pmtime) > > > +{ > > > + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; > > > + object_t oid(o); > > > + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, > > > + psize, pmtime); > > > +} > > > + > > > struct C_WatchCB : public librados::WatchCtx { > > > rados_watchcb_t wcb; > > > void *arg; > > > -- > > > 1.7.10.4 > > > > > > -- > > > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > > > the body of a message to majordomo@vger.kernel.org > > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] implement librados aio_stat 2012-12-19 15:43 ` Sage Weil @ 2012-12-19 15:53 ` Josh Durgin 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 1 sibling, 0 replies; 14+ messages in thread From: Josh Durgin @ 2012-12-19 15:53 UTC (permalink / raw) To: Sage Weil; +Cc: Filippos Giannakos, Yehuda Sadeh, ceph-devel, synnefo-devel On 12/19/2012 07:43 AM, Sage Weil wrote: > On Wed, 19 Dec 2012, Filippos Giannakos wrote: >> OK. About the LIBRADOS_VER_MINOR, do you want me to bump it and submit a >> new patch? > > Yes, please. Also, one other thing: can you add a functional test to > ceph.git/src/test/librados/aio.cc so that all of the the regular testing > and test suites will exercise the new code? Also the C++ version can just be aio_stat rather than rados_aio_stat. It's already in the librados namespace. Josh > Thanks! > sage > > >> >> Best regards, >> Filippos >> >> On 12/15/2012 09:49 AM, Yehuda Sadeh wrote: >>> Went through it briefly, looks fine, though I'd like to go over it >>> some more before picking this up. Note that LIBRADOS_VER_MINOR needs >>> to be bumped up too. >>> >>> Thanks, >>> Yehuda >>> >>> On Fri, Dec 14, 2012 at 3:18 AM, Filippos Giannakos<philipgian@grnet.gr> >>> wrote: >>>> --- >>>> src/include/rados/librados.h | 14 ++++++++++++++ >>>> src/include/rados/librados.hpp | 15 +++++++++++++- >>>> src/librados/IoCtxImpl.cc | 42 >>>> ++++++++++++++++++++++++++++++++++++++++ >>>> src/librados/IoCtxImpl.h | 9 +++++++++ >>>> src/librados/librados.cc | 10 ++++++++++ >>>> 5 files changed, 89 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h >>>> index 44d6f71..7f4b5c0 100644 >>>> --- a/src/include/rados/librados.h >>>> +++ b/src/include/rados/librados.h >>>> @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char >>>> *oid, >>>> */ >>>> int rados_aio_flush(rados_ioctx_t io); >>>> >>>> + >>>> +/** >>>> + * Asynchronously get object stats (size/mtime) >>>> + * >>>> + * @param io ioctx >>>> + * @param o object name >>>> + * @param psize where to store object size >>>> + * @param pmtime where to store modification time >>>> + * @returns 0 on success, negative error code on failure >>>> + */ >>>> +int rados_aio_stat(rados_ioctx_t io, const char *o, >>>> + rados_completion_t completion, >>>> + uint64_t *psize, time_t *pmtime); >>>> + >>>> /** @} Asynchronous I/O */ >>>> >>>> /** >>>> diff --git a/src/include/rados/librados.hpp >>>> b/src/include/rados/librados.hpp >>>> index e50acdb..96bfc15 100644 >>>> --- a/src/include/rados/librados.hpp >>>> +++ b/src/include/rados/librados.hpp >>>> @@ -473,9 +473,22 @@ namespace librados >>>> * other than CEPH_NOSNAP >>>> */ >>>> int aio_remove(const std::string& oid, AioCompletion *c); >>>> - >>>> + >>>> int aio_flush(); >>>> >>>> + /** >>>> + * Asynchronously get object stats (size/mtime) >>>> + * >>>> + * @param io ioctx >>>> + * @param o object name >>>> + * @param psize where to store object size >>>> + * @param pmtime where to store modification time >>>> + * @returns 0 on success, negative error code on failure >>>> + */ >>>> + int rados_aio_stat(rados_ioctx_t io, const char *o, >>>> + rados_completion_t completion, >>>> + uint64_t *psize, time_t *pmtime); >>>> + >>>> int aio_exec(const std::string& oid, AioCompletion *c, const char >>>> *cls, const char *method, >>>> bufferlist& inbl, bufferlist *outbl); >>>> >>>> diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc >>>> index 01b4a94..50aab1e 100644 >>>> --- a/src/librados/IoCtxImpl.cc >>>> +++ b/src/librados/IoCtxImpl.cc >>>> @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const >>>> object_t&oid, AioCompletionImpl *c) >>>> return 0; >>>> } >>>> >>>> + >>>> +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl >>>> *c, >>>> + uint64_t *psize, time_t *pmtime) >>>> +{ >>>> + c->io = this; >>>> + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); >>>> + >>>> + Mutex::Locker l(*lock); >>>> + objecter->stat(oid, oloc, >>>> + snap_seq, psize,&onack->mtime, 0, >>>> + onack,&c->objver); >>>> + >>>> + return 0; >>>> +} >>>> + >>>> int librados::IoCtxImpl::remove(const object_t& oid) >>>> { >>>> utime_t ut = ceph_clock_now(client->cct); >>>> @@ -1562,6 +1577,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) >>>> c->put_unlock(); >>>> } >>>> >>>> +///////////////////////////// C_aio_stat_Ack //////////////////////////// >>>> + >>>> +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl >>>> *_c, >>>> + time_t *pm) >>>> + : c(_c), pmtime(pm) >>>> +{ >>>> + c->get(); >>>> +} >>>> + >>>> +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) >>>> +{ >>>> + c->lock.Lock(); >>>> + c->rval = r; >>>> + c->ack = true; >>>> + c->cond.Signal(); >>>> + >>>> + if (r>= 0&& pmtime) { >>>> + *pmtime = mtime.sec(); >>>> + } >>>> + >>>> + if (c->callback_complete) { >>>> + c->io->client->finisher.queue(new C_AioComplete(c)); >>>> + } >>>> + >>>> + c->put_unlock(); >>>> +} >>>> + >>>> /////////////////////// C_aio_sparse_read_Ack ////////////////////////// >>>> >>>> librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl >>>> *_c, >>>> diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h >>>> index feea0e8..55b07ee 100644 >>>> --- a/src/librados/IoCtxImpl.h >>>> +++ b/src/librados/IoCtxImpl.h >>>> @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { >>>> C_aio_Ack(AioCompletionImpl *_c); >>>> void finish(int r); >>>> }; >>>> + >>>> + struct C_aio_stat_Ack : public Context { >>>> + librados::AioCompletionImpl *c; >>>> + time_t *pmtime; >>>> + utime_t mtime; >>>> + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); >>>> + void finish(int r); >>>> + }; >>>> >>>> struct C_aio_sparse_read_Ack : public Context { >>>> AioCompletionImpl *c; >>>> @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { >>>> int aio_remove(const object_t&oid, AioCompletionImpl *c); >>>> int aio_exec(const object_t& oid, AioCompletionImpl *c, const char >>>> *cls, >>>> const char *method, bufferlist& inbl, bufferlist *outbl); >>>> + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t >>>> *psize, time_t *pmtime); >>>> >>>> int pool_change_auid(unsigned long long auid); >>>> int pool_change_auid_async(unsigned long long auid, >>>> PoolAsyncCompletionImpl *c); >>>> diff --git a/src/librados/librados.cc b/src/librados/librados.cc >>>> index 274119c..af36b38 100644 >>>> --- a/src/librados/librados.cc >>>> +++ b/src/librados/librados.cc >>>> @@ -2167,6 +2167,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) >>>> return 0; >>>> } >>>> >>>> +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, >>>> + rados_completion_t completion, >>>> + uint64_t *psize, time_t *pmtime) >>>> +{ >>>> + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; >>>> + object_t oid(o); >>>> + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, >>>> + psize, pmtime); >>>> +} >>>> + >>>> struct C_WatchCB : public librados::WatchCtx { >>>> rados_watchcb_t wcb; >>>> void *arg; >>>> -- >>>> 1.7.10.4 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 0/2] Librados aio stat 2012-12-19 15:43 ` Sage Weil 2012-12-19 15:53 ` Josh Durgin @ 2012-12-20 20:05 ` Filippos Giannakos 2012-12-20 20:05 ` [PATCH 1/2] Implement librados aio_stat Filippos Giannakos ` (2 more replies) 1 sibling, 3 replies; 14+ messages in thread From: Filippos Giannakos @ 2012-12-20 20:05 UTC (permalink / raw) To: ceph-devel; +Cc: synnefo-devel, philipgian Hi Team, Here is the patch with the changes, plus the tests you requested. Best regards, Filippos ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] Implement librados aio_stat 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos @ 2012-12-20 20:05 ` Filippos Giannakos 2012-12-20 20:05 ` [PATCH 2/2] Add librados aio stat tests Filippos Giannakos 2013-01-04 13:01 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2 siblings, 0 replies; 14+ messages in thread From: Filippos Giannakos @ 2012-12-20 20:05 UTC (permalink / raw) To: ceph-devel; +Cc: synnefo-devel, philipgian Implement aio stat and also export this functionality to the C API. --- src/include/rados/librados.h | 16 ++++++++++++++- src/include/rados/librados.hpp | 4 +++- src/librados/IoCtxImpl.cc | 42 ++++++++++++++++++++++++++++++++++++++++ src/librados/IoCtxImpl.h | 9 +++++++++ src/librados/librados.cc | 18 +++++++++++++++++ 5 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 44d6f71..b2df767 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -23,7 +23,7 @@ extern "C" { #endif #define LIBRADOS_VER_MAJOR 0 -#define LIBRADOS_VER_MINOR 48 +#define LIBRADOS_VER_MINOR 49 #define LIBRADOS_VER_EXTRA 0 #define LIBRADOS_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra) @@ -1444,6 +1444,20 @@ int rados_aio_read(rados_ioctx_t io, const char *oid, */ int rados_aio_flush(rados_ioctx_t io); + +/** + * Asynchronously get object stats (size/mtime) + * + * @param io ioctx + * @param o object name + * @param psize where to store object size + * @param pmtime where to store modification time + * @returns 0 on success, negative error code on failure + */ +int rados_aio_stat(rados_ioctx_t io, const char *o, + rados_completion_t completion, + uint64_t *psize, time_t *pmtime); + /** @} Asynchronous I/O */ /** diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 3df4c86..b30b18f 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -478,9 +478,11 @@ namespace librados * other than CEPH_NOSNAP */ int aio_remove(const std::string& oid, AioCompletion *c); - + int aio_flush(); + int aio_stat(const std::string& oid, AioCompletion *c, uint64_t *psize, time_t *pmtime); + int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method, bufferlist& inbl, bufferlist *outbl); diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 934a101..808a30e 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -851,6 +851,21 @@ int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c) return 0; } + +int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c, + uint64_t *psize, time_t *pmtime) +{ + c->io = this; + C_aio_stat_Ack *onack = new C_aio_stat_Ack(c, pmtime); + + Mutex::Locker l(*lock); + objecter->stat(oid, oloc, + snap_seq, psize, &onack->mtime, 0, + onack, &c->objver); + + return 0; +} + int librados::IoCtxImpl::remove(const object_t& oid) { utime_t ut = ceph_clock_now(client->cct); @@ -1564,6 +1579,33 @@ void librados::IoCtxImpl::C_aio_Ack::finish(int r) c->put_unlock(); } +///////////////////////////// C_aio_stat_Ack //////////////////////////// + +librados::IoCtxImpl::C_aio_stat_Ack::C_aio_stat_Ack(AioCompletionImpl *_c, + time_t *pm) + : c(_c), pmtime(pm) +{ + c->get(); +} + +void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r) +{ + c->lock.Lock(); + c->rval = r; + c->ack = true; + c->cond.Signal(); + + if (r >= 0 && pmtime) { + *pmtime = mtime.sec(); + } + + if (c->callback_complete) { + c->io->client->finisher.queue(new C_AioComplete(c)); + } + + c->put_unlock(); +} + /////////////////////// C_aio_sparse_read_Ack ////////////////////////// librados::IoCtxImpl::C_aio_sparse_read_Ack::C_aio_sparse_read_Ack(AioCompletionImpl *_c, diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index feea0e8..55b07ee 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -144,6 +144,14 @@ struct librados::IoCtxImpl { C_aio_Ack(AioCompletionImpl *_c); void finish(int r); }; + + struct C_aio_stat_Ack : public Context { + librados::AioCompletionImpl *c; + time_t *pmtime; + utime_t mtime; + C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm); + void finish(int r); + }; struct C_aio_sparse_read_Ack : public Context { AioCompletionImpl *c; @@ -177,6 +185,7 @@ struct librados::IoCtxImpl { int aio_remove(const object_t &oid, AioCompletionImpl *c); int aio_exec(const object_t& oid, AioCompletionImpl *c, const char *cls, const char *method, bufferlist& inbl, bufferlist *outbl); + int aio_stat(const object_t& oid, AioCompletionImpl *c, uint64_t *psize, time_t *pmtime); int pool_change_auid(unsigned long long auid); int pool_change_auid_async(unsigned long long auid, PoolAsyncCompletionImpl *c); diff --git a/src/librados/librados.cc b/src/librados/librados.cc index c31b82a..c3756cd 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -978,6 +978,14 @@ int librados::IoCtx::aio_flush() return 0; } +int librados::IoCtx::aio_stat(const std::string& oid, librados::AioCompletion *c, + uint64_t *psize, time_t *pmtime) +{ + object_t obj(oid); + return io_ctx_impl->aio_stat(oid, c->pc, psize, pmtime); +} + + int librados::IoCtx::watch(const string& oid, uint64_t ver, uint64_t *cookie, librados::WatchCtx *ctx) { @@ -2173,6 +2181,16 @@ extern "C" int rados_aio_flush(rados_ioctx_t io) return 0; } +extern "C" int rados_aio_stat(rados_ioctx_t io, const char *o, + rados_completion_t completion, + uint64_t *psize, time_t *pmtime) +{ + librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; + object_t oid(o); + return ctx->aio_stat(oid, (librados::AioCompletionImpl*)completion, + psize, pmtime); +} + struct C_WatchCB : public librados::WatchCtx { rados_watchcb_t wcb; void *arg; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] Add librados aio stat tests 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2012-12-20 20:05 ` [PATCH 1/2] Implement librados aio_stat Filippos Giannakos @ 2012-12-20 20:05 ` Filippos Giannakos 2013-01-04 13:01 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2 siblings, 0 replies; 14+ messages in thread From: Filippos Giannakos @ 2012-12-20 20:05 UTC (permalink / raw) To: ceph-devel; +Cc: synnefo-devel, philipgian Implement simple write-stat test, and a write-stat-remove-stat test cycle. --- src/include/rados/librados.h | 2 +- src/test/librados/aio.cc | 176 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 1 deletion(-) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index b2df767..d40d9b5 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -1454,7 +1454,7 @@ int rados_aio_flush(rados_ioctx_t io); * @param pmtime where to store modification time * @returns 0 on success, negative error code on failure */ -int rados_aio_stat(rados_ioctx_t io, const char *o, +int rados_aio_stat(rados_ioctx_t io, const char *o, rados_completion_t completion, uint64_t *psize, time_t *pmtime); diff --git a/src/test/librados/aio.cc b/src/test/librados/aio.cc index 4983fee..33b5942 100644 --- a/src/test/librados/aio.cc +++ b/src/test/librados/aio.cc @@ -762,6 +762,182 @@ TEST(LibRadosAio, RoundTripWriteFullPP) { delete my_completion3; } + +TEST(LibRadosAio, SimpleStat) { + AioTestData test_data; + rados_completion_t my_completion; + ASSERT_EQ("", test_data.init()); + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion)); + char buf[128]; + memset(buf, 0xcc, sizeof(buf)); + ASSERT_EQ(0, rados_aio_write(test_data.m_ioctx, "foo", + my_completion, buf, sizeof(buf), 0)); + { + TestAlarm alarm; + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); + } + uint64_t psize; + time_t pmtime; + rados_completion_t my_completion2; + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion2)); + ASSERT_EQ(0, rados_aio_stat(test_data.m_ioctx, "foo", + my_completion2, &psize, &pmtime)); + { + TestAlarm alarm; + ASSERT_EQ(0, rados_aio_wait_for_complete(my_completion2)); + } + ASSERT_EQ(sizeof(buf), psize); + rados_aio_release(my_completion); + rados_aio_release(my_completion2); +} + +TEST(LibRadosAio, SimpleStatPP) { + AioTestDataPP test_data; + ASSERT_EQ("", test_data.init()); + AioCompletion *my_completion = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + AioCompletion *my_completion_null = NULL; + ASSERT_NE(my_completion, my_completion_null); + char buf[128]; + memset(buf, 0xcc, sizeof(buf)); + bufferlist bl1; + bl1.append(buf, sizeof(buf)); + ASSERT_EQ(0, test_data.m_ioctx.aio_write("foo", my_completion, + bl1, sizeof(buf), 0)); + { + TestAlarm alarm; + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); + } + uint64_t psize; + time_t pmtime; + AioCompletion *my_completion2 = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + ASSERT_NE(my_completion2, my_completion_null); + ASSERT_EQ(0, test_data.m_ioctx.aio_stat("foo", my_completion2, + &psize, &pmtime)); + { + TestAlarm alarm; + ASSERT_EQ(0, my_completion2->wait_for_complete()); + } + ASSERT_EQ(sizeof(buf), psize); + delete my_completion; + delete my_completion2; +} + +TEST(LibRadosAio, StatRemove) { + AioTestData test_data; + rados_completion_t my_completion; + ASSERT_EQ("", test_data.init()); + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion)); + char buf[128]; + memset(buf, 0xcc, sizeof(buf)); + ASSERT_EQ(0, rados_aio_write(test_data.m_ioctx, "foo", + my_completion, buf, sizeof(buf), 0)); + { + TestAlarm alarm; + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); + } + uint64_t psize; + time_t pmtime; + rados_completion_t my_completion2; + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion2)); + ASSERT_EQ(0, rados_aio_stat(test_data.m_ioctx, "foo", + my_completion2, &psize, &pmtime)); + { + TestAlarm alarm; + ASSERT_EQ(0, rados_aio_wait_for_complete(my_completion2)); + } + ASSERT_EQ(sizeof(buf), psize); + rados_completion_t my_completion3; + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion3)); + ASSERT_EQ(0, rados_aio_remove(test_data.m_ioctx, "foo", my_completion3)); + { + TestAlarm alarm; + ASSERT_EQ(0, rados_aio_wait_for_complete(my_completion3)); + } + uint64_t psize2; + time_t pmtime2; + rados_completion_t my_completion4; + ASSERT_EQ(0, rados_aio_create_completion((void*)&test_data, + set_completion_complete, set_completion_safe, &my_completion4)); + ASSERT_EQ(0, rados_aio_stat(test_data.m_ioctx, "foo", + my_completion4, &psize2, &pmtime2)); + { + TestAlarm alarm; + ASSERT_EQ(0, rados_aio_wait_for_complete(my_completion4)); + } + ASSERT_EQ(-ENOENT, rados_aio_get_return_value(my_completion4)); + rados_aio_release(my_completion); + rados_aio_release(my_completion2); + rados_aio_release(my_completion3); + rados_aio_release(my_completion4); +} + +TEST(LibRadosAio, StatRemovePP) { + AioTestDataPP test_data; + ASSERT_EQ("", test_data.init()); + AioCompletion *my_completion = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + AioCompletion *my_completion_null = NULL; + ASSERT_NE(my_completion, my_completion_null); + char buf[128]; + memset(buf, 0xcc, sizeof(buf)); + bufferlist bl1; + bl1.append(buf, sizeof(buf)); + ASSERT_EQ(0, test_data.m_ioctx.aio_write("foo", my_completion, + bl1, sizeof(buf), 0)); + { + TestAlarm alarm; + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); + } + uint64_t psize; + time_t pmtime; + AioCompletion *my_completion2 = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + ASSERT_NE(my_completion2, my_completion_null); + ASSERT_EQ(0, test_data.m_ioctx.aio_stat("foo", my_completion2, + &psize, &pmtime)); + { + TestAlarm alarm; + ASSERT_EQ(0, my_completion2->wait_for_complete()); + } + ASSERT_EQ(sizeof(buf), psize); + uint64_t psize2; + time_t pmtime2; + AioCompletion *my_completion3 = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + ASSERT_NE(my_completion3, my_completion_null); + ASSERT_EQ(0, test_data.m_ioctx.aio_remove("foo", my_completion3)); + { + TestAlarm alarm; + ASSERT_EQ(0, my_completion3->wait_for_complete()); + } + + AioCompletion *my_completion4 = test_data.m_cluster.aio_create_completion( + (void*)&test_data, set_completion_complete, set_completion_safe); + ASSERT_NE(my_completion4, my_completion_null); + ASSERT_EQ(0, test_data.m_ioctx.aio_stat("foo", my_completion4, + &psize2, &pmtime2)); + { + TestAlarm alarm; + ASSERT_EQ(0, my_completion4->wait_for_complete()); + } + ASSERT_EQ(-ENOENT, my_completion4->get_return_value()); + delete my_completion; + delete my_completion2; + delete my_completion3; + delete my_completion4; +} + using std::string; using std::map; using std::set; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] Librados aio stat 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2012-12-20 20:05 ` [PATCH 1/2] Implement librados aio_stat Filippos Giannakos 2012-12-20 20:05 ` [PATCH 2/2] Add librados aio stat tests Filippos Giannakos @ 2013-01-04 13:01 ` Filippos Giannakos 2013-01-04 18:00 ` Sage Weil 2013-01-05 0:08 ` Josh Durgin 2 siblings, 2 replies; 14+ messages in thread From: Filippos Giannakos @ 2013-01-04 13:01 UTC (permalink / raw) To: ceph-devel; +Cc: synnefo-devel, Filippos Giannakos Hi Team, Is there any progress or any comments regarding the librados aio stat patch ? Best regards On 12/20/2012 10:05 PM, Filippos Giannakos wrote: > Hi Team, > > Here is the patch with the changes, plus the tests you requested. > > Best regards, > Filippos -- Filippos. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] Librados aio stat 2013-01-04 13:01 ` [PATCH 0/2] Librados aio stat Filippos Giannakos @ 2013-01-04 18:00 ` Sage Weil 2013-01-05 0:08 ` Josh Durgin 1 sibling, 0 replies; 14+ messages in thread From: Sage Weil @ 2013-01-04 18:00 UTC (permalink / raw) To: Filippos Giannakos; +Cc: ceph-devel, synnefo-devel Sorry, I missed this second set of patches when they came through over the break. We'll try to get them merged into master shortly. Thanks! sage On Fri, 4 Jan 2013, Filippos Giannakos wrote: > Hi Team, > > Is there any progress or any comments regarding the librados aio stat > patch ? > > Best regards > > On 12/20/2012 10:05 PM, Filippos Giannakos wrote: > > Hi Team, > > > > Here is the patch with the changes, plus the tests you requested. > > > > Best regards, > > Filippos > > > -- > Filippos. > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] Librados aio stat 2013-01-04 13:01 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2013-01-04 18:00 ` Sage Weil @ 2013-01-05 0:08 ` Josh Durgin 2013-01-07 14:40 ` Filippos Giannakos 1 sibling, 1 reply; 14+ messages in thread From: Josh Durgin @ 2013-01-05 0:08 UTC (permalink / raw) To: Filippos Giannakos; +Cc: ceph-devel, synnefo-devel On 01/04/2013 05:01 AM, Filippos Giannakos wrote: > Hi Team, > > Is there any progress or any comments regarding the librados aio stat > patch ? They look good to me. I put them in the wip-librados-aio-stat branch. Can we add your signed-off-by to them? Thanks, Josh > Best regards > > On 12/20/2012 10:05 PM, Filippos Giannakos wrote: >> Hi Team, >> >> Here is the patch with the changes, plus the tests you requested. >> >> Best regards, >> Filippos > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] Librados aio stat 2013-01-05 0:08 ` Josh Durgin @ 2013-01-07 14:40 ` Filippos Giannakos 2013-01-09 3:40 ` Sage Weil 0 siblings, 1 reply; 14+ messages in thread From: Filippos Giannakos @ 2013-01-07 14:40 UTC (permalink / raw) To: Josh Durgin; +Cc: ceph-devel, synnefo-devel Hi Josh, On 01/05/2013 02:08 AM, Josh Durgin wrote: > On 01/04/2013 05:01 AM, Filippos Giannakos wrote: >> Hi Team, >> >> Is there any progress or any comments regarding the librados aio stat >> patch ? > > They look good to me. I put them in the wip-librados-aio-stat branch. > Can we add your signed-off-by to them? > > Thanks, > Josh Sorry for my late response. You can go ahead with the signed-off. Best Regards -- Filippos. <philipgian@grnet.gr> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] Librados aio stat 2013-01-07 14:40 ` Filippos Giannakos @ 2013-01-09 3:40 ` Sage Weil 0 siblings, 0 replies; 14+ messages in thread From: Sage Weil @ 2013-01-09 3:40 UTC (permalink / raw) To: Filippos Giannakos; +Cc: Josh Durgin, ceph-devel, synnefo-devel On Mon, 7 Jan 2013, Filippos Giannakos wrote: > Hi Josh, > > On 01/05/2013 02:08 AM, Josh Durgin wrote: > > On 01/04/2013 05:01 AM, Filippos Giannakos wrote: > > > Hi Team, > > > > > > Is there any progress or any comments regarding the librados aio stat > > > patch ? > > > > They look good to me. I put them in the wip-librados-aio-stat branch. > > Can we add your signed-off-by to them? > > > > Thanks, > > Josh > > Sorry for my late response. You can go ahead with the signed-off. I merged these into master (Josh is out this week). Thanks! sage ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-01-09 3:40 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-14 11:18 [PATCH] implement librados aio_stat Filippos Giannakos 2012-12-14 12:19 ` Giannakos Filippos 2012-12-15 7:49 ` Yehuda Sadeh 2012-12-19 9:13 ` Filippos Giannakos 2012-12-19 15:43 ` Sage Weil 2012-12-19 15:53 ` Josh Durgin 2012-12-20 20:05 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2012-12-20 20:05 ` [PATCH 1/2] Implement librados aio_stat Filippos Giannakos 2012-12-20 20:05 ` [PATCH 2/2] Add librados aio stat tests Filippos Giannakos 2013-01-04 13:01 ` [PATCH 0/2] Librados aio stat Filippos Giannakos 2013-01-04 18:00 ` Sage Weil 2013-01-05 0:08 ` Josh Durgin 2013-01-07 14:40 ` Filippos Giannakos 2013-01-09 3:40 ` Sage Weil
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.