Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3343993ioa; Tue, 26 Apr 2022 01:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxOzeVAw8iEMvA7QWIJfHrKOy+WbINZ6qDqVYTJv6Tg2YngR/fDugoA0cLGww7QaneGY6b X-Received: by 2002:a17:907:7255:b0:6f3:9044:5fb0 with SMTP id ds21-20020a170907725500b006f390445fb0mr9728204ejc.98.1650962335808; Tue, 26 Apr 2022 01:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650962335; cv=none; d=google.com; s=arc-20160816; b=PaXhOTOZgNb502RzNAzkPGWsuWniFfNwpaxjxVOG6Km6XKPllcp9ZZ7mMI8uAwKsIK NE6vit0gfYfSpmyGYPe/o0sAE/zpViVwvfPYL8u7QzXjfraUg0OPl0iPReqsnxzCttlq lrzMgDNMpil43fctZj54kUEbeehuv+Cbm3AjhaQfgn1UYfngk5SXYT6W3m14n9c9TbPA kTNJTRv74rZGsVT8Q/cMw4HpU8Zp37isZb5Y3HlEyH1y51LR5rFAXkbZkeh3tL1YXhs6 0Io83GCQXDAWYY5bD6XV5Dk7ksEUn0QvGY3x9ajUgpKLQG/LW+kBslh7sVA/8lP/Nuic 9nfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=93yQFLlMOww55A/5KzWQm4yvkqyGKyPo/Q1g8zznJKg=; b=Yuh5CCv3udH0y8Q7w1ARIU0cc985mnNDfzSR8bzC0KyTNg2vk6TvKkgpy9m+caShba 0CCwXAGMMC0C8Si29ogCWO1Gf+RIyoER2aCK1qauxWXYP93CHa52in/jiNacY0YrGB9s 0jedxLkryn4naqkq6Kyjij3xXk4RI9sC1lzA0rwyzZEOjEdraOLb6DsDMIkcVEjLuqvy wnPDksu+68TkSBAdjZ8PMLqkynbAoUF7PXKldXLoeKjR+88vQy+EW+KJh/42fZ0jRpzo mro9wLZDh6t2KUtPWfDjpPudb9Cy1xrbS/9YuZZlRfrEsxlZDYH/qoahdgScmtxjyRWy bg2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me2-20020a170906aec200b006e7e6c83ea0si15151027ejb.157.2022.04.26.01.38.32; Tue, 26 Apr 2022 01:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241622AbiDYNIO (ORCPT + 99 others); Mon, 25 Apr 2022 09:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241741AbiDYNIB (ORCPT ); Mon, 25 Apr 2022 09:08:01 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E72317A8C; Mon, 25 Apr 2022 06:04:56 -0700 (PDT) Received: from fraeml736-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Kn4rT6BqDz67PFg; Mon, 25 Apr 2022 21:00:57 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml736-chm.china.huawei.com (10.206.15.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Apr 2022 15:04:54 +0200 Received: from [10.47.92.213] (10.47.92.213) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.24; Mon, 25 Apr 2022 14:04:53 +0100 Message-ID: <1bb53912-c5c3-7690-e82f-cf356ca87404@huawei.com> Date: Mon, 25 Apr 2022 14:04:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template To: Krzysztof Kozlowski , Christoph Hellwig CC: "Ewan D. Milne" , "James E.J. Bottomley" , "Martin K. Petersen" , "Alim Akhtar" , Avri Altman , "Doug Gilbert" , , , References: <20220408103027.311624-1-krzysztof.kozlowski@linaro.org> <2a88a992-641a-b3ff-fe39-7a61fff87cb6@huawei.com> <4c3be5b6-50ef-9e9a-6cee-9642df943342@linaro.org> <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com> <24bfb681-faec-3567-3089-9cd5ee182710@linaro.org> From: John Garry In-Reply-To: <24bfb681-faec-3567-3089-9cd5ee182710@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.92.213] X-ClientProxiedBy: lhreml702-chm.china.huawei.com (10.201.108.51) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/04/2022 10:22, Krzysztof Kozlowski wrote: > On 25/04/2022 10:58, John Garry wrote: >> On 20/04/2022 08:03, Christoph Hellwig wrote: >>>> The standard flow is: >>>> >>>> shost = scsi_host_alloc(sht, ) >>>> >>>> // modify shost, like >>>> shost->cmd_per_lun = 5; >>>> >>>> scsi_add_host(shost) >>>> >>>> Is there some reason for which those two drivers can't follow that? >>> I think they should. Method tables should not be mutable data. >>> . >> >> Hi Krzysztof, >> >> Do you have any interest in going further with your work and trying to >> change all SCSI driver instances of scsi_host_template to be const? I am >> not sure if it has been attempted before... > > I can work on this, but what about the SCSI core modifying the template? I hope that this isn't a can of worms... > For example scsi_proc_hostdir_rm(): 'present' and 'proc_dir' members. > Where should they be stored? Should they be moved to the Scsi_Host? > I don't think scsi_Host is appropriate as this is per-scsi host template, unless you see a way to do it that way. Alternatively we could keep a separate list of registered sht, like this: struct sht_proc_dir { int cnt; struct list_head list; struct proc_dir_entry *proc_dir; struct scsi_host_template *sht; }; static LIST_HEAD(sht_proc_dir_list); void scsi_proc_hostdir_add(struct scsi_host_template *sht) { struct sht_proc_dir *dir; if (!sht->show_info) return; mutex_lock(&global_host_template_mutex); list_for_each_entry(dir, &sht_proc_dir_list, list) { if (dir->sht == sht) { dir->cnt++; goto out; } } dir = kzalloc(sizeof(*dir), GFP_KERNEL); if (!dir) goto out; dir->proc_dir = proc_mkdir(sht->proc_name, proc_scsi); if (!dir->proc_dir) { printk(KERN_ERR "%s: proc_mkdir failed for %s\n", __func__, sht->proc_name); kfree(dir); goto out; } dir->cnt++; list_add_tail(&dir->list, &sht_proc_dir_list); out: mutex_unlock(&global_host_template_mutex); } and so on.. --->8--- Thanks, John