From nobody Fri Oct 29 23:58:47 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8B48D181E785; Fri, 29 Oct 2021 23:58:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgzsq2q3sz4Vlq; Fri, 29 Oct 2021 23:58:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9714520246; Fri, 29 Oct 2021 23:58:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TNwlfZ004230; Fri, 29 Oct 2021 23:58:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TNwlx4004229; Fri, 29 Oct 2021 23:58:47 GMT (envelope-from git) Date: Fri, 29 Oct 2021 23:58:47 GMT Message-Id: <202110292358.19TNwlx4004229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: c1d6b0cdca19 - stable/13 - iscsi: Add a helper routine to abort a data-out task. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c1d6b0cdca19a3045b24c0437b447092c3b45118 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c1d6b0cdca19a3045b24c0437b447092c3b45118 commit c1d6b0cdca19a3045b24c0437b447092c3b45118 Author: John Baldwin AuthorDate: 2021-09-15 20:25:04 +0000 Commit: John Baldwin CommitDate: 2021-10-29 23:38:42 +0000 iscsi: Add a helper routine to abort a data-out task. Reviewed by: mav Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D31891 (cherry picked from commit 529364b032d774bff4dc818ff23d20be482f9d99) --- sys/cam/ctl/ctl_frontend_iscsi.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 0cbe3bcefc73..ac94a786a701 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1108,11 +1108,30 @@ cfiscsi_data_wait_free(struct cfiscsi_session *cs, uma_zfree(cfiscsi_data_wait_zone, cdw); } +static void +cfiscsi_data_wait_abort(struct cfiscsi_session *cs, + struct cfiscsi_data_wait *cdw, int status) +{ + union ctl_io *cdw_io; + + /* + * Set nonzero port status; this prevents backends from + * assuming that the data transfer actually succeeded + * and writing uninitialized data to disk. + */ + MPASS(status != 0); + cdw_io = cdw->cdw_ctl_io; + cdw_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; + cdw_io->scsiio.io_hdr.port_status = status; + cfiscsi_data_wait_free(cs, cdw); + ctl_datamove_done(cdw_io, false); +} + static void cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) { struct cfiscsi_data_wait *cdw; - union ctl_io *io, *cdw_io; + union ctl_io *io; int error, last, wait; if (cs->cs_target == NULL) @@ -1139,16 +1158,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) while ((cdw = TAILQ_FIRST(&cs->cs_waiting_for_data_out)) != NULL) { TAILQ_REMOVE(&cs->cs_waiting_for_data_out, cdw, cdw_next); CFISCSI_SESSION_UNLOCK(cs); - /* - * Set nonzero port status; this prevents backends from - * assuming that the data transfer actually succeeded - * and writing uninitialized data to disk. - */ - cdw_io = cdw->cdw_ctl_io; - cdw_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; - cdw_io->scsiio.io_hdr.port_status = 42; - cfiscsi_data_wait_free(cs, cdw); - ctl_datamove_done(cdw_io, false); + cfiscsi_data_wait_abort(cs, cdw, 42); CFISCSI_SESSION_LOCK(cs); } CFISCSI_SESSION_UNLOCK(cs); @@ -2931,7 +2941,6 @@ cfiscsi_task_management_done(union ctl_io *io) struct cfiscsi_data_wait *cdw, *tmpcdw; struct cfiscsi_session *cs, *tcs; struct cfiscsi_softc *softc; - union ctl_io *cdw_io; int cold_reset = 0; request = PRIV_REQUEST(io); @@ -2965,11 +2974,7 @@ cfiscsi_task_management_done(union ctl_io *io) #endif TAILQ_REMOVE(&cs->cs_waiting_for_data_out, cdw, cdw_next); - cdw_io = cdw->cdw_ctl_io; - cdw_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; - cdw_io->scsiio.io_hdr.port_status = 43; - cfiscsi_data_wait_free(cs, cdw); - ctl_datamove_done(cdw_io, false); + cfiscsi_data_wait_abort(cs, cdw, 43); } CFISCSI_SESSION_UNLOCK(cs); }