Lines Matching +full:version +full:- +full:minor

1 // SPDX-License-Identifier: GPL-2.0-only
30 * character followed by a two hex digit version number. Currently the
31 * only things supported is T01, for "Text-base version 0x01". Next, the
32 * client writes the version they would like to use, including the newline.
33 * Thus, the protocol tag is 'T01\n'. If the version tag written is
34 * unknown, -EINVAL is returned. Once the negotiation is complete, the
40 * SETN<space><8-char-hex-nodenum><newline>
49 * SETV<space><2-char-hex-major><space><2-char-hex-minor><newline>
53 * The "SETV" message sets the filesystem locking protocol version as
55 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major
57 * ocfs2_user_plugin.sp_max_proto.pv_major, and the minor number
64 * DOWN<space><32-char-cap-hex-uuid><space><8-char-hex-nodenum><newline>
75 * For now, we have just one protocol version.
127 /* SETN<space><8-char-hex-nodenum><newline> */
135 /* SETV<space><2-char-hex-major><space><2-char-hex-minor><newline> */
141 char minor[OCFS2_CONTROL_MESSAGE_VERNUM_LEN]; member
145 /* DOWN<space><32-char-cap-hex-uuid><space><8-char-hex-nodenum><newline> */
165 static int ocfs2_control_this_node = -1;
175 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_set_handshake_state()
176 p->op_state = state; in ocfs2_control_set_handshake_state()
181 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_get_handshake_state()
182 return p->op_state; in ocfs2_control_get_handshake_state()
193 if ((c->oc_conn->cc_namelen == len) && in ocfs2_connection_find()
194 !strncmp(c->oc_conn->cc_name, name, len)) in ocfs2_connection_find()
212 c->oc_conn = conn; in ocfs2_live_connection_attach()
214 if ((c->oc_type == NO_CONTROLD) || atomic_read(&ocfs2_control_opened)) in ocfs2_live_connection_attach()
215 list_add(&c->oc_list, &ocfs2_live_connection_list); in ocfs2_live_connection_attach()
219 rc = -ESRCH; in ocfs2_live_connection_attach()
233 list_del_init(&c->oc_list); in ocfs2_live_connection_drop()
234 c->oc_conn = NULL; in ocfs2_live_connection_drop()
246 return -EINVAL; in ocfs2_control_cfu()
249 return -EFAULT; in ocfs2_control_cfu()
267 return -EINVAL; in ocfs2_control_validate_protocol()
284 BUG_ON(c->oc_conn == NULL); in ocfs2_control_send_down()
285 c->oc_conn->cc_recovery_handler(nodenum, in ocfs2_control_send_down()
286 c->oc_conn->cc_recovery_data); in ocfs2_control_send_down()
303 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_install_private()
305 BUG_ON(p->op_state != OCFS2_CONTROL_HANDSHAKE_PROTOCOL); in ocfs2_control_install_private()
309 if (p->op_this_node < 0) { in ocfs2_control_install_private()
312 (ocfs2_control_this_node != p->op_this_node)) { in ocfs2_control_install_private()
313 rc = -EINVAL; in ocfs2_control_install_private()
317 if (!p->op_proto.pv_major) { in ocfs2_control_install_private()
320 ((running_proto.pv_major != p->op_proto.pv_major) || in ocfs2_control_install_private()
321 (running_proto.pv_minor != p->op_proto.pv_minor))) { in ocfs2_control_install_private()
322 rc = -EINVAL; in ocfs2_control_install_private()
327 ocfs2_control_this_node = p->op_this_node; in ocfs2_control_install_private()
328 running_proto.pv_major = p->op_proto.pv_major; in ocfs2_control_install_private()
329 running_proto.pv_minor = p->op_proto.pv_minor; in ocfs2_control_install_private()
351 rc = -EINVAL; in ocfs2_control_get_this_node()
364 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_do_setnode_msg()
368 return -EINVAL; in ocfs2_control_do_setnode_msg()
370 if (strncmp(msg->tag, OCFS2_CONTROL_MESSAGE_SETNODE_OP, in ocfs2_control_do_setnode_msg()
372 return -EINVAL; in ocfs2_control_do_setnode_msg()
374 if ((msg->space != ' ') || (msg->newline != '\n')) in ocfs2_control_do_setnode_msg()
375 return -EINVAL; in ocfs2_control_do_setnode_msg()
376 msg->space = msg->newline = '\0'; in ocfs2_control_do_setnode_msg()
378 nodenum = simple_strtol(msg->nodestr, &ptr, 16); in ocfs2_control_do_setnode_msg()
380 return -EINVAL; in ocfs2_control_do_setnode_msg()
384 return -ERANGE; in ocfs2_control_do_setnode_msg()
385 p->op_this_node = nodenum; in ocfs2_control_do_setnode_msg()
393 long major, minor; in ocfs2_control_do_setversion_msg() local
395 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_do_setversion_msg()
401 return -EINVAL; in ocfs2_control_do_setversion_msg()
403 if (strncmp(msg->tag, OCFS2_CONTROL_MESSAGE_SETVERSION_OP, in ocfs2_control_do_setversion_msg()
405 return -EINVAL; in ocfs2_control_do_setversion_msg()
407 if ((msg->space1 != ' ') || (msg->space2 != ' ') || in ocfs2_control_do_setversion_msg()
408 (msg->newline != '\n')) in ocfs2_control_do_setversion_msg()
409 return -EINVAL; in ocfs2_control_do_setversion_msg()
410 msg->space1 = msg->space2 = msg->newline = '\0'; in ocfs2_control_do_setversion_msg()
412 major = simple_strtol(msg->major, &ptr, 16); in ocfs2_control_do_setversion_msg()
414 return -EINVAL; in ocfs2_control_do_setversion_msg()
415 minor = simple_strtol(msg->minor, &ptr, 16); in ocfs2_control_do_setversion_msg()
417 return -EINVAL; in ocfs2_control_do_setversion_msg()
420 * The major must be between 1 and 255, inclusive. The minor in ocfs2_control_do_setversion_msg()
421 * must be between 0 and 255, inclusive. The version passed in in ocfs2_control_do_setversion_msg()
422 * must be within the maximum version supported by the filesystem. in ocfs2_control_do_setversion_msg()
425 (major > (u8)-1) || (major < 1)) in ocfs2_control_do_setversion_msg()
426 return -ERANGE; in ocfs2_control_do_setversion_msg()
427 if ((minor == LONG_MIN) || (minor == LONG_MAX) || in ocfs2_control_do_setversion_msg()
428 (minor > (u8)-1) || (minor < 0)) in ocfs2_control_do_setversion_msg()
429 return -ERANGE; in ocfs2_control_do_setversion_msg()
430 if ((major != max->pv_major) || in ocfs2_control_do_setversion_msg()
431 (minor > max->pv_minor)) in ocfs2_control_do_setversion_msg()
432 return -EINVAL; in ocfs2_control_do_setversion_msg()
434 p->op_proto.pv_major = major; in ocfs2_control_do_setversion_msg()
435 p->op_proto.pv_minor = minor; in ocfs2_control_do_setversion_msg()
448 return -EINVAL; in ocfs2_control_do_down_msg()
450 if (strncmp(msg->tag, OCFS2_CONTROL_MESSAGE_DOWN_OP, in ocfs2_control_do_down_msg()
452 return -EINVAL; in ocfs2_control_do_down_msg()
454 if ((msg->space1 != ' ') || (msg->space2 != ' ') || in ocfs2_control_do_down_msg()
455 (msg->newline != '\n')) in ocfs2_control_do_down_msg()
456 return -EINVAL; in ocfs2_control_do_down_msg()
457 msg->space1 = msg->space2 = msg->newline = '\0'; in ocfs2_control_do_down_msg()
459 nodenum = simple_strtol(msg->nodestr, &p, 16); in ocfs2_control_do_down_msg()
461 return -EINVAL; in ocfs2_control_do_down_msg()
465 return -ERANGE; in ocfs2_control_do_down_msg()
467 ocfs2_control_send_down(msg->uuid, nodenum); in ocfs2_control_do_down_msg()
501 ret = -EINVAL; in ocfs2_control_message()
516 ret = -EINVAL; in ocfs2_control_write()
531 ret = -EIO; in ocfs2_control_write()
539 * This is a naive version. If we ever have a new protocol, we'll expand
562 struct ocfs2_control_private *p = file->private_data; in ocfs2_control_release()
581 * the locking protocol version in ocfs2_control_release()
583 ocfs2_control_this_node = -1; in ocfs2_control_release()
589 list_del_init(&p->op_list); in ocfs2_control_release()
590 file->private_data = NULL; in ocfs2_control_release()
605 return -ENOMEM; in ocfs2_control_open()
606 p->op_this_node = -1; in ocfs2_control_open()
609 file->private_data = p; in ocfs2_control_open()
610 list_add(&p->op_list, &ocfs2_control_private_list); in ocfs2_control_open()
626 .minor = MISC_DYNAMIC_MINOR,
642 -rc); in ocfs2_control_init()
655 int status = lksb->lksb_fsdlm.sb_status; in fsdlm_lock_ast_wrapper()
658 * For now we're punting on the issue of other non-standard errors in fsdlm_lock_ast_wrapper()
662 * since the caller here is under our control. Other non-standard in fsdlm_lock_ast_wrapper()
667 if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL) in fsdlm_lock_ast_wrapper()
668 lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, 0); in fsdlm_lock_ast_wrapper()
670 lksb->lksb_conn->cc_proto->lp_lock_ast(lksb); in fsdlm_lock_ast_wrapper()
677 lksb->lksb_conn->cc_proto->lp_blocking_ast(lksb, level); in fsdlm_blocking_ast_wrapper()
687 if (!lksb->lksb_fsdlm.sb_lvbptr) in user_dlm_lock()
688 lksb->lksb_fsdlm.sb_lvbptr = (char *)lksb + in user_dlm_lock()
691 return dlm_lock(conn->cc_lockspace, mode, &lksb->lksb_fsdlm, in user_dlm_lock()
701 return dlm_unlock(conn->cc_lockspace, lksb->lksb_fsdlm.sb_lkid, in user_dlm_unlock()
702 flags, &lksb->lksb_fsdlm, lksb); in user_dlm_unlock()
707 return lksb->lksb_fsdlm.sb_status; in user_dlm_lock_status()
712 int invalid = lksb->lksb_fsdlm.sb_flags & DLM_SBF_VALNOTVALID; in user_dlm_lvb_valid()
719 if (!lksb->lksb_fsdlm.sb_lvbptr) in user_dlm_lvb()
720 lksb->lksb_fsdlm.sb_lvbptr = (char *)lksb + in user_dlm_lvb()
722 return (void *)(lksb->lksb_fsdlm.sb_lvbptr); in user_dlm_lvb()
744 return dlm_posix_cancel(conn->cc_lockspace, ino, file, fl); in user_plock()
746 return dlm_posix_get(conn->cc_lockspace, ino, file, fl); in user_plock()
748 return dlm_posix_unlock(conn->cc_lockspace, ino, file, fl); in user_plock()
750 return dlm_posix_lock(conn->cc_lockspace, ino, file, cmd, fl); in user_plock()
754 * Compare a requested locking protocol version against the current one.
757 * If the current minor is greater than the request, they are incompatible.
758 * If the current minor is less than or equal to the request, they are
759 * compatible, and the requester should run at the current minor version.
764 if (existing->pv_major != request->pv_major) in fs_protocol_compare()
767 if (existing->pv_minor > request->pv_minor) in fs_protocol_compare()
770 if (existing->pv_minor < request->pv_minor) in fs_protocol_compare()
771 request->pv_minor = existing->pv_minor; in fs_protocol_compare()
784 ver->pv_major = pv->pv_major; in lvb_to_version()
785 ver->pv_minor = pv->pv_minor; in lvb_to_version()
796 pv->pv_major = ver->pv_major; in version_to_lvb()
797 pv->pv_minor = ver->pv_minor; in version_to_lvb()
803 struct ocfs2_live_connection *lc = conn->cc_private; in sync_wait_cb()
804 complete(&lc->oc_sync_wait); in sync_wait_cb()
811 struct ocfs2_live_connection *lc = conn->cc_private; in sync_unlock()
813 error = dlm_unlock(conn->cc_lockspace, lksb->sb_lkid, 0, lksb, conn); in sync_unlock()
816 name, lksb->sb_lkid, error); in sync_unlock()
820 wait_for_completion(&lc->oc_sync_wait); in sync_unlock()
822 if (lksb->sb_status != -DLM_EUNLOCK) { in sync_unlock()
824 name, lksb->sb_lkid, lksb->sb_status); in sync_unlock()
825 return -1; in sync_unlock()
835 struct ocfs2_live_connection *lc = conn->cc_private; in sync_lock()
837 error = dlm_lock(conn->cc_lockspace, mode, lksb, flags, in sync_lock()
842 name, lksb->sb_lkid, flags, mode, error); in sync_lock()
846 wait_for_completion(&lc->oc_sync_wait); in sync_lock()
848 status = lksb->sb_status; in sync_lock()
850 if (status && status != -EAGAIN) { in sync_lock()
852 name, lksb->sb_lkid, flags, mode, status); in sync_lock()
862 struct ocfs2_live_connection *lc = conn->cc_private; in version_lock()
864 &lc->oc_version_lksb, VERSION_LOCK); in version_lock()
869 struct ocfs2_live_connection *lc = conn->cc_private; in version_unlock()
870 return sync_unlock(conn, &lc->oc_version_lksb, VERSION_LOCK); in version_unlock()
875 * To exchange ocfs2 versioning, we use the LVB of the version dlm lock.
877 * 1. Attempt to take the lock in EX mode (non-blocking).
879 * version number and downconvert to PR lock.
880 * 3. If unsuccessful (returns -EAGAIN), read the version from the LVB after
887 struct ocfs2_live_connection *lc = conn->cc_private; in get_protocol_version()
895 lc->oc_version_lksb.sb_lvbptr = lc->oc_lvb; in get_protocol_version()
899 conn->cc_version.pv_major = running_proto.pv_major; in get_protocol_version()
900 conn->cc_version.pv_minor = running_proto.pv_minor; in get_protocol_version()
901 version_to_lvb(&running_proto, lc->oc_lvb); in get_protocol_version()
903 } else if (ret == -EAGAIN) { in get_protocol_version()
907 lvb_to_version(lc->oc_lvb, &pv); in get_protocol_version()
911 ret = -EINVAL; in get_protocol_version()
915 conn->cc_version.pv_major = pv.pv_major; in get_protocol_version()
916 conn->cc_version.pv_minor = pv.pv_minor; in get_protocol_version()
930 slot->nodeid, slot->slot); in user_recover_slot()
931 conn->cc_recovery_handler(slot->nodeid, conn->cc_recovery_data); in user_recover_slot()
940 struct ocfs2_live_connection *lc = conn->cc_private; in user_recover_done()
945 atomic_set(&lc->oc_this_node, slots[i].nodeid); in user_recover_done()
949 lc->oc_our_slot = our_slot; in user_recover_done()
950 wake_up(&lc->oc_wait); in user_recover_done()
962 dlm_release_lockspace(conn->cc_lockspace, 2); in user_cluster_disconnect()
963 conn->cc_lockspace = NULL; in user_cluster_disconnect()
964 ocfs2_live_connection_drop(conn->cc_private); in user_cluster_disconnect()
965 conn->cc_private = NULL; in user_cluster_disconnect()
979 return -ENOMEM; in user_cluster_connect()
981 init_waitqueue_head(&lc->oc_wait); in user_cluster_connect()
982 init_completion(&lc->oc_sync_wait); in user_cluster_connect()
983 atomic_set(&lc->oc_this_node, 0); in user_cluster_connect()
984 conn->cc_private = lc; in user_cluster_connect()
985 lc->oc_type = NO_CONTROLD; in user_cluster_connect()
987 rc = dlm_new_lockspace(conn->cc_name, conn->cc_cluster_name, in user_cluster_connect()
991 if (rc == -EEXIST || rc == -EPROTO) in user_cluster_connect()
993 "lockspace %s (%d), because a ocfs2-tools " in user_cluster_connect()
996 conn->cc_name, rc); in user_cluster_connect()
1000 if (ops_rv == -EOPNOTSUPP) { in user_cluster_connect()
1001 lc->oc_type = WITH_CONTROLD; in user_cluster_connect()
1003 "version of dlm_controld and/or ocfs2-tools." in user_cluster_connect()
1009 conn->cc_lockspace = fsdlm; in user_cluster_connect()
1015 if (lc->oc_type == NO_CONTROLD) { in user_cluster_connect()
1019 " locking version\n"); in user_cluster_connect()
1023 wait_event(lc->oc_wait, (atomic_read(&lc->oc_this_node) > 0)); in user_cluster_connect()
1030 if (fs_protocol_compare(&running_proto, &conn->cc_version)) { in user_cluster_connect()
1032 "Unable to mount with fs locking protocol version " in user_cluster_connect()
1034 conn->cc_version.pv_major, conn->cc_version.pv_minor, in user_cluster_connect()
1036 rc = -EPROTO; in user_cluster_connect()
1052 struct ocfs2_live_connection *lc = conn->cc_private; in user_cluster_this_node()
1054 if (lc->oc_type == WITH_CONTROLD) in user_cluster_this_node()
1056 else if (lc->oc_type == NO_CONTROLD) in user_cluster_this_node()
1057 rc = atomic_read(&lc->oc_this_node); in user_cluster_this_node()
1059 rc = -EINVAL; in user_cluster_this_node()