aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-log.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-12-10 18:52:00 -0500
committerAlasdair G Kergon <agk@redhat.com>2009-12-10 18:52:00 -0500
commit20a34a8ecc7d03eaa5054f58169ebff12f5f1f8c (patch)
tree87dd9a93e2bd11c8917d9c4bb000c3acb85723c8 /drivers/md/dm-log.c
parentb09acf1aa79462bdacfe6744b469a17722a52702 (diff)
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 31dc33df95c7..6b23631db5b5 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)
288 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); 288 return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
289} 289}
290 290
291static int flush_header(struct log_c *lc)
292{
293 struct dm_io_region null_location = {
294 .bdev = lc->header_location.bdev,
295 .sector = 0,
296 .count = 0,
297 };
298
299 lc->io_req.bi_rw = WRITE_BARRIER;
300
301 return dm_io(&lc->io_req, 1, &null_location, NULL);
302}
303
291static int read_header(struct log_c *log) 304static int read_header(struct log_c *log)
292{ 305{
293 int r; 306 int r;
@@ -616,6 +629,8 @@ static int disk_resume(struct dm_dirty_log *log)
616 629
617 /* write the new header */ 630 /* write the new header */
618 r = rw_header(lc, WRITE); 631 r = rw_header(lc, WRITE);
632 if (!r)
633 r = flush_header(lc);
619 if (r) { 634 if (r) {
620 DMWARN("%s: Failed to write header on dirty region log device", 635 DMWARN("%s: Failed to write header on dirty region log device",
621 lc->log_dev->name); 636 lc->log_dev->name);
@@ -669,7 +684,13 @@ static int disk_flush(struct dm_dirty_log *log)
669 if (r) 684 if (r)
670 fail_log_device(lc); 685 fail_log_device(lc);
671 else { 686 else {
672 lc->touched_dirtied = 0; 687 if (lc->touched_dirtied) {
688 r = flush_header(lc);
689 if (r)
690 fail_log_device(lc);
691 else
692 lc->touched_dirtied = 0;
693 }
673 lc->touched_cleaned = 0; 694 lc->touched_cleaned = 0;
674 } 695 }
675 696