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

Implement protocol version so that we can have mixed cluster during u… #16

Merged
merged 1 commit into from
Mar 20, 2018

Conversation

jkryl
Copy link

@jkryl jkryl commented Mar 15, 2018

…pgrade (#55)

This is a proposal for versioning. Suggestions for improvements are welcomed. The most important change is new version field in zrepl messages which is at the first place in "packet". The field is taken into account only in handshake messages. Either client or server first reads initial two bytes which are the version number, and if it determines that the version is incompatible, it does not try to read the rest of the message. zrepl checks the version in handshake message from a target and replies with "version mismatch" error if the version is different from the one supported. In addition to that, it puts the supported version number into reply packet (again in the version field) and closes the connection. So in theory if target supports multiple protocol versions it can wait for a new connection from replica (happens every 5s) and send a handshake with supported version.

Other changes bundled with this change is removal of void pointer from network messages, fixed layout of structures used for network messages (not dependent on cpu architecture and compiler). Other than that I tried to keep the protocol as it was, with minimal changes.

Interesting are C++ unit tests which test three cases:

  • handshake with right version number
  • handshake with unsupported version number
  • handshake with unknown zvol name

if (count <= 0) {
ZREPL_ERRLOG("Replica-iSCSI Tgt connection got "
"disconnected with err:%d\n", errno);
rc = read_handshake(sfd, &hdr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to support/manage many more commands here. Current code assume that it will handle just HANDSHAKE cmd/msg only. We need to have Switch statement here to handle different commands received from iSCSI tgt (Handshake is one of them, now for rebuild I am implementing many more).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. Although the situation is even a bit more complicated. Reading handshake is not like reading any other command:

  1. handshake command must come first
  2. handshake command must not repeat
  3. only first 2 bytes need to be read from handshake message before anything else is, to decide if the sender's version is supported.

Hence I would process handshake command out of the loop and then have the switch statement inside the loop as you have described, but only for all other commands except handshake. But I would make this change once we add more commands - not now when there is just one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, it actually may repeat. It should not repeat on data connection but can repeat on mgmt connection in case iscsit requests information (host:port) for multiple volumes. What do you think? In that case we should perhaps decouple handshake message from zvol query. I mean as in the following picture (that is for mgmt conn):

zrepl iscsit
------connect----->
------HS msg----->
<-----HS repl------
<----zvol query---
-----zvol info------>
<----zvol query---
-----zvol info----->
....

That would eliminate one of the current weirdnesses of the protocol when the client (zrepl) which connects to iscsi, expects iscsit to send the first msg on connection. Now it would be the zrepl who sends HS over the wire and iscsit (server from this point of view) replies to the handshake.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be done i.e. first message from Zrepl to iSCSI controller. But here HS is meant for finding volume which iSCSI know off. Zreplica search that volume and reply back to controller with appropriate response. If Replica has to send first message, I am not what info it should send. I think we should handle HS separately (instead of making code generic for all commands, we can have separate handling for HS).

I can see that I need this flexible/generic code very soon as I am implementing many more commands for rebuild that is why I asked if we can make change now only so that subsequent check-ins do not need to make lots of changes around this area.

* TODO: All structures should be defined with "packed" attribute to avoid
* ambiguous padding added by compiler.
* We don't expect replica protocol to be used between nodes with different
* architecture nevetheless we try to be precise in defining size of members
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo .....

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. thanks

@jkryl jkryl force-pushed the zrepl-prot branch 5 times, most recently from b4de692 to 2e8972a Compare March 16, 2018 19:55
…er during upgrade

Signed-off-by: Jan Kryl <jan.kryl@cloudbyte.com>
Copy link
Collaborator

@satbirchhikara satbirchhikara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go from my side.

Copy link

@vishnuitta vishnuitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@jkryl jkryl merged commit dd6b258 into zfs-0.7-release Mar 20, 2018
@jkryl jkryl deleted the zrepl-prot branch March 20, 2018 09:37
pawanpraka1 added a commit to pawanpraka1/zfs that referenced this pull request Jun 19, 2019
… rebuilding (mayadata-io#16)

Signed-off-by: Pawan <pawan@mayadata.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants