Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347963
b: refs/heads/master
c: 70d6c40
h: refs/heads/master
i:
  347961: 6d44020
  347959: fada679
v: v3
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed Dec 21, 2012
1 parent aa56b56 commit 8ee421b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4f0b70b0479101522b8645ddc1f5ee7137821db3
refs/heads/master: 70d6c400acc386ea910c77318688541fc32e7ce8
23 changes: 18 additions & 5 deletions trunk/drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
unsigned num_bvecs;
sector_t remaining = where->count;
struct request_queue *q = bdev_get_queue(where->bdev);
sector_t discard_sectors;
unsigned short logical_block_size = queue_logical_block_size(q);
sector_t num_sectors;

/*
* where->count may be zero if rw holds a flush and we need to
Expand All @@ -297,7 +298,7 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
/*
* Allocate a suitably sized-bio.
*/
if (rw & REQ_DISCARD)
if ((rw & REQ_DISCARD) || (rw & REQ_WRITE_SAME))
num_bvecs = 1;
else
num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev),
Expand All @@ -310,9 +311,21 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
store_io_and_region_in_bio(bio, io, region);

if (rw & REQ_DISCARD) {
discard_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
bio->bi_size = discard_sectors << SECTOR_SHIFT;
remaining -= discard_sectors;
num_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
bio->bi_size = num_sectors << SECTOR_SHIFT;
remaining -= num_sectors;
} else if (rw & REQ_WRITE_SAME) {
/*
* WRITE SAME only uses a single page.
*/
dp->get_page(dp, &page, &len, &offset);
bio_add_page(bio, page, logical_block_size, offset);
num_sectors = min_t(sector_t, q->limits.max_write_same_sectors, remaining);
bio->bi_size = num_sectors << SECTOR_SHIFT;

offset = 0;
remaining -= num_sectors;
dp->next_page(dp);
} else while (remaining) {
/*
* Try and add as many pages as possible.
Expand Down
18 changes: 14 additions & 4 deletions trunk/drivers/md/dm-kcopyd.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static void complete_io(unsigned long error, void *context)
struct dm_kcopyd_client *kc = job->kc;

if (error) {
if (job->rw == WRITE)
if (job->rw & WRITE)
job->write_err |= error;
else
job->read_err = 1;
Expand All @@ -361,7 +361,7 @@ static void complete_io(unsigned long error, void *context)
}
}

if (job->rw == WRITE)
if (job->rw & WRITE)
push(&kc->complete_jobs, job);

else {
Expand Down Expand Up @@ -432,7 +432,7 @@ static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc,

if (r < 0) {
/* error this rogue job */
if (job->rw == WRITE)
if (job->rw & WRITE)
job->write_err = (unsigned long) -1L;
else
job->read_err = 1;
Expand Down Expand Up @@ -585,6 +585,7 @@ int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
{
struct kcopyd_job *job;
int i;

/*
* Allocate an array of jobs consisting of one master job
Expand All @@ -611,7 +612,16 @@ int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
memset(&job->source, 0, sizeof job->source);
job->source.count = job->dests[0].count;
job->pages = &zero_page_list;
job->rw = WRITE;

/*
* Use WRITE SAME to optimize zeroing if all dests support it.
*/
job->rw = WRITE | REQ_WRITE_SAME;
for (i = 0; i < job->num_dests; i++)
if (!bdev_write_same(job->dests[i].bdev)) {
job->rw = WRITE;
break;
}
}

job->fn = fn;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)

static struct target_type thin_target = {
.name = "thin",
.version = {1, 5, 0},
.version = {1, 6, 0},
.module = THIS_MODULE,
.ctr = thin_ctr,
.dtr = thin_dtr,
Expand Down

0 comments on commit 8ee421b

Please sign in to comment.