Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dlm: use defines for force values in dlm_release_lockspace

Clarify the use of the force parameter by renaming it to
"release_option" and adding defines (with descriptions) for
each of the accepted values.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>

authored by

Alexander Aring and committed by
David Teigland
bea90085 6af515c9

+42 -20
+2 -2
drivers/md/md-cluster.c
··· 979 979 lockres_free(cinfo->resync_lockres); 980 980 lockres_free(cinfo->bitmap_lockres); 981 981 if (cinfo->lockspace) 982 - dlm_release_lockspace(cinfo->lockspace, 2); 982 + dlm_release_lockspace(cinfo->lockspace, DLM_RELEASE_NORMAL); 983 983 mddev->cluster_info = NULL; 984 984 kfree(cinfo); 985 985 return ret; ··· 1042 1042 lockres_free(cinfo->resync_lockres); 1043 1043 lockres_free(cinfo->bitmap_lockres); 1044 1044 unlock_all_bitmaps(mddev); 1045 - dlm_release_lockspace(cinfo->lockspace, 2); 1045 + dlm_release_lockspace(cinfo->lockspace, DLM_RELEASE_NORMAL); 1046 1046 kfree(cinfo); 1047 1047 return 0; 1048 1048 }
+9 -11
fs/dlm/lockspace.c
··· 671 671 This is because there may be LKBs queued as ASTs that have been unlinked 672 672 from their RSBs and are pending deletion once the AST has been delivered */ 673 673 674 - static int lockspace_busy(struct dlm_ls *ls, int force) 674 + static int lockspace_busy(struct dlm_ls *ls, int release_option) 675 675 { 676 676 struct dlm_lkb *lkb; 677 677 unsigned long id; 678 678 int rv = 0; 679 679 680 680 read_lock_bh(&ls->ls_lkbxa_lock); 681 - if (force == 0) { 681 + if (release_option == DLM_RELEASE_NO_LOCKS) { 682 682 xa_for_each(&ls->ls_lkbxa, id, lkb) { 683 683 rv = 1; 684 684 break; 685 685 } 686 - } else if (force == 1) { 686 + } else if (release_option == DLM_RELEASE_UNUSED) { 687 + /* TODO: handle this UNUSED option as NO_LOCKS in later patch */ 687 688 xa_for_each(&ls->ls_lkbxa, id, lkb) { 688 689 if (lkb->lkb_nodeid == 0 && 689 690 lkb->lkb_grmode != DLM_LOCK_IV) { ··· 699 698 return rv; 700 699 } 701 700 702 - static int release_lockspace(struct dlm_ls *ls, int force) 701 + static int release_lockspace(struct dlm_ls *ls, int release_option) 703 702 { 704 703 int busy, rv; 705 704 706 - busy = lockspace_busy(ls, force); 705 + busy = lockspace_busy(ls, release_option); 707 706 708 707 spin_lock_bh(&lslist_lock); 709 708 if (ls->ls_create_count == 1) { ··· 731 730 732 731 dlm_device_deregister(ls); 733 732 734 - if (force != 3 && dlm_user_daemon_available()) 733 + if (release_option != DLM_RELEASE_NO_EVENT && 734 + dlm_user_daemon_available()) 735 735 do_uevent(ls, 0); 736 736 737 737 dlm_recoverd_stop(ls); ··· 784 782 * lockspace must continue to function as usual, participating in recoveries, 785 783 * until this returns. 786 784 * 787 - * Force has 4 possible values: 788 - * 0 - don't destroy lockspace if it has any LKBs 789 - * 1 - destroy lockspace if it has remote LKBs but not if it has local LKBs 790 - * 2 - destroy lockspace regardless of LKBs 791 - * 3 - destroy lockspace as part of a forced shutdown 785 + * See DLM_RELEASE defines for release_option values and their meaning. 792 786 */ 793 787 794 788 int dlm_release_lockspace(void *lockspace, int force)
+3 -3
fs/dlm/user.c
··· 425 425 dlm_put_lockspace(ls); 426 426 427 427 if (error) 428 - dlm_release_lockspace(lockspace, 0); 428 + dlm_release_lockspace(lockspace, DLM_RELEASE_NO_LOCKS); 429 429 else 430 430 error = ls->ls_device.minor; 431 431 ··· 436 436 { 437 437 dlm_lockspace_t *lockspace; 438 438 struct dlm_ls *ls; 439 - int error, force = 0; 439 + int error, force = DLM_RELEASE_NO_LOCKS; 440 440 441 441 if (!capable(CAP_SYS_ADMIN)) 442 442 return -EPERM; ··· 446 446 return -ENOENT; 447 447 448 448 if (params->flags & DLM_USER_LSFLG_FORCEFREE) 449 - force = 2; 449 + force = DLM_RELEASE_NORMAL; 450 450 451 451 lockspace = ls; 452 452 dlm_put_lockspace(ls);
+2 -2
fs/gfs2/lock_dlm.c
··· 1400 1400 return 0; 1401 1401 1402 1402 fail_release: 1403 - dlm_release_lockspace(ls->ls_dlm, 2); 1403 + dlm_release_lockspace(ls->ls_dlm, DLM_RELEASE_NORMAL); 1404 1404 fail_free: 1405 1405 free_recover_size(ls); 1406 1406 fail: ··· 1437 1437 /* mounted_lock and control_lock will be purged in dlm recovery */ 1438 1438 release: 1439 1439 if (ls->ls_dlm) { 1440 - dlm_release_lockspace(ls->ls_dlm, 2); 1440 + dlm_release_lockspace(ls->ls_dlm, DLM_RELEASE_NORMAL); 1441 1441 ls->ls_dlm = NULL; 1442 1442 } 1443 1443
+1 -1
fs/ocfs2/stack_user.c
··· 952 952 static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn) 953 953 { 954 954 version_unlock(conn); 955 - dlm_release_lockspace(conn->cc_lockspace, 2); 955 + dlm_release_lockspace(conn->cc_lockspace, DLM_RELEASE_NORMAL); 956 956 conn->cc_lockspace = NULL; 957 957 ocfs2_live_connection_drop(conn->cc_private); 958 958 conn->cc_private = NULL;
+25 -1
include/linux/dlm.h
··· 88 88 int *ops_result, dlm_lockspace_t **lockspace); 89 89 90 90 /* 91 + * dlm_release_lockspace() release_option values: 92 + * 93 + * DLM_RELEASE_NO_LOCKS returns -EBUSY if any locks (lkb's) 94 + * exist in the local lockspace. 95 + * 96 + * DLM_RELEASE_UNUSED previous value that is no longer used. 97 + * 98 + * DLM_RELEASE_NORMAL releases the lockspace regardless of any 99 + * locks managed in the local lockspace. 100 + * 101 + * DLM_RELEASE_NO_EVENT release the lockspace regardless of any 102 + * locks managed in the local lockspace, and does not submit 103 + * a leave event to the cluster manager, so other nodes will 104 + * not be notified that the node should be removed from the 105 + * list of lockspace members. 106 + */ 107 + #define DLM_RELEASE_NO_LOCKS 0 108 + #define DLM_RELEASE_UNUSED 1 109 + #define DLM_RELEASE_NORMAL 2 110 + #define DLM_RELEASE_NO_EVENT 3 111 + 112 + /* 91 113 * dlm_release_lockspace 92 114 * 93 115 * Stop a lockspace. 116 + * 117 + * release_option: see DLM_RELEASE values above. 94 118 */ 95 119 96 - int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force); 120 + int dlm_release_lockspace(dlm_lockspace_t *lockspace, int release_option); 97 121 98 122 /* 99 123 * dlm_lock