From b88af07ef5a3c9a484255b54149a6e6a635845dc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 28 Dec 2013 10:25:00 -0800 Subject: [PATCH] libcephfs: get osd location on -1 should return EINVAL Signed-off-by: Sage Weil --- src/client/Client.cc | 2 ++ src/test/libcephfs/test.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 68fad0d917a39..db050b94d8958 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8031,6 +8031,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 597d049e2a446..4823d60103ac5 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()); -- 2.39.5