diff options
| author | Alexander Viro <viro@www.linux.org.uk> | 2003-08-30 22:51:54 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-08-30 22:51:54 -0700 |
| commit | fdf6f5efe399c351d85620ceb82ce2d15c6cf907 (patch) | |
| tree | dca103e0cbcf6fbdd5f32b79756e9713a76c824a /fs/block_dev.c | |
| parent | f2820f23b7adb742047f9d38191b9bb8cf0cb6a5 (diff) | |
[PATCH] dev_t handling cleanups (12/12)
added the exclusion between ADD_PARTITION/DELETE_PARTITION/open() (BLKPG
ioctls didn't grab ->bd_sem when they should have).
added bdev->bd_part; it is set at open() to point to the hd_struct of
partition in question, reset on final close.
blk_partition_remap() uses ->bd_part instead of the current mess
->bd_offset is gone, we use ->bd_part->start_sect instead
added missing ->release() to hd_struct kobject, moved kfree() into it
->bd_part cotributes to refcount of hd_struct - we bump it when
->bd_part is set and drop when it's reset.
Diffstat (limited to 'fs/block_dev.c')
| -rw-r--r-- | fs/block_dev.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 94e7f9fd6398..ddfcb6284b5a 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -540,7 +540,6 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * if (ret) goto out_first; } - bdev->bd_offset = 0; if (!bdev->bd_openers) { bd_set_size(bdev,(loff_t)get_capacity(disk)<<9); bdi = blk_get_backing_dev_info(bdev); @@ -572,7 +571,8 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ret = -ENXIO; goto out_first; } - bdev->bd_offset = p->start_sect; + kobject_get(&p->kobj); + bdev->bd_part = p; bd_set_size(bdev, (loff_t) p->nr_sects << 9); up(&whole->bd_sem); } @@ -693,6 +693,10 @@ int blkdev_put(struct block_device *bdev, int kind) put_disk(disk); module_put(owner); + if (bdev->bd_contains != bdev) { + kobject_put(&bdev->bd_part->kobj); + bdev->bd_part = NULL; + } bdev->bd_disk = NULL; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; if (bdev != bdev->bd_contains) { |
