diff options
Diffstat (limited to 'include/linux/genhd.h')
| -rw-r--r-- | include/linux/genhd.h | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 5f2f4c4d8fb0..7a7b9c1644e4 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
| 13 | #include <linux/kdev_t.h> | 13 | #include <linux/kdev_t.h> |
| 14 | #include <linux/rcupdate.h> | 14 | #include <linux/rcupdate.h> |
| 15 | #include <linux/slab.h> | ||
| 15 | 16 | ||
| 16 | #ifdef CONFIG_BLOCK | 17 | #ifdef CONFIG_BLOCK |
| 17 | 18 | ||
| @@ -86,7 +87,15 @@ struct disk_stats { | |||
| 86 | unsigned long io_ticks; | 87 | unsigned long io_ticks; |
| 87 | unsigned long time_in_queue; | 88 | unsigned long time_in_queue; |
| 88 | }; | 89 | }; |
| 89 | 90 | ||
| 91 | #define PARTITION_META_INFO_VOLNAMELTH 64 | ||
| 92 | #define PARTITION_META_INFO_UUIDLTH 16 | ||
| 93 | |||
| 94 | struct partition_meta_info { | ||
| 95 | u8 uuid[PARTITION_META_INFO_UUIDLTH]; /* always big endian */ | ||
| 96 | u8 volname[PARTITION_META_INFO_VOLNAMELTH]; | ||
| 97 | }; | ||
| 98 | |||
| 90 | struct hd_struct { | 99 | struct hd_struct { |
| 91 | sector_t start_sect; | 100 | sector_t start_sect; |
| 92 | sector_t nr_sects; | 101 | sector_t nr_sects; |
| @@ -95,6 +104,7 @@ struct hd_struct { | |||
| 95 | struct device __dev; | 104 | struct device __dev; |
| 96 | struct kobject *holder_dir; | 105 | struct kobject *holder_dir; |
| 97 | int policy, partno; | 106 | int policy, partno; |
| 107 | struct partition_meta_info *info; | ||
| 98 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 108 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
| 99 | int make_it_fail; | 109 | int make_it_fail; |
| 100 | #endif | 110 | #endif |
| @@ -129,8 +139,8 @@ struct blk_scsi_cmd_filter { | |||
| 129 | struct disk_part_tbl { | 139 | struct disk_part_tbl { |
| 130 | struct rcu_head rcu_head; | 140 | struct rcu_head rcu_head; |
| 131 | int len; | 141 | int len; |
| 132 | struct hd_struct *last_lookup; | 142 | struct hd_struct __rcu *last_lookup; |
| 133 | struct hd_struct *part[]; | 143 | struct hd_struct __rcu *part[]; |
| 134 | }; | 144 | }; |
| 135 | 145 | ||
| 136 | struct gendisk { | 146 | struct gendisk { |
| @@ -149,7 +159,7 @@ struct gendisk { | |||
| 149 | * non-critical accesses use RCU. Always access through | 159 | * non-critical accesses use RCU. Always access through |
| 150 | * helpers. | 160 | * helpers. |
| 151 | */ | 161 | */ |
| 152 | struct disk_part_tbl *part_tbl; | 162 | struct disk_part_tbl __rcu *part_tbl; |
| 153 | struct hd_struct part0; | 163 | struct hd_struct part0; |
| 154 | 164 | ||
| 155 | const struct block_device_operations *fops; | 165 | const struct block_device_operations *fops; |
| @@ -181,6 +191,30 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part) | |||
| 181 | return NULL; | 191 | return NULL; |
| 182 | } | 192 | } |
| 183 | 193 | ||
| 194 | static inline void part_pack_uuid(const u8 *uuid_str, u8 *to) | ||
| 195 | { | ||
| 196 | int i; | ||
| 197 | for (i = 0; i < 16; ++i) { | ||
| 198 | *to++ = (hex_to_bin(*uuid_str) << 4) | | ||
| 199 | (hex_to_bin(*(uuid_str + 1))); | ||
| 200 | uuid_str += 2; | ||
| 201 | switch (i) { | ||
| 202 | case 3: | ||
| 203 | case 5: | ||
| 204 | case 7: | ||
| 205 | case 9: | ||
| 206 | uuid_str++; | ||
| 207 | continue; | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline char *part_unpack_uuid(const u8 *uuid, char *out) | ||
| 213 | { | ||
| 214 | sprintf(out, "%pU", uuid); | ||
| 215 | return out; | ||
| 216 | } | ||
| 217 | |||
| 184 | static inline int disk_max_parts(struct gendisk *disk) | 218 | static inline int disk_max_parts(struct gendisk *disk) |
| 185 | { | 219 | { |
| 186 | if (disk->flags & GENHD_FL_EXT_DEVT) | 220 | if (disk->flags & GENHD_FL_EXT_DEVT) |
| @@ -342,6 +376,19 @@ static inline int part_in_flight(struct hd_struct *part) | |||
| 342 | return part->in_flight[0] + part->in_flight[1]; | 376 | return part->in_flight[0] + part->in_flight[1]; |
| 343 | } | 377 | } |
| 344 | 378 | ||
| 379 | static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk) | ||
| 380 | { | ||
| 381 | if (disk) | ||
| 382 | return kzalloc_node(sizeof(struct partition_meta_info), | ||
| 383 | GFP_KERNEL, disk->node_id); | ||
| 384 | return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL); | ||
| 385 | } | ||
| 386 | |||
| 387 | static inline void free_part_info(struct hd_struct *part) | ||
| 388 | { | ||
| 389 | kfree(part->info); | ||
| 390 | } | ||
| 391 | |||
| 345 | /* block/blk-core.c */ | 392 | /* block/blk-core.c */ |
| 346 | extern void part_round_stats(int cpu, struct hd_struct *part); | 393 | extern void part_round_stats(int cpu, struct hd_struct *part); |
| 347 | 394 | ||
| @@ -533,7 +580,9 @@ extern int disk_expand_part_tbl(struct gendisk *disk, int target); | |||
| 533 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 580 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
| 534 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, | 581 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, |
| 535 | int partno, sector_t start, | 582 | int partno, sector_t start, |
| 536 | sector_t len, int flags); | 583 | sector_t len, int flags, |
| 584 | struct partition_meta_info | ||
| 585 | *info); | ||
| 537 | extern void delete_partition(struct gendisk *, int); | 586 | extern void delete_partition(struct gendisk *, int); |
| 538 | extern void printk_all_partitions(void); | 587 | extern void printk_all_partitions(void); |
| 539 | 588 | ||
