From: Sage Weil Date: Sat, 28 Dec 2013 18:25:00 +0000 (-0800) Subject: libcephfs: get osd location on -1 should return EINVAL X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=285a13a1ecb2c9af65cfe39c7d017e277aeb0b00;p=ceph.git libcephfs: get osd location on -1 should return EINVAL Signed-off-by: Sage Weil (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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 440292439de0..7cd5464e8104 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7841,6 +7841,8 @@ int Client::get_file_extent_osds(int fd, loff_t off, loff_t *len, vector& o int Client::get_osd_crush_location(int id, vector >& path) { Mutex::Locker lock(client_lock); + if (id < 0) + return -EINVAL; return osdmap->crush->get_full_location_ordered(id, path); } diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 597d049e2a44..4823d60103ac 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -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());