diff options
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r-- | include/linux/genhd.h | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index af3f06b41dc1..557c3927e70f 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 |
@@ -130,6 +140,7 @@ 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 __rcu *last_lookup; | 142 | struct hd_struct __rcu *last_lookup; |
143 | struct gendisk *disk; | ||
133 | struct hd_struct __rcu *part[]; | 144 | struct hd_struct __rcu *part[]; |
134 | }; | 145 | }; |
135 | 146 | ||
@@ -181,6 +192,30 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part) | |||
181 | return NULL; | 192 | return NULL; |
182 | } | 193 | } |
183 | 194 | ||
195 | static inline void part_pack_uuid(const u8 *uuid_str, u8 *to) | ||
196 | { | ||
197 | int i; | ||
198 | for (i = 0; i < 16; ++i) { | ||
199 | *to++ = (hex_to_bin(*uuid_str) << 4) | | ||
200 | (hex_to_bin(*(uuid_str + 1))); | ||
201 | uuid_str += 2; | ||
202 | switch (i) { | ||
203 | case 3: | ||
204 | case 5: | ||
205 | case 7: | ||
206 | case 9: | ||
207 | uuid_str++; | ||
208 | continue; | ||
209 | } | ||
210 | } | ||
211 | } | ||
212 | |||
213 | static inline char *part_unpack_uuid(const u8 *uuid, char *out) | ||
214 | { | ||
215 | sprintf(out, "%pU", uuid); | ||
216 | return out; | ||
217 | } | ||
218 | |||
184 | static inline int disk_max_parts(struct gendisk *disk) | 219 | static inline int disk_max_parts(struct gendisk *disk) |
185 | { | 220 | { |
186 | if (disk->flags & GENHD_FL_EXT_DEVT) | 221 | if (disk->flags & GENHD_FL_EXT_DEVT) |
@@ -342,6 +377,19 @@ static inline int part_in_flight(struct hd_struct *part) | |||
342 | return part->in_flight[0] + part->in_flight[1]; | 377 | return part->in_flight[0] + part->in_flight[1]; |
343 | } | 378 | } |
344 | 379 | ||
380 | static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk) | ||
381 | { | ||
382 | if (disk) | ||
383 | return kzalloc_node(sizeof(struct partition_meta_info), | ||
384 | GFP_KERNEL, disk->node_id); | ||
385 | return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL); | ||
386 | } | ||
387 | |||
388 | static inline void free_part_info(struct hd_struct *part) | ||
389 | { | ||
390 | kfree(part->info); | ||
391 | } | ||
392 | |||
345 | /* block/blk-core.c */ | 393 | /* block/blk-core.c */ |
346 | extern void part_round_stats(int cpu, struct hd_struct *part); | 394 | extern void part_round_stats(int cpu, struct hd_struct *part); |
347 | 395 | ||
@@ -533,7 +581,9 @@ extern int disk_expand_part_tbl(struct gendisk *disk, int target); | |||
533 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 581 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
534 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, | 582 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, |
535 | int partno, sector_t start, | 583 | int partno, sector_t start, |
536 | sector_t len, int flags); | 584 | sector_t len, int flags, |
585 | struct partition_meta_info | ||
586 | *info); | ||
537 | extern void delete_partition(struct gendisk *, int); | 587 | extern void delete_partition(struct gendisk *, int); |
538 | extern void printk_all_partitions(void); | 588 | extern void printk_all_partitions(void); |
539 | 589 | ||