From nobody Fri May 03 00:15:52 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 4VVrtd32CDz5KJyX; Fri, 3 May 2024 00:15:53 +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 4VVrtd0gMBz4QgT; Fri, 3 May 2024 00:15:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695353; 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=tKOPvzZp+rSrs19lz8i74SrUrYgcuKZx2tWbm6QUeXM=; b=AT8rwkZPlMFrSpwbmolUIws0cKIVHUB8D82yfcNGwJDjRmHaGzDr/89JmQ9mmwde6Qyr2a +rYWO05Z6faavNdBTyjOvLrLUGDFjX+ykom2K2zVBJ1xHF+ELujBe0+njnT80/ihXDnlM6 LGwQW1x5hup2s8EJcWyZWo5fMrfJLfi8MzE6GDpswIDS6yJJx4KuJxloxR8vdp2yEEJiXs ffYL3P+jVKDq+U3TAofDTOKFs18JWKnjonMmSywedJrUjah5hqvWdEKueEvrPNl4+PdzB6 WnwngshJFI1lE2H/dLVIUWdb7uMTU0l93azp/MIAZiE/+qniFi2sS748cpHSMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714695353; a=rsa-sha256; cv=none; b=uSybTH1y0JDSE2l7Jlu0ChqeK0OcgvFQSRY2yWF6xqPugvsZdt7xjVHi4w39qSdd6JC341 WQo7Y/Zg7zLHtgKqHHy9QfbVQuzyN4pU75OPkvaCsJJMb1YnCMdlFLiuFvVHDKF7J1uUML fJrmSmN50VTNLnxXCeVRjGjGRr6eGfXQbU86Mi9ohm7FLoNFuMxdpOE35cPqpOGxqR380z 0quB6c//Em+nbwnLyxMO+sVJGNmWHAFChfCpudWqVXssQrW1eobKEX+71Sp1KI195ZMNTJ ZceRObO3nGJ3ByuG9Gv2juaW1RNNuQB96NZV/BG+Lb60ob6nq0WZCEwxkUfW9w== 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=1714695353; 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=tKOPvzZp+rSrs19lz8i74SrUrYgcuKZx2tWbm6QUeXM=; b=YMf91u/VPVPAr05I/k98l5O7JNiQYCpCk0oDkpe+lKXLC/dU5AfWBySrmiXkGek4SgP029 FU+07nzpVMPrOI3BF2DlRJH4PsydQrSPbv8TDCi5ZcaJ1xz8aUpOYKhFHnEUuan40STqh9 +czsXGdJYZxnEdTo4Ub9BQOJCFFlFjuAk33nE+hFd9nfQT0Q9eclzViuPUTvLPEgRs69Bb +rw7ZvIZe9cfOu9xrxtuX+8OC1bJaoStm6r05IsYd58QX4OXVKdVTSj5VRgDSxzk7lgm3a DYkVy3ArJkoXe3VGgiSSMKqA3Pkn8JYIXoda5CsdnfYV6FrIcPdvTfo0P9n9jQ== 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 4VVrtd06yNzNnJ; Fri, 3 May 2024 00:15:53 +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 4430Fqbb079359; Fri, 3 May 2024 00:15:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4430FqFn079356; Fri, 3 May 2024 00:15:52 GMT (envelope-from git) Date: Fri, 3 May 2024 00:15:52 GMT Message-Id: <202405030015.4430FqFn079356@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: ac7a514e20f3 - main - ctl: Add CTL_IO_ASSERT wrapper macro 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: ac7a514e20f394ffed0126c0c356aa9107821880 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ac7a514e20f394ffed0126c0c356aa9107821880 commit ac7a514e20f394ffed0126c0c356aa9107821880 Author: John Baldwin AuthorDate: 2024-05-02 23:30:44 +0000 Commit: John Baldwin CommitDate: 2024-05-02 23:30:44 +0000 ctl: Add CTL_IO_ASSERT wrapper macro Currently, this pattern is commonly used to assert that a union ctl_io is a SCSI request. In the future it will be used to assert other types. Suggested by: imp Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44844 --- sys/cam/ctl/ctl.c | 12 ++++-------- sys/cam/ctl/ctl_backend_block.c | 3 +-- sys/cam/ctl/ctl_io.h | 15 +++++++++++++++ sys/cam/ctl/scsi_ctl.c | 3 +-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 6951ed6b229a..0a9bb526109a 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -4923,8 +4923,7 @@ ctl_config_move_done(union ctl_io *io, bool samethr) int retval; CTL_DEBUG_PRINT(("ctl_config_move_done\n")); - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); if (ctl_debug & CTL_DEBUG_CDB_DATA) ctl_data_print(io); @@ -10560,8 +10559,7 @@ static int ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint64_t *len) { - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); switch (io->scsiio.cdb[0]) { case COMPARE_AND_WRITE: { @@ -10741,8 +10739,7 @@ ctl_extent_check_unmap(union ctl_io *io, uint64_t lba2, uint64_t len2) uint64_t lba; uint32_t len; - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); /* If not UNMAP -- go other way. */ if (io->scsiio.cdb[0] != UNMAP) @@ -12323,8 +12320,7 @@ ctl_datamove_done_process(union ctl_io *io) struct bintime cur_bt; #endif - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); #ifdef CTL_TIME_IO getbinuptime(&cur_bt); diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 7381202e2c54..56bc38cba07e 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -1819,8 +1819,7 @@ ctl_be_block_submit(union ctl_io *io) be_lun = (struct ctl_be_block_lun *)CTL_BACKEND_LUN(io); - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); PRIV(io)->len = 0; diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h index aa7a9c35c876..62ac05713b47 100644 --- a/sys/cam/ctl/ctl_io.h +++ b/sys/cam/ctl/ctl_io.h @@ -592,6 +592,21 @@ union ctl_io { }; #ifdef _KERNEL +#define _CTL_IO_ASSERT_1(io, _1) \ + KASSERT((io)->io_hdr.io_type == CTL_IO_##_1, \ + ("%s: unexpected I/O type %x", __func__, (io)->io_hdr.io_type)) + +#define _CTL_IO_ASSERT_2(io, _1, _2) \ + KASSERT((io)->io_hdr.io_type == CTL_IO_##_1 || \ + (io)->io_hdr.io_type == CTL_IO_##_2, \ + ("%s: unexpected I/O type %x", __func__, (io)->io_hdr.io_type)) + +#define _CTL_IO_ASSERT_MACRO(io, _1, _2, NAME, ...) \ + NAME + +#define CTL_IO_ASSERT(...) \ + _CTL_IO_ASSERT_MACRO(__VA_ARGS__, _CTL_IO_ASSERT_2, \ + _CTL_IO_ASSERT_1)(__VA_ARGS__) union ctl_io *ctl_alloc_io(void *pool_ref); union ctl_io *ctl_alloc_io_nowait(void *pool_ref); diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 93cb4d71b6a5..68f1cabf6d07 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -1908,8 +1908,7 @@ ctlfe_datamove(union ctl_io *io) struct cam_periph *periph; struct ctlfe_lun_softc *softc; - KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, - ("%s: unexpected I/O type %x", __func__, io->io_hdr.io_type)); + CTL_IO_ASSERT(io, SCSI); io->scsiio.ext_data_filled = 0; ccb = PRIV_CCB(io);