librbd: fix crash using clone of flattened image

The crash occurs due to ImageCtx->parent->parent being uninitialized,
since the inital open_parent() -> open_image(parent) ->
ictx_refresh(parent) occurs before ImageCtx->parent->snap_id is set,
so refresh_parent() is not called to open an ImageCtx for the parent
of the parent. This leaves the ImageCtx->parent->parent NULL, but the
rest of ImageCtx->parent updated to point at the correct parent snapshot.

Setting the parent->snap_id earlier has some unintended side effects
currently, so for now just call refresh_parent() during
open_parent(). This is the easily backportable version of the
fix. Further patches can clean up this whole initialization process.

Fixes: #8845
Backport: firefly, dumpling
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: store and retrieve snapshot metadata based on id

Snapshots are usually accessed by id internally, so change accessors
to take id instead of name. Keep a separate map of name -> id for
looking up human-specified names.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Merge pull request #2205 from ceph/wip-librbd-snap-meta

librbd: fix crash with a chain of flattened images

Reviewed-by: Sage Weil <sage@redhat.com>