]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: get osd location on -1 should return EINVAL
authorSage Weil <sage@inktank.com>
Sat, 28 Dec 2013 18:25:00 +0000 (10:25 -0800)
committerGreg Farnum <greg@inktank.com>
Thu, 2 Oct 2014 04:41:31 +0000 (21:41 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit b88af07ef5a3c9a484255b54149a6e6a635845dc)

c70331db13bdbf1f967ece48cdbec28b97c3d19c backported some
CRUSH changes which necessitate backporting this as well, or
we get failures like successfully looking up an OSD with ID -1.
Reviewed-by: Greg Farnum <greg@inktank.com>
src/client/Client.cc
src/test/libcephfs/test.cc

index 440292439de0c5cc6ab81ea642d74d682e91e706..7cd5464e81044497d88df5cba1c371b01262e5b6 100644 (file)
@@ -7841,6 +7841,8 @@ int Client::get_file_extent_osds(int fd, loff_t off, loff_t *len, vector<int>& o
 int Client::get_osd_crush_location(int id, vector<pair<string, string> >& path)
 {
   Mutex::Locker lock(client_lock);
+  if (id < 0)
+    return -EINVAL;
   return osdmap->crush->get_full_location_ordered(id, path);
 }
 
index 597d049e2a44698d3df5ca559f201bdb7f85be89..4823d60103ac5ca84db924c30358a5eccf9434bc 100644 (file)
@@ -1063,7 +1063,7 @@ TEST(LibCephFS, GetOsdCrushLocation) {
 
   char path[256];
   ASSERT_EQ(ceph_get_osd_crush_location(cmount, 9999999, path, 0), -ENOENT);
-  ASSERT_EQ(ceph_get_osd_crush_location(cmount, -1, path, 0), -ENOENT);
+  ASSERT_EQ(ceph_get_osd_crush_location(cmount, -1, path, 0), -EINVAL);
 
   char test_file[256];
   sprintf(test_file, "test_osds_loc_%d", getpid());