aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2011-05-29 08:03:09 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-05-29 08:03:09 -0400
commitbda8efec5c706a672e0714d341a342e811f0262a (patch)
tree7daf7b505723f5ed2767353dc3fe53b939c46d87 /drivers/md
parentd04714580f12379fcf7a0f799e86c92b96dd4e1f (diff)
dm io: use fixed initial mempool size
Replace the arbitrary calculation of an initial io struct mempool size with a constant. The code calculated the number of reserved structures based on the request size and used a "magic" multiplication constant of 4. This patch changes it to reserve a fixed number - itself still chosen quite arbitrarily. Further testing might show if there is a better number to choose. Note that if there is no memory pressure, we can still allocate an arbitrary number of "struct io" structures. One structure is enough to process the whole request. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-io.c27
-rw-r--r--drivers/md/dm-kcopyd.c2
-rw-r--r--drivers/md/dm-log.c3
-rw-r--r--drivers/md/dm-raid1.c3
-rw-r--r--drivers/md/dm-snap-persistent.c13
5 files changed, 9 insertions, 39 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 76a5af00a26b..2067288f61f9 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -19,6 +19,8 @@
19#define DM_MSG_PREFIX "io" 19#define DM_MSG_PREFIX "io"
20 20
21#define DM_IO_MAX_REGIONS BITS_PER_LONG 21#define DM_IO_MAX_REGIONS BITS_PER_LONG
22#define MIN_IOS 16
23#define MIN_BIOS 16
22 24
23struct dm_io_client { 25struct dm_io_client {
24 mempool_t *pool; 26 mempool_t *pool;
@@ -41,33 +43,21 @@ struct io {
41static struct kmem_cache *_dm_io_cache; 43static struct kmem_cache *_dm_io_cache;
42 44
43/* 45/*
44 * io contexts are only dynamically allocated for asynchronous
45 * io. Since async io is likely to be the majority of io we'll
46 * have the same number of io contexts as bios! (FIXME: must reduce this).
47 */
48
49static unsigned int pages_to_ios(unsigned int pages)
50{
51 return 4 * pages; /* too many ? */
52}
53
54/*
55 * Create a client with mempool and bioset. 46 * Create a client with mempool and bioset.
56 */ 47 */
57struct dm_io_client *dm_io_client_create(unsigned num_pages) 48struct dm_io_client *dm_io_client_create(void)
58{ 49{
59 unsigned ios = pages_to_ios(num_pages);
60 struct dm_io_client *client; 50 struct dm_io_client *client;
61 51
62 client = kmalloc(sizeof(*client), GFP_KERNEL); 52 client = kmalloc(sizeof(*client), GFP_KERNEL);
63 if (!client) 53 if (!client)
64 return ERR_PTR(-ENOMEM); 54 return ERR_PTR(-ENOMEM);
65 55
66 client->pool = mempool_create_slab_pool(ios, _dm_io_cache); 56 client->pool = mempool_create_slab_pool(MIN_IOS, _dm_io_cache);
67 if (!client->pool) 57 if (!client->pool)
68 goto bad; 58 goto bad;
69 59
70 client->bios = bioset_create(16, 0); 60 client->bios = bioset_create(MIN_BIOS, 0);
71 if (!client->bios) 61 if (!client->bios)
72 goto bad; 62 goto bad;
73 63
@@ -81,13 +71,6 @@ struct dm_io_client *dm_io_client_create(unsigned num_pages)
81} 71}
82EXPORT_SYMBOL(dm_io_client_create); 72EXPORT_SYMBOL(dm_io_client_create);
83 73
84int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client)
85{
86 return mempool_resize(client->pool, pages_to_ios(num_pages),
87 GFP_KERNEL);
88}
89EXPORT_SYMBOL(dm_io_client_resize);
90
91void dm_io_client_destroy(struct dm_io_client *client) 74void dm_io_client_destroy(struct dm_io_client *client)
92{ 75{
93 mempool_destroy(client->pool); 76 mempool_destroy(client->pool);
diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c
index 5dfbdcb40a47..719693340d1d 100644
--- a/drivers/md/dm-kcopyd.c
+++ b/drivers/md/dm-kcopyd.c
@@ -667,7 +667,7 @@ int dm_kcopyd_client_create(unsigned min_pages,
667 if (r) 667 if (r)
668 goto bad_client_pages; 668 goto bad_client_pages;
669 669
670 kc->io_client = dm_io_client_create(min_pages); 670 kc->io_client = dm_io_client_create();
671 if (IS_ERR(kc->io_client)) { 671 if (IS_ERR(kc->io_client)) {
672 r = PTR_ERR(kc->io_client); 672 r = PTR_ERR(kc->io_client);
673 goto bad_io_client; 673 goto bad_io_client;
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index a1f321889676..948e3f4925bf 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -449,8 +449,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
449 449
450 lc->io_req.mem.type = DM_IO_VMA; 450 lc->io_req.mem.type = DM_IO_VMA;
451 lc->io_req.notify.fn = NULL; 451 lc->io_req.notify.fn = NULL;
452 lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, 452 lc->io_req.client = dm_io_client_create();
453 PAGE_SIZE));
454 if (IS_ERR(lc->io_req.client)) { 453 if (IS_ERR(lc->io_req.client)) {
455 r = PTR_ERR(lc->io_req.client); 454 r = PTR_ERR(lc->io_req.client);
456 DMWARN("couldn't allocate disk io client"); 455 DMWARN("couldn't allocate disk io client");
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 976ad4688afc..53089aa11387 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -22,7 +22,6 @@
22#define DM_MSG_PREFIX "raid1" 22#define DM_MSG_PREFIX "raid1"
23 23
24#define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */ 24#define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */
25#define DM_IO_PAGES 64
26#define DM_KCOPYD_PAGES 64 25#define DM_KCOPYD_PAGES 64
27 26
28#define DM_RAID1_HANDLE_ERRORS 0x01 27#define DM_RAID1_HANDLE_ERRORS 0x01
@@ -887,7 +886,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
887 return NULL; 886 return NULL;
888 } 887 }
889 888
890 ms->io_client = dm_io_client_create(DM_IO_PAGES); 889 ms->io_client = dm_io_client_create();
891 if (IS_ERR(ms->io_client)) { 890 if (IS_ERR(ms->io_client)) {
892 ti->error = "Error creating dm_io client"; 891 ti->error = "Error creating dm_io client";
893 mempool_destroy(ms->read_record_pool); 892 mempool_destroy(ms->read_record_pool);
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 95891dfcbca0..135c2f1fdbfc 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -154,11 +154,6 @@ struct pstore {
154 struct workqueue_struct *metadata_wq; 154 struct workqueue_struct *metadata_wq;
155}; 155};
156 156
157static unsigned sectors_to_pages(unsigned sectors)
158{
159 return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
160}
161
162static int alloc_area(struct pstore *ps) 157static int alloc_area(struct pstore *ps)
163{ 158{
164 int r = -ENOMEM; 159 int r = -ENOMEM;
@@ -318,8 +313,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
318 chunk_size_supplied = 0; 313 chunk_size_supplied = 0;
319 } 314 }
320 315
321 ps->io_client = dm_io_client_create(sectors_to_pages(ps->store-> 316 ps->io_client = dm_io_client_create();
322 chunk_size));
323 if (IS_ERR(ps->io_client)) 317 if (IS_ERR(ps->io_client))
324 return PTR_ERR(ps->io_client); 318 return PTR_ERR(ps->io_client);
325 319
@@ -368,11 +362,6 @@ static int read_header(struct pstore *ps, int *new_snapshot)
368 return r; 362 return r;
369 } 363 }
370 364
371 r = dm_io_client_resize(sectors_to_pages(ps->store->chunk_size),
372 ps->io_client);
373 if (r)
374 return r;
375
376 r = alloc_area(ps); 365 r = alloc_area(ps);
377 return r; 366 return r;
378 367