Skip to content

Commit

Permalink
feat(replica_id): adding new property 'io.openebs:zvol_replica_id' fo…
Browse files Browse the repository at this point in the history
…r zrepl dataset (#27)

Signed-off-by: mayank <[email protected]>
  • Loading branch information
mynktl authored and vishnuitta committed Sep 27, 2019
1 parent 512c4ac commit 4cc153c
Show file tree
Hide file tree
Showing 26 changed files with 220 additions and 104 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ install:
- sh autogen.sh
- ./configure --enable-debug --with-zfs-headers=$PWD/../cstor/include --with-spl-headers=$PWD/../cstor/lib/libspl/include
- make -j4
- make -f ../cstor/Makefile cstyle CSTORDIR=$PWD/../cstor
- sudo make install
- sudo ldconfig
- cd ..
Expand Down
2 changes: 1 addition & 1 deletion include/data_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/gtest_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/libuzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/mgmt_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/sys/uzfs_zvol.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/sys/vdev_disk_aio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/uzfs_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/uzfs_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/uzfs_rebuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/uzfs_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion include/uzfs_zap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
3 changes: 2 additions & 1 deletion include/zrepl_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down Expand Up @@ -33,6 +33,7 @@ extern "C" {
#define uZFS_ZVOL_WORKERS_DEFAULT 6
#define ZFS_PROP_TARGET_IP "io.openebs:targetip"
#define ZFS_PROP_ZVOL_WORKERS "io.openebs:zvol_workers"
#define ZFS_PROP_ZVOL_REPLICA_ID "io.openebs:zvol_replica_id"

#define REBUILD_IO_SERVER_PORT 3233
#define IO_SERVER_PORT 3232
Expand Down
50 changes: 48 additions & 2 deletions include/zrepl_prot.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down Expand Up @@ -40,10 +40,14 @@ extern "C" {
#define MIN_SUPPORTED_REPLICA_VERSION 3

#define RESIZE_REBUILD_MIN_VERSION 5
#define REPLICA_VERSION 5
#define REPLICA_VERSION 6
#define REPLICA_VERSION_5 5
#define REPLICA_VERSION_4 4
#define REPLICA_VERSION_3 3
#define MAX_NAME_LEN 256
#define MAX_IP_LEN 64
#define TARGET_PORT 6060
#define REPLICA_ID_LEN 32

#define ZVOL_OP_FLAG_REBUILD 0x01
#define ZVOL_OP_FLAG_READ_METADATA 0x02
Expand Down Expand Up @@ -155,10 +159,52 @@ struct mgmt_ack {
uint64_t checkpointed_io_seq;
// checkpointed io_seq when vol is in degraded state
uint64_t checkpointed_degraded_io_seq;
// replica ID
char replica_id[REPLICA_ID_LEN];
} __attribute__((packed));

typedef struct mgmt_ack mgmt_ack_t;

/*
* Payload data send in response to handshake on control connection. It tells
* IP, port where replica listens for data connection to zvol.
* For replica having version < 6
*/
struct mgmt_ack_ver_5 {
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
// checkpointed io_seq when vol is healthy
uint64_t checkpointed_io_seq;
// checkpointed io_seq when vol is in degraded state
uint64_t checkpointed_degraded_io_seq;
} __attribute__((packed));

typedef struct mgmt_ack_ver_5 mgmt_ack_ver_5_t;

struct rebuild_req {
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
// checkpointed io_seq when vol is healthy
uint64_t checkpointed_io_seq;
// checkpointed io_seq when vol is in degraded state
uint64_t checkpointed_degraded_io_seq;
} __attribute__((packed));

typedef struct rebuild_req rebuild_req_t;


/*
* zvol rebuild related state
*/
Expand Down
29 changes: 16 additions & 13 deletions src/data_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down Expand Up @@ -1607,7 +1607,8 @@ handle_afs_transition(zvol_info_t *zinfo, zvol_rebuild_scanner_info_t *warg)
zinfo->name, rc);
rc = -1;
} else if (hdr.opcode != ZVOL_OPCODE_AFS_STARTED) {
LOG_ERR("afs started not received zvol = %s", zinfo->name);
LOG_ERR("afs started not received zvol = %s",
zinfo->name);
rc = -1;
}
}
Expand Down Expand Up @@ -1756,15 +1757,15 @@ uzfs_zvol_rebuild_scanner(void *arg)
" %s, err(%d)", zinfo->name, rc);
goto exit;
}
if (snap_zv != NULL) {
if (warg->version >= RESIZE_REBUILD_MIN_VERSION) {
uint64_t volsize =
ZVOL_VOLUME_SIZE(snap_zv);
uzfs_zvol_send_zio_cmd(zinfo, &hdr,
ZVOL_OPCODE_REBUILD_SNAP_START,
fd, (char *)&volsize,
sizeof (volsize), 0, warg);
}
if (snap_zv != NULL &&
(warg->version >=
RESIZE_REBUILD_MIN_VERSION)) {
uint64_t volsize =
ZVOL_VOLUME_SIZE(snap_zv);
uzfs_zvol_send_zio_cmd(zinfo, &hdr,
ZVOL_OPCODE_REBUILD_SNAP_START,
fd, (char *)&volsize,
sizeof (volsize), 0, warg);
LOG_INFO("Rebuilding from zv:%s\n",
snap_zv->zv_name);
}
Expand Down Expand Up @@ -1806,8 +1807,10 @@ uzfs_zvol_rebuild_scanner(void *arg)
" err(%d)", zinfo->name, rc);
goto exit;
}
if (warg->version >= RESIZE_REBUILD_MIN_VERSION) {
uint64_t volsize = ZVOL_VOLUME_SIZE(snap_zv);
if (warg->version >=
RESIZE_REBUILD_MIN_VERSION) {
uint64_t volsize =
ZVOL_VOLUME_SIZE(snap_zv);
uzfs_zvol_send_zio_cmd(zinfo, &hdr,
ZVOL_OPCODE_REBUILD_SNAP_START,
fd, (char *)&volsize,
Expand Down
2 changes: 1 addition & 1 deletion src/libuzfs_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
2 changes: 1 addition & 1 deletion src/libuzfs_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down
Loading

0 comments on commit 4cc153c

Please sign in to comment.