]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: skip sparse-read result decode if bufferlist is empty 18400/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 20 Oct 2017 02:24:31 +0000 (22:24 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 20 Oct 2017 02:33:01 +0000 (22:33 -0400)
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>
src/osdc/Objecter.h

index 3358d6bb24e8cb1b62b5213d514a03511c039b50..569e328ee6c4e171098231383e4aa7ffdc94571c 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;
+        }
       }
     }
   };