summaryrefslogtreecommitdiff
path: root/drivers/md/dm-log.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-12-10 23:52:00 +0000
committerAlasdair G Kergon <agk@redhat.com>2009-12-10 23:52:00 +0000
commit20a34a8ecc7d03eaa5054f58169ebff12f5f1f8c (patch)
tree87dd9a93e2bd11c8917d9c4bb000c3acb85723c8 /drivers/md/dm-log.c
parentb09acf1aa79462bdacfe6744b469a17722a52702 (diff)
downloadlinux-3.10-20a34a8ecc7d03eaa5054f58169ebff12f5f1f8c.tar.gz
linux-3.10-20a34a8ecc7d03eaa5054f58169ebff12f5f1f8c.tar.bz2
linux-3.10-20a34a8ecc7d03eaa5054f58169ebff12f5f1f8c.zip
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: Mikulas Patocka <mpatocka@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.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 31dc33df95c..6b23631db5b 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -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);
}
+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)
{
int r;
@@ -616,6 +629,8 @@ static int disk_resume(struct dm_dirty_log *log)
/* write the new header */
r = rw_header(lc, WRITE);
+ if (!r)
+ r = flush_header(lc);
if (r) {
DMWARN("%s: Failed to write header on dirty region log device",
lc->log_dev->name);
@@ -669,7 +684,13 @@ static int disk_flush(struct dm_dirty_log *log)
if (r)
fail_log_device(lc);
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;
}