diff options
author | Takahiro Yasui <tyasui@redhat.com> | 2009-01-05 22:04:59 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-01-05 22:04:59 -0500 |
commit | 6f3af01cb0eda0ec50fe1e4cbdf028269dc396fe (patch) | |
tree | 29988ebe5a40ee1092bdbeac45eb0bdc312ff670 /drivers/md/dm-log.c | |
parent | 10d3bd09a3c25df114f74f7f86e1b58d070bef32 (diff) |
dm log: avoid reinitialising io_req on every operation
rw_header function updates three members of io_req data every time
when I/O is processed. bi_rw and notify.fn are never modified once
they get initialized, and so they can be set in advance.
header_to_disk() can also be pulled out of write_header() since only one
caller needs it and write_header() can be replaced by rw_header()
directly.
Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-log.c')
-rw-r--r-- | drivers/md/dm-log.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 13e2a1a1a941..691cb9c22b56 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
@@ -326,8 +326,6 @@ static void header_from_disk(struct log_header *core, struct log_header *disk) | |||
326 | static int rw_header(struct log_c *lc, int rw) | 326 | static int rw_header(struct log_c *lc, int rw) |
327 | { | 327 | { |
328 | lc->io_req.bi_rw = rw; | 328 | lc->io_req.bi_rw = rw; |
329 | lc->io_req.mem.ptr.vma = lc->disk_header; | ||
330 | lc->io_req.notify.fn = NULL; | ||
331 | 329 | ||
332 | return dm_io(&lc->io_req, 1, &lc->header_location, NULL); | 330 | return dm_io(&lc->io_req, 1, &lc->header_location, NULL); |
333 | } | 331 | } |
@@ -362,12 +360,6 @@ static int read_header(struct log_c *log) | |||
362 | return 0; | 360 | return 0; |
363 | } | 361 | } |
364 | 362 | ||
365 | static inline int write_header(struct log_c *log) | ||
366 | { | ||
367 | header_to_disk(&log->header, log->disk_header); | ||
368 | return rw_header(log, WRITE); | ||
369 | } | ||
370 | |||
371 | /*---------------------------------------------------------------- | 363 | /*---------------------------------------------------------------- |
372 | * core log constructor/destructor | 364 | * core log constructor/destructor |
373 | * | 365 | * |
@@ -454,7 +446,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, | |||
454 | buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + | 446 | buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + |
455 | bitset_size, ti->limits.hardsect_size); | 447 | bitset_size, ti->limits.hardsect_size); |
456 | lc->header_location.count = buf_size >> SECTOR_SHIFT; | 448 | lc->header_location.count = buf_size >> SECTOR_SHIFT; |
449 | |||
457 | lc->io_req.mem.type = DM_IO_VMA; | 450 | lc->io_req.mem.type = DM_IO_VMA; |
451 | lc->io_req.notify.fn = NULL; | ||
458 | lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, | 452 | lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, |
459 | PAGE_SIZE)); | 453 | PAGE_SIZE)); |
460 | if (IS_ERR(lc->io_req.client)) { | 454 | if (IS_ERR(lc->io_req.client)) { |
@@ -472,6 +466,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, | |||
472 | return -ENOMEM; | 466 | return -ENOMEM; |
473 | } | 467 | } |
474 | 468 | ||
469 | lc->io_req.mem.ptr.vma = lc->disk_header; | ||
475 | lc->clean_bits = (void *)lc->disk_header + | 470 | lc->clean_bits = (void *)lc->disk_header + |
476 | (LOG_OFFSET << SECTOR_SHIFT); | 471 | (LOG_OFFSET << SECTOR_SHIFT); |
477 | } | 472 | } |
@@ -636,8 +631,10 @@ static int disk_resume(struct dm_dirty_log *log) | |||
636 | /* set the correct number of regions in the header */ | 631 | /* set the correct number of regions in the header */ |
637 | lc->header.nr_regions = lc->region_count; | 632 | lc->header.nr_regions = lc->region_count; |
638 | 633 | ||
634 | header_to_disk(&lc->header, lc->disk_header); | ||
635 | |||
639 | /* write the new header */ | 636 | /* write the new header */ |
640 | r = write_header(lc); | 637 | r = rw_header(lc, WRITE); |
641 | if (r) { | 638 | if (r) { |
642 | DMWARN("%s: Failed to write header on dirty region log device", | 639 | DMWARN("%s: Failed to write header on dirty region log device", |
643 | lc->log_dev->name); | 640 | lc->log_dev->name); |
@@ -687,7 +684,7 @@ static int disk_flush(struct dm_dirty_log *log) | |||
687 | if (!lc->touched) | 684 | if (!lc->touched) |
688 | return 0; | 685 | return 0; |
689 | 686 | ||
690 | r = write_header(lc); | 687 | r = rw_header(lc, WRITE); |
691 | if (r) | 688 | if (r) |
692 | fail_log_device(lc); | 689 | fail_log_device(lc); |
693 | else | 690 | else |