Commit bea90085 authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland
Browse files

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: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 6af515c9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -979,7 +979,7 @@ static int join(struct mddev *mddev, int nodes)
	lockres_free(cinfo->resync_lockres);
	lockres_free(cinfo->bitmap_lockres);
	if (cinfo->lockspace)
		dlm_release_lockspace(cinfo->lockspace, 2);
		dlm_release_lockspace(cinfo->lockspace, DLM_RELEASE_NORMAL);
	mddev->cluster_info = NULL;
	kfree(cinfo);
	return ret;
@@ -1042,7 +1042,7 @@ static int leave(struct mddev *mddev)
	lockres_free(cinfo->resync_lockres);
	lockres_free(cinfo->bitmap_lockres);
	unlock_all_bitmaps(mddev);
	dlm_release_lockspace(cinfo->lockspace, 2);
	dlm_release_lockspace(cinfo->lockspace, DLM_RELEASE_NORMAL);
	kfree(cinfo);
	return 0;
}
+9 −11
Original line number Diff line number Diff line
@@ -671,19 +671,20 @@ int dlm_new_user_lockspace(const char *name, const char *cluster,
   This is because there may be LKBs queued as ASTs that have been unlinked
   from their RSBs and are pending deletion once the AST has been delivered */

static int lockspace_busy(struct dlm_ls *ls, int force)
static int lockspace_busy(struct dlm_ls *ls, int release_option)
{
	struct dlm_lkb *lkb;
	unsigned long id;
	int rv = 0;

	read_lock_bh(&ls->ls_lkbxa_lock);
	if (force == 0) {
	if (release_option == DLM_RELEASE_NO_LOCKS) {
		xa_for_each(&ls->ls_lkbxa, id, lkb) {
			rv = 1;
			break;
		}
	} else if (force == 1) {
	} else if (release_option == DLM_RELEASE_UNUSED) {
		/* TODO: handle this UNUSED option as NO_LOCKS in later patch */
		xa_for_each(&ls->ls_lkbxa, id, lkb) {
			if (lkb->lkb_nodeid == 0 &&
			    lkb->lkb_grmode != DLM_LOCK_IV) {
@@ -698,11 +699,11 @@ static int lockspace_busy(struct dlm_ls *ls, int force)
	return rv;
}

static int release_lockspace(struct dlm_ls *ls, int force)
static int release_lockspace(struct dlm_ls *ls, int release_option)
{
	int busy, rv;

	busy = lockspace_busy(ls, force);
	busy = lockspace_busy(ls, release_option);

	spin_lock_bh(&lslist_lock);
	if (ls->ls_create_count == 1) {
@@ -730,7 +731,8 @@ static int release_lockspace(struct dlm_ls *ls, int force)

	dlm_device_deregister(ls);

	if (force != 3 && dlm_user_daemon_available())
	if (release_option != DLM_RELEASE_NO_EVENT &&
	    dlm_user_daemon_available())
		do_uevent(ls, 0);

	dlm_recoverd_stop(ls);
@@ -782,11 +784,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
 * lockspace must continue to function as usual, participating in recoveries,
 * until this returns.
 *
 * Force has 4 possible values:
 * 0 - don't destroy lockspace if it has any LKBs
 * 1 - destroy lockspace if it has remote LKBs but not if it has local LKBs
 * 2 - destroy lockspace regardless of LKBs
 * 3 - destroy lockspace as part of a forced shutdown
 * See DLM_RELEASE defines for release_option values and their meaning.
 */

int dlm_release_lockspace(void *lockspace, int force)
+3 −3
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ static int device_create_lockspace(struct dlm_lspace_params *params)
	dlm_put_lockspace(ls);

	if (error)
		dlm_release_lockspace(lockspace, 0);
		dlm_release_lockspace(lockspace, DLM_RELEASE_NO_LOCKS);
	else
		error = ls->ls_device.minor;

@@ -436,7 +436,7 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
{
	dlm_lockspace_t *lockspace;
	struct dlm_ls *ls;
	int error, force = 0;
	int error, force = DLM_RELEASE_NO_LOCKS;

	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;
@@ -446,7 +446,7 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
		return -ENOENT;

	if (params->flags & DLM_USER_LSFLG_FORCEFREE)
		force = 2;
		force = DLM_RELEASE_NORMAL;

	lockspace = ls;
	dlm_put_lockspace(ls);
+2 −2
Original line number Diff line number Diff line
@@ -1400,7 +1400,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)
	return 0;

fail_release:
	dlm_release_lockspace(ls->ls_dlm, 2);
	dlm_release_lockspace(ls->ls_dlm, DLM_RELEASE_NORMAL);
fail_free:
	free_recover_size(ls);
fail:
@@ -1437,7 +1437,7 @@ static void gdlm_unmount(struct gfs2_sbd *sdp)
	/* mounted_lock and control_lock will be purged in dlm recovery */
release:
	if (ls->ls_dlm) {
		dlm_release_lockspace(ls->ls_dlm, 2);
		dlm_release_lockspace(ls->ls_dlm, DLM_RELEASE_NORMAL);
		ls->ls_dlm = NULL;
	}

+1 −1
Original line number Diff line number Diff line
@@ -952,7 +952,7 @@ static const struct dlm_lockspace_ops ocfs2_ls_ops = {
static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
{
	version_unlock(conn);
	dlm_release_lockspace(conn->cc_lockspace, 2);
	dlm_release_lockspace(conn->cc_lockspace, DLM_RELEASE_NORMAL);
	conn->cc_lockspace = NULL;
	ocfs2_live_connection_drop(conn->cc_private);
	conn->cc_private = NULL;
Loading