mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +00:00
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
This commit is contained in:
parent
352cf4a64a
commit
ac7a514e20
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue