From patchwork Fri Nov 30 23:34:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 10707405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F77714E2 for ; Fri, 30 Nov 2018 23:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6280530133 for ; Fri, 30 Nov 2018 23:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5550D30327; Fri, 30 Nov 2018 23:34:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5860930133 for ; Fri, 30 Nov 2018 23:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbeLAKpj (ORCPT ); Sat, 1 Dec 2018 05:45:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:59524 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726789AbeLAKpi (ORCPT ); Sat, 1 Dec 2018 05:45:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 84E8CAD22; Fri, 30 Nov 2018 23:34:39 +0000 (UTC) From: David Disseldorp To: target-devel@vger.kernel.org Cc: bvanassche@acm.org, lduncan@suse.com, cvubrugier@fastmail.fm, Mike Christie , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, David Disseldorp Subject: [PATCH v5 5/5] target: perform t10_wwn ID initialisation in target_alloc_device() Date: Sat, 1 Dec 2018 00:34:23 +0100 Message-Id: <20181130233423.26556-6-ddiss@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20181130233423.26556-1-ddiss@suse.de> References: <20181130233423.26556-1-ddiss@suse.de> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Initialise the t10_wwn vendor, model and revision defaults when a device is allocated instead of when it's enabled. This ensures that custom vendor or model strings set prior to enablement are not later overwritten with default values. Signed-off-by: David Disseldorp --- drivers/target/target_core_device.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 5512871f50e4..6318d59a1564 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -810,6 +810,23 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) mutex_init(&xcopy_lun->lun_tg_pt_md_mutex); xcopy_lun->lun_tpg = &xcopy_pt_tpg; + /* + * Preload the initial INQUIRY const values if we are doing + * anything virtual (IBLOCK, FILEIO, RAMDISK), but not for TCM/pSCSI + * passthrough because this is being provided by the backend LLD. + */ + BUILD_BUG_ON(sizeof(dev->t10_wwn.vendor) != INQUIRY_VENDOR_LEN + 1); + BUILD_BUG_ON(sizeof(dev->t10_wwn.model) != INQUIRY_MODEL_LEN + 1); + BUILD_BUG_ON(sizeof(dev->t10_wwn.revision) != INQUIRY_REVISION_LEN + 1); + if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) { + strlcpy(dev->t10_wwn.vendor, "LIO-ORG", + sizeof(dev->t10_wwn.vendor)); + strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod, + sizeof(dev->t10_wwn.model)); + strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, + sizeof(dev->t10_wwn.revision)); + } + return dev; } @@ -984,23 +1001,6 @@ int target_configure_device(struct se_device *dev) */ INIT_WORK(&dev->qf_work_queue, target_qf_do_work); - /* - * Preload the initial INQUIRY const values if we are doing - * anything virtual (IBLOCK, FILEIO, RAMDISK), but not for TCM/pSCSI - * passthrough because this is being provided by the backend LLD. - */ - BUILD_BUG_ON(sizeof(dev->t10_wwn.vendor) != INQUIRY_VENDOR_LEN + 1); - BUILD_BUG_ON(sizeof(dev->t10_wwn.model) != INQUIRY_MODEL_LEN + 1); - BUILD_BUG_ON(sizeof(dev->t10_wwn.revision) != INQUIRY_REVISION_LEN + 1); - if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) { - strlcpy(dev->t10_wwn.vendor, "LIO-ORG", - sizeof(dev->t10_wwn.vendor)); - strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod, - sizeof(dev->t10_wwn.model)); - strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, - sizeof(dev->t10_wwn.revision)); - } - scsi_dump_inquiry(dev); spin_lock(&hba->device_lock);