rbd: simplify __rbd_init_snaps_header()
authorAlex Elder <elder@inktank.com>
Thu, 2 Aug 2012 16:29:46 +0000 (11:29 -0500)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:48 +0000 (14:30 -0500)
commit3593815022998ab75379f64735ff67b3ea388cbe
tree12d4d1f392e5e45494e8ccb8162f4004d484b405
parenta0d271cbfed1dd50278c6b06bead3d00ba0a88f9
rbd: simplify __rbd_init_snaps_header()

The purpose of __rbd_init_snaps_header() is to compare a new
snapshot context with an rbd device's list of existing snapshots.
It updates the list by adding any new snapshots or removing any
that are not present in the new snapshot context.

The code as written is a little confusing, because it traverses both
the existing snapshot list and the set of snapshots in the snapshot
context in reverse.  This was done based on an assumption about
snapshots that is not true--namely that a duplicate snapshot name
could cause an error in intepreting things if they were not
processed in ascending order.

These precautions are not necessary, because:
    - all snapshots are uniquely identified by their snapshot id
    - a new snapshot cannot be created if the rbd device has another
      snapshot with the same name
(It is furthermore not currently possible to rename a snapshot.)

This patch re-implements __rbd_init_snaps_header() so it passes
through both the existing snapshot list and the entries in the
snapshot context in forward order.  It still does the same thing
as before, but I find the logic considerably easier to understand.

By going forward through the names in the snapshot context, there
is no longer a need for the rbd_prev_snap_name() helper function.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c
This page took 0.025644 seconds and 5 git commands to generate.