From patchwork Wed Sep 23 05:52:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11793873 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 A0A3392C for ; Wed, 23 Sep 2020 05:52:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77768221EF for ; Wed, 23 Sep 2020 05:52:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A50k8tVR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbgIWFw6 (ORCPT ); Wed, 23 Sep 2020 01:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbgIWFw6 (ORCPT ); Wed, 23 Sep 2020 01:52:58 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6DA2C061755 for ; Tue, 22 Sep 2020 22:52:57 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id f2so13703601pgd.3 for ; Tue, 22 Sep 2020 22:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dL5bjsBTpI1WHY1Lul+C+ZXEBNZvu4AIQRGli0lUOx4=; b=A50k8tVRgwLxFX6dX3WLie7bUN04fF18rVK6VMuagjWGw0zkav2zad9jjoWwl+7YEp 2o0YwU9LWdUlgGtBF9Sx+oJGXlEpUMTgTRkPn5rnGjQoDPfKvZqU8PnwMuKseoLa44sB TQBrydSWrMiab+3eWHl2KIf1fjNvqMSfRpc0bHTtFYo+oncqaekPCOW8AaI4AtkBQ1tb UmygILV8mn8IincbZSrXeg4XT5dXATGeADnSNWWqjl8bvHdf/vyh/ZxuIByBfjF9EY9T q4dx8uEkwSFlXu+4XoCFwtC9w6colzorfS0TcOpN5sYl1mTAynm71F8jB6nW49Axg+gl m34A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dL5bjsBTpI1WHY1Lul+C+ZXEBNZvu4AIQRGli0lUOx4=; b=s3LlQmvZamHTFN4Wn2+dYG1Qy57irImYeHjrG2MOZXe7dV9KpU3nLkz4r9mK+VX8Wb csNvIVjo1uTh7GxdYAIM0qXTJycjO5NcI01ri4ZSL5w670ZSDufqoksQbGmZSWayOeKB /wTq6g5f3YCHaGlKg7kY15H8yP9qv0idx/3ASDQX7ap5YV98W1lnyZbeZMELpSi2Ttf9 mgilTKbRmMQkvAm+pb02NhYE4UQh5dzFN+HNhJlyX/h8y+iOrAPMxGwEg6XlB6LZ0896 SrF4pMxu7hlJpQ1/i+gyaTvs/3S2p0Zys8TbKINK0d8QCu+/5GpljILggU4s6w5rIKFb fI4g== X-Gm-Message-State: AOAM531T/1wLsOjBduqO1C484QaeDPM4t8/O7VgPMpFucMORUbxcWlWN Lo1jOVDW0MleytWZpJjSR6FEIoZcw+87Aw== X-Google-Smtp-Source: ABdhPJyH82oC4488S4whZofRCzGvvcAlyJ91NPs+7eCAjDRVgnlLy7Wgg2U9blUwuFaSPvbfwJRCaA== X-Received: by 2002:a63:f922:: with SMTP id h34mr6660742pgi.235.1600840377057; Tue, 22 Sep 2020 22:52:57 -0700 (PDT) Received: from localhost.localdomain ([161.81.44.186]) by smtp.gmail.com with ESMTPSA id hg16sm3719883pjb.37.2020.09.22.22.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 22:52:56 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org Cc: Tom Yan Subject: [PATCH 1/2] scsi: sg: use queue_logical_block_size() in max_sectors_bytes() Date: Wed, 23 Sep 2020 13:52:47 +0800 Message-Id: <20200923055248.1901-1-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Logical block size was never / is no longer necessarily 512. Signed-off-by: Tom Yan --- drivers/scsi/sg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 20472aaaf630..8a2cca71017f 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -848,10 +848,11 @@ static int srp_done(Sg_fd *sfp, Sg_request *srp) static int max_sectors_bytes(struct request_queue *q) { unsigned int max_sectors = queue_max_sectors(q); + max_sectors *= queue_logical_block_size(q); - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); + max_sectors = min_t(unsigned int, max_sectors, INT_MAX); - return max_sectors << 9; + return max_sectors; } static void From patchwork Wed Sep 23 05:52:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11793875 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 9A04892C for ; Wed, 23 Sep 2020 05:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D72C221EF for ; Wed, 23 Sep 2020 05:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CH3Se/5E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgIWFxA (ORCPT ); Wed, 23 Sep 2020 01:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbgIWFw7 (ORCPT ); Wed, 23 Sep 2020 01:52:59 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AAF4C061755 for ; Tue, 22 Sep 2020 22:52:59 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id bw23so2648926pjb.2 for ; Tue, 22 Sep 2020 22:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dyqT5DAvLDgsGMi6Y/ooNL+LKnGqQcxgtFjfUSbSM2I=; b=CH3Se/5EJCMjBzsjprzZ0piXXnGcN1kFDC+AvG79KsBkcl9hYso65JQlWurB81YV3p WhBEJMjM4qr4fyU9IR1I/ehz7iNTxXqcaGo+R20qr5+hxZnj6+esBWwsyk02kDwXq8MY sfILrYJEwyd0WVt9uLFJip/lAK/f5Pu4yfRUchIJLdRRp+s0WzKMLNuoYhyQHd4yOFVr jHQXKDeXEYgRPEBvL0asNHrAexroqk+2NgFTBNs80eWmwtQ8tlzQOHggWqAnGZ4GWvQ3 EL+zJVsAvYeyGANqPHRs2PWSA4PzboSMnlyC9hDhIsO7ETNU3ldTw4P5IGbCsCRnAQyS kZFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dyqT5DAvLDgsGMi6Y/ooNL+LKnGqQcxgtFjfUSbSM2I=; b=eFU/xxbQCX88nMyLvfakXOX7LRlEmG1AJi4Oky7fJNVMcVCmeSsfAjYwiVMcEtUBgn hCMosN+P10jyAYd9xaCimPeM2Prx8H2pj5GRZFBu6wRHDEVKJiuqRYMg2uCIKWPP/NNs bDgZoXdVozJOmNVHjWjux78T2/0P508xwcZBpoF+Vgh4UW1mZfBkAHRETNBuHJAFbjM8 jq4H+dLr/bVjrddSZW47Bap796OrPR1Uwc9cVfeq1EXMxtPBAdJm/jvbzOgWGVRQVO31 Yn9zJxfEq2T6+hD5OOXXx14ag0JWXv745iMd/+QfZUGzuTl0c8zjrYdgOtR91QwDGkbB NspA== X-Gm-Message-State: AOAM533kv0acaPNXOrxF0e65ABf8kU1LjctnwZC/SEY4GS4froI6WxAt VeMbgj87NICHz1ILrRsB+B6oRVLQZHgQmA== X-Google-Smtp-Source: ABdhPJzpo1RO0xCcOR+10lbhN73Pr8wdvEqa5/Z9WNlQXcWuQ5562WiPZf4h3qKcv37HjrYvxqo5kQ== X-Received: by 2002:a17:90a:120f:: with SMTP id f15mr7027092pja.120.1600840378732; Tue, 22 Sep 2020 22:52:58 -0700 (PDT) Received: from localhost.localdomain ([161.81.44.186]) by smtp.gmail.com with ESMTPSA id hg16sm3719883pjb.37.2020.09.22.22.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 22:52:57 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org Cc: Tom Yan Subject: [PATCH 2/2] block/scsi_ioctl.c: use queue_logical_block_size() in max_sectors_bytes() Date: Wed, 23 Sep 2020 13:52:48 +0800 Message-Id: <20200923055248.1901-2-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200923055248.1901-1-tom.ty89@gmail.com> References: <20200923055248.1901-1-tom.ty89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Logical block size was never / is no longer necessarily 512. Signed-off-by: Tom Yan --- block/scsi_ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index ef722f04f88a..82ed73f07460 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -73,10 +73,11 @@ static int sg_set_timeout(struct request_queue *q, int __user *p) static int max_sectors_bytes(struct request_queue *q) { unsigned int max_sectors = queue_max_sectors(q); + max_sectors *= queue_logical_block_size(q); - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); + max_sectors = min_t(unsigned int, max_sectors, INT_MAX); - return max_sectors << 9; + return max_sectors; } static int sg_get_reserved_size(struct request_queue *q, int __user *p)