* [PATCH] dm-kcopyd: optionally zero an area instead of copying
@ 2011-06-08 21:55 Mikulas Patocka
2011-06-09 10:04 ` Joe Thornber
0 siblings, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2011-06-08 21:55 UTC (permalink / raw)
To: Edward Thornber, Alasdair G. Kergon, dm-devel
Hi
This patch introduces an option to kcopyd to zero requested area instead
of copying. I think Joe may need something like this in his snapshot
store.
Mikulas
---
dm-kcopyd: optionally zero an area instead of copying
This patch causes kcopyd to zero a requested area instead of copying
if "from" parameter is set to zero.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm-kcopyd.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
Index: linux-2.6.39-fast/drivers/md/dm-kcopyd.c
===================================================================
--- linux-2.6.39-fast.orig/drivers/md/dm-kcopyd.c 2011-06-08 17:07:43.000000000 +0200
+++ linux-2.6.39-fast/drivers/md/dm-kcopyd.c 2011-06-08 17:18:02.000000000 +0200
@@ -69,6 +69,8 @@ struct dm_kcopyd_client {
struct list_head pages_jobs;
};
+static struct page_list zero_page_list;
+
static DEFINE_SPINLOCK(throttle_spinlock);
/*
@@ -339,6 +341,9 @@ int __init dm_kcopyd_init(void)
if (!_job_cache)
return -ENOMEM;
+ zero_page_list.next = &zero_page_list;
+ zero_page_list.page = ZERO_PAGE(0);
+
return 0;
}
@@ -407,7 +412,7 @@ static int run_complete_job(struct kcopy
dm_kcopyd_notify_fn fn = job->fn;
struct dm_kcopyd_client *kc = job->kc;
- if (job->pages)
+ if (job->pages && job->pages != &zero_page_list)
kcopyd_put_pages(kc, job->pages);
/* Do not free sub-jobs */
if (context != job)
@@ -570,6 +575,8 @@ static void dispatch_job(struct kcopyd_j
atomic_inc(&kc->nr_jobs);
if (unlikely(!job->source.count))
push(&kc->complete_jobs, job);
+ else if (job->pages == &zero_page_list)
+ push(&kc->io_jobs, job);
else
push(&kc->pages_jobs, job);
wake(kc);
@@ -681,12 +688,18 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie
job->write_err = 0;
job->rw = READ;
- job->source = *from;
-
job->num_dests = num_dests;
memcpy(&job->dests, dests, sizeof(*dests) * num_dests);
- job->pages = NULL;
+ if (from) {
+ job->source = *from;
+ job->pages = NULL;
+ } else {
+ memset(&job->source, 0, sizeof job->source);
+ job->source.count = job->dests[0].count;
+ job->pages = &zero_page_list;
+ job->rw = WRITE;
+ }
job->fn = fn;
job->context = context;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm-kcopyd: optionally zero an area instead of copying
2011-06-08 21:55 [PATCH] dm-kcopyd: optionally zero an area instead of copying Mikulas Patocka
@ 2011-06-09 10:04 ` Joe Thornber
2011-06-09 15:36 ` Mikulas Patocka
0 siblings, 1 reply; 5+ messages in thread
From: Joe Thornber @ 2011-06-09 10:04 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: dm-devel, Alasdair G. Kergon
On Wed, Jun 08, 2011 at 05:55:37PM -0400, Mikulas Patocka wrote:
> Hi
>
> This patch introduces an option to kcopyd to zero requested area instead
> of copying. I think Joe may need something like this in his snapshot
> store.
Could we have another function please, rather than overloading the
existing entry point?
i.e.,
int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
unsigned num_dests, struct dm_io_region *dests,
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
Thanks,
- Joe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm-kcopyd: optionally zero an area instead of copying
2011-06-09 10:04 ` Joe Thornber
@ 2011-06-09 15:36 ` Mikulas Patocka
2011-06-23 14:34 ` Alasdair G Kergon
0 siblings, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2011-06-09 15:36 UTC (permalink / raw)
To: Joe Thornber; +Cc: dm-devel, Alasdair G. Kergon
On Thu, 9 Jun 2011, Joe Thornber wrote:
> On Wed, Jun 08, 2011 at 05:55:37PM -0400, Mikulas Patocka wrote:
> > Hi
> >
> > This patch introduces an option to kcopyd to zero requested area instead
> > of copying. I think Joe may need something like this in his snapshot
> > store.
>
> Could we have another function please, rather than overloading the
> existing entry point?
>
> i.e.,
>
> int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
> unsigned num_dests, struct dm_io_region *dests,
> unsigned flags, dm_kcopyd_notify_fn fn, void *context);
>
> Thanks,
>
> - Joe
>
Here it is ... but it duplicates some code in dm_kcopyd_copy..
Mikulas
---
dm-kcopyd: optionally zero an area instead of copying
This patch introduces new function "dm_kcopyd_zero" that zeroes a
requested.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm-kcopyd.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-
include/linux/dm-kcopyd.h | 4 +++
2 files changed, 56 insertions(+), 1 deletion(-)
Index: linux-2.6.39-fast/drivers/md/dm-kcopyd.c
===================================================================
--- linux-2.6.39-fast.orig/drivers/md/dm-kcopyd.c 2011-06-09 17:15:34.000000000 +0200
+++ linux-2.6.39-fast/drivers/md/dm-kcopyd.c 2011-06-09 17:20:30.000000000 +0200
@@ -69,6 +69,8 @@ struct dm_kcopyd_client {
struct list_head pages_jobs;
};
+static struct page_list zero_page_list;
+
static DEFINE_SPINLOCK(throttle_spinlock);
/*
@@ -339,6 +341,9 @@ int __init dm_kcopyd_init(void)
if (!_job_cache)
return -ENOMEM;
+ zero_page_list.next = &zero_page_list;
+ zero_page_list.page = ZERO_PAGE(0);
+
return 0;
}
@@ -407,7 +412,7 @@ static int run_complete_job(struct kcopy
dm_kcopyd_notify_fn fn = job->fn;
struct dm_kcopyd_client *kc = job->kc;
- if (job->pages)
+ if (job->pages && job->pages != &zero_page_list)
kcopyd_put_pages(kc, job->pages);
/* Do not free sub-jobs */
if (context != job)
@@ -570,6 +575,8 @@ static void dispatch_job(struct kcopyd_j
atomic_inc(&kc->nr_jobs);
if (unlikely(!job->source.count))
push(&kc->complete_jobs, job);
+ else if (job->pages == &zero_page_list)
+ push(&kc->io_jobs, job);
else
push(&kc->pages_jobs, job);
wake(kc);
@@ -704,6 +711,50 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie
}
EXPORT_SYMBOL(dm_kcopyd_copy);
+int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
+ unsigned int num_dests, struct dm_io_region *dests,
+ unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
+{
+ struct kcopyd_job *job;
+
+ /*
+ * Allocate a new job.
+ */
+ job = mempool_alloc(kc->job_pool, GFP_NOIO);
+
+ /*
+ * set up for the write.
+ */
+ job->kc = kc;
+ job->flags = flags;
+ job->read_err = 0;
+ job->write_err = 0;
+ job->rw = WRITE;
+
+ memset(&job->source, 0, sizeof job->source);
+ job->source.count = dests[0].count;
+
+ job->num_dests = num_dests;
+ memcpy(&job->dests, dests, sizeof(*dests) * num_dests);
+
+ job->pages = &zero_page_list;
+
+ job->fn = fn;
+ job->context = context;
+
+ if (job->source.count <= SUB_JOB_SIZE)
+ dispatch_job(job);
+
+ else {
+ mutex_init(&job->lock);
+ job->progress = 0;
+ split_job(job);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(dm_kcopyd_zero);
+
/*
* Cancels a kcopyd job, eg. someone might be deactivating a
* mirror.
Index: linux-2.6.39-fast/include/linux/dm-kcopyd.h
===================================================================
--- linux-2.6.39-fast.orig/include/linux/dm-kcopyd.h 2011-06-09 17:20:47.000000000 +0200
+++ linux-2.6.39-fast/include/linux/dm-kcopyd.h 2011-06-09 17:21:01.000000000 +0200
@@ -55,5 +55,9 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie
unsigned num_dests, struct dm_io_region *dests,
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
+int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
+ unsigned num_dests, struct dm_io_region *dests,
+ unsigned flags, dm_kcopyd_notify_fn fn, void *context);
+
#endif /* __KERNEL__ */
#endif /* _LINUX_DM_KCOPYD_H */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm-kcopyd: optionally zero an area instead of copying
2011-06-09 15:36 ` Mikulas Patocka
@ 2011-06-23 14:34 ` Alasdair G Kergon
2011-06-23 15:24 ` Mikulas Patocka
0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2011-06-23 14:34 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: dm-devel, Joe Thornber
On Thu, Jun 09, 2011 at 11:36:44AM -0400, Mikulas Patocka wrote:
> Here it is ... but it duplicates some code in dm_kcopyd_copy..
Obviously I don't want the duplication:)
Presumably a wrapper function with the first patch will suffice?
Alasdair
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm-kcopyd: optionally zero an area instead of copying
2011-06-23 14:34 ` Alasdair G Kergon
@ 2011-06-23 15:24 ` Mikulas Patocka
0 siblings, 0 replies; 5+ messages in thread
From: Mikulas Patocka @ 2011-06-23 15:24 UTC (permalink / raw)
To: Alasdair G Kergon; +Cc: dm-devel, Joe Thornber
On Thu, 23 Jun 2011, Alasdair G Kergon wrote:
> On Thu, Jun 09, 2011 at 11:36:44AM -0400, Mikulas Patocka wrote:
> > Here it is ... but it duplicates some code in dm_kcopyd_copy..
>
> Obviously I don't want the duplication:)
>
> Presumably a wrapper function with the first patch will suffice?
>
> Alasdair
Hi
So you can use this patch that adds a new function, but internaly works as
passing NULL from to dm_kcopyd_copy.
Mikulas
---
dm-kcopyd: optionally zero an area instead of copying
This patch introduces new function "dm_kcopyd_zero" that zeroes a
requested.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm-kcopyd.c | 31 ++++++++++++++++++++++++++-----
include/linux/dm-kcopyd.h | 3 +++
2 files changed, 29 insertions(+), 5 deletions(-)
Index: linux-2.6.39-fast/drivers/md/dm-kcopyd.c
===================================================================
--- linux-2.6.39-fast.orig/drivers/md/dm-kcopyd.c 2011-06-23 16:58:49.000000000 +0200
+++ linux-2.6.39-fast/drivers/md/dm-kcopyd.c 2011-06-23 17:02:47.000000000 +0200
@@ -69,6 +69,8 @@ struct dm_kcopyd_client {
struct list_head pages_jobs;
};
+static struct page_list zero_page_list;
+
static DEFINE_SPINLOCK(throttle_spinlock);
/*
@@ -339,6 +341,9 @@ int __init dm_kcopyd_init(void)
if (!_job_cache)
return -ENOMEM;
+ zero_page_list.next = &zero_page_list;
+ zero_page_list.page = ZERO_PAGE(0);
+
return 0;
}
@@ -407,7 +412,7 @@ static int run_complete_job(struct kcopy
dm_kcopyd_notify_fn fn = job->fn;
struct dm_kcopyd_client *kc = job->kc;
- if (job->pages)
+ if (job->pages && job->pages != &zero_page_list)
kcopyd_put_pages(kc, job->pages);
/* Do not free sub-jobs */
if (context != job)
@@ -570,6 +575,8 @@ static void dispatch_job(struct kcopyd_j
atomic_inc(&kc->nr_jobs);
if (unlikely(!job->source.count))
push(&kc->complete_jobs, job);
+ else if (job->pages == &zero_page_list)
+ push(&kc->io_jobs, job);
else
push(&kc->pages_jobs, job);
wake(kc);
@@ -679,14 +686,20 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie
job->flags = flags;
job->read_err = 0;
job->write_err = 0;
- job->rw = READ;
-
- job->source = *from;
job->num_dests = num_dests;
memcpy(&job->dests, dests, sizeof(*dests) * num_dests);
- job->pages = NULL;
+ if (from) {
+ job->source = *from;
+ job->pages = NULL;
+ job->rw = READ;
+ } else {
+ memset(&job->source, 0, sizeof job->source);
+ job->source.count = job->dests[0].count;
+ job->pages = &zero_page_list;
+ job->rw = WRITE;
+ }
job->fn = fn;
job->context = context;
@@ -704,6 +717,14 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie
}
EXPORT_SYMBOL(dm_kcopyd_copy);
+int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
+ unsigned int num_dests, struct dm_io_region *dests,
+ unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
+{
+ return dm_kcopyd_copy(kc, NULL, num_dests, dests, flags, fn, context);
+}
+EXPORT_SYMBOL(dm_kcopyd_zero);
+
/*
* Cancels a kcopyd job, eg. someone might be deactivating a
* mirror.
Index: linux-2.6.39-fast/include/linux/dm-kcopyd.h
===================================================================
--- linux-2.6.39-fast.orig/include/linux/dm-kcopyd.h 2011-06-23 17:00:16.000000000 +0200
+++ linux-2.6.39-fast/include/linux/dm-kcopyd.h 2011-06-23 17:00:42.000000000 +0200
@@ -54,6 +54,9 @@ typedef void (*dm_kcopyd_notify_fn)(int
int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
unsigned num_dests, struct dm_io_region *dests,
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
+int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
+ unsigned num_dests, struct dm_io_region *dests,
+ unsigned flags, dm_kcopyd_notify_fn fn, void *context);
#endif /* __KERNEL__ */
#endif /* _LINUX_DM_KCOPYD_H */
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-06-23 15:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 21:55 [PATCH] dm-kcopyd: optionally zero an area instead of copying Mikulas Patocka
2011-06-09 10:04 ` Joe Thornber
2011-06-09 15:36 ` Mikulas Patocka
2011-06-23 14:34 ` Alasdair G Kergon
2011-06-23 15:24 ` Mikulas Patocka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.