]> git.hungrycats.org Git - linux/commit
rbd: fix rbd_dev_parent_get() when parent_overlap == 0
authorIlya Dryomov <idryomov@redhat.com>
Mon, 19 Jan 2015 15:13:43 +0000 (18:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Feb 2015 06:36:04 +0000 (22:36 -0800)
commit0539097d55226ad671f1434763573d4ec8d00ff4
tree87020d225e0d8ad4d191d2cc1dc83632a3b3e799
parent186eb06e60d4961d03a6404e32ae0aa39eb8a8bf
rbd: fix rbd_dev_parent_get() when parent_overlap == 0

commit ae43e9d05eb4bd324155292f889fbd001c4faea8 upstream.

The comment for rbd_dev_parent_get() said

    * We must get the reference before checking for the overlap to
    * coordinate properly with zeroing the parent overlap in
    * rbd_dev_v2_parent_info() when an image gets flattened.  We
    * drop it again if there is no overlap.

but the "drop it again if there is no overlap" part was missing from
the implementation.  This lead to absurd parent_ref values for images
with parent_overlap == 0, as parent_ref was incremented for each
img_request and virtually never decremented.

Fix this by leveraging the fact that refresh path calls
rbd_dev_v2_parent_info() under header_rwsem and use it for read in
rbd_dev_parent_get(), instead of messing around with atomics.  Get rid
of barriers in rbd_dev_v2_parent_info() while at it - I don't see what
they'd pair with now and I suspect we are in a pretty miserable
situation as far as proper locking goes regardless.

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/rbd.c