aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/kcopyd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/kcopyd.c')
-rw-r--r--drivers/md/kcopyd.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index 21fea42c68c4..4f2c61acf7c6 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -9,9 +9,8 @@
9 * completion notification. 9 * completion notification.
10 */ 10 */
11 11
12#include <asm/types.h> 12#include <linux/types.h>
13#include <asm/atomic.h> 13#include <asm/atomic.h>
14
15#include <linux/blkdev.h> 14#include <linux/blkdev.h>
16#include <linux/fs.h> 15#include <linux/fs.h>
17#include <linux/init.h> 16#include <linux/init.h>
@@ -39,7 +38,7 @@ static void wake(void)
39 * Each kcopyd client has its own little pool of preallocated 38 * Each kcopyd client has its own little pool of preallocated
40 * pages for kcopyd io. 39 * pages for kcopyd io.
41 *---------------------------------------------------------------*/ 40 *---------------------------------------------------------------*/
42struct kcopyd_client { 41struct dm_kcopyd_client {
43 struct list_head list; 42 struct list_head list;
44 43
45 spinlock_t lock; 44 spinlock_t lock;
@@ -76,7 +75,7 @@ static void free_pl(struct page_list *pl)
76 kfree(pl); 75 kfree(pl);
77} 76}
78 77
79static int kcopyd_get_pages(struct kcopyd_client *kc, 78static int kcopyd_get_pages(struct dm_kcopyd_client *kc,
80 unsigned int nr, struct page_list **pages) 79 unsigned int nr, struct page_list **pages)
81{ 80{
82 struct page_list *pl; 81 struct page_list *pl;
@@ -99,7 +98,7 @@ static int kcopyd_get_pages(struct kcopyd_client *kc,
99 return 0; 98 return 0;
100} 99}
101 100
102static void kcopyd_put_pages(struct kcopyd_client *kc, struct page_list *pl) 101static void kcopyd_put_pages(struct dm_kcopyd_client *kc, struct page_list *pl)
103{ 102{
104 struct page_list *cursor; 103 struct page_list *cursor;
105 104
@@ -127,7 +126,7 @@ static void drop_pages(struct page_list *pl)
127 } 126 }
128} 127}
129 128
130static int client_alloc_pages(struct kcopyd_client *kc, unsigned int nr) 129static int client_alloc_pages(struct dm_kcopyd_client *kc, unsigned int nr)
131{ 130{
132 unsigned int i; 131 unsigned int i;
133 struct page_list *pl = NULL, *next; 132 struct page_list *pl = NULL, *next;
@@ -148,7 +147,7 @@ static int client_alloc_pages(struct kcopyd_client *kc, unsigned int nr)
148 return 0; 147 return 0;
149} 148}
150 149
151static void client_free_pages(struct kcopyd_client *kc) 150static void client_free_pages(struct dm_kcopyd_client *kc)
152{ 151{
153 BUG_ON(kc->nr_free_pages != kc->nr_pages); 152 BUG_ON(kc->nr_free_pages != kc->nr_pages);
154 drop_pages(kc->pages); 153 drop_pages(kc->pages);
@@ -162,7 +161,7 @@ static void client_free_pages(struct kcopyd_client *kc)
162 * ever having to do io (which could cause a deadlock). 161 * ever having to do io (which could cause a deadlock).
163 *---------------------------------------------------------------*/ 162 *---------------------------------------------------------------*/
164struct kcopyd_job { 163struct kcopyd_job {
165 struct kcopyd_client *kc; 164 struct dm_kcopyd_client *kc;
166 struct list_head list; 165 struct list_head list;
167 unsigned long flags; 166 unsigned long flags;
168 167
@@ -182,7 +181,7 @@ struct kcopyd_job {
182 * The destinations for the transfer. 181 * The destinations for the transfer.
183 */ 182 */
184 unsigned int num_dests; 183 unsigned int num_dests;
185 struct dm_io_region dests[KCOPYD_MAX_REGIONS]; 184 struct dm_io_region dests[DM_KCOPYD_MAX_REGIONS];
186 185
187 sector_t offset; 186 sector_t offset;
188 unsigned int nr_pages; 187 unsigned int nr_pages;
@@ -192,7 +191,7 @@ struct kcopyd_job {
192 * Set this to ensure you are notified when the job has 191 * Set this to ensure you are notified when the job has
193 * completed. 'context' is for callback to use. 192 * completed. 'context' is for callback to use.
194 */ 193 */
195 kcopyd_notify_fn fn; 194 dm_kcopyd_notify_fn fn;
196 void *context; 195 void *context;
197 196
198 /* 197 /*
@@ -295,8 +294,8 @@ static int run_complete_job(struct kcopyd_job *job)
295 void *context = job->context; 294 void *context = job->context;
296 int read_err = job->read_err; 295 int read_err = job->read_err;
297 unsigned long write_err = job->write_err; 296 unsigned long write_err = job->write_err;
298 kcopyd_notify_fn fn = job->fn; 297 dm_kcopyd_notify_fn fn = job->fn;
299 struct kcopyd_client *kc = job->kc; 298 struct dm_kcopyd_client *kc = job->kc;
300 299
301 kcopyd_put_pages(kc, job->pages); 300 kcopyd_put_pages(kc, job->pages);
302 mempool_free(job, _job_pool); 301 mempool_free(job, _job_pool);
@@ -318,7 +317,7 @@ static void complete_io(unsigned long error, void *context)
318 else 317 else
319 job->read_err = 1; 318 job->read_err = 1;
320 319
321 if (!test_bit(KCOPYD_IGNORE_ERROR, &job->flags)) { 320 if (!test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) {
322 push(&_complete_jobs, job); 321 push(&_complete_jobs, job);
323 wake(); 322 wake();
324 return; 323 return;
@@ -470,7 +469,7 @@ static void segment_complete(int read_err, unsigned long write_err,
470 * Only dispatch more work if there hasn't been an error. 469 * Only dispatch more work if there hasn't been an error.
471 */ 470 */
472 if ((!job->read_err && !job->write_err) || 471 if ((!job->read_err && !job->write_err) ||
473 test_bit(KCOPYD_IGNORE_ERROR, &job->flags)) { 472 test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) {
474 /* get the next chunk of work */ 473 /* get the next chunk of work */
475 progress = job->progress; 474 progress = job->progress;
476 count = job->source.count - progress; 475 count = job->source.count - progress;
@@ -527,9 +526,9 @@ static void split_job(struct kcopyd_job *job)
527 segment_complete(0, 0u, job); 526 segment_complete(0, 0u, job);
528} 527}
529 528
530int kcopyd_copy(struct kcopyd_client *kc, struct dm_io_region *from, 529int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
531 unsigned int num_dests, struct dm_io_region *dests, 530 unsigned int num_dests, struct dm_io_region *dests,
532 unsigned int flags, kcopyd_notify_fn fn, void *context) 531 unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
533{ 532{
534 struct kcopyd_job *job; 533 struct kcopyd_job *job;
535 534
@@ -570,6 +569,7 @@ int kcopyd_copy(struct kcopyd_client *kc, struct dm_io_region *from,
570 569
571 return 0; 570 return 0;
572} 571}
572EXPORT_SYMBOL(dm_kcopyd_copy);
573 573
574/* 574/*
575 * Cancels a kcopyd job, eg. someone might be deactivating a 575 * Cancels a kcopyd job, eg. someone might be deactivating a
@@ -589,14 +589,14 @@ int kcopyd_cancel(struct kcopyd_job *job, int block)
589static DEFINE_MUTEX(_client_lock); 589static DEFINE_MUTEX(_client_lock);
590static LIST_HEAD(_clients); 590static LIST_HEAD(_clients);
591 591
592static void client_add(struct kcopyd_client *kc) 592static void client_add(struct dm_kcopyd_client *kc)
593{ 593{
594 mutex_lock(&_client_lock); 594 mutex_lock(&_client_lock);
595 list_add(&kc->list, &_clients); 595 list_add(&kc->list, &_clients);
596 mutex_unlock(&_client_lock); 596 mutex_unlock(&_client_lock);
597} 597}
598 598
599static void client_del(struct kcopyd_client *kc) 599static void client_del(struct dm_kcopyd_client *kc)
600{ 600{
601 mutex_lock(&_client_lock); 601 mutex_lock(&_client_lock);
602 list_del(&kc->list); 602 list_del(&kc->list);
@@ -650,10 +650,11 @@ static void kcopyd_exit(void)
650 mutex_unlock(&kcopyd_init_lock); 650 mutex_unlock(&kcopyd_init_lock);
651} 651}
652 652
653int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) 653int dm_kcopyd_client_create(unsigned int nr_pages,
654 struct dm_kcopyd_client **result)
654{ 655{
655 int r = 0; 656 int r = 0;
656 struct kcopyd_client *kc; 657 struct dm_kcopyd_client *kc;
657 658
658 r = kcopyd_init(); 659 r = kcopyd_init();
659 if (r) 660 if (r)
@@ -691,8 +692,9 @@ int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result)
691 *result = kc; 692 *result = kc;
692 return 0; 693 return 0;
693} 694}
695EXPORT_SYMBOL(dm_kcopyd_client_create);
694 696
695void kcopyd_client_destroy(struct kcopyd_client *kc) 697void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc)
696{ 698{
697 /* Wait for completion of all jobs submitted by this client. */ 699 /* Wait for completion of all jobs submitted by this client. */
698 wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); 700 wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs));
@@ -703,7 +705,4 @@ void kcopyd_client_destroy(struct kcopyd_client *kc)
703 kfree(kc); 705 kfree(kc);
704 kcopyd_exit(); 706 kcopyd_exit();
705} 707}
706 708EXPORT_SYMBOL(dm_kcopyd_client_destroy);
707EXPORT_SYMBOL(kcopyd_client_create);
708EXPORT_SYMBOL(kcopyd_client_destroy);
709EXPORT_SYMBOL(kcopyd_copy);