From patchwork Sun Sep 6 01:25:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11759429 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 9B91E92C for ; Sun, 6 Sep 2020 01:25:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E1C420797 for ; Sun, 6 Sep 2020 01:25:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CyHQQY39" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbgIFBZi (ORCPT ); Sat, 5 Sep 2020 21:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728742AbgIFBZi (ORCPT ); Sat, 5 Sep 2020 21:25:38 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17320C061573; Sat, 5 Sep 2020 18:25:37 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id m8so990908pgi.3; Sat, 05 Sep 2020 18:25:37 -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=CyHQQY39mVD5MdQkmOEu4m1Lfsa7Yfo1+uFrp6vvolj/HATw9iuXQUZS03eSyyZfUg Giha01eTNrSeDmEERlQ40Fu7LHtUj2Sj4j8JG+bFusqaPGu5mu/nlRi4I1uZFp5TB4av WxQZ73LhDceREPFoFYxQvLxi0QcmkLDYc64jis3TpbrY33dBlJzXAthDzmzLlSgplGVd Akmia9r73rZA/Atf45qgtAmIpq6xh+ryokp28WUH0PwJUeqKWLmRD9jLjN45K1AYWYgk 0aYdng+vkNrQsvaSBBGoH6K2JqqReYApqhtkIZlL9FKJuJBhig8QSA0L0ZbLn3g/y49C DRfA== 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=skQ8CepWK2RBXEOLHFluiBar0F7o2Y9IsZcQMNMEDRoUIOnS2AfYC7pH3Yk48b36FT L32Uw6yGE8XwYbgtPETmqmWq6Rd+pF8gacmj3z+3eMSh1yA0iaIE+ChFlwYa9WV0MEF9 YHBb6tWHEWbUJNvNkjnxZkV4FH60TarqVh16wj2bc4nu8LXW/a9JNTE3ALnnEj8XG13s ITwmqFl78ijKobIX4cogSoAL8nWi237717BBtItjHw00llzxBp+RL+twyEeMdiye0Blh vJ1gMa1zbHfo4vrBTrdD7WMUBQcnK0sp9TbkjU0ru9qCc3PL4/ZcLqBKG6eYVhObcJo+ +ZIQ== X-Gm-Message-State: AOAM533qaR61KWfhdNtr9eX+7omQ2Kgn8tHQJj6mUHFhiGhu5S0Pd0Jz nx5fsRumalJPi/E7BPuPN5bPVv+Fudc= X-Google-Smtp-Source: ABdhPJyAas0c1rm+JxxgA7N8e5Q/XIm7noVCHFHdk/B7mnOyXua7RyPhrtaWcw3zRTTDFHdzv+XRfQ== X-Received: by 2002:a63:f606:: with SMTP id m6mr3821621pgh.193.1599355534940; Sat, 05 Sep 2020 18:25:34 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id w206sm3070386pfc.1.2020.09.05.18.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:25:34 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu.com, 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:25:09 +0800 Message-Id: <20200906012512.1428-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:25:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11759431 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 6DA2E618 for ; Sun, 6 Sep 2020 01:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51DF42078D for ; Sun, 6 Sep 2020 01:25:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Enq4iPbG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgIFBZm (ORCPT ); Sat, 5 Sep 2020 21:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728742AbgIFBZj (ORCPT ); Sat, 5 Sep 2020 21:25:39 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576E4C061573; Sat, 5 Sep 2020 18:25:39 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id u3so1525245pjr.3; Sat, 05 Sep 2020 18:25:39 -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=Enq4iPbG8/ACEw9m66GlXeAjWiJ0CPBHnob6ri6jjW8mOiGH0UGCOXqOI5sF8388QL YBFIJgE18+zpPPQ34agqn0VwdV8LVo6zT1YU4KD+cloz3MzHJhCt3h3uBLgqP0fTSzWU hYhxo+uZh8aMCox7EcV84s/znr9iLbbTRX5z1iaT0AzYMufhJfd7R76CJZRwV3P6yt8O JYBXJX0WgUdkBgaKOj6ctse2fDeN/egafBhWpIgdb4x46YrgDs35QDJAVHR+VlMo2Xb+ MQLdFdoH4Vli3pfVo/k1taj6RSWDlJMSPedSELkhws5TCptSy/7o9OPaMKgoW1nAyVzT WK0Q== 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=JuvZCDvOkjMsQgaHIrcTNu4FUCiwLsLbDTEv74CEDTJQXc4uge08DeKuWVbMp0/2H7 hDwy7v+p4VsxMDoT84Ys4ar7Gw/Y90JTpUE6JQMECRln4GCblwtDN70D29BpURqnkzkO SS42BC7RuteER+BEOlfD1UlHoSr2ja54526i8SgMTZ48Tfk+PVEONM94BDMTDx3Gnxqu ETGb+slbHQX/dgXIQ6PH8gPnCCa7gC+9/5AMRF/0bO3vNle7rojUt3+S3a0sMwVFqrL2 3UJFUBQLUc1OaQZCgz4IUa8HOGf5pVXoFLJX8RMSkyEJ0ss3PmqVd9CFzwxBOgrSRWmW R3Zg== X-Gm-Message-State: AOAM533gTeFbALnPPTz6qE753V4aAGMQhd9f/J3wj2WWUsBflMFY8gcq Nb4L23GDjzHUmjXmeV0PT/2oF4IJg9E= X-Google-Smtp-Source: ABdhPJyzQya9BgMxlhxu6sSwZcA9D8WzGaZnNzbpxeOiVENy0OPxEDXDH5di5cCObQses/Q/zeVmUQ== X-Received: by 2002:a17:90a:bf8c:: with SMTP id d12mr13611265pjs.157.1599355538477; Sat, 05 Sep 2020 18:25:38 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id w206sm3070386pfc.1.2020.09.05.18.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:25:37 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu.com, 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:25:10 +0800 Message-Id: <20200906012512.1428-2-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012512.1428-1-tom.ty89@gmail.com> References: <20200906012512.1428-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:25:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11759433 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 5969192C for ; Sun, 6 Sep 2020 01:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E0782073B for ; Sun, 6 Sep 2020 01:25:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EYr8OBzz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728892AbgIFBZr (ORCPT ); Sat, 5 Sep 2020 21:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728742AbgIFBZn (ORCPT ); Sat, 5 Sep 2020 21:25:43 -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 133A6C061573; Sat, 5 Sep 2020 18:25:43 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id g29so6288260pgl.2; Sat, 05 Sep 2020 18:25:43 -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=EYr8OBzz0mcmFJU3cfOzg/dnRfqpURym5gmJB+meJLEi+o0eamV6xGIDrLwjzAwABz haf3vdwHpIVfBz5xshnBnqApxEZDXp+0vt4SkhK0iNtovNEZj1P/XJm5jRvmobdGSB/R kanD6uFMEMQNXwtKglQ+t450wijeNLF4M7XnIt+MuTPLedZ42mfXSnq9AU9HhIGnHiUK Bt0/rc3BR7vuPqE9lfNY7BHKINFiMRctA1NUYvput6QRsW2m0pEUhvi23LyS8tS6laJ/ Nl+V1tisItPvKZEP7dqUUG9i5577KDGlGA/hc2u/mpJ7+qKFVIBtwvdxdeOgeRMwOkSr /EQQ== 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=DqJ5QLfGfIrgNKV/ILb+TrIc93zvflT0TAb4P4P7VZNCP8tOoB55bxYruNEL5mIbV+ 4D0YldgGIilsxPVOVfHLk/Dn+VLMtCq/EV+GbHYJ7bWmZv1ygDBafhHwVErD0FH617tw fc01YwKf8FdFMSKy30YMudyHcTDFx0CKMB+ge2VAai1l7lLFolL45hJ2qjA6YVHpblfB 8xCBgLLzI5sGxar1F/At9ECkTY7Ux7WoThMRFRemX2a8qxeipJnbEB2xlPd5xtV7P+jh SxZANk+6nHkI3EBHBilD9PkUaCJJ0/GNM4I40W3K4TbwZPQEdp9w14D0G3o8u/DdU+oy voDg== X-Gm-Message-State: AOAM531WcN3uKZaLW54Hyqpkg2a3oQKHlvftWvAfc4vbQMdDQDWCPbv0 Kgi930nvgH0VDsCJN0k67zvNnY+1x+g= X-Google-Smtp-Source: ABdhPJz7w/K6g1YaY8UKnfWgP6HNAKBGMiBxObbrFL8lMbxAe7zeW4gMme+pbeWCy30LWAsuNFbh8A== X-Received: by 2002:a63:e22:: with SMTP id d34mr12802208pgl.120.1599355542280; Sat, 05 Sep 2020 18:25:42 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id w206sm3070386pfc.1.2020.09.05.18.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:25:41 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu.com, 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:25:11 +0800 Message-Id: <20200906012512.1428-3-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012512.1428-1-tom.ty89@gmail.com> References: <20200906012512.1428-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:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11759435 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 21FC692C for ; Sun, 6 Sep 2020 01:25:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0765B20C09 for ; Sun, 6 Sep 2020 01:25:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cs36XKao" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728901AbgIFBZt (ORCPT ); Sat, 5 Sep 2020 21:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728889AbgIFBZq (ORCPT ); Sat, 5 Sep 2020 21:25:46 -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 3EAD5C061573; Sat, 5 Sep 2020 18:25:46 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y6so401465plt.9; Sat, 05 Sep 2020 18:25:46 -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=Cs36XKaosndj0je9wMduaWoGlITk1K/eHiK6esmzM1HbqLeDW42axltpMHvN8r79oW DVtmGBJth4jHdvaC3F9h46E2iR+0FWRn+tFwTa+ynDpECQieE5vHy0B8K9SkxW4n0/0/ JH8QdXxjz2fKhyb/QLxnJb69X2PZxNxTg1/VDFKuCkF3h8dAju7X5tnUGR1DKZpYw4Vc n7X9VeUpcPUdmYCbmpuEWIi2EbIGjmuQ4BwS/ygdK/wteqU7j3z6hyrLITDah6zYPLWq duTQ3Uljg0WkVK98C/fUvMK5X8Zz/KQ5fmvqwLBfvwl2OYE/XiuESixn2jh3QbU2Oupe UnsQ== 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=XRxsoNL406TD3Qnp6uK1LoSW/3b/R5W+90uz1NUo4ufwGzVjWKnyAeam+0BwKJSxbb 7/aOSZJgXqPMfqbC8w84AvqglAv/ZVx7r7GJi/jkStu0QLTsGNO5OHVxClJ2UMyo//wq ZSkSr4V489nPyQpjMxaJRlD+oWjsC4CPD8lDQ3WmIWDdoQv6DvKAicFTopmzFlF2vAve zIruUQl3Q7ZwcPzc6VoDa0yF9n5uwb01bv5e4aDwDu27cyA714IbRse0AxtHZ2zQbynX u1n6TQiN5ROUPdaE2Nx5yiTzJELselR7uU/jJeeudnw3wfx0R4ZqB4wDEsIsByaIIJF3 fFow== X-Gm-Message-State: AOAM533RfPVgq5ofvd3z93MLtJXwktLAc+AFmsco3bTmCqMhGGqwdpdF VG21VRDi9gcgAERYLQMcY/zmYbx9ZC4= X-Google-Smtp-Source: ABdhPJxCefCM8KwY51syKb7wP0I1D+yMIEtjywI5+IPhcrYgf9V7792TumUy6HTZinsbpKdohLJilQ== X-Received: by 2002:a17:902:a581:b029:cf:9367:8d9d with SMTP id az1-20020a170902a581b02900cf93678d9dmr12989758plb.0.1599355545304; Sat, 05 Sep 2020 18:25:45 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id w206sm3070386pfc.1.2020.09.05.18.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 18:25:44 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com, bvanassche@acm.org Cc: stern@rowland.harvard.edu.com, 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:25:12 +0800 Message-Id: <20200906012512.1428-4-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200906012512.1428-1-tom.ty89@gmail.com> References: <20200906012512.1428-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)