]> err.no Git - linux-2.6/blobdiff - drivers/md/dm.c
Merge upstream 2.6.13-rc3 into ieee80211 branch of netdev-2.6.
[linux-2.6] / drivers / md / dm.c
index 5d40555b42ba564b63d4d068761442fe98a0fdf6..54fabbf06678d838407a11e203e2b2c7fea6fb33 100644 (file)
@@ -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: