Change M_NOWAIT to M_INTWAIT or M_WAITOK. CAM does a mediocre job checking
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 12 Mar 2004 03:24:43 +0000 (03:24 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 12 Mar 2004 03:24:43 +0000 (03:24 +0000)
commit898d961b1dcce52a764fc65d826903eb80d47cd1
treebe922b047261fc0916c3c104586259d4673bb5c9
parent5d83ebde1cb839d7b20449607e0f4e05cc402420
Change M_NOWAIT to M_INTWAIT or M_WAITOK.  CAM does a mediocre job checking
for NULL returns from malloc() and even when it does it generally causes
the device operation to fail instead of retrying, resulting in unacceptable
behavior.  M_NOWAIT semantics allow NULL to be returned during normal system
operation.  This is especially true in DragonFly.

Also remove much of the code that previously checked for NULL.  By using
M_INTWAIT or M_WAITOK, malloc() will panic rather then return NULL.  Only
the addition of M_NULLOK allows a blocking malloc() to return NULL, and we
do not use that flag in CAM.

Add M_ZERO to a number of malloc()'s and remove subsequent bzero()'s, and
add M_ZERO to a few mallocs (primarily for the read capacity data structure)
that did not bother zeroing out the structure before.  While the data is
supposed to be overwritten read-capacity is often quite fragile due to the
SCSI simulation layer, so we do not take any chances.
17 files changed:
sys/bus/cam/cam_extend.c
sys/bus/cam/cam_periph.c
sys/bus/cam/cam_queue.c
sys/bus/cam/cam_sim.c
sys/bus/cam/cam_xpt.c
sys/bus/cam/scsi/scsi_cd.c
sys/bus/cam/scsi/scsi_ch.c
sys/bus/cam/scsi/scsi_da.c
sys/bus/cam/scsi/scsi_low.c
sys/bus/cam/scsi/scsi_pass.c
sys/bus/cam/scsi/scsi_pt.c
sys/bus/cam/scsi/scsi_sa.c
sys/bus/cam/scsi/scsi_ses.c
sys/bus/cam/scsi/scsi_targ_bh.c
sys/bus/cam/scsi/scsi_target.c
sys/bus/canbus/canbus.c
sys/bus/eisa/eisaconf.c