X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmd%2Fdm.c;h=54fabbf06678d838407a11e203e2b2c7fea6fb33;hb=327309e899662b482c58cf25f574513d38b5788c;hp=5d40555b42ba564b63d4d068761442fe98a0fdf6;hpb=f6a80ea8ed44de0b19c42d41928be37a186a3f41;p=linux-2.6 diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 5d40555b42..54fabbf066 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -966,23 +966,20 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c) */ int dm_swap_table(struct mapped_device *md, struct dm_table *table) { - int r; + int r = -EINVAL; down_write(&md->lock); /* device must be suspended */ - if (!test_bit(DMF_SUSPENDED, &md->flags)) { - up_write(&md->lock); - return -EPERM; - } + if (!test_bit(DMF_SUSPENDED, &md->flags)) + goto out; __unbind(md); r = __bind(md, table); - if (r) - return r; +out: up_write(&md->lock); - return 0; + return r; } /* @@ -1055,14 +1052,17 @@ int dm_suspend(struct mapped_device *md) if (test_bit(DMF_BLOCK_IO, &md->flags)) goto out_read_unlock; - error = __lock_fs(md); - if (error) - goto out_read_unlock; - map = dm_get_table(md); if (map) + /* This does not get reverted if there's an error later. */ dm_table_presuspend_targets(map); + error = __lock_fs(md); + if (error) { + dm_table_put(map); + goto out_read_unlock; + } + up_read(&md->lock); /* @@ -1121,7 +1121,6 @@ int dm_suspend(struct mapped_device *md) return 0; out_unfreeze: - /* FIXME Undo dm_table_presuspend_targets */ __unlock_fs(md); clear_bit(DMF_BLOCK_IO, &md->flags); out_write_unlock: