diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2011-05-04 04:06:52 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:55:44 -0500 |
commit | d589a21e5d9099a6351862ae6a7f4ae5ec4103d4 (patch) | |
tree | 5cf90cdc5e49cff6ad946882854bce7c0aa6ee2e | |
parent | 9958c857c760eec76f4fdf288b6f33a1c3b41833 (diff) |
drbd: Enforce limits of disk_conf members; centralized these checks
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 7fda3d9445ca..812e91f1b6d4 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -937,9 +937,6 @@ static int drbd_check_al_size(struct drbd_conf *mdev, struct disk_conf *dc) | |||
937 | unsigned int in_use; | 937 | unsigned int in_use; |
938 | int i; | 938 | int i; |
939 | 939 | ||
940 | if (!expect(dc->al_extents >= DRBD_AL_EXTENTS_MIN)) | ||
941 | dc->al_extents = DRBD_AL_EXTENTS_MIN; | ||
942 | |||
943 | if (mdev->act_log && | 940 | if (mdev->act_log && |
944 | mdev->act_log->nr_elements == dc->al_extents) | 941 | mdev->act_log->nr_elements == dc->al_extents) |
945 | return 0; | 942 | return 0; |
@@ -1102,6 +1099,17 @@ static bool should_set_defaults(struct genl_info *info) | |||
1102 | return 0 != (flags & DRBD_GENL_F_SET_DEFAULTS); | 1099 | return 0 != (flags & DRBD_GENL_F_SET_DEFAULTS); |
1103 | } | 1100 | } |
1104 | 1101 | ||
1102 | static void enforce_disk_conf_limits(struct disk_conf *dc) | ||
1103 | { | ||
1104 | if (dc->al_extents < DRBD_AL_EXTENTS_MIN) | ||
1105 | dc->al_extents = DRBD_AL_EXTENTS_MIN; | ||
1106 | if (dc->al_extents > DRBD_AL_EXTENTS_MAX) | ||
1107 | dc->al_extents = DRBD_AL_EXTENTS_MAX; | ||
1108 | |||
1109 | if (dc->c_plan_ahead > DRBD_C_PLAN_AHEAD_MAX) | ||
1110 | dc->c_plan_ahead = DRBD_C_PLAN_AHEAD_MAX; | ||
1111 | } | ||
1112 | |||
1105 | int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info) | 1113 | int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info) |
1106 | { | 1114 | { |
1107 | enum drbd_ret_code retcode; | 1115 | enum drbd_ret_code retcode; |
@@ -1146,11 +1154,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info) | |||
1146 | if (!expect(new_disk_conf->resync_rate >= 1)) | 1154 | if (!expect(new_disk_conf->resync_rate >= 1)) |
1147 | new_disk_conf->resync_rate = 1; | 1155 | new_disk_conf->resync_rate = 1; |
1148 | 1156 | ||
1149 | /* clip to allowed range */ | 1157 | enforce_disk_conf_limits(new_disk_conf); |
1150 | if (!expect(new_disk_conf->al_extents >= DRBD_AL_EXTENTS_MIN)) | ||
1151 | new_disk_conf->al_extents = DRBD_AL_EXTENTS_MIN; | ||
1152 | if (!expect(new_disk_conf->al_extents <= DRBD_AL_EXTENTS_MAX)) | ||
1153 | new_disk_conf->al_extents = DRBD_AL_EXTENTS_MAX; | ||
1154 | 1158 | ||
1155 | fifo_size = (new_disk_conf->c_plan_ahead * 10 * SLEEP_TIME) / HZ; | 1159 | fifo_size = (new_disk_conf->c_plan_ahead * 10 * SLEEP_TIME) / HZ; |
1156 | if (fifo_size != mdev->rs_plan_s->size) { | 1160 | if (fifo_size != mdev->rs_plan_s->size) { |
@@ -1273,6 +1277,8 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) | |||
1273 | goto fail; | 1277 | goto fail; |
1274 | } | 1278 | } |
1275 | 1279 | ||
1280 | enforce_disk_conf_limits(new_disk_conf); | ||
1281 | |||
1276 | new_plan = fifo_alloc((new_disk_conf->c_plan_ahead * 10 * SLEEP_TIME) / HZ); | 1282 | new_plan = fifo_alloc((new_disk_conf->c_plan_ahead * 10 * SLEEP_TIME) / HZ); |
1277 | if (!new_plan) { | 1283 | if (!new_plan) { |
1278 | retcode = ERR_NOMEM; | 1284 | retcode = ERR_NOMEM; |
@@ -1450,8 +1456,6 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) | |||
1450 | else | 1456 | else |
1451 | clear_bit(MD_NO_FUA, &mdev->flags); | 1457 | clear_bit(MD_NO_FUA, &mdev->flags); |
1452 | 1458 | ||
1453 | /* FIXME Missing stuff: clip al range */ | ||
1454 | |||
1455 | /* Point of no return reached. | 1459 | /* Point of no return reached. |
1456 | * Devices and memory are no longer released by error cleanup below. | 1460 | * Devices and memory are no longer released by error cleanup below. |
1457 | * now mdev takes over responsibility, and the state engine should | 1461 | * now mdev takes over responsibility, and the state engine should |