]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: store data in cache even if short read 25123/head
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Nov 2018 02:26:14 +0000 (18:26 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Nov 2018 02:26:14 +0000 (18:26 -0800)
Also, don't set DATA flag if zero bytes are being read. This caused
an issue now that we don't read attrs directly (but go through
unfiltered_attrs first). Since we returned early in case we read the
exact amount we requested, *attrs wasn't populated.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/services/svc_sys_obj_cache.cc
src/rgw/services/svc_sys_obj_core.cc

index db1f4f731e19dcce3d32657113abb3d07d23a7ec..7c2817fed912089be080e1307deae9f21212a8d2 100644 (file)
@@ -99,7 +99,7 @@ int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx,
   string oid;
   if (ofs != 0) {
     return RGWSI_SysObj_Core::read(obj_ctx, read_state, objv_tracker,
-                          obj, obl, ofs, end, attrs, true,
+                          obj, obl, ofs, end, attrs, raw_attrs,
                           cache_info, refresh_version);
   }
 
@@ -108,7 +108,7 @@ int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx,
 
   ObjectCacheInfo info;
 
-  uint32_t flags = CACHE_FLAG_DATA;
+  uint32_t flags = (end != 0 ? CACHE_FLAG_DATA : 0);
   if (objv_tracker)
     flags |= CACHE_FLAG_OBJV;
   if (attrs)
@@ -155,14 +155,15 @@ int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx,
 
   if (obl->length() == end + 1) {
     /* in this case, most likely object contains more data, we can't cache it */
-    return r;
+    flags &= ~CACHE_FLAG_DATA;
+  } else {
+    bufferptr p(r);
+    bufferlist& bl = info.data;
+    bl.clear();
+    bufferlist::iterator o = obl->begin();
+    o.copy_all(bl);
   }
 
-  bufferptr p(r);
-  bufferlist& bl = info.data;
-  bl.clear();
-  bufferlist::iterator o = obl->begin();
-  o.copy_all(bl);
   info.status = 0;
   info.flags = flags;
   if (objv_tracker) {
index 847f3dd79d8f3450e05688d7b26989baff34f77e..c3683ae6bd7e4c2946b49862d9a31b181d0622da 100644 (file)
@@ -206,7 +206,11 @@ int RGWSI_SysObj_Core::read(RGWSysObjectCtxBase& obj_ctx,
   map<string, bufferlist> unfiltered_attrset;
 
   if (attrs) {
-    op.getxattrs(&unfiltered_attrset, nullptr);
+    if (raw_attrs) {
+      op.getxattrs(attrs, nullptr);
+    } else {
+      op.getxattrs(&unfiltered_attrset, nullptr);
+    }
   }
 
   RGWSI_RADOS::Obj rados_obj;
@@ -230,12 +234,8 @@ int RGWSI_SysObj_Core::read(RGWSysObjectCtxBase& obj_ctx,
     return -ECANCELED;
   }
 
-  if (attrs) {
-    if (raw_attrs) {
-      attrs->swap(unfiltered_attrset);
-    } else {
-      rgw_filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, attrs);
-    }
+  if (attrs && !raw_attrs) {
+    rgw_filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, attrs);
   }
 
   read_state.last_ver = op_ver;