aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorWill Drewry <wad@chromium.org>2010-08-31 16:47:05 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-09-15 10:13:18 -0400
commit6d1d8050b4bc89d0165d29b58e894aeba2564a97 (patch)
treeb5c5b730bd7b80fe9041c031a6fcf08f42fff0d5 /include/linux/genhd.h
parent144177991ca624841ddbd1e7edff958fc0f6d1fe (diff)
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>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h53
1 files changed, 51 insertions, 2 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 5f2f4c4d8fb0..66e26b5a1537 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
94struct partition_meta_info {
95 u8 uuid[PARTITION_META_INFO_UUIDLTH]; /* always big endian */
96 u8 volname[PARTITION_META_INFO_VOLNAMELTH];
97};
98
90struct hd_struct { 99struct 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
@@ -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
194static 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
212static inline char *part_unpack_uuid(const u8 *uuid, char *out)
213{
214 sprintf(out, "%pU", uuid);
215 return out;
216}
217
184static inline int disk_max_parts(struct gendisk *disk) 218static 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
379static 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
387static 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 */
346extern void part_round_stats(int cpu, struct hd_struct *part); 393extern 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);
533extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 580extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
534extern struct hd_struct * __must_check add_partition(struct gendisk *disk, 581extern 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);
537extern void delete_partition(struct gendisk *, int); 586extern void delete_partition(struct gendisk *, int);
538extern void printk_all_partitions(void); 587extern void printk_all_partitions(void);
539 588