Commit 6d1d8050b4bc89d0165d29b58e894aeba2564a97
block, partition: add partition_meta_info to hd_struct
I'm reposting this patch series as v4 since there have been no additional comments, and I cleaned up one extra bit of unneeded code (in 3/3). The patches are against Linus's tree: 2bfc96a127bc1cc94d26bfaa40159966064f9c8c (2.6.36-rc3). Would this patchset be suitable for inclusion in an mm branch? This changes adds a partition_meta_info struct which itself contains a union of structures that provide partition table specific metadata. This change leaves the union empty. The subsequent patch includes an implementation for CONFIG_EFI_PARTITION-based metadata. Signed-off-by: Will Drewry <wad@chromium.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Showing 5 changed files with 76 additions and 6 deletions Side-by-side Diff
... | ... | @@ -352,6 +352,7 @@ |
352 | 352 | { |
353 | 353 | struct hd_struct *p = dev_to_part(dev); |
354 | 354 | free_part_stats(p); |
355 | + free_part_info(p); | |
355 | 356 | kfree(p); |
356 | 357 | } |
357 | 358 | |
... | ... | @@ -401,7 +402,8 @@ |
401 | 402 | whole_disk_show, NULL); |
402 | 403 | |
403 | 404 | struct hd_struct *add_partition(struct gendisk *disk, int partno, |
404 | - sector_t start, sector_t len, int flags) | |
405 | + sector_t start, sector_t len, int flags, | |
406 | + struct partition_meta_info *info) | |
405 | 407 | { |
406 | 408 | struct hd_struct *p; |
407 | 409 | dev_t devt = MKDEV(0, 0); |
... | ... | @@ -438,6 +440,14 @@ |
438 | 440 | p->partno = partno; |
439 | 441 | p->policy = get_disk_ro(disk); |
440 | 442 | |
443 | + if (info) { | |
444 | + struct partition_meta_info *pinfo = alloc_part_info(disk); | |
445 | + if (!pinfo) | |
446 | + goto out_free_stats; | |
447 | + memcpy(pinfo, info, sizeof(*info)); | |
448 | + p->info = pinfo; | |
449 | + } | |
450 | + | |
441 | 451 | dname = dev_name(ddev); |
442 | 452 | if (isdigit(dname[strlen(dname) - 1])) |
443 | 453 | dev_set_name(pdev, "%sp%d", dname, partno); |
... | ... | @@ -451,7 +461,7 @@ |
451 | 461 | |
452 | 462 | err = blk_alloc_devt(p, &devt); |
453 | 463 | if (err) |
454 | - goto out_free_stats; | |
464 | + goto out_free_info; | |
455 | 465 | pdev->devt = devt; |
456 | 466 | |
457 | 467 | /* delay uevent until 'holders' subdir is created */ |
... | ... | @@ -481,6 +491,8 @@ |
481 | 491 | |
482 | 492 | return p; |
483 | 493 | |
494 | +out_free_info: | |
495 | + free_part_info(p); | |
484 | 496 | out_free_stats: |
485 | 497 | free_part_stats(p); |
486 | 498 | out_free: |
... | ... | @@ -642,6 +654,7 @@ |
642 | 654 | /* add partitions */ |
643 | 655 | for (p = 1; p < state->limit; p++) { |
644 | 656 | sector_t size, from; |
657 | + struct partition_meta_info *info = NULL; | |
645 | 658 | |
646 | 659 | size = state->parts[p].size; |
647 | 660 | if (!size) |
648 | 661 | |
... | ... | @@ -675,8 +688,12 @@ |
675 | 688 | size = get_capacity(disk) - from; |
676 | 689 | } |
677 | 690 | } |
691 | + | |
692 | + if (state->parts[p].has_info) | |
693 | + info = &state->parts[p].info; | |
678 | 694 | part = add_partition(disk, p, from, size, |
679 | - state->parts[p].flags); | |
695 | + state->parts[p].flags, | |
696 | + &state->parts[p].info); | |
680 | 697 | if (IS_ERR(part)) { |
681 | 698 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", |
682 | 699 | disk->disk_name, p, -PTR_ERR(part)); |
1 | 1 | #include <linux/pagemap.h> |
2 | 2 | #include <linux/blkdev.h> |
3 | +#include <linux/genhd.h> | |
3 | 4 | |
4 | 5 | /* |
5 | 6 | * add_gd_partition adds a partitions details to the devices partition |
... | ... | @@ -12,6 +13,8 @@ |
12 | 13 | sector_t from; |
13 | 14 | sector_t size; |
14 | 15 | int flags; |
16 | + bool has_info; | |
17 | + struct partition_meta_info info; | |
15 | 18 | } parts[DISK_MAX_PARTS]; |
16 | 19 | int next; |
17 | 20 | int limit; |
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | #include <linux/types.h> |
13 | 13 | #include <linux/kdev_t.h> |
14 | 14 | #include <linux/rcupdate.h> |
15 | +#include <linux/slab.h> | |
15 | 16 | |
16 | 17 | #ifdef CONFIG_BLOCK |
17 | 18 | |
... | ... | @@ -86,7 +87,15 @@ |
86 | 87 | unsigned long io_ticks; |
87 | 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 | 99 | struct hd_struct { |
91 | 100 | sector_t start_sect; |
92 | 101 | sector_t nr_sects; |
... | ... | @@ -95,6 +104,7 @@ |
95 | 104 | struct device __dev; |
96 | 105 | struct kobject *holder_dir; |
97 | 106 | int policy, partno; |
107 | + struct partition_meta_info *info; | |
98 | 108 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
99 | 109 | int make_it_fail; |
100 | 110 | #endif |
... | ... | @@ -181,6 +191,30 @@ |
181 | 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 | 218 | static inline int disk_max_parts(struct gendisk *disk) |
185 | 219 | { |
186 | 220 | if (disk->flags & GENHD_FL_EXT_DEVT) |
... | ... | @@ -342,6 +376,19 @@ |
342 | 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 | 392 | /* block/blk-core.c */ |
346 | 393 | extern void part_round_stats(int cpu, struct hd_struct *part); |
347 | 394 | |
... | ... | @@ -533,7 +580,9 @@ |
533 | 580 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
534 | 581 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, |
535 | 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 | 586 | extern void delete_partition(struct gendisk *, int); |
538 | 587 | extern void printk_all_partitions(void); |
539 | 588 |
-
mentioned in commit 19e404
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d
-
mentioned in commit 05c69d