Date: Mon, 6 Mar 2017 06:41:06 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r314761 - stable/10/sys/cam/ctl Message-ID: <201703060641.v266f6Bf001016@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Mar 6 06:41:06 2017 New Revision: 314761 URL: https://svnweb.freebsd.org/changeset/base/314761 Log: MFC r314387: Make ctl_queue_sense() not sleep. It may be called in non-sleepable frontend context. Modified: stable/10/sys/cam/ctl/ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Mon Mar 6 06:40:33 2017 (r314760) +++ stable/10/sys/cam/ctl/ctl.c Mon Mar 6 06:41:06 2017 (r314761) @@ -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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703060641.v266f6Bf001016>