From patchwork Wed Sep 23 01:33:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11793733 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 9823F112C for ; Wed, 23 Sep 2020 01:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7677C238D7 for ; Wed, 23 Sep 2020 01:34:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fkpqMzKD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbgIWBe5 (ORCPT ); Tue, 22 Sep 2020 21:34:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52573 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727052AbgIWBe5 (ORCPT ); Tue, 22 Sep 2020 21:34:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600824896; 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=9rNE0+J0ez+vRJhUnHjNNHKhYUmcLxWjpubeK72BSDw=; b=fkpqMzKDP5G+WzO9wTCHGQ1yiy0l5CARofCOwODCCZCZjwZv0lS9/hKofVKsOWgNy4mMm8 9UzrHCa6zGtxUUD7MdrN06NpGRZUglJKvQadpC9KKFs4kzc1sNXtfRgngZidjdDSj2p9QW WrtEvNGtbE6V9GE5QJ7Oj8+KUw74jTg= 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-333-sM4p0Kd5Nji8ytHirLZ_Eg-1; Tue, 22 Sep 2020 21:34:54 -0400 X-MC-Unique: sM4p0Kd5Nji8ytHirLZ_Eg-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 094FC56BE2; Wed, 23 Sep 2020 01:34:53 +0000 (UTC) Received: from localhost (ovpn-12-168.pek2.redhat.com [10.72.12.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBC6919D6C; Wed, 23 Sep 2020 01:34:48 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Ming Lei , Omar Sandoval , Kashyap Desai , Sumanesh Samanta , "Ewan D . Milne" , Hannes Reinecke Subject: [PATCH V3 for 5.11 11/12] scsi: make sure sdev->queue_depth is <= shost->can_queue Date: Wed, 23 Sep 2020 09:33:38 +0800 Message-Id: <20200923013339.1621784-12-ming.lei@redhat.com> In-Reply-To: <20200923013339.1621784-1-ming.lei@redhat.com> References: <20200923013339.1621784-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Obviously scsi device's queue depth can't be > host's can_queue, so make it explicitely in scsi_change_queue_depth(). Cc: Omar Sandoval Cc: Kashyap Desai Cc: Sumanesh Samanta Cc: Ewan D. Milne Cc: Hannes Reinecke Signed-off-by: Ming Lei Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 24619c3bebd5..cc6ff1ae8c16 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -223,6 +223,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd) */ int scsi_change_queue_depth(struct scsi_device *sdev, int depth) { + depth = min_t(int, depth, sdev->host->can_queue); + if (depth > 0) { sdev->queue_depth = depth; wmb();