]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add set_alloc_hint2 with flags
authorSage Weil <sage@redhat.com>
Thu, 8 Oct 2015 19:32:10 +0000 (15:32 -0400)
committerSage Weil <sage@redhat.com>
Sat, 14 May 2016 13:18:49 +0000 (09:18 -0400)
Flags indicate expected future access pattern so the
OSD can behave accordingly.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/librados.cc
src/osdc/Objecter.h
src/tracing/librados.tp

index 502c97522e6e9cfae0875637aebb309bc10a9775..b3d4818374eaff838ffda03740514baab7223a26 100644 (file)
@@ -127,6 +127,24 @@ enum {
 };
 /** @} */
 
+/**
+ * @name Alloc hint flags
+ * Flags for rados_write_op_alloc_hint2() and rados_set_alloc_hint2()
+ * indicating future IO patterns.
+ * @{
+ */
+enum {
+  LIBRADOS_ALLOC_HINT_SEQUENTIAL_WRITE = 1,
+  LIBRADOS_ALLOC_HINT_RANDOM_WRITE = 2,
+  LIBRADOS_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
+  LIBRADOS_ALLOC_HINT_FLAG_RANDOM_READ = 8,
+  LIBRADOS_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
+  LIBRADOS_ALLOC_HINT_FLAG_IMMUTABLE = 32,
+  LIBRADOS_ALLOC_HINT_FLAG_SHORTLIVED = 64,
+  LIBRADOS_ALLOC_HINT_FLAG_LONGLIVED = 128,
+};
+/** @} */
+
 /*
  * snap id contants
  */
@@ -2399,6 +2417,25 @@ CEPH_RADOS_API int rados_set_alloc_hint(rados_ioctx_t io, const char *o,
                                         uint64_t expected_object_size,
                                         uint64_t expected_write_size);
 
+/**
+ * Set allocation hint for an object
+ *
+ * This is an advisory operation, it will always succeed (as if it was
+ * submitted with a LIBRADOS_OP_FLAG_FAILOK flag set) and is not
+ * guaranteed to do anything on the backend.
+ *
+ * @param io the pool the object is in
+ * @param o the name of the object
+ * @param expected_object_size expected size of the object, in bytes
+ * @param expected_write_size expected size of writes to the object, in bytes
+ * @param flags hints about future IO patterns
+ * @returns 0 on success, negative error code on failure
+ */
+CEPH_RADOS_API int rados_set_alloc_hint2(rados_ioctx_t io, const char *o,
+                                        uint64_t expected_object_size,
+                                        uint64_t expected_write_size,
+                                        uint32_t flags);
+
 /** @} Hints */
 
 /**
@@ -2660,6 +2697,19 @@ CEPH_RADOS_API void rados_write_op_set_alloc_hint(rados_write_op_t write_op,
                                                   uint64_t expected_object_size,
                                                   uint64_t expected_write_size);
 
+/**
+ * Set allocation hint for an object
+ *
+ * @param write_op operation to add this action to
+ * @param expected_object_size expected size of the object, in bytes
+ * @param expected_write_size expected size of writes to the object, in bytes
+ * @param flags hints about future IO patterns
+ */
+CEPH_RADOS_API void rados_write_op_set_alloc_hint2(rados_write_op_t write_op,
+                                                  uint64_t expected_object_size,
+                                                  uint64_t expected_write_size,
+                                                  uint32_t flags);
+
 /**
  * Perform a write operation synchronously
  * @param write_op operation to perform
index 5c6abdb63f0ea418b865ad961a863908c04b943f..599f34f6b4270bc0e1219ef4387fb1bf52cf2cf5 100644 (file)
@@ -280,6 +280,20 @@ namespace librados
     OPERATION_FULL_TRY           = LIBRADOS_OPERATION_FULL_TRY,
   };
 
+  /*
+   * Alloc hint flags for the alloc_hint operation.
+   */
+  enum AllocHintFlags {
+    ALLOC_HINT_SEQUENTIAL_WRITE = 1,
+    ALLOC_HINT_RANDOM_WRITE = 2,
+    ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
+    ALLOC_HINT_FLAG_RANDOM_READ = 8,
+    ALLOC_HINT_FLAG_APPEND_ONLY = 16,
+    ALLOC_HINT_FLAG_IMMUTABLE = 32,
+    ALLOC_HINT_FLAG_SHORTLIVED = 64,
+    ALLOC_HINT_FLAG_LONGLIVED = 128,
+  };
+
   /*
    * ObjectOperation : compound object operation
    * Batch multiple object operations into a single request, to be applied
@@ -448,9 +462,13 @@ namespace librados
      *
      * @param expected_object_size expected size of the object, in bytes
      * @param expected_write_size expected size of writes to the object, in bytes
+     * @param flags flags ()
      */
     void set_alloc_hint(uint64_t expected_object_size,
                         uint64_t expected_write_size);
+    void set_alloc_hint2(uint64_t expected_object_size,
+                        uint64_t expected_write_size,
+                        uint32_t flags);
 
     /**
      * Pin/unpin an object in cache tier
@@ -1082,6 +1100,10 @@ namespace librados
     int set_alloc_hint(const std::string& o,
                        uint64_t expected_object_size,
                        uint64_t expected_write_size);
+    int set_alloc_hint2(const std::string& o,
+                       uint64_t expected_object_size,
+                       uint64_t expected_write_size,
+                       uint32_t flags);
 
     // assert version for next sync operations
     void set_assert_version(uint64_t ver);
index ccbf897aac9eedf44f7bc97c36840be88c2ff5b7..358d561535324d7fd02ebc36a7ad64cb8d25a0a2 100644 (file)
@@ -1622,11 +1622,12 @@ int librados::IoCtxImpl::aio_notify(const object_t& oid, AioCompletionImpl *c,
 
 int librados::IoCtxImpl::set_alloc_hint(const object_t& oid,
                                         uint64_t expected_object_size,
-                                        uint64_t expected_write_size)
+                                        uint64_t expected_write_size,
+                                       uint32_t flags)
 {
   ::ObjectOperation wr;
   prepare_assert_ops(&wr);
-  wr.set_alloc_hint(expected_object_size, expected_write_size);
+  wr.set_alloc_hint(expected_object_size, expected_write_size, flags);
   return operate(oid, &wr, NULL);
 }
 
index e76ae7c5a3a4435ad09c527f14f8560e7e26ca18..02c906eb6610ffc30ec505804e2a97db76952b1d 100644 (file)
@@ -253,7 +253,8 @@ struct librados::IoCtxImpl {
 
   int set_alloc_hint(const object_t& oid,
                      uint64_t expected_object_size,
-                     uint64_t expected_write_size);
+                     uint64_t expected_write_size,
+                    uint32_t flags);
 
   version_t last_version();
   void set_assert_version(uint64_t ver);
index aa18fd0e2c1d773f3dd05776100364157707f5fc..904349ed03f53e8a092eb9cf1ad19eb1cb47e8bf 100644 (file)
@@ -553,7 +553,15 @@ void librados::ObjectWriteOperation::set_alloc_hint(
                                             uint64_t expected_write_size)
 {
   ::ObjectOperation *o = &impl->o;
-  o->set_alloc_hint(expected_object_size, expected_write_size);
+  o->set_alloc_hint(expected_object_size, expected_write_size, 0);
+}
+void librados::ObjectWriteOperation::set_alloc_hint2(
+                                            uint64_t expected_object_size,
+                                            uint64_t expected_write_size,
+                                           uint32_t flags)
+{
+  ::ObjectOperation *o = &impl->o;
+  o->set_alloc_hint(expected_object_size, expected_write_size, flags);
 }
 
 void librados::ObjectWriteOperation::cache_pin()
@@ -1961,7 +1969,17 @@ int librados::IoCtx::set_alloc_hint(const std::string& o,
 {
   object_t oid(o);
   return io_ctx_impl->set_alloc_hint(oid, expected_object_size,
-                                     expected_write_size);
+                                     expected_write_size, 0);
+}
+
+int librados::IoCtx::set_alloc_hint2(const std::string& o,
+                                    uint64_t expected_object_size,
+                                    uint64_t expected_write_size,
+                                    uint32_t flags)
+{
+  object_t oid(o);
+  return io_ctx_impl->set_alloc_hint(oid, expected_object_size,
+                                     expected_write_size, flags);
 }
 
 void librados::IoCtx::set_assert_version(uint64_t ver)
@@ -4676,11 +4694,26 @@ extern "C" int rados_set_alloc_hint(rados_ioctx_t io, const char *o,
   tracepoint(librados, rados_set_alloc_hint_enter, io, o, expected_object_size, expected_write_size);
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
   object_t oid(o);
-  int retval = ctx->set_alloc_hint(oid, expected_object_size, expected_write_size);
+  int retval = ctx->set_alloc_hint(oid, expected_object_size,
+                                  expected_write_size, 0);
   tracepoint(librados, rados_set_alloc_hint_exit, retval);
   return retval;
 }
 
+extern "C" int rados_set_alloc_hint2(rados_ioctx_t io, const char *o,
+                                    uint64_t expected_object_size,
+                                    uint64_t expected_write_size,
+                                    uint32_t flags)
+{
+  tracepoint(librados, rados_set_alloc_hint2_enter, io, o, expected_object_size, expected_write_size, flags);
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  object_t oid(o);
+  int retval = ctx->set_alloc_hint(oid, expected_object_size,
+                                  expected_write_size, flags);
+  tracepoint(librados, rados_set_alloc_hint2_exit, retval);
+  return retval;
+}
+
 extern "C" int rados_lock_exclusive(rados_ioctx_t io, const char * o,
                          const char * name, const char * cookie,
                          const char * desc, struct timeval * duration,
@@ -5039,10 +5072,22 @@ extern "C" void rados_write_op_set_alloc_hint(rados_write_op_t write_op,
 {
   tracepoint(librados, rados_write_op_set_alloc_hint_enter, write_op, expected_object_size, expected_write_size);
   ((::ObjectOperation *)write_op)->set_alloc_hint(expected_object_size,
-                                                  expected_write_size);
+                                                  expected_write_size, 0);
   tracepoint(librados, rados_write_op_set_alloc_hint_exit);
 }
 
+extern "C" void rados_write_op_set_alloc_hint2(rados_write_op_t write_op,
+                                              uint64_t expected_object_size,
+                                              uint64_t expected_write_size,
+                                              uint32_t flags)
+{
+  tracepoint(librados, rados_write_op_set_alloc_hint2_enter, write_op, expected_object_size, expected_write_size, flags);
+  ((::ObjectOperation *)write_op)->set_alloc_hint(expected_object_size,
+                                                  expected_write_size,
+                                                 flags);
+  tracepoint(librados, rados_write_op_set_alloc_hint2_exit);
+}
+
 extern "C" int rados_write_op_operate(rados_write_op_t write_op,
                                       rados_ioctx_t io,
                                       const char *oid,
index 163e7db384cbe5553983ad83f00f80c77c457ea9..612b8fdf186fe42a1e0c4cda39280f600ba682a5 100644 (file)
@@ -215,10 +215,12 @@ struct ObjectOperation {
     ::encode(cookie, osd_op.indata);
   }
   void add_alloc_hint(int op, uint64_t expected_object_size,
-                     uint64_t expected_write_size) {
+                      uint64_t expected_write_size,
+                     uint32_t flags) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.alloc_hint.expected_object_size = expected_object_size;
     osd_op.op.alloc_hint.expected_write_size = expected_write_size;
+    osd_op.op.alloc_hint.flags = flags;
   }
 
   // ------
@@ -1089,9 +1091,10 @@ struct ObjectOperation {
   }
 
   void set_alloc_hint(uint64_t expected_object_size,
-                     uint64_t expected_write_size ) {
+                      uint64_t expected_write_size,
+                     uint32_t flags) {
     add_alloc_hint(CEPH_OSD_OP_SETALLOCHINT, expected_object_size,
-                  expected_write_size);
+                  expected_write_size, flags);
 
     // CEPH_OSD_OP_SETALLOCHINT op is advisory and therefore deemed
     // not worth a feature bit.  Set FAILOK per-op flag to make
index 8afe1e29ebf43787e17ef919f924032a0708feb6..c4aaf4cedc65ee99cf7e5911eaae0f05a25a0cf4 100644 (file)
@@ -2583,6 +2583,30 @@ TRACEPOINT_EVENT(librados, rados_set_alloc_hint_exit,
     )
 )
 
+TRACEPOINT_EVENT(librados, rados_set_alloc_hint2_enter,
+    TP_ARGS(
+        rados_ioctx_t, ioctx,
+        const char*, oid,
+        uint64_t, expected_object_size,
+        uint64_t, expected_write_size,
+       uint32_t, flags),
+    TP_FIELDS(
+        ctf_integer_hex(rados_ioctx_t, ioctx, ioctx)
+        ctf_string(oid, oid)
+        ctf_integer(uint64_t, expected_object_size, expected_object_size)
+        ctf_integer(uint64_t, expected_write_size, expected_write_size)
+        ctf_integer(uint32_t, flags, flags)
+    )
+)
+
+TRACEPOINT_EVENT(librados, rados_set_alloc_hint2_exit,
+    TP_ARGS(
+        int, retval),
+    TP_FIELDS(
+        ctf_integer(int, retval, retval)
+    )
+)
+
 TRACEPOINT_EVENT(librados, rados_lock_exclusive_enter,
     TP_ARGS(
         rados_ioctx_t, ioctx,
@@ -3114,6 +3138,25 @@ TRACEPOINT_EVENT(librados, rados_write_op_set_alloc_hint_exit,
     TP_FIELDS()
 )
 
+TRACEPOINT_EVENT(librados, rados_write_op_set_alloc_hint2_enter,
+    TP_ARGS(
+        rados_write_op_t, op,
+        uint64_t, expected_object_size,
+        uint64_t, expected_write_size,
+        uint32_t, flags),
+    TP_FIELDS(
+        ctf_integer_hex(rados_write_op_t, op, op)
+        ctf_integer(uint64_t, expected_object_size, expected_object_size)
+        ctf_integer(uint64_t, expected_write_size, expected_write_size)
+        ctf_integer(uint32_t, flags, flags)
+    )
+)
+
+TRACEPOINT_EVENT(librados, rados_write_op_set_alloc_hint2_exit,
+    TP_ARGS(),
+    TP_FIELDS()
+)
+
 TRACEPOINT_EVENT(librados, rados_write_op_operate_enter,
     TP_ARGS(
         rados_write_op_t, op,