From patchwork Sun Sep 6 01:27:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 296848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F61C43461 for ; Sun, 6 Sep 2020 01:27:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81A5E20C09 for ; Sun, 6 Sep 2020 01:27:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RORyzFdn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728889AbgIFB11 (ORCPT ); Sat, 5 Sep 2020 21:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728751AbgIFB1Z (ORCPT ); Sat, 5 Sep 2020 21:27:25 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34BCCC061573; Sat, 5 Sep 2020 18:27:25 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id c3so2592322plz.5; Sat, 05 Sep 2020 18:27:25 -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=VTiZOrUEwCVKpqxE/AFo1ktXq/+qAF9fLESFNSzH6aE=; b=RORyzFdnPw8rzwXfdX8BenHMboLNmmQH/WJxBIsEvRCXhcPCo7xF1SfNLn+wtK7/p9 iHrU2JUh/F2ygpPz57jSyiMPnkSrHvxweZJLJmS8muxz7bWJLsvFbwGuy6IMiol/E/IT yKhh/BLf2J3MF/XR8bLw0ST3zOjS3XuBAy+Qvkh+zD86Cp/cRSmTJe5bFeqw8LzqenB+ 7ud+FOq/gwXS79BtCEkG1g4fPEvCIq+pZefIPFacNrV2GF0TZYm1vl/kNnENRAFfpJ79 AI6vpZKRhRVE27qlU9d5GM9I2PyW912qQdbgbiZUUY7XVbonTUN4YfhE0enKj1lexReZ SeSw== 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=VTiZOrUEwCVKpqxE/AFo1ktXq/+qAF9fLESFNSzH6aE=; b=TE9IWQ0m5zmbDg4LJqk58Lu7dO1ganb95JI5FDBuX84U9JgFctwDvk2+N8HX0xvoeb /r36Znz/48UTdr0iIQIE6lGt0ybDtAREIVPgSFCcG1VuGEc+3YggEiP1UM3urPxl84GI FqLheCiGy5lc2zpg2sALdPDjisb0HAtJ9uHSZOM9yaYJ4A4NWpH770wkinAsR6iYAU3L UBFuVwyrDVZPFDUZzk9IBYVyi+UsDahNpB+10+PR2+ibyKZalKqMD8jWmPVDO5lOk+fv 7QrA60hounRnZxZHnaGCqG/5Uq+vYXxeRMbdVDrVcgeAnAgHC/FAnmcQm66CHNivK6g2 PhrA== X-Gm-Message-State: AOAM531wdksmlCYtN/TDBLacglB31M/r5NLMQcygAElaVOaDc0kudkmF 467ImHNXarkBtjAyaCw1N+CVnQCdF0Q= X-Google-Smtp-Source: ABdhPJxHCkLOIo7Y8EK4Hc6Cy1ZGSSzTV+kB9ypMQ0HnkpMQIheEyxFf/UqP46ubj8YqWg4VrbEX2Q== X-Received: by 2002:a17:90b:80f:: with SMTP id bk15mr14574357pjb.36.1599355644115; Sat, 05 Sep 2020 18:27:24 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id gx5sm8462072pjb.57.2020.09.05.18.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:27:23 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu, akinobu.mita@gmail.com, hch@lst.de, linux-api@vger.kernel.org, Tom Yan Subject: [PATCH RESEND 1/4] scsi: sg: fix BLKSECTGET ioctl Date: Sun, 6 Sep 2020 09:27:13 +0800 Message-Id: <20200906012716.1553-1-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org It should give out the maximum number of sectors per request instead of maximum number of bytes. Signed-off-by: Tom Yan --- drivers/scsi/sg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 20472aaaf630..e57831910228 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -922,6 +922,7 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp, int result, val, read_only; Sg_request *srp; unsigned long iflags; + unsigned int max_sectors; SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp, "sg_ioctl: cmd=0x%x\n", (int) cmd_in)); @@ -1114,8 +1115,9 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp, sdp->sgdebug = (char) val; return 0; case BLKSECTGET: - return put_user(max_sectors_bytes(sdp->device->request_queue), - ip); + max_sectors = min_t(unsigned int, USHRT_MAX, + queue_max_sectors(sdp->device->request_queue)); + return put_user(max_sectors, ip); case BLKTRACESETUP: return blk_trace_setup(sdp->device->request_queue, sdp->disk->disk_name, From patchwork Sun Sep 6 01:27:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 257726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AE64C433E2 for ; Sun, 6 Sep 2020 01:27:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBE7F2078E for ; Sun, 6 Sep 2020 01:27:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XVkGvuJ7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbgIFB1a (ORCPT ); Sat, 5 Sep 2020 21:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728751AbgIFB12 (ORCPT ); Sat, 5 Sep 2020 21:27:28 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521FAC061573; Sat, 5 Sep 2020 18:27:28 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id mm21so4934304pjb.4; Sat, 05 Sep 2020 18:27:28 -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=EcapTIGFf+31wVMqsHZgBSE+2BUv5P+WBgtFpuHKTB4=; b=XVkGvuJ7HP2sZez2I9DMGX5mHm+XHqvqSLW35Gd43qB4iTHIrBbgpNH+G3fZt5CmGY VpI2esHqqYEMZ+iTwJ8wagFX5OO90+EQxsBWljZFEZAAMGqv60r3K4NkyQU3ta0JdSss E9s5tYldKdsmst2hOC2mEpuQrm9Bdf7HOPARKquWrHh8jZLBQFEAWCMvMK3PAsPcuuLb ZiWKJDgpQCUx7x3oAD5zGa99i9PYii+0iX8Nh6hxDn5StrWlWqH6dJg6/nzIOUsZTtX9 PFwNRz1uIzbQSA07YozkZ8AsoLraI+DgYtFcVpt5O+U5gRK571lE3Dw1A31FkfGiN2j+ 3TGg== 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=EcapTIGFf+31wVMqsHZgBSE+2BUv5P+WBgtFpuHKTB4=; b=rEbTFyJZw9NtLzcnsQu1Uacq9Oj26bW734En57wFpuVU2j0VABIXJoHAzdKcnw5xp+ Yo2Jj85LnCa4VFfTzQ4+fZ7F2ntG3IwKIf7Q7LQgZs+5ZNMzM+6wzm0LEOgIY9YtmjdK Z2A4+r9CEuWI7b0+cGptrq7/O3ZEgl4JVvM9eVI2zw8nEq324jUo03+sNhPvVZIsSOsH 6baE97+9sca0Odn0iuJ5X27abBb6ZsQAe8gWPp5wfCTmf7nbkLp7mS553ni8QUZ9egzG /tW4O4cu/1pAMiaes0g+h77Uv2AD3tOULOB4dMAE5sm/1DDjnZmH5DbwbPhX+L+Z3utP o1qQ== X-Gm-Message-State: AOAM533++hCu517fxSRnIOiy8ojzn0ERJ1jrb84cLlAB3pxmlyeGxOxS bkE68NyU8RfaMRPfqQZmNFEskam/bdY= X-Google-Smtp-Source: ABdhPJxiZgNRLuDB5tAwzb8DOXAO2RFYF4y39+dYnebw1HM5wCZUamDO66vWRurY/iac4ynpfFdr8Q== X-Received: by 2002:a17:90a:d703:: with SMTP id y3mr14650797pju.183.1599355647554; Sat, 05 Sep 2020 18:27:27 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id gx5sm8462072pjb.57.2020.09.05.18.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:27:26 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu, akinobu.mita@gmail.com, hch@lst.de, linux-api@vger.kernel.org, Tom Yan Subject: [PATCH RESEND 2/4] scsi: sg: implement BLKSSZGET Date: Sun, 6 Sep 2020 09:27:14 +0800 Message-Id: <20200906012716.1553-2-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012716.1553-1-tom.ty89@gmail.com> References: <20200906012716.1553-1-tom.ty89@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Provide an ioctl to get the logical sector size so that the maximum bytes per request can be derived. Follow-up of the BLKSECTGET fix. Signed-off-by: Tom Yan --- drivers/scsi/sg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index e57831910228..0e3f084141a3 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1118,6 +1118,8 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp, max_sectors = min_t(unsigned int, USHRT_MAX, queue_max_sectors(sdp->device->request_queue)); return put_user(max_sectors, ip); + case BLKSSZGET: + return put_user(queue_logical_block_size(sdp->device->request_queue), ip); case BLKTRACESETUP: return blk_trace_setup(sdp->device->request_queue, sdp->disk->disk_name, From patchwork Sun Sep 6 01:27:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 296847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1B01C43461 for ; Sun, 6 Sep 2020 01:27:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89FCF2078E for ; Sun, 6 Sep 2020 01:27:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lx9SlxI0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728909AbgIFB1e (ORCPT ); Sat, 5 Sep 2020 21:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728751AbgIFB1b (ORCPT ); Sat, 5 Sep 2020 21:27:31 -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 74C33C061573; Sat, 5 Sep 2020 18:27:31 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id b17so2616347pji.1; Sat, 05 Sep 2020 18:27:31 -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=GH3vO2zorCGfPUvIZzkKisvrCrW3Qnmk8aOiUtht/RM=; b=Lx9SlxI0Tg96CwHFeg946IVwM7dxn1aIbviLj4xiQXvff5cJsBmF9CxYOAtsgqn4Ya W0DsIiEpL6uVUvn9vV0MENbbfldlFigjuU3R9oKGzNz0LiMvYfmNGAEetihDNaWjAnTb Zw+0/Cv+5WcvJf+kVaiJ8IUoYnDuokBGAm04NhVLmpNXSXaMSnAhz9Q2HLnTQr+c6Ezu ifvWyyXLmbaVp797MbVooCN4QcL+sNBLeM0Ti+rXcaTMtMyOtJGzznz8Htiaeynb2ESM cezia2hTYAeSOPbsjQnO+mGM78LQU1PaF/EsWrtbQjes7Te6GMwB76uRN2BPdqcFIfgX bk3Q== 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=GH3vO2zorCGfPUvIZzkKisvrCrW3Qnmk8aOiUtht/RM=; b=eagl+DJM2Aiy8FmyMEKvzCsHM5uc1xUAZbHMkEy2PEZqSa3C8iOdETlsw1eEE0wfC2 a88vb5smU4Xf5Vj5tgaD8ZqymYajLu1Ig0LoLZ8SZi9f05edD7UgFOmWeQonNAF85c0Q qpW2OuKo1hc+aQ668TSxHEeAo6TtyxZ7pG8b5MZ61vwdX5Omo4bIP12ceGVWWSMnxYGs s3YODb/F5XRHrCi+A19tbdsBT5A61q0Q55vkS3O/nMdQ0OEaKFfOlT7JGbtMu/Y9YACa xgTbmJDOWSmtIPYq7kzPS7mQukFCj1xwSARBbIX5U4J+2oipW4mgxi7VxS7pSWasyHn8 o8QQ== X-Gm-Message-State: AOAM531cJXsiiYA0iaqrlPc+4qkbPXXXg5bFtVYpod2NT+u+xSLRyUc5 ZHPY2Z90i4e+WpAxG71g98uo1ngb8CU= X-Google-Smtp-Source: ABdhPJz2GG2b673zx7JzWVN5kDxxZJC4o+yy8Rls0BDtfVO25hh67iEAMLJCmGBVRh1H1fljP9hjLQ== X-Received: by 2002:a17:90a:bd0e:: with SMTP id y14mr14471221pjr.13.1599355650713; Sat, 05 Sep 2020 18:27:30 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id gx5sm8462072pjb.57.2020.09.05.18.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:27:30 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu, akinobu.mita@gmail.com, hch@lst.de, linux-api@vger.kernel.org, Tom Yan Subject: [PATCH RESEND 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Date: Sun, 6 Sep 2020 09:27:15 +0800 Message-Id: <20200906012716.1553-3-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012716.1553-1-tom.ty89@gmail.com> References: <20200906012716.1553-1-tom.ty89@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 0e3f084141a3..deeab4855172 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); + unsigned int logical_block_size = queue_logical_block_size(q); - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); + max_sectors = min_t(unsigned int, max_sectors, USHRT_MAX); - return max_sectors << 9; + return max_sectors * logical_block_size; } static void From patchwork Sun Sep 6 01:27:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 257725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5895EC43461 for ; Sun, 6 Sep 2020 01:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 216F82078E for ; Sun, 6 Sep 2020 01:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OmkEN5sA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbgIFB1g (ORCPT ); Sat, 5 Sep 2020 21:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728751AbgIFB1e (ORCPT ); Sat, 5 Sep 2020 21:27:34 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C04E7C061573; Sat, 5 Sep 2020 18:27:34 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id n3so6332435pjq.1; Sat, 05 Sep 2020 18:27:34 -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=bg1T/4Ha1GXOocbDAQsf5gtGn1bi3WAb271zUVCosk8=; b=OmkEN5sAudh66UEkXdATHHM7c6WY8B9mwx5twLEEC60AHeUOsNvhPXwvN128tXhgqH R4DuE/hcchGRyPb58ULw70zj1Ji/EsqcriXEbUT+YhW0aPKvCqE1tiI4A3PDxoTldgx+ XDtUmZQIRTMcBX365GyEEIxS1aB139jubdy49YuZrpg9q2Snu0Pgtc05TcpP+IHBsWzD XPgIqeEaetqS2GwJJXlECqGz+ferjsy1j6FzhBu4tidOyIusuNphW8SnKWzT5MxSQ9+z j0E7fS/WMKlbOnRT1eAJHEGy6hLU90C1fT8yuFUJS4RWooq7MNopSkGz2ukAp8uo2df5 to1A== 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=bg1T/4Ha1GXOocbDAQsf5gtGn1bi3WAb271zUVCosk8=; b=XadPKBN6M65FAuhIEW8YlbRjynLtQgKzcQ9lYvc91U2AS1EGNg38Eh2VAhwZ+Up1nF Qwv4XtI7s/nMJ6gvyr3zFZVg81f6h+bEnzQm3dWQ9ef3UmhQWWU8cDVJktZS0gyA1oGg UOFJTy/+qnClWEpRRTlGsizSj5iW89YLU/2mFcbUX1mYb7Os/A27+n5nXBTj4XX49PSh cSWeP6faPYkzF9G8Ig+1P5goiLfL5abLhGIFJy+ZHVyQSG8kLNTsnimnHpk4fGZg0U8s WwQj7NTlaGK47gbwTMzzAIlGaNIPjA2by+WxyW09LRiEAIeI9MssKgmqad/QX/978bjI sEHw== X-Gm-Message-State: AOAM533G8lAB998WKUoF+waHSHf0ItOvi/hD1nSfAqO/cPbLoHahDnj/ emcjH8vZ2HNTAiX5unGK5AWfd1AKZ+c= X-Google-Smtp-Source: ABdhPJwiaQljkH2yb6ew2rqB3WdgihEEr7+c61XfZC6uMMrm4jSC7pK2Ukv7Dx/kOE70Ae8nHjfVRA== X-Received: by 2002:a17:902:fe15:: with SMTP id g21mr14454297plj.22.1599355653759; Sat, 05 Sep 2020 18:27:33 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id gx5sm8462072pjb.57.2020.09.05.18.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:27:33 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu, akinobu.mita@gmail.com, hch@lst.de, linux-api@vger.kernel.org, Tom Yan Subject: [PATCH RESEND 4/4] block/scsi_ioctl.c: use queue_logical_sector_size() in max_sectors_bytes() Date: Sun, 6 Sep 2020 09:27:16 +0800 Message-Id: <20200906012716.1553-4-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012716.1553-1-tom.ty89@gmail.com> References: <20200906012716.1553-1-tom.ty89@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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..ae6aae40a8b6 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); + unsigned int logical_block_size = queue_logical_block_size(q); - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); + max_sectors = min_t(unsigned int, max_sectors, USHRT_MAX); - return max_sectors << 9; + return max_sectors * logical_block_size; } static int sg_get_reserved_size(struct request_queue *q, int __user *p)