]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix osd smart data collection segment fault issue. 21691/head
authorGu Zhongyan <guzhongyan@360.cn>
Fri, 27 Apr 2018 10:20:02 +0000 (18:20 +0800)
committerGu Zhongyan <guzhongyan@360.cn>
Fri, 11 May 2018 08:05:07 +0000 (16:05 +0800)
output.read_fd() could return zero length. it needs to
be handled gracefully.

always call invoke join() if spawn() is successfully returned.
otherwise there will be assert failure in ~SubProcess().

Fixes: http://tracker.ceph.com/issues/23899
Signed-off-by: Gu Zhongyan <guzhongyan@360.cn>
src/crush/CrushLocation.cc
src/osd/OSD.cc

index 4831616c0cb3ab81cb7987b33763ebbca6be4705..4766a618ab5eacb92e57e0dad3262941659c4181 100644 (file)
@@ -76,7 +76,6 @@ int CrushLocation::update_from_hook()
     lderr(cct) << "stderr:\n";
     err.hexdump(*_dout);
     *_dout << dendl;
-    return ret;
   }
 
   if (hook.join() != 0) {
@@ -84,6 +83,9 @@ int CrushLocation::update_from_hook()
     return -EINVAL;
   }
 
+  if (ret < 0)
+    return ret;
+
   std::string out;
   bl.copy(0, bl.length(), out);
   out.erase(out.find_last_not_of(" \n\r\t")+1);
index 734d1db7b47ad17313f66ac39b762489d3f0aa5d..af085fc8320f0aac8945f3acbd59e72f1cedbbc4 100644 (file)
@@ -6301,17 +6301,19 @@ int OSD::probe_smart_device(const char *device, int timeout, std::string *result
   ret = output.read_fd(smartctl.get_stdout(), 100*1024);
   if (ret < 0) {
     derr << "failed read from smartctl: " << cpp_strerror(-ret) << dendl;
-    return ret;
+  } else {
+    *result = output.to_str();
+    dout(10) << "smartctl output is: " << *result << dendl;
   }
 
-  derr << "smartctl output is: " << output.c_str() << dendl;
-  *result = output.c_str(); 
-
   if (smartctl.join() != 0) {
     derr << smartctl.err() << dendl;
     return -EINVAL;
   }
 
+  if (ret < 0)
+    return ret;
+
   return 0;
 }