From patchwork Tue Jun 23 07:56:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 6659121 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03F27C05AC for ; Tue, 23 Jun 2015 07:56:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0919720610 for ; Tue, 23 Jun 2015 07:56:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 121622060E for ; Tue, 23 Jun 2015 07:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754137AbbFWH4R (ORCPT ); Tue, 23 Jun 2015 03:56:17 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:43458 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754242AbbFWH4N (ORCPT ); Tue, 23 Jun 2015 03:56:13 -0400 Received: from [192.168.1.65] (75-37-194-224.lightspeed.lsatca.sbcglobal.net [75.37.194.224]) (using SSLv3 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nab) by linux-iscsi.org (Postfix) with ESMTPSA id 8D96C22DA19; Tue, 23 Jun 2015 07:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1435045960; bh=K2lqpHpy4Y0ex5EL7zKi4TKO9yfzZcg KAhKw0hCDiKo=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To: References:Content-Type:Mime-Version:Content-Transfer-Encoding; b=eiu2G4SX+sDaiRhX8s4Q37oMkMRgMLLor89pjEyy5WdOMl1AixOhaBiR/SVDucGUY ysYEAFvrNnZBcsiAoFllPZzxJp+kOneYFi8vzjtxSbkZMQSk6aeXbLg5F8QCfpPqqtX jypPS8qfedIjgXVFWWmMaPRfk3eTrpXreUhAXss= Message-ID: <1435046172.7460.26.camel@haakon3.risingtidesystems.com> Subject: Re: [PATCH 6/6] target: Send UA when changing LUN inventory From: "Nicholas A. Bellinger" To: Christoph Hellwig Cc: Hannes Reinecke , Nic Bellinger , target-devel@vger.kernel.org, linux-scsi@vger.kernel.org Date: Tue, 23 Jun 2015 00:56:12 -0700 In-Reply-To: <20150619130733.GC7783@lst.de> References: <1434009689-112909-1-git-send-email-hare@suse.de> <1434009689-112909-7-git-send-email-hare@suse.de> <20150619130733.GC7783@lst.de> X-Mailer: Evolution 3.4.4-1 Mime-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2015-06-19 at 15:07 +0200, Christoph Hellwig wrote: > > + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) { > > + if (tmp == new) > > + continue; > > + core_scsi3_ua_allocate(tmp, 0x3F, > > + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); > > + } > > + rcu_read_unlock(); > > + > > > + rcu_read_lock(); > > + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) { > > + if (tmp == new) > > + continue; > > + core_scsi3_ua_allocate(tmp, 0x3F, > > + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); > > + } > > + rcu_read_unlock(); > > > + > > + rcu_read_lock(); > > + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) > > + core_scsi3_ua_allocate(tmp, 0x3F, > > + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); > > + rcu_read_unlock(); > > Please add a helper instead of duplicating this three times. Applying the following squashed commit: From 7c0d0d51d26497866d2951a35f1736fc765e4fcf Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 11 Jun 2015 10:01:29 +0200 Subject: [PATCH 68/76] target: Send UA when changing LUN inventory When changind the LUN inventory via core_enable_device_list_for_node() or core_disable_device_list_for_node() a REPORTED LUNS DATA HAS CHANGED UA should be send. (Convert to target_luns_data_has_changed helper usage - hch) Signed-off-by: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_device.c | 23 +++++++++++++++++++---- drivers/target/target_core_ua.h | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index b6df5b9..5244848 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -293,10 +293,22 @@ void target_pr_kref_release(struct kref *kref) complete(&deve->pr_comp); } -/* core_enable_device_list_for_node(): - * - * - */ +static void +target_luns_data_has_changed(struct se_node_acl *nacl, struct se_dev_entry *new, + bool skip_new) +{ + struct se_dev_entry *tmp; + + rcu_read_lock(); + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) { + if (skip_new && tmp == new) + continue; + core_scsi3_ua_allocate(tmp, 0x3F, + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); + } + rcu_read_unlock(); +} + int core_enable_device_list_for_node( struct se_lun *lun, struct se_lun_acl *lun_acl, @@ -360,6 +372,7 @@ int core_enable_device_list_for_node( kref_put(&orig->pr_kref, target_pr_kref_release); wait_for_completion(&orig->pr_comp); + target_luns_data_has_changed(nacl, new, true); kfree_rcu(orig, rcu_head); return 0; } @@ -373,6 +386,7 @@ int core_enable_device_list_for_node( list_add_tail(&new->lun_link, &lun->lun_deve_list); spin_unlock(&lun->lun_deve_lock); + target_luns_data_has_changed(nacl, new, true); return 0; } @@ -428,6 +442,7 @@ void core_disable_device_list_for_node( kfree_rcu(orig, rcu_head); core_scsi3_free_pr_reg_from_nacl(dev, nacl); + target_luns_data_has_changed(nacl, NULL, false); } /* core_clear_lun_from_tpg(): diff --git a/drivers/target/target_core_ua.h b/drivers/target/target_core_ua.h index 59278d6..bd6e78b 100644 --- a/drivers/target/target_core_ua.h +++ b/drivers/target/target_core_ua.h @@ -26,6 +26,7 @@ #define ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS 0x09 #define ASCQ_3FH_INQUIRY_DATA_HAS_CHANGED 0x03 +#define ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED 0x0E extern struct kmem_cache *se_ua_cache;