diff options
author | Mike Snitzer <snitzer@redhat.com> | 2011-01-13 19:53:46 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-03-21 12:45:00 -0700 |
commit | 8e71d6122e26d85672d9e7ef5e001dec289190b4 (patch) | |
tree | 8f2c75d13e7d39a230a1f6c67ad94c76d5fc42c6 /drivers | |
parent | bc0a20a9e8d35e81dd4b6bd65f03db30074f0581 (diff) | |
download | kernel-common-8e71d6122e26d85672d9e7ef5e001dec289190b4.tar.gz kernel-common-8e71d6122e26d85672d9e7ef5e001dec289190b4.tar.bz2 kernel-common-8e71d6122e26d85672d9e7ef5e001dec289190b4.zip |
dm: dont take i_mutex to change device size
commit c217649bf2d60ac119afd71d938278cffd55962b upstream.
No longer needlessly hold md->bdev->bd_inode->i_mutex when changing the
size of a DM device. This additional locking is unnecessary because
i_size_write() is already protected by the existing critical section in
dm_swap_table(). DM already has a reference on md->bdev so the
associated bd_inode may be changed without lifetime concerns.
A negative side-effect of having held md->bdev->bd_inode->i_mutex was
that a concurrent DM device resize and flush (via fsync) would deadlock.
Dropping md->bdev->bd_inode->i_mutex eliminates this potential for
deadlock. The following reproducer no longer deadlocks:
https://www.redhat.com/archives/dm-devel/2009-July/msg00284.html
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index fe8889e5e355..2e41d5ee7cc8 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2039,13 +2039,14 @@ static void event_callback(void *context) wake_up(&md->eventq); } +/* + * Protected by md->suspend_lock obtained by dm_swap_table(). + */ static void __set_size(struct mapped_device *md, sector_t size) { set_capacity(md->disk, size); - mutex_lock(&md->bdev->bd_inode->i_mutex); i_size_write(md->bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); - mutex_unlock(&md->bdev->bd_inode->i_mutex); } /* |