From nobody Sat Jan 29 10:17:14 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 4F2501981818; Sat, 29 Jan 2022 10:17:15 +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 4Jm9HH1pdxz3rFh; Sat, 29 Jan 2022 10:17:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643451435; 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=5APngXxBi9oBtcqkZEkwt2jxF9EszsJW+iid7hZvhLo=; b=MWDFGCX1hgQfWdqoB6lSkTYJPHsgT+EErhv0KO8usegXWi1lT/WNskjI1qz6ATQXTs14X8 odk56lgXQbuHBFGkdIsRQ3ukjb+2JI9irL9uJcoG0e9IaH8mWoM+Oxe5wHBYtiABsGXQpN 84GBIJCbt12Hl+5HiQiopOVchIZvpJk2pw1L7cWaWdufYkRQvzEvxAeaHNEuJUyjOnxjkN SM0MO0Ofamtu8hbtLY/ILrOmBmzaZsVqSmw3DNmEXVaqWidiIi2om67pFAENI8927Wm6XY V740ox02imqJWGOhxJfPKbz8TUC2+X5lCdH/M3n4YoIutlx7+le4ZbzdtofEyg== 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 1A97614094; Sat, 29 Jan 2022 10:17:15 +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 20TAHEHG064991; Sat, 29 Jan 2022 10:17:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20TAHEVL064990; Sat, 29 Jan 2022 10:17:14 GMT (envelope-from git) Date: Sat, 29 Jan 2022 10:17:14 GMT Message-Id: <202201291017.20TAHEVL064990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Jeremy Subject: git: afcd1210246b - main - 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/main X-Git-Reftype: branch X-Git-Commit: afcd1210246bebd8ed9bdaf31bd5218630af4cdc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643451435; 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=5APngXxBi9oBtcqkZEkwt2jxF9EszsJW+iid7hZvhLo=; b=bKgYeVkzZ5HToFbiHlhTxIJU40tmZr/a9OIVdmyVb4fKPEOTsS86hgX0uLpsuEt6C+KxXx 47LUGFdg0spr5ZH8iskdQ+pWPab0PNAlRDjJzwYQJ9dv7pxAUQUVGgEspdicQxuvdJBoJo Gztg9CNRUXQZanZ741kr91B0uFk5kDEoN1cCEO2C0iuIFRKqBZsuaqTcFoCXsV4hQp2lb/ ojbBbVv7e4E+707v0QdXg8NSOEqFvOcQiWDVC1Euucw2Q9pG80CYt+SVuwtcDVBQbCbgYQ jw8+Y3mBaI4q1emDv9qzskVkzwaOjXxD3x/lQCfszxwTR4Up1YnGFO07yoG7jA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643451435; a=rsa-sha256; cv=none; b=sbEz1JFcLhdBXYZoKm9UpXXmoYFGj8whm9As4+0iHeTjMb3Lnn+ENrfnV5LwQEmIiidoHR EVxd3L+PrHvmL1fdoZ8UybudIiUxJPWy8pMAfVrTjcdn16MNlbs+vasqYoCG0mznKAOmWK GujHBAZoCsjNe6MWe2pANRjmoxjA9LYyuKITPQZrs3HVtQxfOTU2ZlfbPPB4JQYONfApbv BoFxQW9y5l3sfDuFl/ru5l4Nm3Q5E2FjpsTYY3X03Nlj274P4jjZ/XWv9uYL4bKPtwJN34 GJ+AdHxw7F2IzYhINWkcRjWxZyTiiezkvatkY6zeyAmEie9AjsVvVphTeCIb3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by peterj: URL: https://cgit.FreeBSD.org/src/commit/?id=afcd1210246bebd8ed9bdaf31bd5218630af4cdc commit afcd1210246bebd8ed9bdaf31bd5218630af4cdc Author: Peter Jeremy AuthorDate: 2022-01-29 10:15:51 +0000 Commit: Peter Jeremy CommitDate: 2022-01-29 10:15:51 +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 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33996 --- 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 &&