From nobody Thu Feb 17 06:48:34 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 1E03C19C330B; Thu, 17 Feb 2022 06:48:35 +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 4Jzlll0LCMz3JV0; Thu, 17 Feb 2022 06:48:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645080515; 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=Gfim1RPwSfPKgbjD82zxH14ZqHZtscF5A/ad2zRuAZs=; b=LaWozbFLA5Pmjf9bCsQCE7pt0zmompGmUi1R+tYKljpC+QT24MFRGGfUzZki65dPoB0lu0 +cv1Sk197zN9dKuvmBdq/Dbolxsj/MxQ9LAP5XlFZ5hskY7L2O4qA5i9Sqa4TZOwKnA+XP i/nGt8TRgWFmClvmXOoF/EdTxVvnjx5mooB4uY9dFQrAL4Yn/XBed1qyLfJlEpzQ6RXNBc y1CcUCsmY4hMJIzuuJoBecAUicWGXMA9piuzpjWVJRWMfP6mhowG21FssR3fPnQQ3DB+gi yroRgkDgEZ7l4xa0rz4nK0sF3BgiiGNPRDTzcTIaDGnaq7RSGNuf9g5wfd42Ng== 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 DFCC32522D; Thu, 17 Feb 2022 06:48:34 +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 21H6mYJC083984; Thu, 17 Feb 2022 06:48:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21H6mY6C083983; Thu, 17 Feb 2022 06:48:34 GMT (envelope-from git) Date: Thu, 17 Feb 2022 06:48:34 GMT Message-Id: <202202170648.21H6mY6C083983@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: cb702452adeb - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: cb702452adeb2cab1e5c083f81108f049bcafa3a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645080515; 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=Gfim1RPwSfPKgbjD82zxH14ZqHZtscF5A/ad2zRuAZs=; b=b9gCrnXKJ0q77XGnbzZ+oX6238AAPUVMabXEwcaySbHXNx7umUm3ixqDDWv67lXBRLK5tr TlUrwbCkbJtgeBrKsC+qL55v7ahVl3aAHzytaJBr1aQf3XYVd3/J9XyI1Z5iOj1TZuy5tk TVOeBor48mq3CwYOaQyoTcdiOfkCX3SYmfZvSvr6BLdEwFQxoLc7twoVVGphDsjPLyRVsk mFsjyy3S2hEhiIUhXCVrDs51xeNnel2Z10YfAZDLYKLLiDJvN6Cmo7A/tQqW/Pf1b9idaj zoAcBqcijhoN5/QjRMP8ZCZCmvVAViiEHyGi6MvOvMqs6lHlZBzFTA1EyyJzBA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645080515; a=rsa-sha256; cv=none; b=EeEgxFDTp/KH5xpTIb92kj2azY4diglzN0LRtrP8BVzmmLDPyx1WMtcyDbZUqi2jG6lOG5 YDWa5UVoQ7Jy1lTGtJ4yowoRZYTWBWsLKJo/iXl9WH4TWJPYslsFw8jZKAZi6HnWj/sAwF KqDLn58deeX8I6kULJpcnxYVkcIGH/Cw0aV/KbXqbtG7p/m9thAwM1pq3lQZVhqGuYkQ6S A4whHo457pd3d7Lr/YnlG0uSjs2U2XyXUJ9kOU180viOtedj2iT3ex5i0X5Y2EACRMY35s JepX3wjHu01sByb9OSw57XA/gUQ3mI2jB5dF+DUIjvT7MLVEmSzmA50m1ReWUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=cb702452adeb2cab1e5c083f81108f049bcafa3a commit cb702452adeb2cab1e5c083f81108f049bcafa3a Author: Andriy Gapon AuthorDate: 2022-01-27 10:49:04 +0000 Commit: Andriy Gapon CommitDate: 2022-02-17 06:46:14 +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 455aae4bebf8..cb5129dabd33 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);