]> git.openfabrics.org - ~shefty/rdma-dev.git/commit
rbd: return earlier in rbd_header_from_disk()
authorAlex Elder <elder@inktank.com>
Fri, 27 Jul 2012 04:37:15 +0000 (23:37 -0500)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:48 +0000 (14:30 -0500)
commit28cb775de1bd1bcc62c43f767ab81b7b9cfb6678
treea9ed5f43be03561446be1c08b8221c183ca6ca4c
parent6a52325f61760c6a7d7f3ea9736029bc9f63e7f3
rbd: return earlier in rbd_header_from_disk()

The only caller of rbd_header_from_disk() is rbd_read_header().
It passes as allocated_snaps the number of snapshots it will
have received from the server for the snapshot context that
rbd_header_from_disk() is to interpret.  The first time through
it provides 0--mainly to extract the number of snapshots from
the snapshot context header--so that it can allocate an
appropriately-sized buffer to receive the entire snapshot
context from the server in a second request.

rbd_header_from_disk() will not fill in the array of snapshot ids
unless the number in the snapshot matches the number the caller
had allocated.

This patch adjusts that logic a little further to be more efficient.
rbd_read_header() doesn't even examine the snapshot context unless
the snapshot count (stored in header->total_snaps) matches the
number of snapshots allocated.  So rbd_header_from_disk() doesn't
need to allocate or fill in the snapshot context field at all in
that case.

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