diff options
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index f6b03957efc..54fabbf0667 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -384,7 +384,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone, | |||
384 | /* error the io and bail out */ | 384 | /* error the io and bail out */ |
385 | struct dm_io *io = tio->io; | 385 | struct dm_io *io = tio->io; |
386 | free_tio(tio->io->md, tio); | 386 | free_tio(tio->io->md, tio); |
387 | dec_pending(io, -EIO); | 387 | dec_pending(io, r); |
388 | bio_put(clone); | 388 | bio_put(clone); |
389 | } | 389 | } |
390 | } | 390 | } |
@@ -966,23 +966,20 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c) | |||
966 | */ | 966 | */ |
967 | int dm_swap_table(struct mapped_device *md, struct dm_table *table) | 967 | int dm_swap_table(struct mapped_device *md, struct dm_table *table) |
968 | { | 968 | { |
969 | int r; | 969 | int r = -EINVAL; |
970 | 970 | ||
971 | down_write(&md->lock); | 971 | down_write(&md->lock); |
972 | 972 | ||
973 | /* device must be suspended */ | 973 | /* device must be suspended */ |
974 | if (!test_bit(DMF_SUSPENDED, &md->flags)) { | 974 | if (!test_bit(DMF_SUSPENDED, &md->flags)) |
975 | up_write(&md->lock); | 975 | goto out; |
976 | return -EPERM; | ||
977 | } | ||
978 | 976 | ||
979 | __unbind(md); | 977 | __unbind(md); |
980 | r = __bind(md, table); | 978 | r = __bind(md, table); |
981 | if (r) | ||
982 | return r; | ||
983 | 979 | ||
980 | out: | ||
984 | up_write(&md->lock); | 981 | up_write(&md->lock); |
985 | return 0; | 982 | return r; |
986 | } | 983 | } |
987 | 984 | ||
988 | /* | 985 | /* |
@@ -1055,14 +1052,17 @@ int dm_suspend(struct mapped_device *md) | |||
1055 | if (test_bit(DMF_BLOCK_IO, &md->flags)) | 1052 | if (test_bit(DMF_BLOCK_IO, &md->flags)) |
1056 | goto out_read_unlock; | 1053 | goto out_read_unlock; |
1057 | 1054 | ||
1058 | error = __lock_fs(md); | ||
1059 | if (error) | ||
1060 | goto out_read_unlock; | ||
1061 | |||
1062 | map = dm_get_table(md); | 1055 | map = dm_get_table(md); |
1063 | if (map) | 1056 | if (map) |
1057 | /* This does not get reverted if there's an error later. */ | ||
1064 | dm_table_presuspend_targets(map); | 1058 | dm_table_presuspend_targets(map); |
1065 | 1059 | ||
1060 | error = __lock_fs(md); | ||
1061 | if (error) { | ||
1062 | dm_table_put(map); | ||
1063 | goto out_read_unlock; | ||
1064 | } | ||
1065 | |||
1066 | up_read(&md->lock); | 1066 | up_read(&md->lock); |
1067 | 1067 | ||
1068 | /* | 1068 | /* |
@@ -1121,7 +1121,6 @@ int dm_suspend(struct mapped_device *md) | |||
1121 | return 0; | 1121 | return 0; |
1122 | 1122 | ||
1123 | out_unfreeze: | 1123 | out_unfreeze: |
1124 | /* FIXME Undo dm_table_presuspend_targets */ | ||
1125 | __unlock_fs(md); | 1124 | __unlock_fs(md); |
1126 | clear_bit(DMF_BLOCK_IO, &md->flags); | 1125 | clear_bit(DMF_BLOCK_IO, &md->flags); |
1127 | out_write_unlock: | 1126 | out_write_unlock: |