Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2018 23:14:46 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328452 - head/sys/cam/nvme
Message-ID:  <201801262314.w0QNEkpP066084@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Jan 26 23:14:46 2018
New Revision: 328452
URL: https://svnweb.freebsd.org/changeset/base/328452

Log:
  Fix a sleepable malloc in ndastart. We shouldn't be sleeping
  here. Return ENOMEM when we can't malloc a buffer for the DSM
  TRIM. This should fix the WITNESS warnings similar to the following:
  
  uma_zalloc_arg: zone "16" with the following non-sleepable locks held:
  exclusive sleep mutex CAM device lock (CAM device lock) r = 0 (0xfffff800080c34d0) locked @ /usr/src/sys/cam/nvme/nvme_da.c:351
  
  Reviewed by: scottl@
  Sponsored by: Netflix

Modified:
  head/sys/cam/nvme/nvme_da.c

Modified: head/sys/cam/nvme/nvme_da.c
==============================================================================
--- head/sys/cam/nvme/nvme_da.c	Fri Jan 26 22:23:24 2018	(r328451)
+++ head/sys/cam/nvme/nvme_da.c	Fri Jan 26 23:14:46 2018	(r328452)
@@ -897,7 +897,13 @@ ndastart(struct cam_periph *periph, union ccb *start_c
 			struct nvme_dsm_range *dsm_range;
 
 			dsm_range =
-			    malloc(sizeof(*dsm_range), M_NVMEDA, M_ZERO | M_WAITOK);
+			    malloc(sizeof(*dsm_range), M_NVMEDA, M_ZERO | M_NOWAIT);
+			if (dsm_range == NULL) {
+				biofinish(bp, NULL, ENOMEM);
+				xpt_release_ccb(start_ccb);
+				ndaschedule(periph);
+				return;
+			}
 			dsm_range->length =
 			    bp->bio_bcount / softc->disk->d_sectorsize;
 			dsm_range->starting_lba =



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801262314.w0QNEkpP066084>