提交 5f43ba29 编写于 作者: M Mikulas Patocka 提交者: Alasdair G Kergon

dm kcopyd: reserve fewer pages

Reserve just the minimum of pages needed to process one job.

Because we allocate pages from page allocator, we don't need to reserve
a large number of pages.  The maximum job size is SUB_JOB_SIZE and we
calculate the number of reserved pages based on this.
Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 bda8efec
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define SUB_JOB_SIZE 128 #define SUB_JOB_SIZE 128
#define SPLIT_COUNT 8 #define SPLIT_COUNT 8
#define MIN_JOBS 8 #define MIN_JOBS 8
#define RESERVE_PAGES (DIV_ROUND_UP(SUB_JOB_SIZE << SECTOR_SHIFT, PAGE_SIZE))
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* Each kcopyd client has its own little pool of preallocated * Each kcopyd client has its own little pool of preallocated
...@@ -636,8 +637,7 @@ int kcopyd_cancel(struct kcopyd_job *job, int block) ...@@ -636,8 +637,7 @@ int kcopyd_cancel(struct kcopyd_job *job, int block)
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* Client setup * Client setup
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
int dm_kcopyd_client_create(unsigned min_pages, int dm_kcopyd_client_create(struct dm_kcopyd_client **result)
struct dm_kcopyd_client **result)
{ {
int r = -ENOMEM; int r = -ENOMEM;
struct dm_kcopyd_client *kc; struct dm_kcopyd_client *kc;
...@@ -663,7 +663,7 @@ int dm_kcopyd_client_create(unsigned min_pages, ...@@ -663,7 +663,7 @@ int dm_kcopyd_client_create(unsigned min_pages,
kc->pages = NULL; kc->pages = NULL;
kc->nr_reserved_pages = kc->nr_free_pages = 0; kc->nr_reserved_pages = kc->nr_free_pages = 0;
r = client_reserve_pages(kc, min_pages); r = client_reserve_pages(kc, RESERVE_PAGES);
if (r) if (r)
goto bad_client_pages; goto bad_client_pages;
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#define DM_MSG_PREFIX "raid1" #define DM_MSG_PREFIX "raid1"
#define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */ #define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */
#define DM_KCOPYD_PAGES 64
#define DM_RAID1_HANDLE_ERRORS 0x01 #define DM_RAID1_HANDLE_ERRORS 0x01
#define errors_handled(p) ((p)->features & DM_RAID1_HANDLE_ERRORS) #define errors_handled(p) ((p)->features & DM_RAID1_HANDLE_ERRORS)
...@@ -1116,7 +1115,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -1116,7 +1115,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto err_destroy_wq; goto err_destroy_wq;
} }
r = dm_kcopyd_client_create(DM_KCOPYD_PAGES, &ms->kcopyd_client); r = dm_kcopyd_client_create(&ms->kcopyd_client);
if (r) if (r)
goto err_destroy_wq; goto err_destroy_wq;
......
...@@ -39,11 +39,6 @@ static const char dm_snapshot_merge_target_name[] = "snapshot-merge"; ...@@ -39,11 +39,6 @@ static const char dm_snapshot_merge_target_name[] = "snapshot-merge";
*/ */
#define SNAPSHOT_COPY_PRIORITY 2 #define SNAPSHOT_COPY_PRIORITY 2
/*
* Reserve 1MB for each snapshot initially (with minimum of 1 page).
*/
#define SNAPSHOT_PAGES (((1UL << 20) >> PAGE_SHIFT) ? : 1)
/* /*
* The size of the mempool used to track chunks in use. * The size of the mempool used to track chunks in use.
*/ */
...@@ -1116,7 +1111,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -1116,7 +1111,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad_hash_tables; goto bad_hash_tables;
} }
r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client); r = dm_kcopyd_client_create(&s->kcopyd_client);
if (r) { if (r) {
ti->error = "Could not create kcopyd client"; ti->error = "Could not create kcopyd client";
goto bad_kcopyd; goto bad_kcopyd;
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
* To use kcopyd you must first create a dm_kcopyd_client object. * To use kcopyd you must first create a dm_kcopyd_client object.
*/ */
struct dm_kcopyd_client; struct dm_kcopyd_client;
int dm_kcopyd_client_create(unsigned num_pages, int dm_kcopyd_client_create(struct dm_kcopyd_client **result);
struct dm_kcopyd_client **result);
void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc); void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc);
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册