Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp745107ybl; Wed, 4 Dec 2019 10:09:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyfq7wF2GK7Bxt3x1lE0f6cjudXHgwaunjp3+mONRHfkKoh2s0/BQeqR6Xu9y7YEi/bfGGu X-Received: by 2002:aca:fdc2:: with SMTP id b185mr2670569oii.74.1575482964767; Wed, 04 Dec 2019 10:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575482964; cv=none; d=google.com; s=arc-20160816; b=CA7jaTBqgVN+OBTCjGbZeE1Z68b5g6V4dYGxqUAxEClLJNgyFS4Ar38r3Ld4zghOUY qLbN5dJVL8fwx7h1dnfoMU+OXQflx3rzS8gGbEw4Wsp4+piJXZ1DnMe3ilIRNWP4F0CM Le4Bh3ve3OUrJNU7wQn2kvdX+QxFla1WLggSTkaJTYF8g0qqNNHkivEmVpLnISJcxF8P xXDQHAww25Xv3cE7b+s1Z9Rpi4CdsNBDGZ6sZnhPxy9SzAR0+YrxU65qinIxPHrCajkD +1ZIYIoh2ZGdkvDdy+yXF6p7BNsi6Zg9tRIyzWt3Hqd/YwG1w+FhaC+x3SIE68+y45On qrfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OeJ0nde6IxeHd2HrzLoDMb8EMggyrTNt81OvfKLMnEQ=; b=xbQo39/5TN9afwgSYoWUQNpIvualrOQ2DeNhHkSNc3+y7s+DvWVYrDO2cOVo5E/VQW vpxlwD3TQvCSrGSoW0eym6Je8bVyPIMIkH9Jfrx5PEVHz3O/NpXltGEm4pgmGHUyneZ8 CxH5quncJu7XqB/6esuykccclQNhIAMBTXrDXnzoaayzia9KipJhOZFzK2GGECnpLZiY ul5SxpRssMhtYGtXmOyuNI5NOHJe0WSTXUjOZ5AZK6xgGEnNkxAXd6qo8ahLjis+ukgE ILPg/oyI017DWT1uy5mjVsHtvNNC/knGz0ngJQr9qqbXmYR+cx+ouyTS2QeAo9x8N0wu /5gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jKcPC8qP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si3647895otn.53.2019.12.04.10.09.12; Wed, 04 Dec 2019 10:09:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jKcPC8qP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730664AbfLDSG4 (ORCPT + 99 others); Wed, 4 Dec 2019 13:06:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:55934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730654AbfLDSGz (ORCPT ); Wed, 4 Dec 2019 13:06:55 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B6B920674; Wed, 4 Dec 2019 18:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482814; bh=yX1fRkoZa9hfgOfU+yD5L5Gfs4/CUrl+xZh79cZVmSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jKcPC8qPQaV8Gk8YevIUZzyTEbWcW/MpJ5chUjm0rSuYoksuEpLqx9gAhrLf1p7YT l22JXpe1jEpaKRNt8T3762zykCCj1CBgDR4ewg+uJBaH+y5D6Ad3FPPOtZ9Gsfrz8v n6JYvtIeexmUtXH9I63MYcxFOWuv1ZTgHKgDSpDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars Ellenberg , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 101/209] drbd: do not block when adjusting "disk-options" while IO is frozen Date: Wed, 4 Dec 2019 18:55:13 +0100 Message-Id: <20191204175328.815507288@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Ellenberg [ Upstream commit f708bd08ecbdc23d03aaedf5b3311ebe44cfdb50 ] "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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/drbd/drbd_nl.c | 37 ++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index a675a0f61f9c0..31d7fe4480afd 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1515,6 +1515,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; @@ -1577,15 +1601,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; } -- 2.20.1