Skip to content

Commit efadc98

Browse files
committed
rbd: ignore unmapped snapshots that no longer exist
This prevents erroring out while adding a device when a snapshot unrelated to the current mapping is deleted between reading the snapshot context and reading the snapshot names. If the mapped snapshot name is not found an error still occurs as usual. Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent 9875201 commit efadc98

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/block/rbd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4078,8 +4078,13 @@ static u64 rbd_v2_snap_id_by_name(struct rbd_device *rbd_dev, const char *name)
40784078

40794079
snap_id = snapc->snaps[which];
40804080
snap_name = rbd_dev_v2_snap_name(rbd_dev, snap_id);
4081-
if (IS_ERR(snap_name))
4082-
break;
4081+
if (IS_ERR(snap_name)) {
4082+
/* ignore no-longer existing snapshots */
4083+
if (PTR_ERR(snap_name) == -ENOENT)
4084+
continue;
4085+
else
4086+
break;
4087+
}
40834088
found = !strcmp(name, snap_name);
40844089
kfree(snap_name);
40854090
}

0 commit comments

Comments
 (0)