dm_suspend tidying --- diff/drivers/md/dm.c 2005-07-06 19:21:04.000000000 +0100 +++ source/drivers/md/dm.c 2005-07-06 19:19:49.000000000 +0100 @@ -1047,6 +1047,9 @@ down_write(&md->suspend_lock); + if (dm_suspended(md)) + goto out; + /* Flush I/O to the device. */ down_read(&md->io_lock); if (test_bit(DMF_BLOCK_IO, &md->flags)) @@ -1115,9 +1118,11 @@ dm_table_postsuspend_targets(map); dm_table_put(map); up_write(&md->io_lock); - up_write(&md->suspend_lock); - return 0; + r = 0; +out: + up_write(&md->suspend_lock); + return r; out_unfreeze: __unlock_fs(md); @@ -1135,20 +1140,19 @@ int dm_resume(struct mapped_device *md) { + int r = -EINVAL; struct bio *def; - struct dm_table *map = dm_get_table(md); + struct dm_table *map = NULL; down_write(&md->suspend_lock); - down_write(&md->io_lock); - if (!map || - !dm_suspended(md) || - !dm_table_get_size(map)) { - up_write(&md->io_lock); - up_write(&md->suspend_lock); - dm_table_put(map); - return -EINVAL; - } + if (!dm_suspended(md)) + goto out; + map = dm_get_table(md); + if (!map || !dm_table_get_size(map)) + goto out; + + down_write(&md->io_lock); dm_table_resume_targets(map); clear_bit(DMF_SUSPENDED, &md->flags); clear_bit(DMF_BLOCK_IO, &md->flags); @@ -1156,12 +1160,18 @@ def = bio_list_get(&md->deferred); __flush_deferred_io(md, def); up_write(&md->io_lock); + __unlock_fs(md); + dm_table_unplug_all(map); + + r = 0; + +out: dm_table_put(map); up_write(&md->suspend_lock); - return 0; + return r; } /*-----------------------------------------------------------------