diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 13:45:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 13:45:01 -0500 |
commit | 275220f0fcff1adf28a717076e00f575edf05fda (patch) | |
tree | d249bccc80c64443dab211639050c4fb14332648 /include/linux/genhd.h | |
parent | fe3c560b8a22cb28e54fe8950abef38e88d75831 (diff) | |
parent | 81c5e2ae33c4b19e53966b427e33646bf6811830 (diff) |
Merge branch 'for-2.6.38/core' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.38/core' of git://git.kernel.dk/linux-2.6-block: (43 commits)
block: ensure that completion error gets properly traced
blktrace: add missing probe argument to block_bio_complete
block cfq: don't use atomic_t for cfq_group
block cfq: don't use atomic_t for cfq_queue
block: trace event block fix unassigned field
block: add internal hd part table references
block: fix accounting bug on cross partition merges
kref: add kref_test_and_get
bio-integrity: mark kintegrityd_wq highpri and CPU intensive
block: make kblockd_workqueue smarter
Revert "sd: implement sd_check_events()"
block: Clean up exit_io_context() source code.
Fix compile warnings due to missing removal of a 'ret' variable
fs/block: type signature of major_to_index(int) to major_to_index(unsigned)
block: convert !IS_ERR(p) && p to !IS_ERR_NOR_NULL(p)
cfq-iosched: don't check cfqg in choose_service_tree()
fs/splice: Pull buf->ops->confirm() from splice_from_pipe actors
cdrom: export cdrom_check_events()
sd: implement sd_check_events()
sr: implement sr_check_events()
...
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r-- | include/linux/genhd.h | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 7a7b9c1644e4..c0d5f6945c1e 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -115,6 +115,7 @@ struct hd_struct { | |||
115 | #else | 115 | #else |
116 | struct disk_stats dkstats; | 116 | struct disk_stats dkstats; |
117 | #endif | 117 | #endif |
118 | atomic_t ref; | ||
118 | struct rcu_head rcu_head; | 119 | struct rcu_head rcu_head; |
119 | }; | 120 | }; |
120 | 121 | ||
@@ -127,6 +128,11 @@ struct hd_struct { | |||
127 | #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ | 128 | #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ |
128 | #define GENHD_FL_NATIVE_CAPACITY 128 | 129 | #define GENHD_FL_NATIVE_CAPACITY 128 |
129 | 130 | ||
131 | enum { | ||
132 | DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ | ||
133 | DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */ | ||
134 | }; | ||
135 | |||
130 | #define BLK_SCSI_MAX_CMDS (256) | 136 | #define BLK_SCSI_MAX_CMDS (256) |
131 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) | 137 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) |
132 | 138 | ||
@@ -143,6 +149,8 @@ struct disk_part_tbl { | |||
143 | struct hd_struct __rcu *part[]; | 149 | struct hd_struct __rcu *part[]; |
144 | }; | 150 | }; |
145 | 151 | ||
152 | struct disk_events; | ||
153 | |||
146 | struct gendisk { | 154 | struct gendisk { |
147 | /* major, first_minor and minors are input parameters only, | 155 | /* major, first_minor and minors are input parameters only, |
148 | * don't use directly. Use disk_devt() and disk_max_parts(). | 156 | * don't use directly. Use disk_devt() and disk_max_parts(). |
@@ -154,6 +162,10 @@ struct gendisk { | |||
154 | 162 | ||
155 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ | 163 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ |
156 | char *(*devnode)(struct gendisk *gd, mode_t *mode); | 164 | char *(*devnode)(struct gendisk *gd, mode_t *mode); |
165 | |||
166 | unsigned int events; /* supported events */ | ||
167 | unsigned int async_events; /* async events, subset of all */ | ||
168 | |||
157 | /* Array of pointers to partitions indexed by partno. | 169 | /* Array of pointers to partitions indexed by partno. |
158 | * Protected with matching bdev lock but stat and other | 170 | * Protected with matching bdev lock but stat and other |
159 | * non-critical accesses use RCU. Always access through | 171 | * non-critical accesses use RCU. Always access through |
@@ -171,9 +183,8 @@ struct gendisk { | |||
171 | struct kobject *slave_dir; | 183 | struct kobject *slave_dir; |
172 | 184 | ||
173 | struct timer_rand_state *random; | 185 | struct timer_rand_state *random; |
174 | |||
175 | atomic_t sync_io; /* RAID */ | 186 | atomic_t sync_io; /* RAID */ |
176 | struct work_struct async_notify; | 187 | struct disk_events *ev; |
177 | #ifdef CONFIG_BLK_DEV_INTEGRITY | 188 | #ifdef CONFIG_BLK_DEV_INTEGRITY |
178 | struct blk_integrity *integrity; | 189 | struct blk_integrity *integrity; |
179 | #endif | 190 | #endif |
@@ -395,7 +406,6 @@ extern void part_round_stats(int cpu, struct hd_struct *part); | |||
395 | /* block/genhd.c */ | 406 | /* block/genhd.c */ |
396 | extern void add_disk(struct gendisk *disk); | 407 | extern void add_disk(struct gendisk *disk); |
397 | extern void del_gendisk(struct gendisk *gp); | 408 | extern void del_gendisk(struct gendisk *gp); |
398 | extern void unlink_gendisk(struct gendisk *gp); | ||
399 | extern struct gendisk *get_gendisk(dev_t dev, int *partno); | 409 | extern struct gendisk *get_gendisk(dev_t dev, int *partno); |
400 | extern struct block_device *bdget_disk(struct gendisk *disk, int partno); | 410 | extern struct block_device *bdget_disk(struct gendisk *disk, int partno); |
401 | 411 | ||
@@ -407,6 +417,11 @@ static inline int get_disk_ro(struct gendisk *disk) | |||
407 | return disk->part0.policy; | 417 | return disk->part0.policy; |
408 | } | 418 | } |
409 | 419 | ||
420 | extern void disk_block_events(struct gendisk *disk); | ||
421 | extern void disk_unblock_events(struct gendisk *disk); | ||
422 | extern void disk_check_events(struct gendisk *disk); | ||
423 | extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask); | ||
424 | |||
410 | /* drivers/char/random.c */ | 425 | /* drivers/char/random.c */ |
411 | extern void add_disk_randomness(struct gendisk *disk); | 426 | extern void add_disk_randomness(struct gendisk *disk); |
412 | extern void rand_initialize_disk(struct gendisk *disk); | 427 | extern void rand_initialize_disk(struct gendisk *disk); |
@@ -583,6 +598,7 @@ extern struct hd_struct * __must_check add_partition(struct gendisk *disk, | |||
583 | sector_t len, int flags, | 598 | sector_t len, int flags, |
584 | struct partition_meta_info | 599 | struct partition_meta_info |
585 | *info); | 600 | *info); |
601 | extern void __delete_partition(struct hd_struct *); | ||
586 | extern void delete_partition(struct gendisk *, int); | 602 | extern void delete_partition(struct gendisk *, int); |
587 | extern void printk_all_partitions(void); | 603 | extern void printk_all_partitions(void); |
588 | 604 | ||
@@ -611,6 +627,29 @@ extern ssize_t part_fail_store(struct device *dev, | |||
611 | const char *buf, size_t count); | 627 | const char *buf, size_t count); |
612 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ | 628 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ |
613 | 629 | ||
630 | static inline void hd_ref_init(struct hd_struct *part) | ||
631 | { | ||
632 | atomic_set(&part->ref, 1); | ||
633 | smp_mb(); | ||
634 | } | ||
635 | |||
636 | static inline void hd_struct_get(struct hd_struct *part) | ||
637 | { | ||
638 | atomic_inc(&part->ref); | ||
639 | smp_mb__after_atomic_inc(); | ||
640 | } | ||
641 | |||
642 | static inline int hd_struct_try_get(struct hd_struct *part) | ||
643 | { | ||
644 | return atomic_inc_not_zero(&part->ref); | ||
645 | } | ||
646 | |||
647 | static inline void hd_struct_put(struct hd_struct *part) | ||
648 | { | ||
649 | if (atomic_dec_and_test(&part->ref)) | ||
650 | __delete_partition(part); | ||
651 | } | ||
652 | |||
614 | #else /* CONFIG_BLOCK */ | 653 | #else /* CONFIG_BLOCK */ |
615 | 654 | ||
616 | static inline void printk_all_partitions(void) { } | 655 | static inline void printk_all_partitions(void) { } |