Skip to content

Commit

Permalink
drbd: drbd_adm_down(): Move valid resource name check to drbd_adm_pre…
Browse files Browse the repository at this point in the history
…pare()

Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
  • Loading branch information
Andreas Gruenbacher authored and Philipp Reisner committed Feb 17, 2014
1 parent 77c556f commit a10f6b8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/block/drbd/drbd_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info,
}
if (!adm_ctx.connection && (flags & DRBD_ADM_NEED_RESOURCE)) {
drbd_msg_put_info("unknown resource");
if (adm_ctx.resource_name)
return ERR_RES_NOT_KNOWN;
return ERR_INVALID_REQUEST;
}

Expand Down Expand Up @@ -3355,17 +3357,12 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info)
struct drbd_device *device;
unsigned i;

retcode = drbd_adm_prepare(skb, info, 0);
retcode = drbd_adm_prepare(skb, info, DRBD_ADM_NEED_RESOURCE);
if (!adm_ctx.reply_skb)
return retcode;
if (retcode != NO_ERROR)
goto out;

if (!adm_ctx.connection) {
retcode = ERR_RES_NOT_KNOWN;
goto out;
}

/* demote */
idr_for_each_entry(&adm_ctx.connection->volumes, device, i) {
retcode = drbd_set_role(device, R_SECONDARY, 0);
Expand Down

0 comments on commit a10f6b8

Please sign in to comment.