From owner-svn-src-all@freebsd.org Sun Mar 10 23:05:39 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9A63E15459DC; Sun, 10 Mar 2019 23:05:39 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32FAC6BD11; Sun, 10 Mar 2019 23:05:39 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 215EF1FFF; Sun, 10 Mar 2019 23:05:39 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2AN5daQ017776; Sun, 10 Mar 2019 23:05:39 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2AN5c4s017775; Sun, 10 Mar 2019 23:05:38 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201903102305.x2AN5c4s017775@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 10 Mar 2019 23:05:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344987 - head/sys/dev/smartpqi X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/sys/dev/smartpqi X-SVN-Commit-Revision: 344987 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 32FAC6BD11 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 23:05:39 -0000 Author: trasz Date: Sun Mar 10 23:05:38 2019 New Revision: 344987 URL: https://svnweb.freebsd.org/changeset/base/344987 Log: Fix crash in low memory conditions. Usual backtrace looked like this: pqisrc_build_sgl() at pqisrc_build_sgl+0x8d/frame 0xfffffe009e8b7a00 pqisrc_build_raid_io() at pqisrc_build_raid_io+0x231/frame 0xfffffe009e8b7a40 pqisrc_build_send_io() at pqisrc_build_send_io+0x375/frame 0xfffffe009e8b7b00 pqi_request_map_helper() at pqi_request_map_helper+0x282/frame 0xfffffe009e8b7ba0 bus_dmamap_load_ccb() at bus_dmamap_load_ccb+0xd7/frame 0xfffffe009e8b7c00 pqi_map_request() at pqi_map_request+0x9b/frame 0xfffffe009e8b7c70 pqisrc_io_start() at pqisrc_io_start+0x55c/frame 0xfffffe009e8b7d50 smartpqi_cam_action() at smartpqi_cam_action+0xb8/frame 0xfffffe009e8b7de0 xpt_run_devq() at xpt_run_devq+0x30a/frame 0xfffffe009e8b7e40 xpt_action_default() at xpt_action_default+0x94b/frame 0xfffffe009e8b7e90 dastart() at dastart+0x33b/frame 0xfffffe009e8b7ee0 xpt_run_allocq() at xpt_run_allocq+0x1a2/frame 0xfffffe009e8b7f30 dastrategy() at dastrategy+0x71/frame 0xfffffe009e8b7f60 g_disk_start() at g_disk_start+0x351/frame 0xfffffe009e8b7fc0 g_io_request() at g_io_request+0x3cf/frame 0xfffffe009e8b8010 g_part_start() at g_part_start+0x120/frame 0xfffffe009e8b8090 g_io_request() at g_io_request+0x3cf/frame 0xfffffe009e8b80e0 zio_vdev_io_start() at zio_vdev_io_start+0x4b2/frame 0xfffffe009e8b8140 zio_execute() at zio_execute+0x17c/frame 0xfffffe009e8b8180 zio_nowait() at zio_nowait+0xc4/frame 0xfffffe009e8b81b0 vdev_queue_io_done() at vdev_queue_io_done+0x138/frame 0xfffffe009e8b81f0 zio_vdev_io_done() at zio_vdev_io_done+0x151/frame 0xfffffe009e8b8220 zio_execute() at zio_execute+0x17c/frame 0xfffffe009e8b8260 taskqueue_run_locked() at taskqueue_run_locked+0x10c/frame 0xfffffe009e8b82c0 taskqueue_thread_loop() at taskqueue_thread_loop+0x88/frame 0xfffffe009e8b82f0 fork_exit() at fork_exit+0x84/frame 0xfffffe009e8b8330 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe009e8b8330 Reviewed by: deepak.ukey_microsemi.com, sbruno MFC after: 2 weeks Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D19470 Modified: head/sys/dev/smartpqi/smartpqi_cam.c Modified: head/sys/dev/smartpqi/smartpqi_cam.c ============================================================================== --- head/sys/dev/smartpqi/smartpqi_cam.c Sun Mar 10 21:43:13 2019 (r344986) +++ head/sys/dev/smartpqi/smartpqi_cam.c Sun Mar 10 23:05:38 2019 (r344987) @@ -483,13 +483,21 @@ pqi_request_map_helper(void *arg, bus_dma_segment_t *s } rcb->sgt = os_mem_alloc(softs, nseg * sizeof(rcb_t)); + if (rcb->sgt == NULL) { + xpt_freeze_simq(softs->os_specific.sim, 1); + rcb->cm_ccb->ccb_h.status |= (CAM_REQUEUE_REQ| + CAM_RELEASE_SIMQ); + DBG_ERR_BTL(rcb->dvp, "os_mem_alloc() failed; nseg = %d\n", nseg); + pqi_unmap_request(rcb); + xpt_done((union ccb *)rcb->cm_ccb); + return; + } + rcb->nseg = nseg; - if (rcb->sgt != NULL) { - for (int i = 0; i < nseg; i++) { - rcb->sgt[i].addr = segs[i].ds_addr; - rcb->sgt[i].len = segs[i].ds_len; - rcb->sgt[i].flags = 0; - } + for (int i = 0; i < nseg; i++) { + rcb->sgt[i].addr = segs[i].ds_addr; + rcb->sgt[i].len = segs[i].ds_len; + rcb->sgt[i].flags = 0; } if (rcb->data_dir == SOP_DATA_DIR_FROM_DEVICE)