]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
rbd: fix leak of snapshots during initial probe
authorAlex Elder <elder@inktank.com>
Thu, 25 Apr 2013 20:09:41 +0000 (15:09 -0500)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:19:26 +0000 (21:19 -0700)
commit522a0cc0f0ecdb1857db7795b1c17591f28f9ca0
tree4504b4a8c4ff457eb0682cb998a4c5d56843a671
parent3e83b65bb9a9f3a4d7f0200139bd947c940ec3ab
rbd: fix leak of snapshots during initial probe

When an rbd image is initially mapped, its snapshot context is
collected, and then a list of snapshot entries representing the
snapshots in that context is created.  The list is created using
rbd_dev_snaps_update().  (This function also supports updating an
existing snapshot list based on a new snapshot context.)

If an error occurs, updating the list is aborted, and the list is
currently left as-is, in an inconsistent state.  At that point,
there may be a partially-constructed list, but the calling functions
(rbd_dev_probe_finish() from rbd_dev_probe() from rbd_add()) never
clean them up.  So this constitutes a leak.

A snapshot list that is inconsistent with the current snapshot
context is of no use, and might even be actively bad.  So rather
than just having the caller clean it up, have rbd_dev_snaps_update()
just clear out the entire snapshot list in the event an error
occurs.

The other place rbd_dev_snaps_update() is used is when a refresh is
triggered, either because of a watch callback or via a write to the
/sys/bus/rbd/devices/<id>/refresh interface.  An error while
updating the snapshots has no substantive effect in either of those
cases, but one of them issues a warning.  Move that warning to the
common rbd_dev_refresh() function so it gets issued regardless of
how it got initiated.

This is part of:
    http://tracker.ceph.com/issues/4803

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c