summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-03-06 06:41:06 +0000
committermav <mav@FreeBSD.org>2017-03-06 06:41:06 +0000
commit76bde87ec2dbb16674040ab93f518c631df8388b (patch)
tree4972c483b8d00203c7b31d3fdb0206014ebcdadf /sys/cam
parent7bda0961bd1ee092c53a0b33de9d5135a33530f3 (diff)
downloadFreeBSD-src-76bde87ec2dbb16674040ab93f518c631df8388b.zip
FreeBSD-src-76bde87ec2dbb16674040ab93f518c631df8388b.tar.gz
MFC r314387: Make ctl_queue_sense() not sleep.
It may be called in non-sleepable frontend context.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 7f3fd72..ee8dee2 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -13142,21 +13142,15 @@ ctl_queue_sense(union ctl_io *io)
initidx = ctl_get_initindex(&io->io_hdr.nexus);
p = initidx / CTL_MAX_INIT_PER_PORT;
- if ((ps = lun->pending_sense[p]) == NULL) {
- mtx_unlock(&lun->lun_lock);
- ps = malloc(sizeof(*ps) * CTL_MAX_INIT_PER_PORT, M_CTL,
- M_WAITOK | M_ZERO);
- mtx_lock(&lun->lun_lock);
- if (lun->pending_sense[p] == NULL) {
- lun->pending_sense[p] = ps;
- } else {
- free(ps, M_CTL);
- ps = lun->pending_sense[p];
- }
+ if (lun->pending_sense[p] == NULL) {
+ lun->pending_sense[p] = malloc(sizeof(*ps) * CTL_MAX_INIT_PER_PORT,
+ M_CTL, M_NOWAIT | M_ZERO);
+ }
+ if ((ps = lun->pending_sense[p]) != NULL) {
+ ps += initidx % CTL_MAX_INIT_PER_PORT;
+ memset(ps, 0, sizeof(*ps));
+ memcpy(ps, &io->scsiio.sense_data, io->scsiio.sense_len);
}
- ps += initidx % CTL_MAX_INIT_PER_PORT;
- memset(ps, 0, sizeof(*ps));
- memcpy(ps, &io->scsiio.sense_data, io->scsiio.sense_len);
mtx_unlock(&lun->lun_lock);
bailout:
OpenPOWER on IntegriCloud