diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2011-01-20 07:25:21 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-03-10 05:48:01 -0500 |
commit | 62b0da3a244ac33d25a77861ef1cc0080103f2ff (patch) | |
tree | a4313df7c46ac50d751fb0798323e34a3e4efbee /drivers/block/drbd/drbd_main.c | |
parent | d07c9c10e5620c632aae9cac2b609033398f6139 (diff) |
drbd: log UUIDs whenever they change
All decisions about sync, sync direction, and wether or not to
allow a connect or attach are based on our set of UUIDs to tag a
data generation.
Log changes to the UUIDs whenever they occur,
logging "new current UUID P:Q:R:S" is more useful
than "Creating new current UUID".
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index e0be4077d564..b68332a0e73e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1159,6 +1159,10 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, | |||
1159 | atomic_inc(&mdev->local_cnt); | 1159 | atomic_inc(&mdev->local_cnt); |
1160 | 1160 | ||
1161 | mdev->state = ns; | 1161 | mdev->state = ns; |
1162 | |||
1163 | if (os.disk == D_ATTACHING && ns.disk >= D_NEGOTIATING) | ||
1164 | drbd_print_uuids(mdev, "attached to UUIDs"); | ||
1165 | |||
1162 | wake_up(&mdev->misc_wait); | 1166 | wake_up(&mdev->misc_wait); |
1163 | wake_up(&mdev->state_wait); | 1167 | wake_up(&mdev->state_wait); |
1164 | 1168 | ||
@@ -2035,6 +2039,24 @@ int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev) | |||
2035 | return _drbd_send_uuids(mdev, 8); | 2039 | return _drbd_send_uuids(mdev, 8); |
2036 | } | 2040 | } |
2037 | 2041 | ||
2042 | void drbd_print_uuids(struct drbd_conf *mdev, const char *text) | ||
2043 | { | ||
2044 | if (get_ldev_if_state(mdev, D_NEGOTIATING)) { | ||
2045 | u64 *uuid = mdev->ldev->md.uuid; | ||
2046 | dev_info(DEV, "%s %016llX:%016llX:%016llX:%016llX\n", | ||
2047 | text, | ||
2048 | (unsigned long long)uuid[UI_CURRENT], | ||
2049 | (unsigned long long)uuid[UI_BITMAP], | ||
2050 | (unsigned long long)uuid[UI_HISTORY_START], | ||
2051 | (unsigned long long)uuid[UI_HISTORY_END]); | ||
2052 | put_ldev(mdev); | ||
2053 | } else { | ||
2054 | dev_info(DEV, "%s effective data uuid: %016llX\n", | ||
2055 | text, | ||
2056 | (unsigned long long)mdev->ed_uuid); | ||
2057 | } | ||
2058 | } | ||
2059 | |||
2038 | int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev) | 2060 | int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev) |
2039 | { | 2061 | { |
2040 | struct p_rs_uuid p; | 2062 | struct p_rs_uuid p; |
@@ -2044,6 +2066,7 @@ int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev) | |||
2044 | 2066 | ||
2045 | uuid = mdev->ldev->md.uuid[UI_BITMAP] + UUID_NEW_BM_OFFSET; | 2067 | uuid = mdev->ldev->md.uuid[UI_BITMAP] + UUID_NEW_BM_OFFSET; |
2046 | drbd_uuid_set(mdev, UI_BITMAP, uuid); | 2068 | drbd_uuid_set(mdev, UI_BITMAP, uuid); |
2069 | drbd_print_uuids(mdev, "updated sync UUID"); | ||
2047 | drbd_md_sync(mdev); | 2070 | drbd_md_sync(mdev); |
2048 | p.uuid = cpu_to_be64(uuid); | 2071 | p.uuid = cpu_to_be64(uuid); |
2049 | 2072 | ||
@@ -3749,28 +3772,6 @@ int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) | |||
3749 | return rv; | 3772 | return rv; |
3750 | } | 3773 | } |
3751 | 3774 | ||
3752 | static void debug_drbd_uuid(struct drbd_conf *mdev, enum drbd_uuid_index index) | ||
3753 | { | ||
3754 | static char *uuid_str[UI_EXTENDED_SIZE] = { | ||
3755 | [UI_CURRENT] = "CURRENT", | ||
3756 | [UI_BITMAP] = "BITMAP", | ||
3757 | [UI_HISTORY_START] = "HISTORY_START", | ||
3758 | [UI_HISTORY_END] = "HISTORY_END", | ||
3759 | [UI_SIZE] = "SIZE", | ||
3760 | [UI_FLAGS] = "FLAGS", | ||
3761 | }; | ||
3762 | |||
3763 | if (index >= UI_EXTENDED_SIZE) { | ||
3764 | dev_warn(DEV, " uuid_index >= EXTENDED_SIZE\n"); | ||
3765 | return; | ||
3766 | } | ||
3767 | |||
3768 | dynamic_dev_dbg(DEV, " uuid[%s] now %016llX\n", | ||
3769 | uuid_str[index], | ||
3770 | (unsigned long long)mdev->ldev->md.uuid[index]); | ||
3771 | } | ||
3772 | |||
3773 | |||
3774 | /** | 3775 | /** |
3775 | * drbd_md_mark_dirty() - Mark meta data super block as dirty | 3776 | * drbd_md_mark_dirty() - Mark meta data super block as dirty |
3776 | * @mdev: DRBD device. | 3777 | * @mdev: DRBD device. |
@@ -3800,10 +3801,8 @@ static void drbd_uuid_move_history(struct drbd_conf *mdev) __must_hold(local) | |||
3800 | { | 3801 | { |
3801 | int i; | 3802 | int i; |
3802 | 3803 | ||
3803 | for (i = UI_HISTORY_START; i < UI_HISTORY_END; i++) { | 3804 | for (i = UI_HISTORY_START; i < UI_HISTORY_END; i++) |
3804 | mdev->ldev->md.uuid[i+1] = mdev->ldev->md.uuid[i]; | 3805 | mdev->ldev->md.uuid[i+1] = mdev->ldev->md.uuid[i]; |
3805 | debug_drbd_uuid(mdev, i+1); | ||
3806 | } | ||
3807 | } | 3806 | } |
3808 | 3807 | ||
3809 | void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | 3808 | void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) |
@@ -3818,7 +3817,6 @@ void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
3818 | } | 3817 | } |
3819 | 3818 | ||
3820 | mdev->ldev->md.uuid[idx] = val; | 3819 | mdev->ldev->md.uuid[idx] = val; |
3821 | debug_drbd_uuid(mdev, idx); | ||
3822 | drbd_md_mark_dirty(mdev); | 3820 | drbd_md_mark_dirty(mdev); |
3823 | } | 3821 | } |
3824 | 3822 | ||
@@ -3828,7 +3826,6 @@ void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
3828 | if (mdev->ldev->md.uuid[idx]) { | 3826 | if (mdev->ldev->md.uuid[idx]) { |
3829 | drbd_uuid_move_history(mdev); | 3827 | drbd_uuid_move_history(mdev); |
3830 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[idx]; | 3828 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[idx]; |
3831 | debug_drbd_uuid(mdev, UI_HISTORY_START); | ||
3832 | } | 3829 | } |
3833 | _drbd_uuid_set(mdev, idx, val); | 3830 | _drbd_uuid_set(mdev, idx, val); |
3834 | } | 3831 | } |
@@ -3843,14 +3840,16 @@ void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
3843 | void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local) | 3840 | void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local) |
3844 | { | 3841 | { |
3845 | u64 val; | 3842 | u64 val; |
3843 | unsigned long long bm_uuid = mdev->ldev->md.uuid[UI_BITMAP]; | ||
3844 | |||
3845 | if (bm_uuid) | ||
3846 | dev_warn(DEV, "bm UUID was already set: %llX\n", bm_uuid); | ||
3846 | 3847 | ||
3847 | dev_info(DEV, "Creating new current UUID\n"); | ||
3848 | D_ASSERT(mdev->ldev->md.uuid[UI_BITMAP] == 0); | ||
3849 | mdev->ldev->md.uuid[UI_BITMAP] = mdev->ldev->md.uuid[UI_CURRENT]; | 3848 | mdev->ldev->md.uuid[UI_BITMAP] = mdev->ldev->md.uuid[UI_CURRENT]; |
3850 | debug_drbd_uuid(mdev, UI_BITMAP); | ||
3851 | 3849 | ||
3852 | get_random_bytes(&val, sizeof(u64)); | 3850 | get_random_bytes(&val, sizeof(u64)); |
3853 | _drbd_uuid_set(mdev, UI_CURRENT, val); | 3851 | _drbd_uuid_set(mdev, UI_CURRENT, val); |
3852 | drbd_print_uuids(mdev, "new current UUID"); | ||
3854 | /* get it to stable storage _now_ */ | 3853 | /* get it to stable storage _now_ */ |
3855 | drbd_md_sync(mdev); | 3854 | drbd_md_sync(mdev); |
3856 | } | 3855 | } |
@@ -3864,16 +3863,12 @@ void drbd_uuid_set_bm(struct drbd_conf *mdev, u64 val) __must_hold(local) | |||
3864 | drbd_uuid_move_history(mdev); | 3863 | drbd_uuid_move_history(mdev); |
3865 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[UI_BITMAP]; | 3864 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[UI_BITMAP]; |
3866 | mdev->ldev->md.uuid[UI_BITMAP] = 0; | 3865 | mdev->ldev->md.uuid[UI_BITMAP] = 0; |
3867 | debug_drbd_uuid(mdev, UI_HISTORY_START); | ||
3868 | debug_drbd_uuid(mdev, UI_BITMAP); | ||
3869 | } else { | 3866 | } else { |
3870 | if (mdev->ldev->md.uuid[UI_BITMAP]) | 3867 | unsigned long long bm_uuid = mdev->ldev->md.uuid[UI_BITMAP]; |
3871 | dev_warn(DEV, "bm UUID already set"); | 3868 | if (bm_uuid) |
3872 | 3869 | dev_warn(DEV, "bm UUID was already set: %llX\n", bm_uuid); | |
3873 | mdev->ldev->md.uuid[UI_BITMAP] = val; | ||
3874 | mdev->ldev->md.uuid[UI_BITMAP] &= ~((u64)1); | ||
3875 | 3870 | ||
3876 | debug_drbd_uuid(mdev, UI_BITMAP); | 3871 | mdev->ldev->md.uuid[UI_BITMAP] = val & ~((u64)1); |
3877 | } | 3872 | } |
3878 | drbd_md_mark_dirty(mdev); | 3873 | drbd_md_mark_dirty(mdev); |
3879 | } | 3874 | } |