diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.23/0021-dm-persistent-data-fix-allocation-failure-in-space-m.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.23/0021-dm-persistent-data-fix-allocation-failure-in-space-m.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.23/0021-dm-persistent-data-fix-allocation-failure-in-space-m.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.23/0021-dm-persistent-data-fix-allocation-failure-in-space-m.patch new file mode 100644 index 00000000..b8121c82 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.23/0021-dm-persistent-data-fix-allocation-failure-in-space-m.patch | |||
@@ -0,0 +1,95 @@ | |||
1 | From d93e7e98bbff07495ac95fd10c02c2e0d5392079 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mike Snitzer <snitzer@redhat.com> | ||
3 | Date: Tue, 3 Jul 2012 12:55:37 +0100 | ||
4 | Subject: [PATCH 21/49] dm persistent data: fix allocation failure in space | ||
5 | map checker init | ||
6 | |||
7 | commit b0239faaf87c38bb419c9264bf20817438ddc3a9 upstream. | ||
8 | |||
9 | If CONFIG_DM_DEBUG_SPACE_MAPS is enabled and memory is fragmented and a | ||
10 | sufficiently-large metadata device is used in a thin pool then the space | ||
11 | map checker will fail to allocate the memory it requires. | ||
12 | |||
13 | Switch from kmalloc to vmalloc to allow larger virtually contiguous | ||
14 | allocations for the space map checker's internal count arrays. | ||
15 | |||
16 | Reported-by: Vivek Goyal <vgoyal@redhat.com> | ||
17 | Signed-off-by: Mike Snitzer <snitzer@redhat.com> | ||
18 | Signed-off-by: Alasdair G Kergon <agk@redhat.com> | ||
19 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
20 | --- | ||
21 | drivers/md/persistent-data/dm-space-map-checker.c | 30 +++++++++++++-------- | ||
22 | 1 file changed, 19 insertions(+), 11 deletions(-) | ||
23 | |||
24 | diff --git a/drivers/md/persistent-data/dm-space-map-checker.c b/drivers/md/persistent-data/dm-space-map-checker.c | ||
25 | index 6d7c832..fc90c11 100644 | ||
26 | --- a/drivers/md/persistent-data/dm-space-map-checker.c | ||
27 | +++ b/drivers/md/persistent-data/dm-space-map-checker.c | ||
28 | @@ -8,6 +8,7 @@ | ||
29 | |||
30 | #include <linux/device-mapper.h> | ||
31 | #include <linux/export.h> | ||
32 | +#include <linux/vmalloc.h> | ||
33 | |||
34 | #ifdef CONFIG_DM_DEBUG_SPACE_MAPS | ||
35 | |||
36 | @@ -89,13 +90,23 @@ static int ca_create(struct count_array *ca, struct dm_space_map *sm) | ||
37 | |||
38 | ca->nr = nr_blocks; | ||
39 | ca->nr_free = nr_blocks; | ||
40 | - ca->counts = kzalloc(sizeof(*ca->counts) * nr_blocks, GFP_KERNEL); | ||
41 | - if (!ca->counts) | ||
42 | - return -ENOMEM; | ||
43 | + | ||
44 | + if (!nr_blocks) | ||
45 | + ca->counts = NULL; | ||
46 | + else { | ||
47 | + ca->counts = vzalloc(sizeof(*ca->counts) * nr_blocks); | ||
48 | + if (!ca->counts) | ||
49 | + return -ENOMEM; | ||
50 | + } | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | +static void ca_destroy(struct count_array *ca) | ||
56 | +{ | ||
57 | + vfree(ca->counts); | ||
58 | +} | ||
59 | + | ||
60 | static int ca_load(struct count_array *ca, struct dm_space_map *sm) | ||
61 | { | ||
62 | int r; | ||
63 | @@ -126,12 +137,14 @@ static int ca_load(struct count_array *ca, struct dm_space_map *sm) | ||
64 | static int ca_extend(struct count_array *ca, dm_block_t extra_blocks) | ||
65 | { | ||
66 | dm_block_t nr_blocks = ca->nr + extra_blocks; | ||
67 | - uint32_t *counts = kzalloc(sizeof(*counts) * nr_blocks, GFP_KERNEL); | ||
68 | + uint32_t *counts = vzalloc(sizeof(*counts) * nr_blocks); | ||
69 | if (!counts) | ||
70 | return -ENOMEM; | ||
71 | |||
72 | - memcpy(counts, ca->counts, sizeof(*counts) * ca->nr); | ||
73 | - kfree(ca->counts); | ||
74 | + if (ca->counts) { | ||
75 | + memcpy(counts, ca->counts, sizeof(*counts) * ca->nr); | ||
76 | + ca_destroy(ca); | ||
77 | + } | ||
78 | ca->nr = nr_blocks; | ||
79 | ca->nr_free += extra_blocks; | ||
80 | ca->counts = counts; | ||
81 | @@ -151,11 +164,6 @@ static int ca_commit(struct count_array *old, struct count_array *new) | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | -static void ca_destroy(struct count_array *ca) | ||
86 | -{ | ||
87 | - kfree(ca->counts); | ||
88 | -} | ||
89 | - | ||
90 | /*----------------------------------------------------------------*/ | ||
91 | |||
92 | struct sm_checker { | ||
93 | -- | ||
94 | 1.7.10 | ||
95 | |||