mirror of
https://github.com/ceph/ceph
synced 2025-02-21 09:57:26 +00:00
Merge pull request #55397 from jagombar/fixInvalidSnapId2
librbd: return ENOENT from Snapshot::get_timestamp for nonexistent snap_id Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
commit
5952230d90
@ -378,7 +378,9 @@ int Snapshot<I>::remove(I *ictx, const char *snap_name, uint32_t flags,
|
||||
template <typename I>
|
||||
int Snapshot<I>::get_timestamp(I *ictx, uint64_t snap_id, struct timespec *timestamp) {
|
||||
auto snap_it = ictx->snap_info.find(snap_id);
|
||||
ceph_assert(snap_it != ictx->snap_info.end());
|
||||
if (snap_it == ictx->snap_info.end()) {
|
||||
return -ENOENT;
|
||||
}
|
||||
utime_t time = snap_it->second.timestamp;
|
||||
time.to_timespec(timestamp);
|
||||
return 0;
|
||||
|
@ -1902,6 +1902,8 @@ TEST_F(TestLibRBD, TestGetSnapShotTimeStamp)
|
||||
ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
|
||||
ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));
|
||||
|
||||
ASSERT_EQ(-ENOENT, rbd_snap_get_timestamp(image, 0, NULL));
|
||||
|
||||
ASSERT_EQ(0, rbd_snap_create(image, "snap1"));
|
||||
num_snaps = rbd_snap_list(image, snaps, &max_size);
|
||||
ASSERT_EQ(1, num_snaps);
|
||||
|
Loading…
Reference in New Issue
Block a user