Commit 6f3af01c authored by Takahiro Yasui's avatar Takahiro Yasui Committed by Alasdair G Kergon

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: default avatarTakahiro Yasui <tyasui@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 10d3bd09
...@@ -326,8 +326,6 @@ static void header_from_disk(struct log_header *core, struct log_header *disk) ...@@ -326,8 +326,6 @@ static void header_from_disk(struct log_header *core, struct log_header *disk)
static int rw_header(struct log_c *lc, int rw) static int rw_header(struct log_c *lc, int rw)
{ {
lc->io_req.bi_rw = rw; lc->io_req.bi_rw = rw;
lc->io_req.mem.ptr.vma = lc->disk_header;
lc->io_req.notify.fn = NULL;
return dm_io(&lc->io_req, 1, &lc->header_location, NULL); return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
} }
...@@ -362,12 +360,6 @@ static int read_header(struct log_c *log) ...@@ -362,12 +360,6 @@ static int read_header(struct log_c *log)
return 0; return 0;
} }
static inline int write_header(struct log_c *log)
{
header_to_disk(&log->header, log->disk_header);
return rw_header(log, WRITE);
}
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* core log constructor/destructor * core log constructor/destructor
* *
...@@ -454,7 +446,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, ...@@ -454,7 +446,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
bitset_size, ti->limits.hardsect_size); bitset_size, ti->limits.hardsect_size);
lc->header_location.count = buf_size >> SECTOR_SHIFT; lc->header_location.count = buf_size >> SECTOR_SHIFT;
lc->io_req.mem.type = DM_IO_VMA; lc->io_req.mem.type = DM_IO_VMA;
lc->io_req.notify.fn = NULL;
lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, lc->io_req.client = dm_io_client_create(dm_div_up(buf_size,
PAGE_SIZE)); PAGE_SIZE));
if (IS_ERR(lc->io_req.client)) { 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,6 +466,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
return -ENOMEM; return -ENOMEM;
} }
lc->io_req.mem.ptr.vma = lc->disk_header;
lc->clean_bits = (void *)lc->disk_header + lc->clean_bits = (void *)lc->disk_header +
(LOG_OFFSET << SECTOR_SHIFT); (LOG_OFFSET << SECTOR_SHIFT);
} }
...@@ -636,8 +631,10 @@ static int disk_resume(struct dm_dirty_log *log) ...@@ -636,8 +631,10 @@ static int disk_resume(struct dm_dirty_log *log)
/* set the correct number of regions in the header */ /* set the correct number of regions in the header */
lc->header.nr_regions = lc->region_count; lc->header.nr_regions = lc->region_count;
header_to_disk(&lc->header, lc->disk_header);
/* write the new header */ /* write the new header */
r = write_header(lc); r = rw_header(lc, WRITE);
if (r) { if (r) {
DMWARN("%s: Failed to write header on dirty region log device", DMWARN("%s: Failed to write header on dirty region log device",
lc->log_dev->name); lc->log_dev->name);
...@@ -687,7 +684,7 @@ static int disk_flush(struct dm_dirty_log *log) ...@@ -687,7 +684,7 @@ static int disk_flush(struct dm_dirty_log *log)
if (!lc->touched) if (!lc->touched)
return 0; return 0;
r = write_header(lc); r = rw_header(lc, WRITE);
if (r) if (r)
fail_log_device(lc); fail_log_device(lc);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment