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>

authored by

Takahiro Yasui and committed by
Alasdair G Kergon
6f3af01c 10d3bd09

+7 -10
+7 -10
drivers/md/dm-log.c
··· 326 326 static int rw_header(struct log_c *lc, int rw) 327 327 { 328 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 330 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); 333 331 } ··· 358 360 } 359 361 360 362 return 0; 361 - } 362 - 363 - static inline int write_header(struct log_c *log) 364 - { 365 - header_to_disk(&log->header, log->disk_header); 366 - return rw_header(log, WRITE); 367 363 } 368 364 369 365 /*---------------------------------------------------------------- ··· 446 454 buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + 447 455 bitset_size, ti->limits.hardsect_size); 448 456 lc->header_location.count = buf_size >> SECTOR_SHIFT; 457 + 449 458 lc->io_req.mem.type = DM_IO_VMA; 459 + lc->io_req.notify.fn = NULL; 450 460 lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, 451 461 PAGE_SIZE)); 452 462 if (IS_ERR(lc->io_req.client)) { ··· 466 472 return -ENOMEM; 467 473 } 468 474 475 + lc->io_req.mem.ptr.vma = lc->disk_header; 469 476 lc->clean_bits = (void *)lc->disk_header + 470 477 (LOG_OFFSET << SECTOR_SHIFT); 471 478 } ··· 631 636 /* set the correct number of regions in the header */ 632 637 lc->header.nr_regions = lc->region_count; 633 638 639 + header_to_disk(&lc->header, lc->disk_header); 640 + 634 641 /* write the new header */ 635 - r = write_header(lc); 642 + r = rw_header(lc, WRITE); 636 643 if (r) { 637 644 DMWARN("%s: Failed to write header on dirty region log device", 638 645 lc->log_dev->name); ··· 684 687 if (!lc->touched) 685 688 return 0; 686 689 687 - r = write_header(lc); 690 + r = rw_header(lc, WRITE); 688 691 if (r) 689 692 fail_log_device(lc); 690 693 else