From: myoungwon oh Date: Wed, 12 Sep 2018 12:25:24 +0000 (+0900) Subject: osd, src/common: return sha1 value if zero-length buffer. X-Git-Tag: v14.0.1~268^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b8685d855263ec8c8df3ac7d10b401409c556973;p=ceph.git osd, src/common: return sha1 value if zero-length buffer. Signed-off-by: Myoungwon Oh --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index b88e74a9caf28..b0ba27ded8aa8 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -2473,23 +2473,15 @@ void buffer::list::invalidate_crc() #include "common/ceph_crypto.h" using ceph::crypto::SHA1; -boost::optional 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::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); } /** diff --git a/src/include/buffer.h b/src/include/buffer.h index f32285a158b15..54e320ead0945 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -61,7 +61,6 @@ #endif #include "inline_memory.h" -#include #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(); + sha1_digest_t sha1(); // These functions return a bufferlist with a pointer to a single // static buffer. They /must/ not outlive the memory they diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 0577e0bf6324b..d11cb9ed836c3 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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 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;