From patchwork Fri Sep 4 20:05:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11758465 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 8B7F517FB for ; Fri, 4 Sep 2020 20:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B3762084D for ; Fri, 4 Sep 2020 20:06:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dEuI1hor" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgIDUGF (ORCPT ); Fri, 4 Sep 2020 16:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgIDUGF (ORCPT ); Fri, 4 Sep 2020 16:06:05 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8FF0C061244 for ; Fri, 4 Sep 2020 13:06:04 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id b16so3711291pjp.0 for ; Fri, 04 Sep 2020 13:06:04 -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=dEuI1horz5xCF85dt1kA0LCWRa9Xe+drIHCSMp2Ny6oPEGSHyjyIgPVNHqPp3ZbBHF WLiKwbCE1muYrgMcHTbU9K4zIduV6f9vepv2iz+cC+XyHO6lNvt0+xxU38hocNb8vdJH 5joggfllSTgJ0Pqwpqv1j1kW/87OqsnyLac5PfAPQaP8lWXl43YbCGRwGwHP8P64IDQV +L25s6ZNbXtMLtNVFsNgwxqda25fBZ0mueTkDh4zClFCC2x14A8hpXp3mWNOdgWUjDgT M4GK35aYJJ1/2pOIRHO5Swr71D8Lj26uVOSn3fl+zNquKY/Vz+C5iYGzqwlF51/B2aVn fUow== 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=WRuFwcYt4a7vBKX57W3YD4vVuXLCYic7HRB3IX8rD3Xu9FS5McD0xVdsylJWtlP8r5 kkQfSmmRkJYsXSZLDkhDz+9/lqjuFZa2dAM8h3HScbAGn2/pFXsNwVA/KmUFcLwzjjys fCeKXvAYCDQaY5Np05jR3PPgc2jI3nOsihgYV85iMDZMundPSjcleoLA5XieOuL1vGWp mAxmhpUwS3OTe7k43F2abyEPiwMNk5N6E/cVukHNLECaNu7b1+TKzDcbLiF/f6tNKtH9 y/FCQhu+07pjGGLsdWcQWugJgeNOgG3njOIrLzlE/7o+j8g0HV3PlC5JBJEaX9FhvuNO LrsA== X-Gm-Message-State: AOAM531YpOb/s9ECD6sW0fekIFM8i1998aXRs9FWo0B4idlP7Tn02n9g jNt7dMJLpSmWa6njeeK7j6AOQlZKm3o= X-Google-Smtp-Source: ABdhPJxY6y5v6wylJFZV9jORtn0++LW3DnVrOByB0cCgZjp8soKYEyA4s5YRsXVEl+f6FlzILn1wMg== X-Received: by 2002:a17:90b:3014:: with SMTP id hg20mr7468352pjb.128.1599249963842; Fri, 04 Sep 2020 13:06:03 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id k5sm21131905pjl.3.2020.09.04.13.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 13:06:02 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com Cc: stern@rowland.harvard.edu, James.Bottomley@SteelEye.com, akinobu.mita@gmail.com, hch@lst.de, jens.axboe@oracle.com, Tom Yan Subject: [PATCH 1/4] scsi: sg: fix BLKSECTGET ioctl Date: Sat, 5 Sep 2020 04:05:51 +0800 Message-Id: <20200904200554.168979-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 Acked-by: Douglas Gilbert --- 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 Fri Sep 4 20:05:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11758467 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 63400112E for ; Fri, 4 Sep 2020 20:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 416E120665 for ; Fri, 4 Sep 2020 20:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LdZ1iew7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbgIDUGK (ORCPT ); Fri, 4 Sep 2020 16:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgIDUGI (ORCPT ); Fri, 4 Sep 2020 16:06:08 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C838FC061244 for ; Fri, 4 Sep 2020 13:06:08 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h2so1673925plr.0 for ; Fri, 04 Sep 2020 13:06:08 -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=LdZ1iew781MsmUY9b5ayzdV8tZn4cX+ULtEHpTLX2wxSqa3q1eCh2Rb0Vy10Is8vsF lqvvA9Y5FyVU4l2ni5ijNwJllCfyu/Qnzqm+C8Bt+PQk6pyKYOm4+/TtSWrK2tk4iq8p jn4hXE4r2/V429/yXum1WDMVpeiR3OXCmwh6LnDEnhqYn6tMQxrCYqck8lwfudsdCfla BptYvLVcR8IJt9d8H571KslUJDTGF2Yb1IqeNvzDv4hfbM+L6Qwy593y9i0XEYx7gz3g LezfpNYnqCZI9ccDXQMeIQ0s50pOgXZTaKa0+bXV/Mmb5QAOPUQ4Pasu/PfKq7pThqhA iiLQ== 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=nIp5HDARnxbPQSJZthLy5cQnGyFx6cr7VyioLTWOndKdpH3ohzlPh0Avo1tcqyDj0s 91q2MeplEFq9FxYXlkrDbhP8qSuqdh0btT/zYQ9FxKrqyoLmAz7qzYjpQgRI8bFs5CUE PQIumDXFKTAJgf9LMkl8ZM2rlxWgYWA0PcYj3kZZrUaWibAf+hBpf/liMzRs03wx3VYo IfAhtCmev1Ogcm+R4GpiQH0kIkc0/CWYbKo8xbrFM3+pjPCuSgNz9B1pj4T9E9fZ2vnC leHDOJI9sLohFFBR+CgUtupMjoa0KlOhY2zWKf294uP9m0L/ngn4SXZBVASclilgwdeH l8dw== X-Gm-Message-State: AOAM530Ypj29PgwjC0D0d8C4DKiTX1Zx4s6wuEaiGWlHhCDDcfQZyWZE JxsK6vf4LPpeXoTBTTtzwrk2NZ5SX74= X-Google-Smtp-Source: ABdhPJz1yHiYC4VvTFmAiQ0vmglbgBCb0gJtN9PCc/o+LHsUI4ZZnc38M7yHnUn8T7Jwjch9qqx3qw== X-Received: by 2002:a17:902:a60e:: with SMTP id u14mr10353745plq.179.1599249968026; Fri, 04 Sep 2020 13:06:08 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id k5sm21131905pjl.3.2020.09.04.13.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 13:06:07 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com Cc: stern@rowland.harvard.edu, James.Bottomley@SteelEye.com, akinobu.mita@gmail.com, hch@lst.de, jens.axboe@oracle.com, Tom Yan Subject: [PATCH 2/4] scsi: sg: implement BLKSSZGET Date: Sat, 5 Sep 2020 04:05:52 +0800 Message-Id: <20200904200554.168979-2-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904200554.168979-1-tom.ty89@gmail.com> References: <20200904200554.168979-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 Acked-by: Douglas Gilbert --- 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 Fri Sep 4 20:05:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11758469 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 985AB112E for ; Fri, 4 Sep 2020 20:06:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 794FA2087C for ; Fri, 4 Sep 2020 20:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jAGlZSlE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727855AbgIDUGN (ORCPT ); Fri, 4 Sep 2020 16:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgIDUGM (ORCPT ); Fri, 4 Sep 2020 16:06:12 -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 D063CC061244 for ; Fri, 4 Sep 2020 13:06:11 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id s10so1669579plp.1 for ; Fri, 04 Sep 2020 13:06:11 -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=jAGlZSlEVcbd43mtRZUEtflBOiKgmHEETXnSYUPQoQZ3/wBaeC/09c3tur/dwWnm5a Dn2C/FBR7BsFs3Jegl+/dTzY4NzhFtIVfrDC3kMu3eDfU7lqn3VLyIbcQbpR/5RhoW2e gwC784Av+1A64yihrBgAQOLosOh6j7JQ+giHJxFGJ6zU+3RnZK/XiP+2NiROXFyBl6zp 7l48N6s9fa690oVojbdw3MJ2GY4D0NH1Fqkn2XE/TtQa/MZRDKMJTSZarGBOuc+FESHu hyoAkykux3Osc9j0d0BX+xPlZN41N5AG4qbpUvqz6FFB+OMKaDISY29iUF35DeA3TJ7N eqFw== 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=VhcpkvcEYbd+5/y13a9n5rIcN2AjFupEc5N90ouLwUQAEHsLTLJ4nF08h9CFQIWsSs AP8Q5zi2RsHnZ3DaLzXSe7ZXy8YG3sw6czHtBHIrM3xyihkt3dilx5HrEuBdSNHZCMRQ qbYYJ0zl3+BqWIsbcntQxKEnIq45NS37LOMV5BQtRVUlWQMGc8sPHb+Y4wrCijYNCGzm 5U/lI0FDhQMrKyFo4GqwD9LSY4pxUb3l5sHO/ONqNFwGdg6ejw+hqjPLBOsoR10K10K2 kDWY8FpHiz0rbUo50T44ZlwEu4bHHtuIYsi9X95RVdPixnZbbFagBpnXd8C8rbEYMO8i j8jw== X-Gm-Message-State: AOAM532K36En+dJXHX9lpoRB/PF5D61AcGpM/zeCBRG8ghE0o2p6X4MZ vdY5RF69YXk4VMbNguxJwoshRO/bswk= X-Google-Smtp-Source: ABdhPJwlnJZ6d7IDPK1pENRPn9CV8VUXLyCCuFLGn5Xethn7+5WnqcQ7cSVf66PtrU5i7gb/fRqfbg== X-Received: by 2002:a17:90a:ac07:: with SMTP id o7mr9955161pjq.194.1599249971113; Fri, 04 Sep 2020 13:06:11 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id k5sm21131905pjl.3.2020.09.04.13.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 13:06:10 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com Cc: stern@rowland.harvard.edu, James.Bottomley@SteelEye.com, akinobu.mita@gmail.com, hch@lst.de, jens.axboe@oracle.com, Tom Yan Subject: [PATCH 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Date: Sat, 5 Sep 2020 04:05:53 +0800 Message-Id: <20200904200554.168979-3-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904200554.168979-1-tom.ty89@gmail.com> References: <20200904200554.168979-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 Acked-by: Douglas Gilbert --- 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 Fri Sep 4 20:05:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 11758471 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 75E78112E for ; Fri, 4 Sep 2020 20:06:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 593062084D for ; Fri, 4 Sep 2020 20:06:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XBkwK5CA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727923AbgIDUGU (ORCPT ); Fri, 4 Sep 2020 16:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgIDUGT (ORCPT ); Fri, 4 Sep 2020 16:06:19 -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 E9C4FC061244 for ; Fri, 4 Sep 2020 13:06:18 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id w186so4860810pgb.8 for ; Fri, 04 Sep 2020 13:06:18 -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=XBkwK5CA0CApuYZMzegPF4t+Xxim413gDj4R5lhx1BRnPYsKrDTq16u9Uv4rytwh4W xBhI35mqqC87mMXxzDoHPzu+S4QPnUtdQ4oxC2KfwOja4EGGj0qEggK/3q2YmVe2PO3u /rbCB4KfGkpwKehabVYBQ2lCFlRO/1UdxNQMBQ/Qob6gMo8YaBSsJHoxCgibBFRvMIwE q+4Kr6kGvD5twGcMVgb4x21RRj+Yo+dkyyAmKZpmDk/Iaq/Eqli+fsKZFFVjWx2KHtvU oIHsqDZ+OjwWBrKV8hlJxw4UbZnvPoxwJDm0X2mbZl/HK/8l3sTPcE/45/4uZCvI5Kct EUpQ== 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=l8DlelapmKox1zBpgFU+K3OFJMp4wY3+HusZOZrfMOO77Aiaikgv+dgSg13Idode8A 03d2ZKyw/oiAuiteGbby5Rm46/e9syU1Q84I1wWIicbCSAumhO5NigYoqlL//rgbZ06g jv/4jfF2eZeotsmpT59HxgaK1yNdHBKIR2LH+EK+/6Yl7jvukAwjhn2wOXEW764NfZpI uog/IHIlxRWTtv8mt2WrI6ymlvEQCQsZg5J8IXzEUbwu+5NmQVFvvNg/NtOgBMD49fpS b+YMqs27Lf9cg9rL1bjxBgCuYepuBXyc+Sbn6rWhNscZaNLiwXHTiVa0nzrCKjugtoPh 9yVg== X-Gm-Message-State: AOAM531v1bOqR7f2m6h68TSl5H5MxURjEWCG1BqQpktwoN7WuqvaEihX Poa4Jk/ViWuhLQJVQZ2iBaUZe0lwHBI= X-Google-Smtp-Source: ABdhPJxtgzwVWt89jgU4AKB3SpR+NtDBnBl8kMwQdX5yankr/j1IjHFyPMziNt5ixwnInA/C5lZdQQ== X-Received: by 2002:a63:e1f:: with SMTP id d31mr8723418pgl.262.1599249974143; Fri, 04 Sep 2020 13:06:14 -0700 (PDT) Received: from localhost.localdomain ([161.81.62.213]) by smtp.gmail.com with ESMTPSA id k5sm21131905pjl.3.2020.09.04.13.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 13:06:13 -0700 (PDT) From: Tom Yan To: linux-scsi@vger.kernel.org, dgilbert@interlog.com Cc: stern@rowland.harvard.edu, James.Bottomley@SteelEye.com, akinobu.mita@gmail.com, hch@lst.de, jens.axboe@oracle.com, Tom Yan Subject: [PATCH 4/4] block/scsi_ioctl.c: use queue_logical_sector_size() in max_sectors_bytes() Date: Sat, 5 Sep 2020 04:05:54 +0800 Message-Id: <20200904200554.168979-4-tom.ty89@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904200554.168979-1-tom.ty89@gmail.com> References: <20200904200554.168979-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 Reviewed-by: Douglas Gilbert --- 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)