From nobody Thu Feb 17 06:56:10 2022 X-Original-To: dev-commits-src-branches@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 5FCD519C5D42; Thu, 17 Feb 2022 06:56:10 +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 4JzlwV2DsDz3LNP; Thu, 17 Feb 2022 06:56:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645080970; 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=Z5IQogpEeXe2To3tEz4KL6Tqd3i9IM1iAetZ+t1lhls=; b=tknlqNqbS1tVYqq/Nx46hZamKutsLYpsP7Ild8o2HHKLRYv2PK/vxiEc0X4igK8rNIbHq6 p583qPLL3M/EHRhOXm1eYUSO7XuMSocxXDpMWqgtYe+NFi3ajhSQZPd7F+7ZXilNpx6TOj PkW2CfIl+hWX+WZ8MaDhAgRFdrIGwZwETFnFm1/4ZDqldycZrUJN723r5fcXd4xDlIY8JW JQiSE/2Hxqj2h8pN88utxJvlPxqW0Jz9/n4DQeyle2dWEOXdUYcp8AgyFN35vCzvF+TYEb UKZXFhS+GUDL/YG/yIBnE6E6FCuALBROKsHhs2KlYjENV5Tg2O/9b5QuKJdGPA== 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 22797252C1; Thu, 17 Feb 2022 06:56:10 +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 21H6uAxt097163; Thu, 17 Feb 2022 06:56:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21H6uAGT097162; Thu, 17 Feb 2022 06:56:10 GMT (envelope-from git) Date: Thu, 17 Feb 2022 06:56:10 GMT Message-Id: <202202170656.21H6uAGT097162@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 77eb3a831ec0 - stable/12 - g_mirror: don't fail reads while losing next-to-last disk List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/12 X-Git-Reftype: branch X-Git-Commit: 77eb3a831ec0b60139502b6ce3e01b1641e985ec Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645080970; 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=Z5IQogpEeXe2To3tEz4KL6Tqd3i9IM1iAetZ+t1lhls=; b=dnfbbgG5ZtVqhuNOCCkYXx55tg4NIjurmymcOvCbW7FogqX+7VSjh1PBAJhZOaXnLJoDnT OuwIThe0IYYrfxI1c9Nmer4D/xftQ6BuzB48SQ1xkBJkqpEg178YOggzFM8IpJhrvfPToZ q6MFKtSjXjEAyUcYh52G42gsQ10vdkI8P4k5D6FFAVWeKARYPtAG+Qg4Z66Qc2A/WG7SC2 OVo9+TkzOX3s/lQCjEI+EhOC5nRmBKxR4bwVpmsVgzbvQstp2nsRogF2PGVsXSAOFGt5om SiQyW5nKVsYUwmlBFwgm+j7YFOuNnXYWc4zsHQ0Uz515NOXFJR0lNhc1yvCm8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645080970; a=rsa-sha256; cv=none; b=fR2IooYDr8CUA6i6qkDjgjECc+32aqID6HIcLlD6CNzwGjkzsUkVJrPTCwa7JJuwCiZiEo WNlk2AnB56VDadF/4BvjAbIzYgJ8W1aKx73au5q5kUwaNy3cAUSzyr54wxdPgDf9gk5WbD c/ThHap9kHYcfK+u8YA5PA5jNbkPPeJJr8KJam71O/5TySyrL5JVG3QqD5bs5BKNajqbNL VhWkXXc/RTibAnevpz91EoFGTpX4Zb/MUJwzeg1LjlE22gATHAmLdVLsQ0bzElQKy8HuJT KiDUQS1of30LZqL7LhyG9AMQWM17m/z6xpd/w05BWyJbrkUvTl99wucPG9vdBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=77eb3a831ec0b60139502b6ce3e01b1641e985ec commit 77eb3a831ec0b60139502b6ce3e01b1641e985ec Author: Andriy Gapon AuthorDate: 2022-01-27 10:49:04 +0000 Commit: Andriy Gapon CommitDate: 2022-02-17 06:56:05 +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. (cherry picked from commit 5d5f44623eb3d121d528060d131ee5d6bcd63489) --- 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 15a1503758d8..5633a7c5f5ce 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -1017,9 +1017,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);