Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp34683pxb; Tue, 12 Apr 2022 16:03:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlgS5HIccGf7XsqZ9a/QnQlKMsL7mkbfopW7gkkmathv2ZzHp+E2MKgnCkAsPyS9ZUyX7A X-Received: by 2002:a63:fd53:0:b0:386:66d:b40c with SMTP id m19-20020a63fd53000000b00386066db40cmr32331765pgj.266.1649804630162; Tue, 12 Apr 2022 16:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649804630; cv=none; d=google.com; s=arc-20160816; b=hgX5gPcViBtlI0oXTbG+zjbCtmhrLhp8oeKrOwKvpNfqFVxGPSamWD7n5V/N0ONqfH hwGo3PHOcPNYvQQWIA5RN35KBVUKijFpWQAm1hY9tkavoz7SkwOIXu5P1LIo/Hu7zKOc vyCYQMb+szQRg5gMtOZoQ9XY8sa+lR9WUqyy3WdngXmpuUfZBtlq0mLKnyBrH/ft6QRI 3y/AuAWrRARxeBGNzmaNdik0tRknOWC2xCXj/ClZTvg6tNfc5aBEj/ciPPGF6VtvHatb 0qspiYaBLamsB6gjKjV/NaS63PrhaqhFbX42ggfYWbcyhgZ5EZU5OJximfCFYI13QKi8 Q8QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SgMKF/17FD0PhdDZDStDHvIB+ukf8HDiJ7ZQwx2a7ps=; b=QXSH5pXj9sIihhas7+8DT5t9ud2D3owG2aJPmzmAr2BlfiMbaEbwbQsPiswpMJ0OW2 YBiP078QVESDTExiyV1bCacbev4aeQ4WHGN2nj2CfEfwx37NHpNpQsD6ya5eDqRc0DHu MEH01UCOVQ4EEx5teoiVDGsLqj0cinBMfeGm9OkkfJ/KUXv7hEMmBMlW8alCwbTmGqiS 4jyUNfs2vfSANkFsbbzzqRNrKl6YT4mJYUFKQPiPo8fAB7F6Vseku9E/M1zy8WklpCrF V2d1t7Mb2YsrIXDkl70WsK8ILTKLzzWsCgWThYN6XTc0IQSdU7y4CVSDhj1z9HPDhML/ SPzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RgEQySiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pi19-20020a17090b1e5300b001c6deb4730asi18654963pjb.109.2022.04.12.16.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:03:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RgEQySiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C50B513BAD0; Tue, 12 Apr 2022 14:46:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385186AbiDLIu7 (ORCPT + 99 others); Tue, 12 Apr 2022 04:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358446AbiDLHlj (ORCPT ); Tue, 12 Apr 2022 03:41:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5614B844; Tue, 12 Apr 2022 00:18:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 15E7F61708; Tue, 12 Apr 2022 07:18:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 203F8C385A5; Tue, 12 Apr 2022 07:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747885; bh=+BvEqExuJ4YvosuiNPophXouLG3Vdl4v0/jzgo7XOL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgEQySiSIUn4yczSLW/M6ied5HhGXvjxaRWOW67QRxUiX7PWBt0oelXFvHliF9Ks+ L/LraytGprJCXxioyFYkLWuhmB3/3RT30PDKHEl6WqbUnpYDF1ck3A/a8Rc0aiyi3O kGLweVmxL7IeSPpS3cxJ/efO/kWDB7AURy8zXBlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Ming Lei , Bart Van Assche , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 201/343] scsi: core: Fix sbitmap depth in scsi_realloc_sdev_budget_map() Date: Tue, 12 Apr 2022 08:30:19 +0200 Message-Id: <20220412062957.155676168@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: John Garry [ Upstream commit eaba83b5b8506bbc9ee7ca2f10aeab3fff3719e7 ] In commit edb854a3680b ("scsi: core: Reallocate device's budget map on queue depth change"), the sbitmap for the device budget map may be reallocated after the slave device depth is configured. When the sbitmap is reallocated we use the result from scsi_device_max_queue_depth() for the sbitmap size, but don't resize to match the actual device queue depth. Fix by resizing the sbitmap after reallocating the budget sbitmap. We do this instead of init'ing the sbitmap to the device queue depth as the user may want to change the queue depth later via sysfs or other. Link: https://lore.kernel.org/r/1647423870-143867-1-git-send-email-john.garry@huawei.com Fixes: edb854a3680b ("scsi: core: Reallocate device's budget map on queue depth change") Tested-by: Damien Le Moal Reviewed-by: Ming Lei Reviewed-by: Bart Van Assche Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_scan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index f4e6c68ac99e..2ef78083f1ef 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, int ret; struct sbitmap sb_backup; + depth = min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev)); + /* * realloc if new shift is calculated, which is caused by setting * up one new default queue depth after calling ->slave_configure @@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, scsi_device_max_queue_depth(sdev), new_shift, GFP_KERNEL, sdev->request_queue->node, false, true); + if (!ret) + sbitmap_resize(&sdev->budget_map, depth); + if (need_free) { if (ret) sdev->budget_map = sb_backup; -- 2.35.1