diff options
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index bca448e11878..ace998ce59f6 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -837,12 +837,14 @@ static int dm_merge_bvec(struct request_queue *q, | |||
837 | struct dm_table *map = dm_get_table(md); | 837 | struct dm_table *map = dm_get_table(md); |
838 | struct dm_target *ti; | 838 | struct dm_target *ti; |
839 | sector_t max_sectors; | 839 | sector_t max_sectors; |
840 | int max_size; | 840 | int max_size = 0; |
841 | 841 | ||
842 | if (unlikely(!map)) | 842 | if (unlikely(!map)) |
843 | return 0; | 843 | goto out; |
844 | 844 | ||
845 | ti = dm_table_find_target(map, bvm->bi_sector); | 845 | ti = dm_table_find_target(map, bvm->bi_sector); |
846 | if (!dm_target_is_valid(ti)) | ||
847 | goto out_table; | ||
846 | 848 | ||
847 | /* | 849 | /* |
848 | * Find maximum amount of I/O that won't need splitting | 850 | * Find maximum amount of I/O that won't need splitting |
@@ -861,14 +863,16 @@ static int dm_merge_bvec(struct request_queue *q, | |||
861 | if (max_size && ti->type->merge) | 863 | if (max_size && ti->type->merge) |
862 | max_size = ti->type->merge(ti, bvm, biovec, max_size); | 864 | max_size = ti->type->merge(ti, bvm, biovec, max_size); |
863 | 865 | ||
866 | out_table: | ||
867 | dm_table_put(map); | ||
868 | |||
869 | out: | ||
864 | /* | 870 | /* |
865 | * Always allow an entire first page | 871 | * Always allow an entire first page |
866 | */ | 872 | */ |
867 | if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT)) | 873 | if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT)) |
868 | max_size = biovec->bv_len; | 874 | max_size = biovec->bv_len; |
869 | 875 | ||
870 | dm_table_put(map); | ||
871 | |||
872 | return max_size; | 876 | return max_size; |
873 | } | 877 | } |
874 | 878 | ||