@@ -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;
Return the max_sectors value in bytes. Lifted from scsi_ioctl.c. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/scsi_ioctl.c | 13 ++----------- include/linux/blkdev.h | 5 +++++ 2 files changed, 7 insertions(+), 11 deletions(-)