Skip to content

Commit 2eb4296

Browse files
committed
Merge tag 'dm-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-dm
Pull device-mapper fixes from Alasdair G Kergon: "Fix a couple of serious memory leaks in device-mapper thin provisioning and tidy its MODULE_DESCRIPTION. Mitigate occasional reported hangs associated with multipath scsi_dh module loading." * tag 'dm-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-dm: dm mpath: check if scsi_dh module already loaded before trying to load dm thin: correct module description dm thin: fix unprotected use of prepared_discards list dm thin: reinstate missing mempool_free in cell_release_singleton
2 parents a6c072c + 510193a commit 2eb4296

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

drivers/md/dm-mpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
718718
return 0;
719719

720720
m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);
721-
request_module("scsi_dh_%s", m->hw_handler_name);
722-
if (scsi_dh_handler_exist(m->hw_handler_name) == 0) {
721+
if (!try_then_request_module(scsi_dh_handler_exist(m->hw_handler_name),
722+
"scsi_dh_%s", m->hw_handler_name)) {
723723
ti->error = "unknown hardware handler type";
724724
ret = -EINVAL;
725725
goto fail;

drivers/md/dm-thin.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ static void __cell_release(struct cell *cell, struct bio_list *inmates)
279279

280280
hlist_del(&cell->list);
281281

282-
bio_list_add(inmates, cell->holder);
283-
bio_list_merge(inmates, &cell->bios);
282+
if (inmates) {
283+
bio_list_add(inmates, cell->holder);
284+
bio_list_merge(inmates, &cell->bios);
285+
}
284286

285287
mempool_free(cell, prison->cell_pool);
286288
}
@@ -303,9 +305,10 @@ static void cell_release(struct cell *cell, struct bio_list *bios)
303305
*/
304306
static void __cell_release_singleton(struct cell *cell, struct bio *bio)
305307
{
306-
hlist_del(&cell->list);
307308
BUG_ON(cell->holder != bio);
308309
BUG_ON(!bio_list_empty(&cell->bios));
310+
311+
__cell_release(cell, NULL);
309312
}
310313

311314
static void cell_release_singleton(struct cell *cell, struct bio *bio)
@@ -1177,6 +1180,7 @@ static void no_space(struct cell *cell)
11771180
static void process_discard(struct thin_c *tc, struct bio *bio)
11781181
{
11791182
int r;
1183+
unsigned long flags;
11801184
struct pool *pool = tc->pool;
11811185
struct cell *cell, *cell2;
11821186
struct cell_key key, key2;
@@ -1218,7 +1222,9 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
12181222
m->bio = bio;
12191223

12201224
if (!ds_add_work(&pool->all_io_ds, &m->list)) {
1225+
spin_lock_irqsave(&pool->lock, flags);
12211226
list_add(&m->list, &pool->prepared_discards);
1227+
spin_unlock_irqrestore(&pool->lock, flags);
12221228
wake_worker(pool);
12231229
}
12241230
} else {
@@ -2626,8 +2632,10 @@ static int thin_endio(struct dm_target *ti,
26262632
if (h->all_io_entry) {
26272633
INIT_LIST_HEAD(&work);
26282634
ds_dec(h->all_io_entry, &work);
2635+
spin_lock_irqsave(&pool->lock, flags);
26292636
list_for_each_entry_safe(m, tmp, &work, list)
26302637
list_add(&m->list, &pool->prepared_discards);
2638+
spin_unlock_irqrestore(&pool->lock, flags);
26312639
}
26322640

26332641
mempool_free(h, pool->endio_hook_pool);
@@ -2759,6 +2767,6 @@ static void dm_thin_exit(void)
27592767
module_init(dm_thin_init);
27602768
module_exit(dm_thin_exit);
27612769

2762-
MODULE_DESCRIPTION(DM_NAME "device-mapper thin provisioning target");
2770+
MODULE_DESCRIPTION(DM_NAME " thin provisioning target");
27632771
MODULE_AUTHOR("Joe Thornber <[email protected]>");
27642772
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)