Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28386828rwd; Tue, 4 Jul 2023 18:58:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XWjUjiqKFeY7qyibCKabmjv319ctmk+FcGbw1co6jV0bvOJxYJnqFmm2f0Ic2ZRqlsOk9 X-Received: by 2002:a9d:6948:0:b0:6b7:52ce:ff38 with SMTP id p8-20020a9d6948000000b006b752ceff38mr15865559oto.16.1688522301574; Tue, 04 Jul 2023 18:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688522301; cv=none; d=google.com; s=arc-20160816; b=tYpwfamtHVhWdC4OmbXeXIAuc1YjRKg6/NjY4ZwXLX1UMJSJVAwnwNbis6gzVpAEEQ g8eIz0BS41fsMVIOGHLdbw2eHdHLD2lbhFL2Rlyoic4wA+FLAZ+ygjhelTx/sx9Gkwp3 XH3hpBMKbJbycUREwLWobFR60fA4VXpBaqHykHKny+QO1mJHdacHYlctW+x0CNw1NY72 11TEZciEw/dbhB7tEGIAwCTUHvdHTZ1RzkE0J+dfQFb+uNghUFaU7m0Nr7q7csRuheBu +U22CPGBDJd6bDlZpB7Dtr6nBFzOnzSemG9Zf5czB/9rjtJafzfrvnug8tdVKIKppADK SBZQ== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=nqc3xBQJXWnGcMbHBFWFwVUatK02gQbsK5kPKQ1C7fY=; fh=PbzDjFENBkDrb20zl9pOXIXdIXlZSzMT2nJxfRqMkz0=; b=PK6Z0mnr2NlGdZDgMvP5Qk29VkK9BldODZqIfyJ50SyoYQg7kWPxl702/T+Pvu/dNY JUm54iV5OU26OeW6cgz2t/qETulMWrueKxLTEabVIappfGtIUT7dP19z1gp5ZdJ9YJJn VJcnPNb6m6DF1OgEjBTcr5A7oKtN4SfE6otNFjCUs+BGXUhwCVHkr7bRv3/PlhmlisSi rX8vDw2Z/uicXlaL3GU4p8sUxvElY4KbaRTND3L1LiF2GpggXnhWlKy0Vqo9FybEFLSn YuEvCs2uMBxhJjiapYAgc9TpcPCauPIOel5RhZaqZ7PFpv6rhHwQXxG4J9bqhh5vWY61 ithA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq8-20020a17090b380800b0026370caa5c5si581621pjb.75.2023.07.04.18.58.09; Tue, 04 Jul 2023 18:58:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbjGEBoC (ORCPT + 99 others); Tue, 4 Jul 2023 21:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbjGEBoB (ORCPT ); Tue, 4 Jul 2023 21:44:01 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B4310FC; Tue, 4 Jul 2023 18:43:59 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QwjB36JJCz4f3tPQ; Wed, 5 Jul 2023 09:43:55 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgD3rLDZyqRkooPrNA--.55099S3; Wed, 05 Jul 2023 09:43:55 +0800 (CST) Subject: Re: [PATCH] scsi/sg: don't grab scsi host module reference To: Marc Hartmayer , Yu Kuai Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, hch@lst.de, chaitanyak@nvidia.com, shinichiro.kawasaki@wdc.com, dgilbert@interlog.com, jejb@linux.ibm.com, martin.petersen@oracle.com, axboe@kernel.dk, Benjamin Block , "yukuai (C)" References: <20230621160111.1433521-1-yukuai1@huaweicloud.com> <87lefv622n.fsf@linux.ibm.com> From: Yu Kuai Message-ID: <70432d91-3909-ac3c-9c36-5f7484c1fdf1@huaweicloud.com> Date: Wed, 5 Jul 2023 09:43:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <87lefv622n.fsf@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3rLDZyqRkooPrNA--.55099S3 X-Coremail-Antispam: 1UD129KBjvJXoWxWFy3KF4xKF1kXw4kuFWUtwb_yoW5uw4DpF W0gayYkrW8trWUC3WjvF4UZF1Sq392v34xJFWjkw15uFyUCry5Kr97tFy8Za1UArZ3WayY kFn8tFyvgrn8A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9F14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E 3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hi, 在 2023/07/05 1:04, Marc Hartmayer 写道: > On Thu, Jun 22, 2023 at 12:01 AM +0800, Yu Kuai wrote: >> From: Yu Kuai >> >> In order to prevent request_queue to be freed before cleaning up >> blktrace debugfs entries, commit db59133e9279 ("scsi: sg: fix blktrace >> debugfs entries leakage") use scsi_device_get(), however, >> scsi_device_get() will also grab scsi module reference and scsi module >> can't be removed. >> >> It's reported that blktests can't unload scsi_debug after block/001: >> >> blktests (master) # ./check block >> block/001 (stress device hotplugging) [failed] >> +++ /root/blktests/results/nodev/block/001.out.bad 2023-06-19 >> Running block/001 >> Stressing sd >> +modprobe: FATAL: Module scsi_debug is in use. >> >> Fix this problem by grabbing request_queue reference directly, so that >> scsi host module can still be unloaded while request_queue will be >> pinged by sg device. >> >> Reported-by: Chaitanya Kulkarni >> Link: https://lore.kernel.org/all/1760da91-876d-fc9c-ab51-999a6f66ad50@nvidia.com/ >> Fixes: db59133e9279 ("scsi: sg: fix blktrace debugfs entries leakage") >> Signed-off-by: Yu Kuai >> --- >> drivers/scsi/sg.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c >> index 2433eeef042a..dcb73787c29d 100644 >> --- a/drivers/scsi/sg.c >> +++ b/drivers/scsi/sg.c >> @@ -1497,7 +1497,7 @@ sg_add_device(struct device *cl_dev) >> int error; >> unsigned long iflags; >> >> - error = scsi_device_get(scsidp); >> + error = blk_get_queue(scsidp->request_queue); >> if (error) >> return error; >> >> @@ -1558,7 +1558,7 @@ sg_add_device(struct device *cl_dev) >> out: >> if (cdev) >> cdev_del(cdev); >> - scsi_device_put(scsidp); >> + blk_put_queue(scsidp->request_queue); >> return error; >> } >> >> @@ -1575,7 +1575,7 @@ sg_device_destroy(struct kref *kref) >> */ >> >> blk_trace_remove(q); >> - scsi_device_put(sdp->device); >> + blk_put_queue(q); >> >> write_lock_irqsave(&sg_index_lock, flags); >> idr_remove(&sg_index_idr, sdp->index); >> -- >> 2.39.2 > > Hi, > > This change (bisected) triggers a regression in our KVM on s390x CI. The > symptom is that a “scsi_debug device” does not bind to the scsi_generic > driver. On s390x you can reproduce the problem as follows (I have not > tested on x86): > > With this patch applied: > > $ sudo modprobe scsi_debug > $ # Get the 'scsi_host,channel,target_number,LUN' tuple for the scsi_debug device > $ lsscsi |grep scsi_debug |awk '{ print $1 }' > [0:0:0:0] > $ sudo stat /sys/bus/scsi/devices/0:0:0:0/scsi_generic > stat: cannot statx '/sys/bus/scsi/devices/0:0:0:0/scsi_generic': No such file or directory > > > Patch reverted: > I didn't figure out the root cause, howver, have you tried to reviert this patch as well? db59133e9279 ("scsi: sg: fix blktrace debugfs entries leakage" Thanks, Kuai > $ sudo modprobe scsi_debug > $ lsscsi |grep scsi_debug |awk '{ print $1 }' > [0:0:0:0] > $ sudo stat /sys/bus/scsi/devices/0:0:0:0/scsi_generic > File: /sys/bus/scsi/devices/0:0:0:0/scsi_generic > Size: 0 Blocks: 0 IO Block: 4096 directory > Device: 0,20 Inode: 12155 Links: 3 > … > > Any ideas? > > Marc > . >