diff mbox series

[3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes()

Message ID 20200904200554.168979-3-tom.ty89@gmail.com (mailing list archive)
State Superseded
Headers show
Series [1/4] scsi: sg: fix BLKSECTGET ioctl | expand

Commit Message

Tom Yan Sept. 4, 2020, 8:05 p.m. UTC
Signed-off-by: Tom Yan <tom.ty89@gmail.com>
---
 drivers/scsi/sg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Douglas Gilbert Sept. 5, 2020, 6:37 p.m. UTC | #1
On 2020-09-04 4:05 p.m., Tom Yan wrote:
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> ---
>   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
>
diff mbox series

Patch

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