]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd, src/common: return sha1 value if zero-length buffer.
authormyoungwon oh <omwmw@sk.com>
Wed, 12 Sep 2018 12:25:24 +0000 (21:25 +0900)
committermyoungwon oh <omwmw@sk.com>
Thu, 13 Sep 2018 02:34:15 +0000 (11:34 +0900)
Signed-off-by: Myoungwon Oh <omwmw@sk.com>
src/common/buffer.cc
src/include/buffer.h
src/osd/PrimaryLogPG.cc

index b88e74a9caf28d923b5fe5bba15f34876e6e0ce4..b0ba27ded8aa8227d554d486b36d7d305abff5f6 100644 (file)
@@ -2473,23 +2473,15 @@ void buffer::list::invalidate_crc()
 #include "common/ceph_crypto.h"
 using ceph::crypto::SHA1;
 
-boost::optional<sha1_digest_t> buffer::list::sha1()
+sha1_digest_t buffer::list::sha1()
 {
-  ptr nb;
   unsigned char fingerprint[CEPH_CRYPTO_SHA1_DIGESTSIZE];
-  if (_len == 0) {
-    return boost::none;
-  }
-  nb = buffer::create(_len);
   SHA1 sha1_gen;
-  for (std::list<ptr>::iterator it = _buffers.begin();
-       it != _buffers.end();
-       ++it) {
-    sha1_gen.Update((const unsigned char *)it->c_str(), it->length());
+  for (auto& p : _buffers) {
+    sha1_gen.Update((const unsigned char *)p.c_str(), p.length());
   }
   sha1_gen.Final(fingerprint);
-  sha1_digest_t fp_t(fingerprint);
-  return fp_t;
+  return sha1_digest_t(fingerprint);
 }
 
 /**
index f32285a158b1568c5da560b3e831f939b54f0f74..54e320ead0945e42a4481d76cdd410c149803956 100644 (file)
@@ -61,7 +61,6 @@
 #endif
 
 #include "inline_memory.h"
-#include <boost/optional.hpp>
 
 #if __GNUC__ >= 4
   #define CEPH_BUFFER_API  __attribute__ ((visibility ("default")))
@@ -957,7 +956,7 @@ namespace buffer CEPH_BUFFER_API {
     }
     uint32_t crc32c(uint32_t crc) const;
     void invalidate_crc();
-    boost::optional<sha1_digest_t> sha1(); 
+    sha1_digest_t sha1(); 
 
     // These functions return a bufferlist with a pointer to a single
     // static buffer. They /must/ not outlive the memory they
index 0577e0bf6324bc5f900197fa50cc8a954885d997..d11cb9ed836c3827dd3f9f8fb3b79def33c41a88 100644 (file)
@@ -2614,12 +2614,9 @@ int PrimaryLogPG::do_manifest_flush(OpRequestRef op, ObjectContextRef obc, Flush
       switch (fp_algo_t) {
        case pg_pool_t::TYPE_FINGERPRINT_SHA1:
          {
-           boost::optional<sha1_digest_t> fp_t = chunk_data.sha1();
-           object_t fp_oid;
+           sha1_digest_t sha1r = chunk_data.sha1();
+           object_t fp_oid = sha1r.to_str();
            bufferlist in;
-           if (fp_t != boost::none) {
-             fp_oid = fp_t.get().to_str();
-           }
            if (fp_oid != tgt_soid.oid) {
              // decrement old chunk's reference count 
              ObjectOperation dec_op;