From owner-svn-src-all@FreeBSD.ORG Sat Aug 2 19:51:11 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EED355D1; Sat, 2 Aug 2014 19:51:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC58426E1; Sat, 2 Aug 2014 19:51:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s72JpArp045743; Sat, 2 Aug 2014 19:51:10 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s72JpAMo045742; Sat, 2 Aug 2014 19:51:10 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201408021951.s72JpAMo045742@svn.freebsd.org> From: Alexander Motin Date: Sat, 2 Aug 2014 19:51:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269441 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 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: Sat, 02 Aug 2014 19:51:11 -0000 Author: mav Date: Sat Aug 2 19:51:10 2014 New Revision: 269441 URL: http://svnweb.freebsd.org/changeset/base/269441 Log: Add missing comparisons to make list IDs in EXTENDED COPY per-initiator, as they should be. Wrap it into a function to not duplicate the code. MFC after: 3 days Modified: head/sys/cam/ctl/ctl_tpc.c Modified: head/sys/cam/ctl/ctl_tpc.c ============================================================================== --- head/sys/cam/ctl/ctl_tpc.c Sat Aug 2 18:37:22 2014 (r269440) +++ head/sys/cam/ctl/ctl_tpc.c Sat Aug 2 19:51:10 2014 (r269441) @@ -327,6 +327,21 @@ ctl_receive_copy_operating_parameters(st return (retval); } +static struct tpc_list * +tpc_find_list(struct ctl_lun *lun, uint32_t list_id, uint32_t init_idx) +{ + struct tpc_list *list; + + mtx_assert(&lun->lun_lock, MA_OWNED); + TAILQ_FOREACH(list, &lun->tpc_lists, links) { + if ((list->flags & EC_LIST_ID_USAGE_MASK) != + EC_LIST_ID_USAGE_NONE && list->list_id == list_id && + list->init_idx == init_idx) + break; + } + return (list); +} + int ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio) { @@ -348,11 +363,8 @@ ctl_receive_copy_status_lid1(struct ctl_ list_id = cdb->list_identifier; mtx_lock(&lun->lun_lock); - TAILQ_FOREACH(list, &lun->tpc_lists, links) { - if ((list->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && list->list_id == list_id) - break; - } + list = tpc_find_list(lun, list_id, + ctl_get_resindex(&ctsio->io_hdr.nexus)); if (list == NULL) { mtx_unlock(&lun->lun_lock); ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, @@ -433,12 +445,9 @@ ctl_receive_copy_failure_details(struct list_id = cdb->list_identifier; mtx_lock(&lun->lun_lock); - TAILQ_FOREACH(list, &lun->tpc_lists, links) { - if (list->completed && (list->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && list->list_id == list_id) - break; - } - if (list == NULL) { + list = tpc_find_list(lun, list_id, + ctl_get_resindex(&ctsio->io_hdr.nexus)); + if (list == NULL || !list->completed) { mtx_unlock(&lun->lun_lock); ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, /*field*/ 2, /*bit_valid*/ 0, @@ -507,11 +516,8 @@ ctl_receive_copy_status_lid4(struct ctl_ list_id = scsi_4btoul(cdb->list_identifier); mtx_lock(&lun->lun_lock); - TAILQ_FOREACH(list, &lun->tpc_lists, links) { - if ((list->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && list->list_id == list_id) - break; - } + list = tpc_find_list(lun, list_id, + ctl_get_resindex(&ctsio->io_hdr.nexus)); if (list == NULL) { mtx_unlock(&lun->lun_lock); ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, @@ -596,11 +602,8 @@ ctl_copy_operation_abort(struct ctl_scsi list_id = scsi_4btoul(cdb->list_identifier); mtx_lock(&lun->lun_lock); - TAILQ_FOREACH(list, &lun->tpc_lists, links) { - if ((list->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && list->list_id == list_id) - break; - } + list = tpc_find_list(lun, list_id, + ctl_get_resindex(&ctsio->io_hdr.nexus)); if (list == NULL) { mtx_unlock(&lun->lun_lock); ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, @@ -1210,12 +1213,7 @@ ctl_extended_copy_lid1(struct ctl_scsiio list->lun = lun; mtx_lock(&lun->lun_lock); if ((list->flags & EC_LIST_ID_USAGE_MASK) != EC_LIST_ID_USAGE_NONE) { - TAILQ_FOREACH(tlist, &lun->tpc_lists, links) { - if ((tlist->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && - tlist->list_id == list->list_id) - break; - } + tlist = tpc_find_list(lun, list->list_id, list->init_idx); if (tlist != NULL && !tlist->completed) { mtx_unlock(&lun->lun_lock); free(list, M_CTL); @@ -1338,12 +1336,7 @@ ctl_extended_copy_lid4(struct ctl_scsiio list->lun = lun; mtx_lock(&lun->lun_lock); if ((list->flags & EC_LIST_ID_USAGE_MASK) != EC_LIST_ID_USAGE_NONE) { - TAILQ_FOREACH(tlist, &lun->tpc_lists, links) { - if ((tlist->flags & EC_LIST_ID_USAGE_MASK) != - EC_LIST_ID_USAGE_NONE && - tlist->list_id == list->list_id) - break; - } + tlist = tpc_find_list(lun, list->list_id, list->init_idx); if (tlist != NULL && !tlist->completed) { mtx_unlock(&lun->lun_lock); free(list, M_CTL);