From nobody Fri May 10 20:45:31 2024 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 4VbgrC3m0Kz5KPVP; Fri, 10 May 2024 20:45:31 +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 4VbgrC32V6z4XMT; Fri, 10 May 2024 20:45:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715373931; 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=Vy0o30OZcc05qiW0QA/SlN3PyCZ1OMursndM3Ub27Vg=; b=PnRCqnTb0naie9kakcspQfi/JOFOcpChl5kmYEG9gd1EPCSFr/bv2n+i9VK7vUvwuTvUNp 91tUIh+jF+SbCyZpwAaDK55vMISaNEKIyWW+HYjMOfbOjbkrY0NpnpEdzIBZQr3aZ7jA7B TuUfbjNPqR3A0YWv5eqUhhzAm5hd25BV2urKLjX+mFZSne3RiQjhKFIA2UxRjNUT4YmXMb 4yWWzPHW5dty2xufQ3XPSAKoaOl+jt0RDIyeI2rV4+SR0XZMpN7grHSCy+enuKbhbd0gZ3 OtE3AJIeI6B9Ey1CkTL4O4DTyu7QARKGuXhAAm0qbytdu32urfPYBLb79jCoGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715373931; a=rsa-sha256; cv=none; b=rcU9ptjWkV31ihLT/WqHN8gG7HWCuEyAsbcEjccxtA05meRfLmjjXqU6s593XJFEDpgSv3 XZp1wAZtE06avgtm4MjrKtlHySGlZVBnvHXElJkgZAeRxkOsgXby/ZyuVQyHy6w6lqO/45 2U7rZNlUszHPsQR7Vd8lOswwYBWqo2/UXWEw687hNk3jSp2wNeKjJhoeFRPjOuWxym9dm2 xP/8QjRr2/0WJu+xMga32YD/8tXUUf77eYa82AbBrBTMT8fIPAo9rl+UHe6jdgMQ49wQCh /bcXVew4iNwMJgr5f2bfj5wAH93DAZMlChKtVnjKMIU47nF2VCGlIqNtxqn1Hw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715373931; 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=Vy0o30OZcc05qiW0QA/SlN3PyCZ1OMursndM3Ub27Vg=; b=HnOOXLLLkm7HVnlgLx9FWaQYoBwQY3/OrQWz9XRRsR0b8Upz64qRaBSVo5FmN+i4Y8oMmk Y3SbmRCllpegaZgiS4M6cBJulLgbTfofhwTiGgNGnubBak6r97qOuYyjAVLFnwNddTD1bu JBUBNCmep9QZjycaP/gWzScjNTgw1F6bbuTaH1+p/IHLyBjVFhvBF5EcPaptG7qrZrby1Z 81uvZgYrdzgNZLgdr61DnmWf3VRgNZlNMLIPXd2BcPHw48HdqS1hTV9ritxqdhEZDtqF58 UDuBQpoLDLuLM3fvUuRXpEVVkF5fzLm/f5LZMGAThdwfMCGG7nowJysF9LsGlg== 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 4VbgrC2dkrzsnt; Fri, 10 May 2024 20:45:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44AKjVpB030799; Fri, 10 May 2024 20:45:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44AKjVOK030797; Fri, 10 May 2024 20:45:31 GMT (envelope-from git) Date: Fri, 10 May 2024 20:45:31 GMT Message-Id: <202405102045.44AKjVOK030797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: f75764fea34a - main - md: Merge two switch statements in mdstart_vnode 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f75764fea34afe59f2db338b3e973eba626243ee Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f75764fea34afe59f2db338b3e973eba626243ee commit f75764fea34afe59f2db338b3e973eba626243ee Author: John Baldwin AuthorDate: 2024-05-10 20:43:23 +0000 Commit: John Baldwin CommitDate: 2024-05-10 20:43:23 +0000 md: Merge two switch statements in mdstart_vnode While here, use bp->bio_cmd instead of auio.uio_rw to drive read vs write behavior. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45155 --- sys/dev/md/md.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 241517898ad4..267554031f23 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -887,23 +887,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) int ma_offs, npages; bool mapped; - switch (bp->bio_cmd) { - case BIO_READ: - auio.uio_rw = UIO_READ; - break; - case BIO_WRITE: - auio.uio_rw = UIO_WRITE; - break; - case BIO_FLUSH: - break; - case BIO_DELETE: - if (sc->candelete) - break; - /* FALLTHROUGH */ - default: - return (EOPNOTSUPP); - } - td = curthread; vp = sc->vnode; piov = NULL; @@ -920,7 +903,14 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) * still valid. */ - if (bp->bio_cmd == BIO_FLUSH) { + switch (bp->bio_cmd) { + case BIO_READ: + auio.uio_rw = UIO_READ; + break; + case BIO_WRITE: + auio.uio_rw = UIO_WRITE; + break; + case BIO_FLUSH: do { (void)vn_start_write(vp, &mp, V_WAIT); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); @@ -929,11 +919,17 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) vn_finished_write(mp); } while (error == ERELOOKUP); return (error); - } else if (bp->bio_cmd == BIO_DELETE) { - error = vn_deallocate(vp, &off, &len, 0, - sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred, NOCRED); - bp->bio_resid = len; - return (error); + case BIO_DELETE: + if (sc->candelete) { + error = vn_deallocate(vp, &off, &len, 0, + sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred, + NOCRED); + bp->bio_resid = len; + return (error); + } + /* FALLTHROUGH */ + default: + return (EOPNOTSUPP); } auio.uio_offset = (vm_ooffset_t)bp->bio_offset; @@ -981,7 +977,7 @@ unmapped_step: auio.uio_iovcnt = 1; } iostart = auio.uio_offset; - if (auio.uio_rw == UIO_READ) { + if (bp->bio_cmd == BIO_READ) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_READ(vp, &auio, 0, sc->cred); VOP_UNLOCK(vp);