diff options
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r-- | include/linux/genhd.h | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index ecd2bf63fc8..118216f1bd3 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -110,6 +110,14 @@ struct hd_struct { | |||
110 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 | 110 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 |
111 | #define GENHD_FL_FAIL 64 | 111 | #define GENHD_FL_FAIL 64 |
112 | 112 | ||
113 | #define BLK_SCSI_MAX_CMDS (256) | ||
114 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) | ||
115 | |||
116 | struct blk_scsi_cmd_filter { | ||
117 | unsigned long read_ok[BLK_SCSI_CMD_PER_LONG]; | ||
118 | unsigned long write_ok[BLK_SCSI_CMD_PER_LONG]; | ||
119 | struct kobject kobj; | ||
120 | }; | ||
113 | 121 | ||
114 | struct gendisk { | 122 | struct gendisk { |
115 | int major; /* major number of driver */ | 123 | int major; /* major number of driver */ |
@@ -120,6 +128,7 @@ struct gendisk { | |||
120 | struct hd_struct **part; /* [indexed by minor] */ | 128 | struct hd_struct **part; /* [indexed by minor] */ |
121 | struct block_device_operations *fops; | 129 | struct block_device_operations *fops; |
122 | struct request_queue *queue; | 130 | struct request_queue *queue; |
131 | struct blk_scsi_cmd_filter cmd_filter; | ||
123 | void *private_data; | 132 | void *private_data; |
124 | sector_t capacity; | 133 | sector_t capacity; |
125 | 134 | ||
@@ -141,6 +150,9 @@ struct gendisk { | |||
141 | struct disk_stats dkstats; | 150 | struct disk_stats dkstats; |
142 | #endif | 151 | #endif |
143 | struct work_struct async_notify; | 152 | struct work_struct async_notify; |
153 | #ifdef CONFIG_BLK_DEV_INTEGRITY | ||
154 | struct blk_integrity *integrity; | ||
155 | #endif | ||
144 | }; | 156 | }; |
145 | 157 | ||
146 | /* | 158 | /* |
@@ -178,17 +190,17 @@ static inline struct hd_struct *get_part(struct gendisk *gendiskp, | |||
178 | 190 | ||
179 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { | 191 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { |
180 | int i; | 192 | int i; |
193 | |||
181 | for_each_possible_cpu(i) | 194 | for_each_possible_cpu(i) |
182 | memset(per_cpu_ptr(gendiskp->dkstats, i), value, | 195 | memset(per_cpu_ptr(gendiskp->dkstats, i), value, |
183 | sizeof (struct disk_stats)); | 196 | sizeof(struct disk_stats)); |
184 | } | 197 | } |
185 | 198 | ||
186 | #define __part_stat_add(part, field, addnd) \ | 199 | #define __part_stat_add(part, field, addnd) \ |
187 | (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd) | 200 | (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd) |
188 | 201 | ||
189 | #define __all_stat_add(gendiskp, field, addnd, sector) \ | 202 | #define __all_stat_add(gendiskp, part, field, addnd, sector) \ |
190 | ({ \ | 203 | ({ \ |
191 | struct hd_struct *part = get_part(gendiskp, sector); \ | ||
192 | if (part) \ | 204 | if (part) \ |
193 | __part_stat_add(part, field, addnd); \ | 205 | __part_stat_add(part, field, addnd); \ |
194 | __disk_stat_add(gendiskp, field, addnd); \ | 206 | __disk_stat_add(gendiskp, field, addnd); \ |
@@ -203,11 +215,13 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { | |||
203 | res; \ | 215 | res; \ |
204 | }) | 216 | }) |
205 | 217 | ||
206 | static inline void part_stat_set_all(struct hd_struct *part, int value) { | 218 | static inline void part_stat_set_all(struct hd_struct *part, int value) |
219 | { | ||
207 | int i; | 220 | int i; |
221 | |||
208 | for_each_possible_cpu(i) | 222 | for_each_possible_cpu(i) |
209 | memset(per_cpu_ptr(part->dkstats, i), value, | 223 | memset(per_cpu_ptr(part->dkstats, i), value, |
210 | sizeof(struct disk_stats)); | 224 | sizeof(struct disk_stats)); |
211 | } | 225 | } |
212 | 226 | ||
213 | #else /* !CONFIG_SMP */ | 227 | #else /* !CONFIG_SMP */ |
@@ -223,9 +237,8 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) | |||
223 | #define __part_stat_add(part, field, addnd) \ | 237 | #define __part_stat_add(part, field, addnd) \ |
224 | (part->dkstats.field += addnd) | 238 | (part->dkstats.field += addnd) |
225 | 239 | ||
226 | #define __all_stat_add(gendiskp, field, addnd, sector) \ | 240 | #define __all_stat_add(gendiskp, part, field, addnd, sector) \ |
227 | ({ \ | 241 | ({ \ |
228 | struct hd_struct *part = get_part(gendiskp, sector); \ | ||
229 | if (part) \ | 242 | if (part) \ |
230 | part->dkstats.field += addnd; \ | 243 | part->dkstats.field += addnd; \ |
231 | __disk_stat_add(gendiskp, field, addnd); \ | 244 | __disk_stat_add(gendiskp, field, addnd); \ |
@@ -276,10 +289,10 @@ static inline void part_stat_set_all(struct hd_struct *part, int value) | |||
276 | #define part_stat_sub(gendiskp, field, subnd) \ | 289 | #define part_stat_sub(gendiskp, field, subnd) \ |
277 | part_stat_add(gendiskp, field, -subnd) | 290 | part_stat_add(gendiskp, field, -subnd) |
278 | 291 | ||
279 | #define all_stat_add(gendiskp, field, addnd, sector) \ | 292 | #define all_stat_add(gendiskp, part, field, addnd, sector) \ |
280 | do { \ | 293 | do { \ |
281 | preempt_disable(); \ | 294 | preempt_disable(); \ |
282 | __all_stat_add(gendiskp, field, addnd, sector); \ | 295 | __all_stat_add(gendiskp, part, field, addnd, sector); \ |
283 | preempt_enable(); \ | 296 | preempt_enable(); \ |
284 | } while (0) | 297 | } while (0) |
285 | 298 | ||
@@ -288,15 +301,15 @@ static inline void part_stat_set_all(struct hd_struct *part, int value) | |||
288 | #define all_stat_dec(gendiskp, field, sector) \ | 301 | #define all_stat_dec(gendiskp, field, sector) \ |
289 | all_stat_add(gendiskp, field, -1, sector) | 302 | all_stat_add(gendiskp, field, -1, sector) |
290 | 303 | ||
291 | #define __all_stat_inc(gendiskp, field, sector) \ | 304 | #define __all_stat_inc(gendiskp, part, field, sector) \ |
292 | __all_stat_add(gendiskp, field, 1, sector) | 305 | __all_stat_add(gendiskp, part, field, 1, sector) |
293 | #define all_stat_inc(gendiskp, field, sector) \ | 306 | #define all_stat_inc(gendiskp, part, field, sector) \ |
294 | all_stat_add(gendiskp, field, 1, sector) | 307 | all_stat_add(gendiskp, part, field, 1, sector) |
295 | 308 | ||
296 | #define __all_stat_sub(gendiskp, field, subnd, sector) \ | 309 | #define __all_stat_sub(gendiskp, part, field, subnd, sector) \ |
297 | __all_stat_add(gendiskp, field, -subnd, sector) | 310 | __all_stat_add(gendiskp, part, field, -subnd, sector) |
298 | #define all_stat_sub(gendiskp, field, subnd, sector) \ | 311 | #define all_stat_sub(gendiskp, part, field, subnd, sector) \ |
299 | all_stat_add(gendiskp, field, -subnd, sector) | 312 | all_stat_add(gendiskp, part, field, -subnd, sector) |
300 | 313 | ||
301 | /* Inlines to alloc and free disk stats in struct gendisk */ | 314 | /* Inlines to alloc and free disk stats in struct gendisk */ |
302 | #ifdef CONFIG_SMP | 315 | #ifdef CONFIG_SMP |
@@ -524,11 +537,11 @@ struct unixware_disklabel { | |||
524 | #define ADDPART_FLAG_RAID 1 | 537 | #define ADDPART_FLAG_RAID 1 |
525 | #define ADDPART_FLAG_WHOLEDISK 2 | 538 | #define ADDPART_FLAG_WHOLEDISK 2 |
526 | 539 | ||
527 | extern dev_t blk_lookup_devt(const char *name); | 540 | extern dev_t blk_lookup_devt(const char *name, int part); |
528 | extern char *disk_name (struct gendisk *hd, int part, char *buf); | 541 | extern char *disk_name (struct gendisk *hd, int part, char *buf); |
529 | 542 | ||
530 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 543 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
531 | extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); | 544 | extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); |
532 | extern void delete_partition(struct gendisk *, int); | 545 | extern void delete_partition(struct gendisk *, int); |
533 | extern void printk_all_partitions(void); | 546 | extern void printk_all_partitions(void); |
534 | 547 | ||
@@ -552,7 +565,7 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | |||
552 | 565 | ||
553 | static inline void printk_all_partitions(void) { } | 566 | static inline void printk_all_partitions(void) { } |
554 | 567 | ||
555 | static inline dev_t blk_lookup_devt(const char *name) | 568 | static inline dev_t blk_lookup_devt(const char *name, int part) |
556 | { | 569 | { |
557 | dev_t devt = MKDEV(0, 0); | 570 | dev_t devt = MKDEV(0, 0); |
558 | return devt; | 571 | return devt; |