rbd: protect read of snapshot sequence number
authorJosh Durgin <josh.durgin@dreamhost.com>
Mon, 5 Dec 2011 18:47:13 +0000 (10:47 -0800)
committerAlex Elder <elder@dreamhost.com>
Mon, 14 May 2012 17:12:46 +0000 (12:12 -0500)
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 <josh.durgin@dreamhost.com>
Reviewed-by: Alex Elder <elder@dreamhost.com>
Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net>
drivers/block/rbd.c

index a75fe93a25b173db342f033b2697e86638506f39..5ab9f55d3e0cb08ea4323fdc74159e5d9899dccb 100644 (file)
@@ -1684,7 +1684,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: