summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexander Viro <viro@math.psu.edu>2002-10-15 04:25:32 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-10-15 04:25:32 -0700
commit68c16870dcfaba7c9e2dd5055a2caf4edcf42e87 (patch)
tree7c15437501c7bcf68bf634bfe88108cb5c62e472 /include
parentb288f6add39cf474fc2ec8087d32d3e1d4c1c6d0 (diff)
[PATCH] refcounts for gendisks
Finally. We use disk->dev.refcount as a gendisk refcount. New helper - get_disk(): atomic_inc on refcount. get_gendisk() does it on return, callers of get_gendisk() do put_disk() when they are done.
Diffstat (limited to 'include')
-rw-r--r--include/linux/genhd.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 6b859fad6a8a..030ee2f87891 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -266,6 +266,7 @@ extern void add_partition(struct gendisk *, int, sector_t, sector_t);
extern void delete_partition(struct gendisk *, int);
extern struct gendisk *alloc_disk(int minors);
+extern struct gendisk *get_disk(struct gendisk *disk);
extern void put_disk(struct gendisk *disk);
/* will go away */
@@ -273,9 +274,11 @@ extern void blk_set_probe(int major, struct gendisk *(p)(int));
static inline unsigned int disk_index (kdev_t dev)
{
- int part;
+ int part, res;
struct gendisk *g = get_gendisk(kdev_t_to_nr(dev), &part);
- return g ? (minor(dev) >> g->minor_shift) : 0;
+ res = g ? (minor(dev) >> g->minor_shift) : 0;
+ put_disk(g);
+ return res;
}
#endif