diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-12-10 18:52:02 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-12-10 18:52:02 -0500 |
commit | c0da3748b9a894b9f9b561ecc2d090a913988a0f (patch) | |
tree | 85213c004d3b39dae3d64ab8e4a641958421b231 /drivers/md/dm-raid1.c | |
parent | 076010e2e6ea5b66dfd1f81a6133fb014c9b291d (diff) |
dm raid1: implement mirror_flush
Implement flush callee. It uses dm_io to send zero-size barrier synchronously
and concurrently to all the mirror legs.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid1.c')
-rw-r--r-- | drivers/md/dm-raid1.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index d44bc497dad9..751660b0c574 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -237,6 +237,40 @@ out: | |||
237 | schedule_work(&ms->trigger_event); | 237 | schedule_work(&ms->trigger_event); |
238 | } | 238 | } |
239 | 239 | ||
240 | static int mirror_flush(struct dm_target *ti) | ||
241 | { | ||
242 | struct mirror_set *ms = ti->private; | ||
243 | unsigned long error_bits; | ||
244 | |||
245 | unsigned int i; | ||
246 | struct dm_io_region io[ms->nr_mirrors]; | ||
247 | struct mirror *m; | ||
248 | struct dm_io_request io_req = { | ||
249 | .bi_rw = WRITE_BARRIER, | ||
250 | .mem.type = DM_IO_KMEM, | ||
251 | .mem.ptr.bvec = NULL, | ||
252 | .client = ms->io_client, | ||
253 | }; | ||
254 | |||
255 | for (i = 0, m = ms->mirror; i < ms->nr_mirrors; i++, m++) { | ||
256 | io[i].bdev = m->dev->bdev; | ||
257 | io[i].sector = 0; | ||
258 | io[i].count = 0; | ||
259 | } | ||
260 | |||
261 | error_bits = -1; | ||
262 | dm_io(&io_req, ms->nr_mirrors, io, &error_bits); | ||
263 | if (unlikely(error_bits != 0)) { | ||
264 | for (i = 0; i < ms->nr_mirrors; i++) | ||
265 | if (test_bit(i, &error_bits)) | ||
266 | fail_mirror(ms->mirror + i, | ||
267 | DM_RAID1_WRITE_ERROR); | ||
268 | return -EIO; | ||
269 | } | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | |||
240 | /*----------------------------------------------------------------- | 274 | /*----------------------------------------------------------------- |
241 | * Recovery. | 275 | * Recovery. |
242 | * | 276 | * |
@@ -896,7 +930,8 @@ static struct dm_dirty_log *create_dirty_log(struct dm_target *ti, | |||
896 | return NULL; | 930 | return NULL; |
897 | } | 931 | } |
898 | 932 | ||
899 | dl = dm_dirty_log_create(argv[0], ti, NULL, param_count, argv + 2); | 933 | dl = dm_dirty_log_create(argv[0], ti, mirror_flush, param_count, |
934 | argv + 2); | ||
900 | if (!dl) { | 935 | if (!dl) { |
901 | ti->error = "Error creating mirror dirty log"; | 936 | ti->error = "Error creating mirror dirty log"; |
902 | return NULL; | 937 | return NULL; |