]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add helper to decode compression info from single attr
authorCasey Bodley <cbodley@redhat.com>
Thu, 17 Sep 2020 17:26:32 +0000 (13:26 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 28 Jan 2021 15:46:03 +0000 (16:46 +0100)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a5520be135156c867a6502845603e2afdbb0a44a)

src/rgw/rgw_compression.cc
src/rgw/rgw_compression.h

index 7db8108d69582eff21dc3a2931f0f04db7516f0f..30d9afa3ec92d2f6479e16e97c9e9eb0ada5af47 100644 (file)
@@ -5,29 +5,36 @@
 
 #define dout_subsys ceph_subsys_rgw
 
-int rgw_compression_info_from_attrset(map<string, bufferlist>& attrs,
+int rgw_compression_info_from_attr(const bufferlist& attr,
+                                   bool& need_decompress,
+                                   RGWCompressionInfo& cs_info)
+{
+  auto bliter = attr.cbegin();
+  try {
+    decode(cs_info, bliter);
+  } catch (buffer::error& err) {
+    return -EIO;
+  }
+  if (cs_info.blocks.size() == 0) {
+    return -EIO;
+  }
+  if (cs_info.compression_type != "none")
+    need_decompress = true;
+  else
+    need_decompress = false;
+  return 0;
+}
+
+int rgw_compression_info_from_attrset(const map<string, bufferlist>& attrs,
                                       bool& need_decompress,
-                                      RGWCompressionInfo& cs_info) {
-  map<string, bufferlist>::iterator value = attrs.find(RGW_ATTR_COMPRESSION);
-  if (value != attrs.end()) {
-    auto bliter = value->second.cbegin();
-    try {
-      decode(cs_info, bliter);
-    } catch (buffer::error& err) {
-      return -EIO;
-    }
-    if (cs_info.blocks.size() == 0) {
-      return -EIO;
-    }
-    if (cs_info.compression_type != "none")
-      need_decompress = true;
-    else
-      need_decompress = false;
-    return 0;
-  } else {
+                                      RGWCompressionInfo& cs_info)
+{
+  auto value = attrs.find(RGW_ATTR_COMPRESSION);
+  if (value == attrs.end()) {
     need_decompress = false;
     return 0;
   }
+  return rgw_compression_info_from_attr(value->second, need_decompress, cs_info);
 }
 
 //------------RGWPutObj_Compress---------------
index 4d7f8638412a01bab3656178b8e609c22c5f33d4..cbefa17014c89245dc3ecf592f06b65480fe76da 100644 (file)
 #include "rgw_op.h"
 #include "rgw_compression_types.h"
 
-int rgw_compression_info_from_attrset(map<string, bufferlist>& attrs, bool& need_decompress, RGWCompressionInfo& cs_info);
+int rgw_compression_info_from_attr(const bufferlist& attr,
+                                   bool& need_decompress,
+                                   RGWCompressionInfo& cs_info);
+int rgw_compression_info_from_attrset(const map<string, bufferlist>& attrs,
+                                      bool& need_decompress,
+                                      RGWCompressionInfo& cs_info);
 
 class RGWGetObj_Decompress : public RGWGetObj_Filter
 {