diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/genhd.h | 27 | ||||
-rw-r--r-- | include/linux/kref.h | 1 |
2 files changed, 25 insertions, 3 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 2ba2792a3dd4..2d0468145967 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -115,8 +115,8 @@ 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 | struct kref ref; | ||
120 | }; | 120 | }; |
121 | 121 | ||
122 | #define GENHD_FL_REMOVABLE 1 | 122 | #define GENHD_FL_REMOVABLE 1 |
@@ -584,7 +584,7 @@ extern struct hd_struct * __must_check add_partition(struct gendisk *disk, | |||
584 | sector_t len, int flags, | 584 | sector_t len, int flags, |
585 | struct partition_meta_info | 585 | struct partition_meta_info |
586 | *info); | 586 | *info); |
587 | extern void __delete_partition(struct kref *ref); | 587 | extern void __delete_partition(struct hd_struct *); |
588 | extern void delete_partition(struct gendisk *, int); | 588 | extern void delete_partition(struct gendisk *, int); |
589 | extern void printk_all_partitions(void); | 589 | extern void printk_all_partitions(void); |
590 | 590 | ||
@@ -613,6 +613,29 @@ extern ssize_t part_fail_store(struct device *dev, | |||
613 | const char *buf, size_t count); | 613 | const char *buf, size_t count); |
614 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ | 614 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ |
615 | 615 | ||
616 | static inline void hd_ref_init(struct hd_struct *part) | ||
617 | { | ||
618 | atomic_set(&part->ref, 1); | ||
619 | smp_mb(); | ||
620 | } | ||
621 | |||
622 | static inline void hd_struct_get(struct hd_struct *part) | ||
623 | { | ||
624 | atomic_inc(&part->ref); | ||
625 | smp_mb__after_atomic_inc(); | ||
626 | } | ||
627 | |||
628 | static inline int hd_struct_try_get(struct hd_struct *part) | ||
629 | { | ||
630 | return atomic_inc_not_zero(&part->ref); | ||
631 | } | ||
632 | |||
633 | static inline void hd_struct_put(struct hd_struct *part) | ||
634 | { | ||
635 | if (atomic_dec_and_test(&part->ref)) | ||
636 | __delete_partition(part); | ||
637 | } | ||
638 | |||
616 | #else /* CONFIG_BLOCK */ | 639 | #else /* CONFIG_BLOCK */ |
617 | 640 | ||
618 | static inline void printk_all_partitions(void) { } | 641 | static inline void printk_all_partitions(void) { } |
diff --git a/include/linux/kref.h b/include/linux/kref.h index 90b9e44abf54..6cc38fc07ab7 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h | |||
@@ -23,7 +23,6 @@ struct kref { | |||
23 | 23 | ||
24 | void kref_init(struct kref *kref); | 24 | void kref_init(struct kref *kref); |
25 | void kref_get(struct kref *kref); | 25 | void kref_get(struct kref *kref); |
26 | int kref_test_and_get(struct kref *kref); | ||
27 | int kref_put(struct kref *kref, void (*release) (struct kref *kref)); | 26 | int kref_put(struct kref *kref, void (*release) (struct kref *kref)); |
28 | 27 | ||
29 | #endif /* _KREF_H_ */ | 28 | #endif /* _KREF_H_ */ |