From nobody Thu Jan 27 11:26:51 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 27442197F479; Thu, 27 Jan 2022 11:26:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkywW72wrz3Cyn; Thu, 27 Jan 2022 11:26:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643282812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2V2XemXy0o+b9Cg7oBpW14zh0OyppoB+/ZfSfr1SsLg=; b=RiSW0hwlOFzTvLyC9WXtQ4VkrygntHElIPiEQ4ovpGcQdtB5viufL5iqUMohIa6hUh+45i JV6r96rf5hCgqTUV7YKnNf/dvZ64f4ozrPQLcIhz1hdzNHjRxqjs86+ypOuHH7UWeRLky3 n0mO8OYHojoqGe7ZVt3nj6nsdtnkIdoRq6JiWN7MComQcQxFbfDAVx5uJ7c0EPKXgVZqqF g9rt+aLgM4VdPjBb89iVL+slZ7/HEOeRGkmJbx+E6FezBNCjbMxg77SBD6KJpdG5ELD35V jw0Yx8YlH4ISKu61gytpBE6Nx+4SRfWnI/KgzgDxsxZawHzDO4GZFM47JTO0/g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C689715F5D; Thu, 27 Jan 2022 11:26:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20RBQp3Y098428; Thu, 27 Jan 2022 11:26:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20RBQpRm098427; Thu, 27 Jan 2022 11:26:51 GMT (envelope-from git) Date: Thu, 27 Jan 2022 11:26:51 GMT Message-Id: <202201271126.20RBQpRm098427@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 5d5f44623eb3 - main - g_mirror: don't fail reads while losing next-to-last disk List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d5f44623eb3d121d528060d131ee5d6bcd63489 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643282812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2V2XemXy0o+b9Cg7oBpW14zh0OyppoB+/ZfSfr1SsLg=; b=DEC1I5URZbDJvUxrmlj9R8On9JdUQ9wlMPrSFq4CvcIohv3P1Nm5mbz7vDd0RyNSrnInF4 O85ah5oPWpktWXpij2+mX6R6BvlpBfKkqTW4W42abyMmLxxCrTteQWv/lTD1BFuvavA4Hk ZJC+E5Lwx86sI8PzKRB2wyeq5d1ma2dvIiVA+MYfVi9fZdoU2Ya2mNOhOw3P/JpKHuVDdY 1U+2XYpwcAvdcu743MvvICs4KQX2gd6hwvZnoUvzB8byFkgM6jtKikCCcW/CYM+wZxOyER e5ZRBmMJn2s712Ew6HLiX7UGwILcUXaCjuL2Eo2CjPKPBaDIFDrljsXU8ku0Iw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643282812; a=rsa-sha256; cv=none; b=a5NtSHW1Rfk3vTsxIxFLu/lwH5KxUjK82OGIqD+A+qm+dHh29QNkz0TjlptF7uV4G6+Qde /l+7drGVm42yeU9cNG16AGhVfg7ZxmWwV7ZlpNe/wQWkcBfQ4N5J6r9RG8xsnReeNopOL2 59TKBBcpxW6LsquiZPJCOoI1spB6bdiXXXiKOkbVCPLQ6CrpWP3o91PSF+wKP5VrNMmOsR AK3nun27ALfQak+FgoZB3vzWxqXeRRhQ1cmPSIsaF2SLykRTJC7542j66QBN0xvNGGQ/Bm n1jqzIY84Vn9oJztV3EPUyQECNCSX7fqCZJU8UKPxOGu3Ab1E1hWg9wvfDdROQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=5d5f44623eb3d121d528060d131ee5d6bcd63489 commit 5d5f44623eb3d121d528060d131ee5d6bcd63489 Author: Andriy Gapon AuthorDate: 2022-01-27 10:49:04 +0000 Commit: Andriy Gapon CommitDate: 2022-01-27 11:22:52 +0000 g_mirror: don't fail reads while losing next-to-last disk I observed a situation where some read requests failed when a 2-way geom mirror lost one disk. The problem appears to be in the logic that skips retrying a failed request when a mirror has only one active disk. Generally, that makes sense. But during a transition from two disks to one it is possible that the request failed on the failing disk before it was inactivated and, so, the remaining active disk is the disk that should be tried. This change adds an additional check to ensure that it was the (only) active disk that was already tried. Reviewed by: mav MFC after: 3 weeks --- sys/geom/mirror/g_mirror.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index e639aec99c8c..051628e40700 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -1035,9 +1035,19 @@ g_mirror_regular_request(struct g_mirror_softc *sc, struct bio *bp) case BIO_READ: if (pbp->bio_inbed < pbp->bio_children) break; - if (g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE) == 1) + + /* + * If there is only one active disk we want to double-check that + * it is, in fact, the disk that we already tried. This is + * necessary because we might have just lost a race with a + * removal of the tried disk (likely because of the same error) + * and the only remaining disk is still viable for a retry. + */ + if (g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE) == 1 && + disk != NULL && + disk->d_state == G_MIRROR_DISK_STATE_ACTIVE) { g_io_deliver(pbp, pbp->bio_error); - else { + } else { pbp->bio_error = 0; mtx_lock(&sc->sc_queue_mtx); TAILQ_INSERT_TAIL(&sc->sc_queue, pbp, bio_queue);