Date: Tue, 28 Feb 2017 11:56:17 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314387 - head/sys/cam/ctl Message-ID: <201702281156.v1SBuHhi021647@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Feb 28 11:56:17 2017 New Revision: 314387 URL: https://svnweb.freebsd.org/changeset/base/314387 Log: Make ctl_queue_sense() not sleep. It may be called in non-sleepable frontend context. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Tue Feb 28 11:42:04 2017 (r314386) +++ head/sys/cam/ctl/ctl.c Tue Feb 28 11:56:17 2017 (r314387) @@ -13146,21 +13146,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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702281156.v1SBuHhi021647>