aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_nl.c
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2012-08-08 15:19:09 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-09 08:08:04 -0500
commit39a1aa7f49dc8eae5c8d3a4bf759eb7abeabe6c0 (patch)
treed75405087a78c53b95c99ab5e2e52230a5e8cc5a /drivers/block/drbd/drbd_nl.c
parentfef45d297e447d710abcf0cd0bdbf8738ff469eb (diff)
drbd: Protect accesses to the uuid set with a spinlock
There is at least the worker context, the receiver context, the context of receiving netlink packts. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_nl.c')
-rw-r--r--drivers/block/drbd/drbd_nl.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index c02d5265c397..d31a0261e83e 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1320,6 +1320,8 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1320 retcode = ERR_NOMEM; 1320 retcode = ERR_NOMEM;
1321 goto fail; 1321 goto fail;
1322 } 1322 }
1323 spin_lock_init(&nbc->md.uuid_lock);
1324
1323 new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL); 1325 new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL);
1324 if (!new_disk_conf) { 1326 if (!new_disk_conf) {
1325 retcode = ERR_NOMEM; 1327 retcode = ERR_NOMEM;
@@ -2679,8 +2681,16 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
2679 goto nla_put_failure; 2681 goto nla_put_failure;
2680 2682
2681 if (got_ldev) { 2683 if (got_ldev) {
2684 int err;
2685
2686 spin_lock_irq(&mdev->ldev->md.uuid_lock);
2687 err = nla_put(skb, T_uuids, sizeof(si->uuids), mdev->ldev->md.uuid);
2688 spin_unlock_irq(&mdev->ldev->md.uuid_lock);
2689
2690 if (err)
2691 goto nla_put_failure;
2692
2682 if (nla_put_u32(skb, T_disk_flags, mdev->ldev->md.flags) || 2693 if (nla_put_u32(skb, T_disk_flags, mdev->ldev->md.flags) ||
2683 nla_put(skb, T_uuids, sizeof(si->uuids), mdev->ldev->md.uuid) ||
2684 nla_put_u64(skb, T_bits_total, drbd_bm_bits(mdev)) || 2694 nla_put_u64(skb, T_bits_total, drbd_bm_bits(mdev)) ||
2685 nla_put_u64(skb, T_bits_oos, drbd_bm_total_weight(mdev))) 2695 nla_put_u64(skb, T_bits_oos, drbd_bm_total_weight(mdev)))
2686 goto nla_put_failure; 2696 goto nla_put_failure;