From: Josh Durgin Date: Mon, 5 Dec 2011 18:47:13 +0000 (-0800) Subject: rbd: protect read of snapshot sequence number X-Git-Tag: v3.4.20~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45739514727c294e843269d515b952d5dbd911bf;p=platform%2Fkernel%2Flinux-stable.git rbd: protect read of snapshot sequence number (cherry picked from commit 403f24d3d51760a8b9368d595fa5f48c309f1a0f) This is updated whenever a snapshot is added or deleted, and the snapc pointer is changed with every refresh of the header. Signed-off-by: Josh Durgin Reviewed-by: Alex Elder Reviewed-by: Yehuda Sadeh Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c1f7701..ff224ba 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1683,7 +1683,9 @@ static int rbd_header_add_snap(struct rbd_device *dev, if (ret < 0) return ret; - dev->header.snapc->seq = new_snapid; + down_write(&dev->header_rwsem); + dev->header.snapc->seq = new_snapid; + up_write(&dev->header_rwsem); return 0; bad: