From nobody Sat Mar 05 02:53:02 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 1680A19F8B57; Sat, 5 Mar 2022 02:53:03 +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 4K9TmZ6wR2z4lL2; Sat, 5 Mar 2022 02:53:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646448783; 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=uOwHNkcysKnu23wfHLLwbfjT9vdxYHfKqZPna3r4OI8=; b=IeuDcv5Y4DNAOEXkdzMLSJpDLTEuyc0ctyc6j4wXrJsHC5HDXbEAVM/IgEiYFpro+TmnIg vlZc8gEHOxsfUiDAak34I/0r8Ne3KBj/3EiTCdRM4iFYOqp1AfBPkbMnLoO2bAO3Akkj1x tpZMWrApPXrWpibxOl0jbkxGzhiEWK2gXlwv8ELF7N8UhEMu5hhs3HqQnXid7BfccSReoP sPvVw9xSfHCtO945E33FRXaIC+gs4Cs2YiU6l7ICT5EPsRFCDeH2mLLmgwFX+LWkZzgeYJ UzZIhQRx50UalX0zF/J/wVofSSy2cmjCh/f16mXy0iECwCCKAeEejXM91thsAQ== 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 C2F35184EE; Sat, 5 Mar 2022 02:53:02 +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 2252r2QF046120; Sat, 5 Mar 2022 02:53:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2252r2GG046119; Sat, 5 Mar 2022 02:53:02 GMT (envelope-from git) Date: Sat, 5 Mar 2022 02:53:02 GMT Message-Id: <202203050253.2252r2GG046119@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Peter Jeremy Subject: git: a65f526addaf - stable/13 - geom_gate: Distinguish between classes of errors 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: peterj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a65f526addafccfe55aa3dab3d8c912eb8f05b4f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646448783; 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=uOwHNkcysKnu23wfHLLwbfjT9vdxYHfKqZPna3r4OI8=; b=AWsRxHQAhQyLJhMwzxJ3vBhfsE/HCczMaxf53xwj9zORkKkllydq1dIgcqUflGfxDHcwp4 w5hECeDeBMJdyV9ja+5FUKgx9aAbmYzfAk9bm7DTut0uKbH7PpxZD6klaMpXcvpJH5jxvC CUbEk/PMlF/Ra85Vvwi50+umAOd/aCNiYdWRFxG8dpmkCERx7KCUb1LHBs2hNnEZivPv6r Pqzp8PmQ3618Akug80vtYKBA5rw+Gw3YviaXj70bgrzT2y0M9b1NyoJA8y0KTWeKdmSwbo qVcr56KvwkP4GQje5l7/Dm4zYgvH+aPiQlI279SFHJmURaxBAtvBXW8nFZOPzw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646448783; a=rsa-sha256; cv=none; b=gRFVtThxBXkog5tfFB1AI+z6CbX4H7JVlIGdnoCJaLIozkrR5yPpT8gIFwKujVedcZ3O6r MUdtAKvNLDepvBNkhUg/zXuP/1xhcU01VxeSSw/4nlUTFXf+0s5gnFAsF71VPj15yBz5a9 0m43yF3xTQx80ICLoXACJet4Kw1VV8Ou6qK2q+c5osB5Nyup+Z/YHUB1pDuPQ40/sL7NJ1 COFXxg3tvwF7hMdIN9jeYXbk8Yths6oBryBJyunX/Kst/OkGTWWbRF8Ik7TdtYv5UMv9oL nZiXUwJDxeVGxKBMVRo/lkfmGdbA5bIsl/tRE6gS0Iq5JZ/r7d3X3Tlqbcvz0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by peterj: URL: https://cgit.FreeBSD.org/src/commit/?id=a65f526addafccfe55aa3dab3d8c912eb8f05b4f commit a65f526addafccfe55aa3dab3d8c912eb8f05b4f Author: Peter Jeremy AuthorDate: 2022-01-29 10:15:51 +0000 Commit: Peter Jeremy CommitDate: 2022-03-05 02:52:24 +0000 geom_gate: Distinguish between classes of errors The geom_gate API provides 2 distinct paths for exchanging error details between the kernel and the userland client: Including an error code in the g_gate_ctl_io structure passed in the ioctl(2) call or having the ioctl(2) call return -1 with an error code in errno. The latter reflects errors in the ioctl(2) call itself whilst the former reflects errors within the geom_gate instance. The G_GATE_CMD_START ioctl blocks waiting for an I/O request to be directed to the geom_gate instance and the wait can fail (necessitating an error return) if the geom_gate instance is destroyed or if the msleep(9) fails. The code previously treated both error cases indentically: Returning ECANCELED as a geom_gate instance error (which the ggatec treats as a fatal error). Whilst this is the correct behaviour if the geom_gate instance is destroyed, a msleep(9) failure is unrelated to the geom_gate instance itself and should be reported as an ioctl(2) "failure". The distinction is important because msleep(9) can return ERESTART, which means the system call should be retried (and this will occur automatically as part of the generic syscall return processing). This change alters the msleep(9) handling to directly return the error code from msleep(9), which ensures ERESTART is correctly handled, rather than being treated as a fatal error. Reviewed by: Johannes Totz Differential Revision: https://reviews.freebsd.org/D33996 (cherry picked from commit afcd1210246bebd8ed9bdaf31bd5218630af4cdc) --- sys/geom/gate/g_gate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index 14ec0cc2e9d2..4e98d78c1e43 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -861,11 +861,10 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa mtx_unlock(&sc->sc_queue_mtx); goto start_end; } - if (msleep(sc, &sc->sc_queue_mtx, - PPAUSE | PDROP | PCATCH, "ggwait", 0) != 0) { - ggio->gctl_error = ECANCELED; + error = msleep(sc, &sc->sc_queue_mtx, + PPAUSE | PDROP | PCATCH, "ggwait", 0); + if (error != 0) goto start_end; - } } ggio->gctl_cmd = bp->bio_cmd; if (bp->bio_cmd == BIO_WRITE &&