[lkml]   [2011]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[patch 156/176] dm: dont take i_mutex to change device size
    2.6.36-stable review patch.  If anyone has any objections, please let us know.


    From: Mike Snitzer <>

    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:

    Signed-off-by: Mike Snitzer <>
    Signed-off-by: Mikulas Patocka <>
    Signed-off-by: Alasdair G Kergon <>
    Signed-off-by: Greg Kroah-Hartman <>

    drivers/md/dm.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    --- a/drivers/md/dm.c
    +++ b/drivers/md/dm.c
    @@ -2111,13 +2111,14 @@ static void event_callback(void *context

    + * 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);


     \ /
      Last update: 2011-02-16 02:25    [W:0.019 / U:5.572 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site