From patchwork Sun Jan 19 07:14:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BABCB184C for ; Sun, 19 Jan 2020 07:15:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9905E2072B for ; Sun, 19 Jan 2020 07:15:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fHtNGmSK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbgASHPC (ORCPT ); Sun, 19 Jan 2020 02:15:02 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:45450 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726421AbgASHPC (ORCPT ); Sun, 19 Jan 2020 02:15:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iybflM26WYMeoCRAkRYTW6uRVuVHivY05NfEWJZtDVs=; b=fHtNGmSKZkDQmyQzO2K4rMo3b2GIOnlqaobiwVBLVVx2pcMbn/+9Z7LqdJidlHd2jiAOt8 tLE0weSRyBFmqOq2BD6Eck1h7B4KDNjjbIPtWa1taveHPZ0D/kBQdUZF8w3zwC/4qPER3C +Y4MnoN16HPb5yuZP0Vqs6UzL6keotU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-3Eh3k-aQPU6VwzYAc0Cvkg-1; Sun, 19 Jan 2020 02:14:57 -0500 X-MC-Unique: 3Eh3k-aQPU6VwzYAc0Cvkg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AA47185432D; Sun, 19 Jan 2020 07:14:55 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E6E884BC8; Sun, 19 Jan 2020 07:14:51 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Hannes Reinecke , Bart Van Assche Subject: [PATCH 1/6] scsi: mpt3sas: don't use .device_busy in device reset routine Date: Sun, 19 Jan 2020 15:14:27 +0800 Message-Id: <20200119071432.18558-2-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org scsih_dev_reset() uses scsi_device->device_busy to check if there is inflight commands aimed to this LUN. Uses block layer's helper of blk_mq_tagset_busy_iter() to do that, so we can prepare for bypassing .device_busy for SSD since it is quite expensive to inc/dec the global atomic counter in IO path. With this change, no driver uses scsi_device->device_busy any more. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index c597d544eb39..91766c172d8f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2994,6 +2994,36 @@ scsih_abort(struct scsi_cmnd *scmd) return r; } +struct device_busy { + struct scsi_device *dev; + unsigned int cnt; +}; + +static bool scsi_device_check_in_flight(struct request *rq, void *data, + bool reserved) +{ + struct device_busy *busy = data; + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); + + if (test_bit(SCMD_STATE_INFLIGHT, &cmd->state) && cmd->device == + busy->dev) + (busy->cnt)++; + + return true; +} + +static bool scsih_dev_busy(struct scsi_device *device) +{ + struct device_busy data = { + .dev = device, + .cnt = 0, + }; + + blk_mq_tagset_busy_iter(&device->host->tag_set, + scsi_device_check_in_flight, &data); + return data.cnt > 0; +} + /** * scsih_dev_reset - eh threads main device reset routine * @scmd: pointer to scsi command object @@ -3060,7 +3090,7 @@ scsih_dev_reset(struct scsi_cmnd *scmd) MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0, tr_timeout, tr_method); /* Check for busy commands after reset */ - if (r == SUCCESS && atomic_read(&scmd->device->device_busy)) + if (r == SUCCESS && scsih_dev_busy(scmd->device)) r = FAILED; out: sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", From patchwork Sun Jan 19 07:14:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340585 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1921A109A for ; Sun, 19 Jan 2020 07:15:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB4862073A for ; Sun, 19 Jan 2020 07:15:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EhvzgSh4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726587AbgASHPH (ORCPT ); Sun, 19 Jan 2020 02:15:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60220 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726421AbgASHPH (ORCPT ); Sun, 19 Jan 2020 02:15:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zUbjLNIXOj4TxPklo2uSI4pE/JPo5U6LxEQdwFa1TFE=; b=EhvzgSh4g7T7QCfbwLVMPScC+5uN5mzO4DBaakl5Hx41Oppnrtj7NqtsPtLefcTpIWiH1m A4qJ9SvPJBPZa0E/z2T9M//0xrhdh6MRqrgPFQ0mhZ1xGHvyVQFlIDnkK4MOHsLe1NMFop G8frt5MP3JanIwgdgPCTolWYLLBwcRo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88-MP4Xp-8LN5uQuZhtERsfAQ-1; Sun, 19 Jan 2020 02:15:03 -0500 X-MC-Unique: MP4Xp-8LN5uQuZhtERsfAQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8E968017CC; Sun, 19 Jan 2020 07:15:00 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D296289A7; Sun, 19 Jan 2020 07:14:57 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 2/6] scsi: remove .for_blk_mq Date: Sun, 19 Jan 2020 15:14:28 +0800 Message-Id: <20200119071432.18558-3-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org No one use it any more, so remove the flag. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- drivers/scsi/virtio_scsi.c | 1 - include/scsi/scsi_host.h | 3 --- 2 files changed, 4 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index bfec84aacd90..0e0910c5b942 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -742,7 +742,6 @@ static struct scsi_host_template virtscsi_host_template = { .dma_boundary = UINT_MAX, .map_queues = virtscsi_map_queues, .track_queue_depth = 1, - .force_blk_mq = 1, }; #define virtscsi_config_get(vdev, fld) \ diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index f577647bf5f2..7a97fb8104cf 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -426,9 +426,6 @@ struct scsi_host_template { /* True if the controller does not support WRITE SAME */ unsigned no_write_same:1; - /* True if the low-level driver supports blk-mq only */ - unsigned force_blk_mq:1; - /* * Countdown for host blocking with no commands outstanding. */ From patchwork Sun Jan 19 07:14:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340587 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16E0B13BD for ; Sun, 19 Jan 2020 07:15:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8DA12081E for ; Sun, 19 Jan 2020 07:15:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DSm7FBgS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgASHPN (ORCPT ); Sun, 19 Jan 2020 02:15:13 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53627 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726444AbgASHPN (ORCPT ); Sun, 19 Jan 2020 02:15:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eAGUB+1EGEZIIMkgrPBp+rzVSx6XFXPgJno8wjIOYho=; b=DSm7FBgStJhqZSffdqfIjWhUqMQG0/BIfYpVD2SOo8QF1pw0L6rmmNClw5N3mSIO/FgBfU B0j7GobKr0/u2BrdEIqB6Mp6iRkpbxGUkm2ApGfKmKEogPlAmhjO4J+O1UIH1d4mR12kIs J67V9RFQjubOCDGDHYlZsAzdEwME1T8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-3oOzpheHMlKatQ7VhE93uQ-1; Sun, 19 Jan 2020 02:15:09 -0500 X-MC-Unique: 3oOzpheHMlKatQ7VhE93uQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DD4D107ACCA; Sun, 19 Jan 2020 07:15:07 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 018E260BEC; Sun, 19 Jan 2020 07:15:02 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 3/6] scsi: sd: register request queue after sd_revalidate_disk is done Date: Sun, 19 Jan 2020 15:14:29 +0800 Message-Id: <20200119071432.18558-4-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Prepare for improving SSD performance in the following patch, which needs to read queue flag of QUEUE_FLAG_NONROT in IO path. So we have to freeze queue before changing this flag in sd_revalidate_disk(). However, queue freezing becomes quite slow after the queue is registered because RCU grace period is involved. So delay registering queue after sd_revalidate_disk() is done for avoiding slow queue freezing which will be added to sd_revalidate_disk() in the following patch. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Reviewed-by: Hannes Reinecke Signed-off-by: Ming Lei --- drivers/scsi/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 5afb0046b12a..f401ba96dcfd 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3380,11 +3380,12 @@ static int sd_probe(struct device *dev) pm_runtime_set_autosuspend_delay(dev, sdp->host->hostt->rpm_autosuspend_delay); } - device_add_disk(dev, gd, NULL); + device_add_disk_no_queue_reg(dev, gd); if (sdkp->capacity) sd_dif_config_host(sdkp); sd_revalidate_disk(gd); + blk_register_queue(gd); if (sdkp->security) { sdkp->opal_dev = init_opal_dev(sdp, &sd_sec_submit); From patchwork Sun Jan 19 07:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38369109A for ; Sun, 19 Jan 2020 07:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1759B20880 for ; Sun, 19 Jan 2020 07:15:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Xs5hHJFv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbgASHPW (ORCPT ); Sun, 19 Jan 2020 02:15:22 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37267 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726421AbgASHPW (ORCPT ); Sun, 19 Jan 2020 02:15:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5XwGpGzb35Aht5FANg0+PHZ30iYq94l9uvU4jwniegA=; b=Xs5hHJFvuX/rxTu13H9IhGW2mfmCYmiLEuA/zWGtYPyxZRa9PUXDnf12ufZOghPQww9HMJ qKsQCSQ/sBBzmxBWB0execqhUcLL6r7MR15E9Jz436u4A0IuxBaIk//vrfK7hFcB+ka3Y0 x4mnBTb4pAJF2Uf5a/mC5c67IqOxhxE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-8MmHpCgcN3iVqwSU_H0-pw-1; Sun, 19 Jan 2020 02:15:15 -0500 X-MC-Unique: 8MmHpCgcN3iVqwSU_H0-pw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAA31185432C; Sun, 19 Jan 2020 07:15:12 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 958EA5D9CD; Sun, 19 Jan 2020 07:15:09 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 4/6] block: freeze queue for updating QUEUE_FLAG_NONROT Date: Sun, 19 Jan 2020 15:14:30 +0800 Message-Id: <20200119071432.18558-5-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We will read the NONROT flag for bypassing scsi->device_busy in SCSI IO path, so have to freeze queue when updating this flag. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei --- block/blk-sysfs.c | 14 +++++++++++++- drivers/scsi/sd.c | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index fca9b158f4a0..9cc0dd5f88a1 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -281,6 +281,18 @@ QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0); QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0); #undef QUEUE_SYSFS_BIT_FNS +static ssize_t queue_store_nonrot_freeze(struct request_queue *q, + const char *page, size_t count) +{ + size_t ret; + + blk_mq_freeze_queue(q); + ret = queue_store_nonrot(q, page, count); + blk_mq_unfreeze_queue(q); + + return ret; +} + static ssize_t queue_zoned_show(struct request_queue *q, char *page) { switch (blk_queue_zoned_model(q)) { @@ -642,7 +654,7 @@ static struct queue_sysfs_entry queue_write_zeroes_max_entry = { static struct queue_sysfs_entry queue_nonrot_entry = { .attr = {.name = "rotational", .mode = 0644 }, .show = queue_show_nonrot, - .store = queue_store_nonrot, + .store = queue_store_nonrot_freeze, }; static struct queue_sysfs_entry queue_zoned_entry = { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f401ba96dcfd..349c944b29a3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2935,7 +2935,9 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) rot = get_unaligned_be16(&buffer[4]); if (rot == 1) { + blk_mq_freeze_queue(q); blk_queue_flag_set(QUEUE_FLAG_NONROT, q); + blk_mq_unfreeze_queue(q); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); } @@ -3131,7 +3133,9 @@ static int sd_revalidate_disk(struct gendisk *disk) * cause this to be updated correctly and any device which * doesn't support it should be treated as rotational. */ + blk_mq_freeze_queue(q); blk_queue_flag_clear(QUEUE_FLAG_NONROT, q); + blk_mq_unfreeze_queue(q); blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q); if (scsi_device_supports_vpd(sdp)) { From patchwork Sun Jan 19 07:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C772513BD for ; Sun, 19 Jan 2020 07:15:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CB282087E for ; Sun, 19 Jan 2020 07:15:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LTP0pVAK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgASHPZ (ORCPT ); Sun, 19 Jan 2020 02:15:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30946 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726421AbgASHPZ (ORCPT ); Sun, 19 Jan 2020 02:15:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DlR31H0UiDgmum6L83kqDXST3JGsU/beKwaxBIY8doc=; b=LTP0pVAK3/Ad/MvSfnegHl1HbdT9hfRo7UyF7I+X3BzB7dn81A731iEO9HozpUWAypNyEx BRKEAjCEIq1RE624TNv+Yk58r61G+b6VWAIjPc744fdxZJ5uFsnx0D7b2Wb3xLO8lQ3F7y 0rMQKJ+aZyt2DmhhuHDFvNRJEcH3yDI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-bDrRvOxUOdC462uwmRLR4A-1; Sun, 19 Jan 2020 02:15:20 -0500 X-MC-Unique: bDrRvOxUOdC462uwmRLR4A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 438C0800EBF; Sun, 19 Jan 2020 07:15:18 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0823886C48; Sun, 19 Jan 2020 07:15:14 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 5/6] scsi: core: don't limit per-LUN queue depth for SSD when HBA needs Date: Sun, 19 Jan 2020 15:14:31 +0800 Message-Id: <20200119071432.18558-6-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org SCSI core uses the atomic variable of sdev->device_busy to track in-flight IO requests dispatched to this scsi device. IO request may be submitted from any CPU, so the cost for maintaining the shared atomic counter can be very big on big NUMA machine with lots of CPU cores. sdev->queue_depth is usually used for two purposes: 1) improve IO merge; 2) fair IO request scattered among all LUNs. blk-mq already provides fair request allocation among all active shared request queues(LUNs), see hctx_may_queue(). NVMe doesn't have such per-request-queue(namespace) queue depth, so it is reasonable to ignore the limit for SCSI SSD too. Also IO merge won't play big role for reaching top SSD performance. With this patch, big cost for tracking in-flight per-LUN requests via atomic variable can be saved for some high end controller with SSD. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei --- drivers/scsi/scsi_lib.c | 34 ++++++++++++++++++++++++++++------ include/scsi/scsi_host.h | 3 +++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 610ee41fa54c..0903697dd843 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -344,6 +344,16 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost, struct scsi_cmnd *cmd) rcu_read_unlock(); } +static inline bool scsi_bypass_device_busy(struct scsi_device *sdev) +{ + struct Scsi_Host *shost = sdev->host; + + if (!shost->hostt->no_device_queue_for_ssd) + return false; + + return blk_queue_nonrot(sdev->request_queue); +} + void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd) { struct Scsi_Host *shost = sdev->host; @@ -354,7 +364,8 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd) if (starget->can_queue > 0) atomic_dec(&starget->target_busy); - atomic_dec(&sdev->device_busy); + if (!scsi_bypass_device_busy(sdev)) + atomic_dec(&sdev->device_busy); } static void scsi_kick_queue(struct request_queue *q) @@ -410,7 +421,8 @@ static void scsi_single_lun_run(struct scsi_device *current_sdev) static inline bool scsi_device_is_busy(struct scsi_device *sdev) { - if (atomic_read(&sdev->device_busy) >= sdev->queue_depth) + if (!scsi_bypass_device_busy(sdev) && + atomic_read(&sdev->device_busy) >= sdev->queue_depth) return true; if (atomic_read(&sdev->device_blocked) > 0) return true; @@ -1283,8 +1295,12 @@ static inline int scsi_dev_queue_ready(struct request_queue *q, struct scsi_device *sdev) { unsigned int busy; + bool bypass = scsi_bypass_device_busy(sdev); - busy = atomic_inc_return(&sdev->device_busy) - 1; + if (!bypass) + busy = atomic_inc_return(&sdev->device_busy) - 1; + else + busy = 0; if (atomic_read(&sdev->device_blocked)) { if (busy) goto out_dec; @@ -1298,12 +1314,16 @@ static inline int scsi_dev_queue_ready(struct request_queue *q, "unblocking device at zero depth\n")); } + if (bypass) + return 1; + if (busy >= sdev->queue_depth) goto out_dec; return 1; out_dec: - atomic_dec(&sdev->device_busy); + if (!bypass) + atomic_dec(&sdev->device_busy); return 0; } @@ -1624,7 +1644,8 @@ static void scsi_mq_put_budget(struct blk_mq_hw_ctx *hctx) struct request_queue *q = hctx->queue; struct scsi_device *sdev = q->queuedata; - atomic_dec(&sdev->device_busy); + if (!scsi_bypass_device_busy(sdev)) + atomic_dec(&sdev->device_busy); } static bool scsi_mq_get_budget(struct blk_mq_hw_ctx *hctx) @@ -1706,7 +1727,8 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, case BLK_STS_OK: break; case BLK_STS_RESOURCE: - if (atomic_read(&sdev->device_busy) || + if ((!scsi_bypass_device_busy(sdev) && + atomic_read(&sdev->device_busy)) || scsi_device_blocked(sdev)) ret = BLK_STS_DEV_RESOURCE; break; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 7a97fb8104cf..8e80edfd5a6d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -426,6 +426,9 @@ struct scsi_host_template { /* True if the controller does not support WRITE SAME */ unsigned no_write_same:1; + /* True if the controller needn't to maintain device queue for SSD */ + unsigned no_device_queue_for_ssd:1; + /* * Countdown for host blocking with no commands outstanding. */ From patchwork Sun Jan 19 07:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11340601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D816613BD for ; Sun, 19 Jan 2020 07:15:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B82A8208E4 for ; Sun, 19 Jan 2020 07:15:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YeN/z+VY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbgASHPa (ORCPT ); Sun, 19 Jan 2020 02:15:30 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:58042 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726396AbgASHPa (ORCPT ); Sun, 19 Jan 2020 02:15:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579418128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pn4SA7nmTt+ix5HXMB4kLh+eSavv2+gG8CXaUSteEw4=; b=YeN/z+VYAEz14OESAlwDSpwVRE9c9vHq/g71JoCVhK69fVcKLPyG5Rhvh0qWPx6NVp6WLm dBQ6kDb8LPxpT43IyG2WVcjY/+mQSTw9NrPTdN+IaZ9b5aoqvONWXrmc7nv3JKM0zjaIjT R0UzZvkjKS1Loc98cvtN1YUkeEQp9bo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-1Q2T7_OJMieiKD9k-A8Svg-1; Sun, 19 Jan 2020 02:15:25 -0500 X-MC-Unique: 1Q2T7_OJMieiKD9k-A8Svg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8845D800D41; Sun, 19 Jan 2020 07:15:23 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B25684BC8; Sun, 19 Jan 2020 07:15:20 +0000 (UTC) From: Ming Lei To: James Bottomley , linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: linux-block@vger.kernel.org, Jens Axboe , Ming Lei , Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , Kashyap Desai , Sumit Saxena , Shivasharan S , "Ewan D . Milne" , Christoph Hellwig , Hannes Reinecke , Bart Van Assche Subject: [PATCH 6/6] scsi: megaraid: set flag of no_device_queue_for_ssd Date: Sun, 19 Jan 2020 15:14:32 +0800 Message-Id: <20200119071432.18558-7-ming.lei@redhat.com> In-Reply-To: <20200119071432.18558-1-ming.lei@redhat.com> References: <20200119071432.18558-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org megraraid sas is one high end HBA, and the IOPS may reach million level. As discussed before, megaraid sas performance can be improved on SSD when the device busy check is bypassed. So set the flag of no_device_queue_for_ssd for megaraid sas. Cc: Sathya Prakash Cc: Chaitra P B Cc: Suganath Prabu Subramani Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: Ewan D. Milne Cc: Christoph Hellwig , Cc: Hannes Reinecke Cc: Bart Van Assche Signed-off-by: Ming Lei --- drivers/scsi/megaraid/megaraid_sas_base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 43cbc749f66c..8f3770af7382 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3424,6 +3424,7 @@ static struct scsi_host_template megasas_template = { .bios_param = megasas_bios_param, .change_queue_depth = scsi_change_queue_depth, .max_segment_size = 0xffffffff, + .no_device_queue_for_ssd = 1, }; /**