Commit afae25b7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] preparation to use of driverfs refcounts, part 1 - partitions

	* update_partition() split into add_partition() and delete_partition().
	* all updating of ->part[] is switched to these two (including initial
filling/final cleaning).
	* per-partition devices are allocated on-demand and never reused.
We allocate struct device in add_partition() and put reference to it into
hd_struct.  ->release() for that struct device frees it.  delete_partition()
removes reference from hd_struct and does put_device() on it.  Basically,
we get rid of problems with reused struct device by never reusing them...
	At that point devices for partitions are nice and sane.
parent c6973580
...@@ -58,9 +58,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg) ...@@ -58,9 +58,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg)
return -EBUSY; return -EBUSY;
} }
/* all seems OK */ /* all seems OK */
disk->part[part - 1].start_sect = start; add_partition(disk, part, start, length);
disk->part[part - 1].nr_sects = length;
update_partition(disk, part);
return 0; return 0;
case BLKPG_DEL_PARTITION: case BLKPG_DEL_PARTITION:
if (disk->part[part - 1].nr_sects == 0) if (disk->part[part - 1].nr_sects == 0)
...@@ -79,9 +77,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg) ...@@ -79,9 +77,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg)
fsync_bdev(bdevp); fsync_bdev(bdevp);
invalidate_bdev(bdevp, 0); invalidate_bdev(bdevp, 0);
disk->part[part].start_sect = 0; delete_partition(disk, part);
disk->part[part].nr_sects = 0;
update_partition(disk, part);
bd_release(bdevp); bd_release(bdevp);
bdput(bdevp); bdput(bdevp);
return 0; return 0;
......
This diff is collapsed.
...@@ -62,7 +62,7 @@ struct hd_struct { ...@@ -62,7 +62,7 @@ struct hd_struct {
sector_t start_sect; sector_t start_sect;
sector_t nr_sects; sector_t nr_sects;
devfs_handle_t de; /* primary (master) devfs entry */ devfs_handle_t de; /* primary (master) devfs entry */
struct device hd_driverfs_dev; /* support driverfs hiearchy */ struct device *hd_driverfs_dev; /* support driverfs hiearchy */
}; };
#define GENHD_FL_REMOVABLE 1 #define GENHD_FL_REMOVABLE 1
...@@ -262,7 +262,8 @@ struct unixware_disklabel { ...@@ -262,7 +262,8 @@ struct unixware_disklabel {
char *disk_name (struct gendisk *hd, int part, char *buf); char *disk_name (struct gendisk *hd, int part, char *buf);
extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
extern void update_partition(struct gendisk *disk, int part); 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 *alloc_disk(int minors);
extern void put_disk(struct gendisk *disk); extern void put_disk(struct gendisk *disk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment