mirror of https://gitee.com/openkylin/linux.git
drbd: do not block when adjusting "disk-options" while IO is frozen
"suspending" IO is overloaded. It can mean "do not allow new requests" (obviously), but it also may mean "must not complete pending IO", for example while the fencing handlers do their arbitration. When adjusting disk options, we suspend io (disallow new requests), then wait for the activity-log to become unused (drain all IO completions), and possibly replace it with a new activity log of different size. If the other "suspend IO" aspect is active, pending IO completions won't happen, and we would block forever (unkillable drbdsetup process). Fix this by skipping the activity log adjustment if the "al-extents" setting did not change. Also, in case it did change, fail early without blocking if it looks like we would block forever. Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
a2823ea920
commit
f708bd08ec
|
@ -1540,6 +1540,30 @@ static void sanitize_disk_conf(struct drbd_device *device, struct disk_conf *dis
|
|||
}
|
||||
}
|
||||
|
||||
static int disk_opts_check_al_size(struct drbd_device *device, struct disk_conf *dc)
|
||||
{
|
||||
int err = -EBUSY;
|
||||
|
||||
if (device->act_log &&
|
||||
device->act_log->nr_elements == dc->al_extents)
|
||||
return 0;
|
||||
|
||||
drbd_suspend_io(device);
|
||||
/* If IO completion is currently blocked, we would likely wait
|
||||
* "forever" for the activity log to become unused. So we don't. */
|
||||
if (atomic_read(&device->ap_bio_cnt))
|
||||
goto out;
|
||||
|
||||
wait_event(device->al_wait, lc_try_lock(device->act_log));
|
||||
drbd_al_shrink(device);
|
||||
err = drbd_check_al_size(device, dc);
|
||||
lc_unlock(device->act_log);
|
||||
wake_up(&device->al_wait);
|
||||
out:
|
||||
drbd_resume_io(device);
|
||||
return err;
|
||||
}
|
||||
|
||||
int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
struct drbd_config_context adm_ctx;
|
||||
|
@ -1602,15 +1626,12 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
|
|||
}
|
||||
}
|
||||
|
||||
drbd_suspend_io(device);
|
||||
wait_event(device->al_wait, lc_try_lock(device->act_log));
|
||||
drbd_al_shrink(device);
|
||||
err = drbd_check_al_size(device, new_disk_conf);
|
||||
lc_unlock(device->act_log);
|
||||
wake_up(&device->al_wait);
|
||||
drbd_resume_io(device);
|
||||
|
||||
err = disk_opts_check_al_size(device, new_disk_conf);
|
||||
if (err) {
|
||||
/* Could be just "busy". Ignore?
|
||||
* Introduce dedicated error code? */
|
||||
drbd_msg_put_info(adm_ctx.reply_skb,
|
||||
"Try again without changing current al-extents setting");
|
||||
retcode = ERR_NOMEM;
|
||||
goto fail_unlock;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue