summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-07-24 09:20:21 +0200
committerMartin K. Petersen <martin.petersen@oracle.com>2021-07-29 04:24:25 +0200
commit547e2f7093b19a993d76c249b4c3ec8af8127d09 (patch)
treeea1d8388ce3da300fba114a07763d2c8779cb87b /block
parentscsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl() (diff)
downloadlinux-547e2f7093b19a993d76c249b4c3ec8af8127d09.tar.xz
linux-547e2f7093b19a993d76c249b4c3ec8af8127d09.zip
scsi: block: Add a queue_max_bytes() helper
Return the max_sectors value in bytes. Lifted from scsi_ioctl.c. Link: https://lore.kernel.org/r/20210724072033.1284840-13-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/scsi_ioctl.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index ca7b84452d9d..c3871529e283 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -68,18 +68,9 @@ static int sg_set_timeout(struct request_queue *q, int __user *p)
return err;
}
-static int max_sectors_bytes(struct request_queue *q)
-{
- unsigned int max_sectors = queue_max_sectors(q);
-
- max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9);
-
- return max_sectors << 9;
-}
-
static int sg_get_reserved_size(struct request_queue *q, int __user *p)
{
- int val = min_t(int, q->sg_reserved_size, max_sectors_bytes(q));
+ int val = min(q->sg_reserved_size, queue_max_bytes(q));
return put_user(val, p);
}
@@ -94,7 +85,7 @@ static int sg_set_reserved_size(struct request_queue *q, int __user *p)
if (size < 0)
return -EINVAL;
- q->sg_reserved_size = min(size, max_sectors_bytes(q));
+ q->sg_reserved_size = min_t(unsigned int, size, queue_max_bytes(q));
return 0;
}