Commit 4e90188b authored by Alasdair G Kergon's avatar Alasdair G Kergon Committed by Linus Torvalds

[PATCH] device-mapper: fix deadlocks in core

Avoid another bdget_disk which can deadlock.
Signed-Off-By: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cf222b37
...@@ -825,18 +825,13 @@ static void event_callback(void *context) ...@@ -825,18 +825,13 @@ static void event_callback(void *context)
wake_up(&md->eventq); wake_up(&md->eventq);
} }
static void __set_size(struct gendisk *disk, sector_t size) static void __set_size(struct mapped_device *md, sector_t size)
{ {
struct block_device *bdev; set_capacity(md->disk, size);
set_capacity(disk, size); down(&md->frozen_bdev->bd_inode->i_sem);
bdev = bdget_disk(disk, 0); i_size_write(md->frozen_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
if (bdev) { up(&md->frozen_bdev->bd_inode->i_sem);
down(&bdev->bd_inode->i_sem);
i_size_write(bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
up(&bdev->bd_inode->i_sem);
bdput(bdev);
}
} }
static int __bind(struct mapped_device *md, struct dm_table *t) static int __bind(struct mapped_device *md, struct dm_table *t)
...@@ -845,7 +840,7 @@ static int __bind(struct mapped_device *md, struct dm_table *t) ...@@ -845,7 +840,7 @@ static int __bind(struct mapped_device *md, struct dm_table *t)
sector_t size; sector_t size;
size = dm_table_get_size(t); size = dm_table_get_size(t);
__set_size(md->disk, size); __set_size(md, size);
if (size == 0) if (size == 0)
return 0; return 0;
......
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