aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_actlog.c
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2013-03-19 13:16:43 -0400
committerJens Axboe <axboe@kernel.dk>2013-03-22 20:13:59 -0400
commitae8bf312e97d554b6aa32e7b2ceb993812ad0835 (patch)
tree7ed6d4fcf6385c1dbc694cf4f43f884436ae104a /drivers/block/drbd/drbd_actlog.c
parent9114d79569a3fb858a7ecb1f21cb1dec93dc2f21 (diff)
drbd: cleanup ondisk meta data layout calculations and defines
Add a comment about our meta data layout variants, and rename a few defines (e.g. MD_RESERVED_SECT -> MD_128MB_SECT) to make it clear that they are short hand for fixed constants, and not arbitrarily to be redefined as one may see fit. Properly pad struct meta_data_on_disk to 4kB, and initialize to zero not only the first 512 Byte, but all of it in drbd_md_sync(). Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/drbd/drbd_actlog.c')
-rw-r--r--drivers/block/drbd/drbd_actlog.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 92510f8ad013..b230d91ec430 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -209,7 +209,8 @@ int drbd_md_sync_page_io(struct drbd_conf *mdev, struct drbd_backing_dev *bdev,
209 current->comm, current->pid, __func__, 209 current->comm, current->pid, __func__,
210 (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ"); 210 (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ");
211 211
212 err = _drbd_md_sync_page_io(mdev, bdev, iop, sector, rw, MD_BLOCK_SIZE); 212 /* we do all our meta data IO in aligned 4k blocks. */
213 err = _drbd_md_sync_page_io(mdev, bdev, iop, sector, rw, 4096);
213 if (err) { 214 if (err) {
214 dev_err(DEV, "drbd_md_sync_page_io(,%llus,%s) failed with error %d\n", 215 dev_err(DEV, "drbd_md_sync_page_io(,%llus,%s) failed with error %d\n",
215 (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ", err); 216 (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ", err);
@@ -350,6 +351,24 @@ static unsigned int rs_extent_to_bm_page(unsigned int rs_enr)
350 (BM_EXT_SHIFT - BM_BLOCK_SHIFT)); 351 (BM_EXT_SHIFT - BM_BLOCK_SHIFT));
351} 352}
352 353
354static sector_t al_tr_number_to_on_disk_sector(struct drbd_conf *mdev)
355{
356 const unsigned int stripes = 1;
357 const unsigned int stripe_size_4kB = MD_32kB_SECT/MD_4kB_SECT;
358
359 /* transaction number, modulo on-disk ring buffer wrap around */
360 unsigned int t = mdev->al_tr_number % (stripe_size_4kB * stripes);
361
362 /* ... to aligned 4k on disk block */
363 t = ((t % stripes) * stripe_size_4kB) + t/stripes;
364
365 /* ... to 512 byte sector in activity log */
366 t *= 8;
367
368 /* ... plus offset to the on disk position */
369 return mdev->ldev->md.md_offset + mdev->ldev->md.al_offset + t;
370}
371
353static int 372static int
354_al_write_transaction(struct drbd_conf *mdev) 373_al_write_transaction(struct drbd_conf *mdev)
355{ 374{
@@ -432,13 +451,12 @@ _al_write_transaction(struct drbd_conf *mdev)
432 if (mdev->al_tr_cycle >= mdev->act_log->nr_elements) 451 if (mdev->al_tr_cycle >= mdev->act_log->nr_elements)
433 mdev->al_tr_cycle = 0; 452 mdev->al_tr_cycle = 0;
434 453
435 sector = mdev->ldev->md.md_offset 454 sector = al_tr_number_to_on_disk_sector(mdev);
436 + mdev->ldev->md.al_offset
437 + mdev->al_tr_pos * (MD_BLOCK_SIZE>>9);
438 455
439 crc = crc32c(0, buffer, 4096); 456 crc = crc32c(0, buffer, 4096);
440 buffer->crc32c = cpu_to_be32(crc); 457 buffer->crc32c = cpu_to_be32(crc);
441 458
459 /* normal execution path goes through all three branches */
442 if (drbd_bm_write_hinted(mdev)) 460 if (drbd_bm_write_hinted(mdev))
443 err = -EIO; 461 err = -EIO;
444 /* drbd_chk_io_error done already */ 462 /* drbd_chk_io_error done already */
@@ -446,8 +464,6 @@ _al_write_transaction(struct drbd_conf *mdev)
446 err = -EIO; 464 err = -EIO;
447 drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR); 465 drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
448 } else { 466 } else {
449 /* advance ringbuffer position and transaction counter */
450 mdev->al_tr_pos = (mdev->al_tr_pos + 1) % (MD_AL_SECTORS*512/MD_BLOCK_SIZE);
451 mdev->al_tr_number++; 467 mdev->al_tr_number++;
452 } 468 }
453 469