diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2011-01-07 08:43:37 +0100 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-01-07 08:43:37 +0100 |
commit | 6c23a9681c0fe7fb7dd331b39dda11926f43746e (patch) | |
tree | bf113a475a17faa866e7e59806378107dcb3aa40 /include/linux | |
parent | 09e099d4bafea3b15be003d548bdf94b4b6e0e17 (diff) | |
download | blackbird-op-linux-6c23a9681c0fe7fb7dd331b39dda11926f43746e.tar.gz blackbird-op-linux-6c23a9681c0fe7fb7dd331b39dda11926f43746e.zip |
block: add internal hd part table references
We can't use krefs since it's apparently restricted to very basic
reference counting.
This reverts commit e4a683c8.
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
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 { #else struct disk_stats dkstats; #endif + atomic_t ref; struct rcu_head rcu_head; - struct kref ref; }; #define GENHD_FL_REMOVABLE 1 @@ -584,7 +584,7 @@ extern struct hd_struct * __must_check add_partition(struct gendisk *disk, sector_t len, int flags, struct partition_meta_info *info); -extern void __delete_partition(struct kref *ref); +extern void __delete_partition(struct hd_struct *); extern void delete_partition(struct gendisk *, int); extern void printk_all_partitions(void); @@ -613,6 +613,29 @@ extern ssize_t part_fail_store(struct device *dev, const char *buf, size_t count); #endif /* CONFIG_FAIL_MAKE_REQUEST */ +static inline void hd_ref_init(struct hd_struct *part) +{ + atomic_set(&part->ref, 1); + smp_mb(); +} + +static inline void hd_struct_get(struct hd_struct *part) +{ + atomic_inc(&part->ref); + smp_mb__after_atomic_inc(); +} + +static inline int hd_struct_try_get(struct hd_struct *part) +{ + return atomic_inc_not_zero(&part->ref); +} + +static inline void hd_struct_put(struct hd_struct *part) +{ + if (atomic_dec_and_test(&part->ref)) + __delete_partition(part); +} + #else /* CONFIG_BLOCK */ 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 { void kref_init(struct kref *kref); void kref_get(struct kref *kref); -int kref_test_and_get(struct kref *kref); int kref_put(struct kref *kref, void (*release) (struct kref *kref)); #endif /* _KREF_H_ */ |