diff options
author | Lars Ellenberg | 2011-03-14 13:22:35 +0100 |
---|---|---|
committer | Philipp Reisner | 2012-11-04 00:16:21 +0100 |
commit | 38f19616d2c6d4e0ab2de01e4c2f159cd5aa8b49 (patch) | |
tree | ff173524bc659960d9b25976d6f963cee2172090 /drivers/block/drbd/drbd_nl.c | |
parent | drbd: Allow a Diskless Secondary volume to be removed (diff) | |
download | kernel-qcow2-linux-38f19616d2c6d4e0ab2de01e4c2f159cd5aa8b49.tar.gz kernel-qcow2-linux-38f19616d2c6d4e0ab2de01e4c2f159cd5aa8b49.tar.xz kernel-qcow2-linux-38f19616d2c6d4e0ab2de01e4c2f159cd5aa8b49.zip |
drbd: new-connection and new-minor succeed, if the object already exists
Follow O_CREAT semantics when creating connection or minor device/volume
objects. If we need O_CREAT|O_EXCL semantics some time down the road,
we can add NLM_F_EXCL to the netlink message flags.
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.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 9b0312f2d2f8..0d3753be371c 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -2590,8 +2590,11 @@ int drbd_adm_create_connection(struct sk_buff *skb, struct genl_info *info) goto out; if (adm_ctx.tconn) { - retcode = ERR_INVALID_REQUEST; - drbd_msg_put_info("connection exists"); + if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) { + retcode = ERR_INVALID_REQUEST; + drbd_msg_put_info("connection exists"); + } + /* else: still NO_ERROR */ goto out; } @@ -2626,6 +2629,15 @@ int drbd_adm_add_minor(struct sk_buff *skb, struct genl_info *info) goto out; } + /* drbd_adm_prepare made sure already + * that mdev->tconn and mdev->vnr match the request. */ + if (adm_ctx.mdev) { + if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) + retcode = ERR_MINOR_EXISTS; + /* else: still NO_ERROR */ + goto out; + } + retcode = conn_new_minor(adm_ctx.tconn, dh->minor, adm_ctx.volume); out: drbd_adm_finish(info, retcode); |