Commit 20a34a8e authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm log: add flush_header function

Introduce flush_header and use it to flush the log device.

Note that we don't have to flush if all the regions transition
from "dirty" to "clean" state.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent b09acf1a
...@@ -288,6 +288,19 @@ static int rw_header(struct log_c *lc, int rw) ...@@ -288,6 +288,19 @@ static int rw_header(struct log_c *lc, int rw)
return dm_io(&lc->io_req, 1, &lc->header_location, NULL); return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
} }
static int flush_header(struct log_c *lc)
{
struct dm_io_region null_location = {
.bdev = lc->header_location.bdev,
.sector = 0,
.count = 0,
};
lc->io_req.bi_rw = WRITE_BARRIER;
return dm_io(&lc->io_req, 1, &null_location, NULL);
}
static int read_header(struct log_c *log) static int read_header(struct log_c *log)
{ {
int r; int r;
...@@ -616,6 +629,8 @@ static int disk_resume(struct dm_dirty_log *log) ...@@ -616,6 +629,8 @@ static int disk_resume(struct dm_dirty_log *log)
/* write the new header */ /* write the new header */
r = rw_header(lc, WRITE); r = rw_header(lc, WRITE);
if (!r)
r = flush_header(lc);
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);
...@@ -669,7 +684,13 @@ static int disk_flush(struct dm_dirty_log *log) ...@@ -669,7 +684,13 @@ static int disk_flush(struct dm_dirty_log *log)
if (r) if (r)
fail_log_device(lc); fail_log_device(lc);
else { else {
lc->touched_dirtied = 0; if (lc->touched_dirtied) {
r = flush_header(lc);
if (r)
fail_log_device(lc);
else
lc->touched_dirtied = 0;
}
lc->touched_cleaned = 0; lc->touched_cleaned = 0;
} }
......
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