Re: [PATCH] implement librados aio_stat

2012-12-19 Thread Filippos Giannakos

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 Giannakosphilipg...@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_toid, 
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_toid, 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 

Re: [PATCH] implement librados aio_stat

2012-12-19 Thread Sage Weil
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 Giannakosphilipg...@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_toid, 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 {
 

Re: [PATCH] implement librados aio_stat

2012-12-19 Thread Josh Durgin

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 Giannakosphilipg...@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_toid, 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);
+

Re: [PATCH] implement librados aio_stat

2012-12-14 Thread Giannakos Filippos

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_toid, 
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_toid, 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