]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/cls/cmpomap/server.cc
import ceph 16.2.6
[ceph.git] / ceph / src / cls / cmpomap / server.cc
index 691832bfe63663f4e244ac6556d4a51ff35e50de..86e16d940f3efc2bfc484b8606fbdb84e2f87c2f 100644 (file)
@@ -37,17 +37,20 @@ static int compare_values(Op op, const T& lhs, const T& rhs)
 
 static int compare_values_u64(Op op, uint64_t lhs, const bufferlist& value)
 {
-  try {
-    // decode existing value as rhs
-    uint64_t rhs;
-    auto p = value.cbegin();
-    using ceph::decode;
-    decode(rhs, p);
-    return compare_values(op, lhs, rhs);
-  } catch (const buffer::error&) {
-    // failures to decode existing values are reported as EIO
-    return -EIO;
+  // empty values compare as 0 for backward compat
+  uint64_t rhs = 0;
+  if (value.length()) {
+    try {
+      // decode existing value as rhs
+      auto p = value.cbegin();
+      using ceph::decode;
+      decode(rhs, p);
+    } catch (const buffer::error&) {
+      // failures to decode existing values are reported as EIO
+      return -EIO;
+    }
   }
+  return compare_values(op, lhs, rhs);
 }
 
 static int compare_value(Mode mode, Op op, const bufferlist& input,