Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

US3959 feat(ephemeral_disk) : exchanging quorum while doing handshake #164

Merged
merged 3 commits into from Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/zrepl_mgmt.h
Expand Up @@ -246,6 +246,9 @@ int uzfs_zvol_destroy_snapshot_clone(zvol_state_t *zv, zvol_state_t *snap_zv,
zvol_state_t *clone_zv);
int uzfs_zinfo_destroy_internal_clone(zvol_info_t *zv);

uint8_t uzfs_zinfo_get_quorum(zvol_info_t *zinfo);
int uzfs_zinfo_set_quorum(zvol_info_t *zinfo, uint64_t val);

/*
* API to drop refcnt on zinfo. If refcnt
* dropped to zero then free zinfo.
Expand Down
4 changes: 3 additions & 1 deletion include/zrepl_prot.h
Expand Up @@ -45,7 +45,7 @@ extern "C" {
* properly aligned (and packed).
*/

#define REPLICA_VERSION 2
#define REPLICA_VERSION 3
#define MAX_NAME_LEN 256
#define MAX_IP_LEN 64
#define TARGET_PORT 6060
Expand Down Expand Up @@ -134,6 +134,8 @@ struct mgmt_ack {
uint64_t pool_guid;
uint64_t zvol_guid;
uint16_t port;
uint8_t quorum;
uint8_t reserved[5];
char ip[MAX_IP_LEN];
char volname[MAX_NAME_LEN]; // zvol helping rebuild
char dw_volname[MAX_NAME_LEN]; // zvol being rebuilt
Expand Down
21 changes: 21 additions & 0 deletions lib/libzpool/zrepl_mgmt.c
Expand Up @@ -5,6 +5,8 @@
#include <sys/uzfs_zvol.h>
#include <sys/dnode.h>
#include <sys/dsl_destroy.h>
#include <sys/dsl_prop.h>
#include <sys/dsl_dir.h>
#include <zrepl_mgmt.h>
#include <uzfs_mgmt.h>
#include <uzfs_zap.h>
Expand Down Expand Up @@ -457,6 +459,25 @@ uzfs_zinfo_store_last_committed_degraded_io_no(zvol_info_t *zinfo,
DEGRADED_IO_SEQNUM, io_seq);
}

uint8_t
uzfs_zinfo_get_quorum(zvol_info_t *zinfo)
{
uint64_t quorum;
VERIFY0(dsl_prop_get_integer(zinfo->main_zv->zv_name,
zfs_prop_to_name(ZFS_PROP_QUORUM), &quorum, NULL));
return (!!quorum);
}

int
uzfs_zinfo_set_quorum(zvol_info_t *zinfo, uint64_t val)
{
int err = dsl_dataset_set_quorum(zinfo->main_zv->zv_name,
ZPROP_SRC_LOCAL, 1);
if (err)
return (err);
return (0);
}

/*
* Stores given io_seq as healthy_io_seqnum if previously committed is
* less than given io_seq.
Expand Down
3 changes: 1 addition & 2 deletions lib/libzrepl/data_conn.c
Expand Up @@ -841,8 +841,7 @@ uzfs_zvol_rebuild_dw_replica(void *arg)
* set the quorum to 1 once rebuild is done. istgt will
* start considering it in the quorum decision.
*/
VERIFY0(dsl_dataset_set_quorum(zinfo->main_zv->zv_name,
ZPROP_SRC_LOCAL, 1));
VERIFY0(uzfs_zinfo_set_quorum(zinfo, 1));

mutex_enter(&zinfo->main_zv->rebuild_mtx);
/* Mark replica healthy now */
Expand Down
1 change: 1 addition & 0 deletions lib/libzrepl/mgmt_conn.c
Expand Up @@ -513,6 +513,7 @@ uzfs_zvol_mgmt_get_handshake_info(zvol_io_hdr_t *in_hdr, const char *name,
mgmt_ack->checkpointed_io_seq = zinfo->checkpointed_ionum;
mgmt_ack->checkpointed_degraded_io_seq =
zinfo->degraded_checkpointed_ionum;
mgmt_ack->quorum = uzfs_zinfo_get_quorum(zinfo);

return (0);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cbtest/gtest/test_uzfs.cc
Expand Up @@ -2571,7 +2571,7 @@ void mock_tgt_thread(void *arg)

/* Send wrong protocol version */
if (mgmt_test_case == 2)
hdr.version = 3;
hdr.version = -1;

/* Header len is greater than MAX_NAME_LEN */
if (mgmt_test_case == 4)
Expand Down