summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@dreamhost.com>2011-12-05 10:47:13 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-26 11:38:10 -0800
commit45739514727c294e843269d515b952d5dbd911bf (patch)
tree96021d986c838adf85f6799d40e3583ce026eddf
parent095cb2142dfb10daea5a3351ed9646d3178a6823 (diff)
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 <josh.durgin@dreamhost.com> Reviewed-by: Alex Elder <elder@dreamhost.com> Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/block/rbd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index c1f770131654..ff224baf0ff6 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: