]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: skip sparse-read result decode if bufferlist is empty 18744/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 20 Oct 2017 02:24:31 +0000 (22:24 -0400)
committerShinobu Kinjo <shinobu@redhat.com>
Sun, 5 Nov 2017 03:48:31 +0000 (12:48 +0900)
If the OSD does not execute sub-ops due to errors encountered prior to
the sub-op, the sub-op result remains zeroed with empty out data.
Attempting to decode the empty bufferlist results in large exception
handling CPU overhead.

Fixes: http://tracker.ceph.com/issues/21844
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit dc9b309d03074862daad9ef05ef643da870f6722)

src/osdc/Objecter.h

index 527022b5d2ac830318965a8723bef33111e4cc45..87ace75699acee5b19b06140c57d5bb3dd07bbc3 100644 (file)
@@ -335,13 +335,20 @@ struct ObjectOperation {
     void finish(int r) override {
       bufferlist::iterator iter = bl.begin();
       if (r >= 0) {
-       try {
-         ::decode(*extents, iter);
-         ::decode(*data_bl, iter);
-       } catch (buffer::error& e) {
-         if (prval)
-           *prval = -EIO;
-       }
+        // NOTE: it's possible the sub-op has not been executed but the result
+        // code remains zeroed. Avoid the costly exception handling on a
+        // potential IO path.
+        if (bl.length() > 0) {
+         try {
+           ::decode(*extents, iter);
+           ::decode(*data_bl, iter);
+         } catch (buffer::error& e) {
+           if (prval)
+              *prval = -EIO;
+         }
+        } else if (prval) {
+          *prval = -EIO;
+        }
       }
     }
   };