diff options
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r-- | drivers/md/dm.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 98dff36b89a3..20a8d63754bf 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -1953,9 +1953,10 @@ static void free_dev(struct mapped_device *md) | |||
1953 | kvfree(md); | 1953 | kvfree(md); |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | static void __bind_mempools(struct mapped_device *md, struct dm_table *t) | 1956 | static int __bind_mempools(struct mapped_device *md, struct dm_table *t) |
1957 | { | 1957 | { |
1958 | struct dm_md_mempools *p = dm_table_get_md_mempools(t); | 1958 | struct dm_md_mempools *p = dm_table_get_md_mempools(t); |
1959 | int ret = 0; | ||
1959 | 1960 | ||
1960 | if (dm_table_bio_based(t)) { | 1961 | if (dm_table_bio_based(t)) { |
1961 | /* | 1962 | /* |
@@ -1982,13 +1983,16 @@ static void __bind_mempools(struct mapped_device *md, struct dm_table *t) | |||
1982 | bioset_initialized(&md->bs) || | 1983 | bioset_initialized(&md->bs) || |
1983 | bioset_initialized(&md->io_bs)); | 1984 | bioset_initialized(&md->io_bs)); |
1984 | 1985 | ||
1985 | md->bs = p->bs; | 1986 | ret = bioset_init_from_src(&md->bs, &p->bs); |
1986 | memset(&p->bs, 0, sizeof(p->bs)); | 1987 | if (ret) |
1987 | md->io_bs = p->io_bs; | 1988 | goto out; |
1988 | memset(&p->io_bs, 0, sizeof(p->io_bs)); | 1989 | ret = bioset_init_from_src(&md->io_bs, &p->io_bs); |
1990 | if (ret) | ||
1991 | bioset_exit(&md->bs); | ||
1989 | out: | 1992 | out: |
1990 | /* mempool bind completed, no longer need any mempools in the table */ | 1993 | /* mempool bind completed, no longer need any mempools in the table */ |
1991 | dm_table_free_md_mempools(t); | 1994 | dm_table_free_md_mempools(t); |
1995 | return ret; | ||
1992 | } | 1996 | } |
1993 | 1997 | ||
1994 | /* | 1998 | /* |
@@ -2033,6 +2037,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, | |||
2033 | struct request_queue *q = md->queue; | 2037 | struct request_queue *q = md->queue; |
2034 | bool request_based = dm_table_request_based(t); | 2038 | bool request_based = dm_table_request_based(t); |
2035 | sector_t size; | 2039 | sector_t size; |
2040 | int ret; | ||
2036 | 2041 | ||
2037 | lockdep_assert_held(&md->suspend_lock); | 2042 | lockdep_assert_held(&md->suspend_lock); |
2038 | 2043 | ||
@@ -2068,7 +2073,11 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, | |||
2068 | md->immutable_target = dm_table_get_immutable_target(t); | 2073 | md->immutable_target = dm_table_get_immutable_target(t); |
2069 | } | 2074 | } |
2070 | 2075 | ||
2071 | __bind_mempools(md, t); | 2076 | ret = __bind_mempools(md, t); |
2077 | if (ret) { | ||
2078 | old_map = ERR_PTR(ret); | ||
2079 | goto out; | ||
2080 | } | ||
2072 | 2081 | ||
2073 | old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); | 2082 | old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); |
2074 | rcu_assign_pointer(md->map, (void *)t); | 2083 | rcu_assign_pointer(md->map, (void *)t); |
@@ -2078,6 +2087,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, | |||
2078 | if (old_map) | 2087 | if (old_map) |
2079 | dm_sync_table(md); | 2088 | dm_sync_table(md); |
2080 | 2089 | ||
2090 | out: | ||
2081 | return old_map; | 2091 | return old_map; |
2082 | } | 2092 | } |
2083 | 2093 | ||