diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2013-03-19 13:16:43 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-03-22 20:13:59 -0400 |
commit | ae8bf312e97d554b6aa32e7b2ceb993812ad0835 (patch) | |
tree | 7ed6d4fcf6385c1dbc694cf4f43f884436ae104a /drivers/block/drbd/drbd_nl.c | |
parent | 9114d79569a3fb858a7ecb1f21cb1dec93dc2f21 (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_nl.c')
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 2af26fc95280..581f6800cc30 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -696,12 +696,32 @@ out: | |||
696 | return 0; | 696 | return 0; |
697 | } | 697 | } |
698 | 698 | ||
699 | /* initializes the md.*_offset members, so we are able to find | 699 | /* Initializes the md.*_offset members, so we are able to find |
700 | * the on disk meta data */ | 700 | * the on disk meta data. |
701 | * | ||
702 | * We currently have two possible layouts: | ||
703 | * external: | ||
704 | * |----------- md_size_sect ------------------| | ||
705 | * [ 4k superblock ][ activity log ][ Bitmap ] | ||
706 | * | al_offset == 8 | | ||
707 | * | bm_offset = al_offset + X | | ||
708 | * ==> bitmap sectors = md_size_sect - bm_offset | ||
709 | * | ||
710 | * internal: | ||
711 | * |----------- md_size_sect ------------------| | ||
712 | * [data.....][ Bitmap ][ activity log ][ 4k superblock ] | ||
713 | * | al_offset < 0 | | ||
714 | * | bm_offset = al_offset - Y | | ||
715 | * ==> bitmap sectors = Y = al_offset - bm_offset | ||
716 | * | ||
717 | * Activity log size used to be fixed 32kB, | ||
718 | * but is about to become configurable. | ||
719 | */ | ||
701 | static void drbd_md_set_sector_offsets(struct drbd_conf *mdev, | 720 | static void drbd_md_set_sector_offsets(struct drbd_conf *mdev, |
702 | struct drbd_backing_dev *bdev) | 721 | struct drbd_backing_dev *bdev) |
703 | { | 722 | { |
704 | sector_t md_size_sect = 0; | 723 | sector_t md_size_sect = 0; |
724 | unsigned int al_size_sect = MD_32kB_SECT; | ||
705 | int meta_dev_idx; | 725 | int meta_dev_idx; |
706 | 726 | ||
707 | rcu_read_lock(); | 727 | rcu_read_lock(); |
@@ -710,23 +730,23 @@ static void drbd_md_set_sector_offsets(struct drbd_conf *mdev, | |||
710 | switch (meta_dev_idx) { | 730 | switch (meta_dev_idx) { |
711 | default: | 731 | default: |
712 | /* v07 style fixed size indexed meta data */ | 732 | /* v07 style fixed size indexed meta data */ |
713 | bdev->md.md_size_sect = MD_RESERVED_SECT; | 733 | bdev->md.md_size_sect = MD_128MB_SECT; |
714 | bdev->md.md_offset = drbd_md_ss__(mdev, bdev); | 734 | bdev->md.md_offset = drbd_md_ss__(mdev, bdev); |
715 | bdev->md.al_offset = MD_AL_OFFSET; | 735 | bdev->md.al_offset = MD_4kB_SECT; |
716 | bdev->md.bm_offset = MD_BM_OFFSET; | 736 | bdev->md.bm_offset = MD_4kB_SECT + al_size_sect; |
717 | break; | 737 | break; |
718 | case DRBD_MD_INDEX_FLEX_EXT: | 738 | case DRBD_MD_INDEX_FLEX_EXT: |
719 | /* just occupy the full device; unit: sectors */ | 739 | /* just occupy the full device; unit: sectors */ |
720 | bdev->md.md_size_sect = drbd_get_capacity(bdev->md_bdev); | 740 | bdev->md.md_size_sect = drbd_get_capacity(bdev->md_bdev); |
721 | bdev->md.md_offset = 0; | 741 | bdev->md.md_offset = 0; |
722 | bdev->md.al_offset = MD_AL_OFFSET; | 742 | bdev->md.al_offset = MD_4kB_SECT; |
723 | bdev->md.bm_offset = MD_BM_OFFSET; | 743 | bdev->md.bm_offset = MD_4kB_SECT + al_size_sect; |
724 | break; | 744 | break; |
725 | case DRBD_MD_INDEX_INTERNAL: | 745 | case DRBD_MD_INDEX_INTERNAL: |
726 | case DRBD_MD_INDEX_FLEX_INT: | 746 | case DRBD_MD_INDEX_FLEX_INT: |
727 | bdev->md.md_offset = drbd_md_ss__(mdev, bdev); | 747 | bdev->md.md_offset = drbd_md_ss__(mdev, bdev); |
728 | /* al size is still fixed */ | 748 | /* al size is still fixed */ |
729 | bdev->md.al_offset = -MD_AL_SECTORS; | 749 | bdev->md.al_offset = -al_size_sect; |
730 | /* we need (slightly less than) ~ this much bitmap sectors: */ | 750 | /* we need (slightly less than) ~ this much bitmap sectors: */ |
731 | md_size_sect = drbd_get_capacity(bdev->backing_bdev); | 751 | md_size_sect = drbd_get_capacity(bdev->backing_bdev); |
732 | md_size_sect = ALIGN(md_size_sect, BM_SECT_PER_EXT); | 752 | md_size_sect = ALIGN(md_size_sect, BM_SECT_PER_EXT); |
@@ -735,11 +755,11 @@ static void drbd_md_set_sector_offsets(struct drbd_conf *mdev, | |||
735 | 755 | ||
736 | /* plus the "drbd meta data super block", | 756 | /* plus the "drbd meta data super block", |
737 | * and the activity log; */ | 757 | * and the activity log; */ |
738 | md_size_sect += MD_BM_OFFSET; | 758 | md_size_sect += MD_4kB_SECT + al_size_sect; |
739 | 759 | ||
740 | bdev->md.md_size_sect = md_size_sect; | 760 | bdev->md.md_size_sect = md_size_sect; |
741 | /* bitmap offset is adjusted by 'super' block size */ | 761 | /* bitmap offset is adjusted by 'super' block size */ |
742 | bdev->md.bm_offset = -md_size_sect + MD_AL_OFFSET; | 762 | bdev->md.bm_offset = -md_size_sect + MD_4kB_SECT; |
743 | break; | 763 | break; |
744 | } | 764 | } |
745 | rcu_read_unlock(); | 765 | rcu_read_unlock(); |
@@ -1416,7 +1436,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) | |||
1416 | min_md_device_sectors = (2<<10); | 1436 | min_md_device_sectors = (2<<10); |
1417 | } else { | 1437 | } else { |
1418 | max_possible_sectors = DRBD_MAX_SECTORS; | 1438 | max_possible_sectors = DRBD_MAX_SECTORS; |
1419 | min_md_device_sectors = MD_RESERVED_SECT * (new_disk_conf->meta_dev_idx + 1); | 1439 | min_md_device_sectors = MD_128MB_SECT * (new_disk_conf->meta_dev_idx + 1); |
1420 | } | 1440 | } |
1421 | 1441 | ||
1422 | if (drbd_get_capacity(nbc->md_bdev) < min_md_device_sectors) { | 1442 | if (drbd_get_capacity(nbc->md_bdev) < min_md_device_sectors) { |