]>
Commit | Line | Data |
---|---|---|
b889272d GKH |
1 | From 948f581a53b704b984aa20df009f0a2b4cf7f907 Mon Sep 17 00:00:00 2001 |
2 | From: Dennis Yang <dennisyang@qnap.com> | |
3 | Date: Tue, 18 Apr 2017 15:27:06 +0800 | |
4 | Subject: dm thin: fix a memory leak when passing discard bio down | |
5 | ||
6 | From: Dennis Yang <dennisyang@qnap.com> | |
7 | ||
8 | commit 948f581a53b704b984aa20df009f0a2b4cf7f907 upstream. | |
9 | ||
10 | dm-thin does not free the discard_parent bio after all chained sub | |
11 | bios finished. The following kmemleak report could be observed after | |
12 | pool with discard_passdown option processes discard bios in | |
13 | linux v4.11-rc7. To fix this, we drop the discard_parent bio reference | |
14 | when its endio (passdown_endio) called. | |
15 | ||
16 | unreferenced object 0xffff8803d6b29700 (size 256): | |
17 | comm "kworker/u8:0", pid 30349, jiffies 4379504020 (age 143002.776s) | |
18 | hex dump (first 32 bytes): | |
19 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
20 | 01 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 00 ................ | |
21 | backtrace: | |
22 | [<ffffffff81a5efd9>] kmemleak_alloc+0x49/0xa0 | |
23 | [<ffffffff8114ec34>] kmem_cache_alloc+0xb4/0x100 | |
24 | [<ffffffff8110eec0>] mempool_alloc_slab+0x10/0x20 | |
25 | [<ffffffff8110efa5>] mempool_alloc+0x55/0x150 | |
26 | [<ffffffff81374939>] bio_alloc_bioset+0xb9/0x260 | |
27 | [<ffffffffa018fd20>] process_prepared_discard_passdown_pt1+0x40/0x1c0 [dm_thin_pool] | |
28 | [<ffffffffa018b409>] break_up_discard_bio+0x1a9/0x200 [dm_thin_pool] | |
29 | [<ffffffffa018b484>] process_discard_cell_passdown+0x24/0x40 [dm_thin_pool] | |
30 | [<ffffffffa018b24d>] process_discard_bio+0xdd/0xf0 [dm_thin_pool] | |
31 | [<ffffffffa018ecf6>] do_worker+0xa76/0xd50 [dm_thin_pool] | |
32 | [<ffffffff81086239>] process_one_work+0x139/0x370 | |
33 | [<ffffffff810867b1>] worker_thread+0x61/0x450 | |
34 | [<ffffffff8108b316>] kthread+0xd6/0xf0 | |
35 | [<ffffffff81a6cd1f>] ret_from_fork+0x3f/0x70 | |
36 | [<ffffffffffffffff>] 0xffffffffffffffff | |
37 | ||
38 | Signed-off-by: Dennis Yang <dennisyang@qnap.com> | |
39 | Signed-off-by: Mike Snitzer <snitzer@redhat.com> | |
40 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
41 | ||
42 | --- | |
43 | drivers/md/dm-thin.c | 1 + | |
44 | 1 file changed, 1 insertion(+) | |
45 | ||
46 | --- a/drivers/md/dm-thin.c | |
47 | +++ b/drivers/md/dm-thin.c | |
48 | @@ -1069,6 +1069,7 @@ static void passdown_endio(struct bio *b | |
49 | * to unmap (we ignore err). | |
50 | */ | |
51 | queue_passdown_pt2(bio->bi_private); | |
52 | + bio_put(bio); | |
53 | } | |
54 | ||
55 | static void process_prepared_discard_passdown_pt1(struct dm_thin_new_mapping *m) |