diff options
-rw-r--r-- | block/compat_ioctl.c | 13 | ||||
-rw-r--r-- | block/ioctl.c | 17 | ||||
-rw-r--r-- | include/linux/blkdev.h | 35 | ||||
-rw-r--r-- | include/linux/fs.h | 4 |
4 files changed, 62 insertions, 7 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 7865a34e0faa..9bd086c1a4d5 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -21,6 +21,11 @@ static int compat_put_int(unsigned long arg, int val) | |||
21 | return put_user(val, (compat_int_t __user *)compat_ptr(arg)); | 21 | return put_user(val, (compat_int_t __user *)compat_ptr(arg)); |
22 | } | 22 | } |
23 | 23 | ||
24 | static int compat_put_uint(unsigned long arg, unsigned int val) | ||
25 | { | ||
26 | return put_user(val, (compat_uint_t __user *)compat_ptr(arg)); | ||
27 | } | ||
28 | |||
24 | static int compat_put_long(unsigned long arg, long val) | 29 | static int compat_put_long(unsigned long arg, long val) |
25 | { | 30 | { |
26 | return put_user(val, (compat_long_t __user *)compat_ptr(arg)); | 31 | return put_user(val, (compat_long_t __user *)compat_ptr(arg)); |
@@ -734,6 +739,14 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
734 | switch (cmd) { | 739 | switch (cmd) { |
735 | case HDIO_GETGEO: | 740 | case HDIO_GETGEO: |
736 | return compat_hdio_getgeo(disk, bdev, compat_ptr(arg)); | 741 | return compat_hdio_getgeo(disk, bdev, compat_ptr(arg)); |
742 | case BLKPBSZGET: | ||
743 | return compat_put_uint(arg, bdev_physical_block_size(bdev)); | ||
744 | case BLKIOMIN: | ||
745 | return compat_put_uint(arg, bdev_io_min(bdev)); | ||
746 | case BLKIOOPT: | ||
747 | return compat_put_uint(arg, bdev_io_opt(bdev)); | ||
748 | case BLKALIGNOFF: | ||
749 | return compat_put_int(arg, bdev_alignment_offset(bdev)); | ||
737 | case BLKFLSBUF: | 750 | case BLKFLSBUF: |
738 | case BLKROSET: | 751 | case BLKROSET: |
739 | case BLKDISCARD: | 752 | case BLKDISCARD: |
diff --git a/block/ioctl.c b/block/ioctl.c index d3e6b5827a34..1f4d1de12b09 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -138,6 +138,11 @@ static int put_int(unsigned long arg, int val) | |||
138 | return put_user(val, (int __user *)arg); | 138 | return put_user(val, (int __user *)arg); |
139 | } | 139 | } |
140 | 140 | ||
141 | static int put_uint(unsigned long arg, unsigned int val) | ||
142 | { | ||
143 | return put_user(val, (unsigned int __user *)arg); | ||
144 | } | ||
145 | |||
141 | static int put_long(unsigned long arg, long val) | 146 | static int put_long(unsigned long arg, long val) |
142 | { | 147 | { |
143 | return put_user(val, (long __user *)arg); | 148 | return put_user(val, (long __user *)arg); |
@@ -263,10 +268,18 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, | |||
263 | return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512); | 268 | return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512); |
264 | case BLKROGET: | 269 | case BLKROGET: |
265 | return put_int(arg, bdev_read_only(bdev) != 0); | 270 | return put_int(arg, bdev_read_only(bdev) != 0); |
266 | case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */ | 271 | case BLKBSZGET: /* get block device soft block size (cf. BLKSSZGET) */ |
267 | return put_int(arg, block_size(bdev)); | 272 | return put_int(arg, block_size(bdev)); |
268 | case BLKSSZGET: /* get block device hardware sector size */ | 273 | case BLKSSZGET: /* get block device logical block size */ |
269 | return put_int(arg, bdev_logical_block_size(bdev)); | 274 | return put_int(arg, bdev_logical_block_size(bdev)); |
275 | case BLKPBSZGET: /* get block device physical block size */ | ||
276 | return put_uint(arg, bdev_physical_block_size(bdev)); | ||
277 | case BLKIOMIN: | ||
278 | return put_uint(arg, bdev_io_min(bdev)); | ||
279 | case BLKIOOPT: | ||
280 | return put_uint(arg, bdev_io_opt(bdev)); | ||
281 | case BLKALIGNOFF: | ||
282 | return put_int(arg, bdev_alignment_offset(bdev)); | ||
270 | case BLKSECTGET: | 283 | case BLKSECTGET: |
271 | return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev))); | 284 | return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev))); |
272 | case BLKRASET: | 285 | case BLKRASET: |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a7323930d2ba..25119041e034 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1081,25 +1081,37 @@ static inline unsigned int queue_physical_block_size(struct request_queue *q) | |||
1081 | return q->limits.physical_block_size; | 1081 | return q->limits.physical_block_size; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | static inline int bdev_physical_block_size(struct block_device *bdev) | ||
1085 | { | ||
1086 | return queue_physical_block_size(bdev_get_queue(bdev)); | ||
1087 | } | ||
1088 | |||
1084 | static inline unsigned int queue_io_min(struct request_queue *q) | 1089 | static inline unsigned int queue_io_min(struct request_queue *q) |
1085 | { | 1090 | { |
1086 | return q->limits.io_min; | 1091 | return q->limits.io_min; |
1087 | } | 1092 | } |
1088 | 1093 | ||
1094 | static inline int bdev_io_min(struct block_device *bdev) | ||
1095 | { | ||
1096 | return queue_io_min(bdev_get_queue(bdev)); | ||
1097 | } | ||
1098 | |||
1089 | static inline unsigned int queue_io_opt(struct request_queue *q) | 1099 | static inline unsigned int queue_io_opt(struct request_queue *q) |
1090 | { | 1100 | { |
1091 | return q->limits.io_opt; | 1101 | return q->limits.io_opt; |
1092 | } | 1102 | } |
1093 | 1103 | ||
1104 | static inline int bdev_io_opt(struct block_device *bdev) | ||
1105 | { | ||
1106 | return queue_io_opt(bdev_get_queue(bdev)); | ||
1107 | } | ||
1108 | |||
1094 | static inline int queue_alignment_offset(struct request_queue *q) | 1109 | static inline int queue_alignment_offset(struct request_queue *q) |
1095 | { | 1110 | { |
1096 | if (q && q->limits.misaligned) | 1111 | if (q->limits.misaligned) |
1097 | return -1; | 1112 | return -1; |
1098 | 1113 | ||
1099 | if (q && q->limits.alignment_offset) | 1114 | return q->limits.alignment_offset; |
1100 | return q->limits.alignment_offset; | ||
1101 | |||
1102 | return 0; | ||
1103 | } | 1115 | } |
1104 | 1116 | ||
1105 | static inline int queue_sector_alignment_offset(struct request_queue *q, | 1117 | static inline int queue_sector_alignment_offset(struct request_queue *q, |
@@ -1109,6 +1121,19 @@ static inline int queue_sector_alignment_offset(struct request_queue *q, | |||
1109 | & (q->limits.io_min - 1); | 1121 | & (q->limits.io_min - 1); |
1110 | } | 1122 | } |
1111 | 1123 | ||
1124 | static inline int bdev_alignment_offset(struct block_device *bdev) | ||
1125 | { | ||
1126 | struct request_queue *q = bdev_get_queue(bdev); | ||
1127 | |||
1128 | if (q->limits.misaligned) | ||
1129 | return -1; | ||
1130 | |||
1131 | if (bdev != bdev->bd_contains) | ||
1132 | return bdev->bd_part->alignment_offset; | ||
1133 | |||
1134 | return q->limits.alignment_offset; | ||
1135 | } | ||
1136 | |||
1112 | static inline int queue_dma_alignment(struct request_queue *q) | 1137 | static inline int queue_dma_alignment(struct request_queue *q) |
1113 | { | 1138 | { |
1114 | return q ? q->dma_alignment : 511; | 1139 | return q ? q->dma_alignment : 511; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 2adaa2529f18..883eaacfd924 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -300,6 +300,10 @@ struct inodes_stat_t { | |||
300 | #define BLKTRACESTOP _IO(0x12,117) | 300 | #define BLKTRACESTOP _IO(0x12,117) |
301 | #define BLKTRACETEARDOWN _IO(0x12,118) | 301 | #define BLKTRACETEARDOWN _IO(0x12,118) |
302 | #define BLKDISCARD _IO(0x12,119) | 302 | #define BLKDISCARD _IO(0x12,119) |
303 | #define BLKIOMIN _IO(0x12,120) | ||
304 | #define BLKIOOPT _IO(0x12,121) | ||
305 | #define BLKALIGNOFF _IO(0x12,122) | ||
306 | #define BLKPBSZGET _IO(0x12,123) | ||
303 | 307 | ||
304 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ | 308 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ |
305 | #define FIBMAP _IO(0x00,1) /* bmap access */ | 309 | #define FIBMAP _IO(0x00,1) /* bmap access */ |