Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm kcopyd: clean interface

Clean up the kcopyd interface to prepare for publishing it in include/linux.

Signed-off-by: Heinz Mauelshagen <hjm@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

authored by

Heinz Mauelshagen and committed by
Alasdair G Kergon
eb69aca5 22a1ceb1

+62 -58
+8 -8
drivers/md/dm-raid1.c
··· 133 133 struct dm_target *ti; 134 134 struct list_head list; 135 135 struct region_hash rh; 136 - struct kcopyd_client *kcopyd_client; 136 + struct dm_kcopyd_client *kcopyd_client; 137 137 uint64_t features; 138 138 139 139 spinlock_t lock; /* protects the lists */ ··· 788 788 { 789 789 int r; 790 790 unsigned int i; 791 - struct dm_io_region from, to[KCOPYD_MAX_REGIONS], *dest; 791 + struct dm_io_region from, to[DM_KCOPYD_MAX_REGIONS], *dest; 792 792 struct mirror *m; 793 793 unsigned long flags = 0; 794 794 ··· 820 820 } 821 821 822 822 /* hand to kcopyd */ 823 - set_bit(KCOPYD_IGNORE_ERROR, &flags); 824 - r = kcopyd_copy(ms->kcopyd_client, &from, ms->nr_mirrors - 1, to, flags, 825 - recovery_complete, reg); 823 + set_bit(DM_KCOPYD_IGNORE_ERROR, &flags); 824 + r = dm_kcopyd_copy(ms->kcopyd_client, &from, ms->nr_mirrors - 1, to, 825 + flags, recovery_complete, reg); 826 826 827 827 return r; 828 828 } ··· 1504 1504 argc -= args_used; 1505 1505 1506 1506 if (!argc || sscanf(argv[0], "%u", &nr_mirrors) != 1 || 1507 - nr_mirrors < 2 || nr_mirrors > KCOPYD_MAX_REGIONS + 1) { 1507 + nr_mirrors < 2 || nr_mirrors > DM_KCOPYD_MAX_REGIONS + 1) { 1508 1508 ti->error = "Invalid number of mirrors"; 1509 1509 dm_destroy_dirty_log(dl); 1510 1510 return -EINVAL; ··· 1569 1569 goto err_destroy_wq; 1570 1570 } 1571 1571 1572 - r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); 1572 + r = dm_kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); 1573 1573 if (r) 1574 1574 goto err_destroy_wq; 1575 1575 ··· 1588 1588 struct mirror_set *ms = (struct mirror_set *) ti->private; 1589 1589 1590 1590 flush_workqueue(ms->kmirrord_wq); 1591 - kcopyd_client_destroy(ms->kcopyd_client); 1591 + dm_kcopyd_client_destroy(ms->kcopyd_client); 1592 1592 destroy_workqueue(ms->kmirrord_wq); 1593 1593 free_context(ms, ti, ms->nr_mirrors); 1594 1594 }
+4 -4
drivers/md/dm-snap.c
··· 558 558 goto bad4; 559 559 } 560 560 561 - r = kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client); 561 + r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client); 562 562 if (r) { 563 563 ti->error = "Could not create kcopyd client"; 564 564 goto bad5; ··· 591 591 return 0; 592 592 593 593 bad6: 594 - kcopyd_client_destroy(s->kcopyd_client); 594 + dm_kcopyd_client_destroy(s->kcopyd_client); 595 595 596 596 bad5: 597 597 s->store.destroy(&s->store); ··· 613 613 614 614 static void __free_exceptions(struct dm_snapshot *s) 615 615 { 616 - kcopyd_client_destroy(s->kcopyd_client); 616 + dm_kcopyd_client_destroy(s->kcopyd_client); 617 617 s->kcopyd_client = NULL; 618 618 619 619 exit_exception_table(&s->pending, pending_cache); ··· 839 839 dest.count = src.count; 840 840 841 841 /* Hand over to kcopyd */ 842 - kcopyd_copy(s->kcopyd_client, 842 + dm_kcopyd_copy(s->kcopyd_client, 843 843 &src, 1, &dest, 0, copy_callback, pe); 844 844 } 845 845
+1 -1
drivers/md/dm-snap.h
··· 169 169 /* The on disk metadata handler */ 170 170 struct exception_store store; 171 171 172 - struct kcopyd_client *kcopyd_client; 172 + struct dm_kcopyd_client *kcopyd_client; 173 173 174 174 /* Queue of snapshot writes for ksnapd to flush */ 175 175 struct bio_list queued_bios;
+25 -26
drivers/md/kcopyd.c
··· 9 9 * completion notification. 10 10 */ 11 11 12 - #include <asm/types.h> 12 + #include <linux/types.h> 13 13 #include <asm/atomic.h> 14 - 15 14 #include <linux/blkdev.h> 16 15 #include <linux/fs.h> 17 16 #include <linux/init.h> ··· 38 39 * Each kcopyd client has its own little pool of preallocated 39 40 * pages for kcopyd io. 40 41 *---------------------------------------------------------------*/ 41 - struct kcopyd_client { 42 + struct dm_kcopyd_client { 42 43 struct list_head list; 43 44 44 45 spinlock_t lock; ··· 75 76 kfree(pl); 76 77 } 77 78 78 - static int kcopyd_get_pages(struct kcopyd_client *kc, 79 + static int kcopyd_get_pages(struct dm_kcopyd_client *kc, 79 80 unsigned int nr, struct page_list **pages) 80 81 { 81 82 struct page_list *pl; ··· 98 99 return 0; 99 100 } 100 101 101 - static void kcopyd_put_pages(struct kcopyd_client *kc, struct page_list *pl) 102 + static void kcopyd_put_pages(struct dm_kcopyd_client *kc, struct page_list *pl) 102 103 { 103 104 struct page_list *cursor; 104 105 ··· 126 127 } 127 128 } 128 129 129 - static int client_alloc_pages(struct kcopyd_client *kc, unsigned int nr) 130 + static int client_alloc_pages(struct dm_kcopyd_client *kc, unsigned int nr) 130 131 { 131 132 unsigned int i; 132 133 struct page_list *pl = NULL, *next; ··· 147 148 return 0; 148 149 } 149 150 150 - static void client_free_pages(struct kcopyd_client *kc) 151 + static void client_free_pages(struct dm_kcopyd_client *kc) 151 152 { 152 153 BUG_ON(kc->nr_free_pages != kc->nr_pages); 153 154 drop_pages(kc->pages); ··· 161 162 * ever having to do io (which could cause a deadlock). 162 163 *---------------------------------------------------------------*/ 163 164 struct kcopyd_job { 164 - struct kcopyd_client *kc; 165 + struct dm_kcopyd_client *kc; 165 166 struct list_head list; 166 167 unsigned long flags; 167 168 ··· 181 182 * The destinations for the transfer. 182 183 */ 183 184 unsigned int num_dests; 184 - struct dm_io_region dests[KCOPYD_MAX_REGIONS]; 185 + struct dm_io_region dests[DM_KCOPYD_MAX_REGIONS]; 185 186 186 187 sector_t offset; 187 188 unsigned int nr_pages; ··· 191 192 * Set this to ensure you are notified when the job has 192 193 * completed. 'context' is for callback to use. 193 194 */ 194 - kcopyd_notify_fn fn; 195 + dm_kcopyd_notify_fn fn; 195 196 void *context; 196 197 197 198 /* ··· 294 295 void *context = job->context; 295 296 int read_err = job->read_err; 296 297 unsigned long write_err = job->write_err; 297 - kcopyd_notify_fn fn = job->fn; 298 - struct kcopyd_client *kc = job->kc; 298 + dm_kcopyd_notify_fn fn = job->fn; 299 + struct dm_kcopyd_client *kc = job->kc; 299 300 300 301 kcopyd_put_pages(kc, job->pages); 301 302 mempool_free(job, _job_pool); ··· 317 318 else 318 319 job->read_err = 1; 319 320 320 - if (!test_bit(KCOPYD_IGNORE_ERROR, &job->flags)) { 321 + if (!test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) { 321 322 push(&_complete_jobs, job); 322 323 wake(); 323 324 return; ··· 469 470 * Only dispatch more work if there hasn't been an error. 470 471 */ 471 472 if ((!job->read_err && !job->write_err) || 472 - test_bit(KCOPYD_IGNORE_ERROR, &job->flags)) { 473 + test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) { 473 474 /* get the next chunk of work */ 474 475 progress = job->progress; 475 476 count = job->source.count - progress; ··· 526 527 segment_complete(0, 0u, job); 527 528 } 528 529 529 - int kcopyd_copy(struct kcopyd_client *kc, struct dm_io_region *from, 530 - unsigned int num_dests, struct dm_io_region *dests, 531 - unsigned int flags, kcopyd_notify_fn fn, void *context) 530 + int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, 531 + unsigned int num_dests, struct dm_io_region *dests, 532 + unsigned int flags, dm_kcopyd_notify_fn fn, void *context) 532 533 { 533 534 struct kcopyd_job *job; 534 535 ··· 569 570 570 571 return 0; 571 572 } 573 + EXPORT_SYMBOL(dm_kcopyd_copy); 572 574 573 575 /* 574 576 * Cancels a kcopyd job, eg. someone might be deactivating a ··· 589 589 static DEFINE_MUTEX(_client_lock); 590 590 static LIST_HEAD(_clients); 591 591 592 - static void client_add(struct kcopyd_client *kc) 592 + static void client_add(struct dm_kcopyd_client *kc) 593 593 { 594 594 mutex_lock(&_client_lock); 595 595 list_add(&kc->list, &_clients); 596 596 mutex_unlock(&_client_lock); 597 597 } 598 598 599 - static void client_del(struct kcopyd_client *kc) 599 + static void client_del(struct dm_kcopyd_client *kc) 600 600 { 601 601 mutex_lock(&_client_lock); 602 602 list_del(&kc->list); ··· 650 650 mutex_unlock(&kcopyd_init_lock); 651 651 } 652 652 653 - int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) 653 + int dm_kcopyd_client_create(unsigned int nr_pages, 654 + struct dm_kcopyd_client **result) 654 655 { 655 656 int r = 0; 656 - struct kcopyd_client *kc; 657 + struct dm_kcopyd_client *kc; 657 658 658 659 r = kcopyd_init(); 659 660 if (r) ··· 692 691 *result = kc; 693 692 return 0; 694 693 } 694 + EXPORT_SYMBOL(dm_kcopyd_client_create); 695 695 696 - void kcopyd_client_destroy(struct kcopyd_client *kc) 696 + void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc) 697 697 { 698 698 /* Wait for completion of all jobs submitted by this client. */ 699 699 wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); ··· 705 703 kfree(kc); 706 704 kcopyd_exit(); 707 705 } 708 - 709 - EXPORT_SYMBOL(kcopyd_client_create); 710 - EXPORT_SYMBOL(kcopyd_client_destroy); 711 - EXPORT_SYMBOL(kcopyd_copy); 706 + EXPORT_SYMBOL(dm_kcopyd_client_destroy);
+24 -19
drivers/md/kcopyd.h
··· 1 1 /* 2 - * Copyright (C) 2001 Sistina Software 2 + * Copyright (C) 2001 - 2003 Sistina Software 3 + * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved. 4 + * 5 + * kcopyd provides a simple interface for copying an area of one 6 + * block-device to one or more other block-devices, either synchronous 7 + * or with an asynchronous completion notification. 3 8 * 4 9 * This file is released under the GPL. 5 - * 6 - * Kcopyd provides a simple interface for copying an area of one 7 - * block-device to one or more other block-devices, with an asynchronous 8 - * completion notification. 9 10 */ 10 11 11 - #ifndef DM_KCOPYD_H 12 - #define DM_KCOPYD_H 12 + #ifndef _LINUX_DM_KCOPYD_H 13 + #define _LINUX_DM_KCOPYD_H 14 + 15 + #ifdef __KERNEL__ 13 16 14 17 #include "dm-io.h" 15 18 16 19 /* FIXME: make this configurable */ 17 - #define KCOPYD_MAX_REGIONS 8 20 + #define DM_KCOPYD_MAX_REGIONS 8 18 21 19 - #define KCOPYD_IGNORE_ERROR 1 22 + #define DM_KCOPYD_IGNORE_ERROR 1 20 23 21 24 /* 22 - * To use kcopyd you must first create a kcopyd client object. 25 + * To use kcopyd you must first create a dm_kcopyd_client object. 23 26 */ 24 - struct kcopyd_client; 25 - int kcopyd_client_create(unsigned int num_pages, struct kcopyd_client **result); 26 - void kcopyd_client_destroy(struct kcopyd_client *kc); 27 + struct dm_kcopyd_client; 28 + int dm_kcopyd_client_create(unsigned num_pages, 29 + struct dm_kcopyd_client **result); 30 + void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc); 27 31 28 32 /* 29 33 * Submit a copy job to kcopyd. This is built on top of the ··· 36 32 * read_err is a boolean, 37 33 * write_err is a bitset, with 1 bit for each destination region 38 34 */ 39 - typedef void (*kcopyd_notify_fn)(int read_err, unsigned long write_err, 40 - void *context); 35 + typedef void (*dm_kcopyd_notify_fn)(int read_err, unsigned long write_err, 36 + void *context); 41 37 42 - int kcopyd_copy(struct kcopyd_client *kc, struct dm_io_region *from, 43 - unsigned num_dests, struct dm_io_region *dests, 44 - unsigned int flags, kcopyd_notify_fn fn, void *context); 38 + int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, 39 + unsigned num_dests, struct dm_io_region *dests, 40 + unsigned flags, dm_kcopyd_notify_fn fn, void *context); 45 41 46 - #endif 42 + #endif /* __KERNEL__ */ 43 + #endif /* _LINUX_DM_KCOPYD_H */