mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
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>
This commit is contained in:
parent
2e27f576ab
commit
547e2f7093
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1373,6 +1373,11 @@ static inline unsigned int queue_max_sectors(const struct request_queue *q)
|
||||
return q->limits.max_sectors;
|
||||
}
|
||||
|
||||
static inline unsigned int queue_max_bytes(struct request_queue *q)
|
||||
{
|
||||
return min_t(unsigned int, queue_max_sectors(q), INT_MAX >> 9) << 9;
|
||||
}
|
||||
|
||||
static inline unsigned int queue_max_hw_sectors(const struct request_queue *q)
|
||||
{
|
||||
return q->limits.max_hw_sectors;
|
||||
|
Loading…
Reference in New Issue
Block a user