aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-log.c68
-rw-r--r--drivers/md/dm-raid1.c2
2 files changed, 20 insertions, 50 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index d73779a42417..ae41628b75c0 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -155,8 +155,6 @@ struct log_c {
155 155
156 struct io_region header_location; 156 struct io_region header_location;
157 struct log_header *disk_header; 157 struct log_header *disk_header;
158
159 struct io_region bits_location;
160}; 158};
161 159
162/* 160/*
@@ -241,29 +239,6 @@ static inline int write_header(struct log_c *log)
241} 239}
242 240
243/*---------------------------------------------------------------- 241/*----------------------------------------------------------------
244 * Bits IO
245 *--------------------------------------------------------------*/
246static int read_bits(struct log_c *log)
247{
248 int r;
249 unsigned long ebits;
250
251 r = dm_io_sync_vm(1, &log->bits_location, READ,
252 log->clean_bits, &ebits);
253 if (r)
254 return r;
255
256 return 0;
257}
258
259static int write_bits(struct log_c *log)
260{
261 unsigned long ebits;
262 return dm_io_sync_vm(1, &log->bits_location, WRITE,
263 log->clean_bits, &ebits);
264}
265
266/*----------------------------------------------------------------
267 * core log constructor/destructor 242 * core log constructor/destructor
268 * 243 *
269 * argv contains region_size followed optionally by [no]sync 244 * argv contains region_size followed optionally by [no]sync
@@ -373,9 +348,10 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
373 unsigned int argc, char **argv) 348 unsigned int argc, char **argv)
374{ 349{
375 int r; 350 int r;
376 size_t size; 351 size_t size, bitset_size;
377 struct log_c *lc; 352 struct log_c *lc;
378 struct dm_dev *dev; 353 struct dm_dev *dev;
354 uint32_t *clean_bits;
379 355
380 if (argc < 2 || argc > 3) { 356 if (argc < 2 || argc > 3) {
381 DMWARN("wrong number of arguments to disk mirror log"); 357 DMWARN("wrong number of arguments to disk mirror log");
@@ -399,23 +375,26 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
399 /* setup the disk header fields */ 375 /* setup the disk header fields */
400 lc->header_location.bdev = lc->log_dev->bdev; 376 lc->header_location.bdev = lc->log_dev->bdev;
401 lc->header_location.sector = 0; 377 lc->header_location.sector = 0;
402 lc->header_location.count = 1;
403 378
404 /* 379 /* Include both the header and the bitset in one buffer. */
405 * We can't read less than this amount, even though we'll 380 bitset_size = lc->bitset_uint32_count * sizeof(uint32_t);
406 * not be using most of this space. 381 size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + bitset_size,
407 */ 382 ti->limits.hardsect_size);
408 lc->disk_header = vmalloc(1 << SECTOR_SHIFT); 383 lc->header_location.count = size >> SECTOR_SHIFT;
384
385 lc->disk_header = vmalloc(size);
409 if (!lc->disk_header) 386 if (!lc->disk_header)
410 goto bad; 387 goto bad;
411 388
412 /* setup the disk bitset fields */ 389 /*
413 lc->bits_location.bdev = lc->log_dev->bdev; 390 * Deallocate the clean_bits buffer that was allocated in core_ctr()
414 lc->bits_location.sector = LOG_OFFSET; 391 * and point it at the appropriate place in the disk_header buffer.
392 */
393 clean_bits = lc->clean_bits;
394 lc->clean_bits = (void *)lc->disk_header + (LOG_OFFSET << SECTOR_SHIFT);
395 memcpy(lc->clean_bits, clean_bits, bitset_size);
396 vfree(clean_bits);
415 397
416 size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t),
417 1 << SECTOR_SHIFT);
418 lc->bits_location.count = size >> SECTOR_SHIFT;
419 return 0; 398 return 0;
420 399
421 bad: 400 bad:
@@ -429,6 +408,7 @@ static void disk_dtr(struct dirty_log *log)
429 struct log_c *lc = (struct log_c *) log->context; 408 struct log_c *lc = (struct log_c *) log->context;
430 dm_put_device(lc->ti, lc->log_dev); 409 dm_put_device(lc->ti, lc->log_dev);
431 vfree(lc->disk_header); 410 vfree(lc->disk_header);
411 lc->clean_bits = NULL;
432 core_dtr(log); 412 core_dtr(log);
433} 413}
434 414
@@ -454,11 +434,6 @@ static int disk_resume(struct dirty_log *log)
454 if (r) 434 if (r)
455 return r; 435 return r;
456 436
457 /* read the bits */
458 r = read_bits(lc);
459 if (r)
460 return r;
461
462 /* set or clear any new bits */ 437 /* set or clear any new bits */
463 if (lc->sync == NOSYNC) 438 if (lc->sync == NOSYNC)
464 for (i = lc->header.nr_regions; i < lc->region_count; i++) 439 for (i = lc->header.nr_regions; i < lc->region_count; i++)
@@ -473,11 +448,6 @@ static int disk_resume(struct dirty_log *log)
473 memcpy(lc->sync_bits, lc->clean_bits, size); 448 memcpy(lc->sync_bits, lc->clean_bits, size);
474 lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); 449 lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
475 450
476 /* write the bits */
477 r = write_bits(lc);
478 if (r)
479 return r;
480
481 /* set the correct number of regions in the header */ 451 /* set the correct number of regions in the header */
482 lc->header.nr_regions = lc->region_count; 452 lc->header.nr_regions = lc->region_count;
483 453
@@ -518,7 +488,7 @@ static int disk_flush(struct dirty_log *log)
518 if (!lc->touched) 488 if (!lc->touched)
519 return 0; 489 return 0;
520 490
521 r = write_bits(lc); 491 r = write_header(lc);
522 if (!r) 492 if (!r)
523 lc->touched = 0; 493 lc->touched = 0;
524 494
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 346f3a59e776..84f2ed6d9c5b 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1220,7 +1220,7 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
1220 1220
1221static struct target_type mirror_target = { 1221static struct target_type mirror_target = {
1222 .name = "mirror", 1222 .name = "mirror",
1223 .version = {1, 0, 1}, 1223 .version = {1, 0, 2},
1224 .module = THIS_MODULE, 1224 .module = THIS_MODULE,
1225 .ctr = mirror_ctr, 1225 .ctr = mirror_ctr,
1226 .dtr = mirror_dtr, 1226 .dtr = mirror_dtr,