diff options
Diffstat (limited to 'fs/nfs/nfs4state.c')
| -rw-r--r-- | fs/nfs/nfs4state.c | 49 | 
1 files changed, 11 insertions, 38 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 848f6853c59e..22fe35104c0c 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -787,21 +787,12 @@ void nfs4_close_sync(struct nfs4_state *state, fmode_t fmode)   * that is compatible with current->files   */  static struct nfs4_lock_state * -__nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner, pid_t fl_pid, unsigned int type) +__nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)  {  	struct nfs4_lock_state *pos;  	list_for_each_entry(pos, &state->lock_states, ls_locks) { -		if (type != NFS4_ANY_LOCK_TYPE && pos->ls_owner.lo_type != type) +		if (pos->ls_owner != fl_owner)  			continue; -		switch (pos->ls_owner.lo_type) { -		case NFS4_POSIX_LOCK_TYPE: -			if (pos->ls_owner.lo_u.posix_owner != fl_owner) -				continue; -			break; -		case NFS4_FLOCK_LOCK_TYPE: -			if (pos->ls_owner.lo_u.flock_owner != fl_pid) -				continue; -		}  		atomic_inc(&pos->ls_count);  		return pos;  	} @@ -813,7 +804,7 @@ __nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner, pid_t fl_p   * exists, return an uninitialized one.   *   */ -static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner, pid_t fl_pid, unsigned int type) +static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)  {  	struct nfs4_lock_state *lsp;  	struct nfs_server *server = state->owner->so_server; @@ -824,17 +815,7 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f  	nfs4_init_seqid_counter(&lsp->ls_seqid);  	atomic_set(&lsp->ls_count, 1);  	lsp->ls_state = state; -	lsp->ls_owner.lo_type = type; -	switch (lsp->ls_owner.lo_type) { -	case NFS4_FLOCK_LOCK_TYPE: -		lsp->ls_owner.lo_u.flock_owner = fl_pid; -		break; -	case NFS4_POSIX_LOCK_TYPE: -		lsp->ls_owner.lo_u.posix_owner = fl_owner; -		break; -	default: -		goto out_free; -	} +	lsp->ls_owner = fl_owner;  	lsp->ls_seqid.owner_id = ida_simple_get(&server->lockowner_id, 0, 0, GFP_NOFS);  	if (lsp->ls_seqid.owner_id < 0)  		goto out_free; @@ -857,13 +838,13 @@ void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp   * exists, return an uninitialized one.   *   */ -static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner, pid_t pid, unsigned int type) +static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner)  {  	struct nfs4_lock_state *lsp, *new = NULL;  	for(;;) {  		spin_lock(&state->state_lock); -		lsp = __nfs4_find_lock_state(state, owner, pid, type); +		lsp = __nfs4_find_lock_state(state, owner);  		if (lsp != NULL)  			break;  		if (new != NULL) { @@ -874,7 +855,7 @@ static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_  			break;  		}  		spin_unlock(&state->state_lock); -		new = nfs4_alloc_lock_state(state, owner, pid, type); +		new = nfs4_alloc_lock_state(state, owner);  		if (new == NULL)  			return NULL;  	} @@ -935,13 +916,7 @@ int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)  	if (fl->fl_ops != NULL)  		return 0; -	if (fl->fl_flags & FL_POSIX) -		lsp = nfs4_get_lock_state(state, fl->fl_owner, 0, NFS4_POSIX_LOCK_TYPE); -	else if (fl->fl_flags & FL_FLOCK) -		lsp = nfs4_get_lock_state(state, NULL, fl->fl_pid, -				NFS4_FLOCK_LOCK_TYPE); -	else -		return -EINVAL; +	lsp = nfs4_get_lock_state(state, fl->fl_owner);  	if (lsp == NULL)  		return -ENOMEM;  	fl->fl_u.nfs4_fl.owner = lsp; @@ -955,7 +930,6 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,  {  	struct nfs4_lock_state *lsp;  	fl_owner_t fl_owner; -	pid_t fl_pid;  	int ret = -ENOENT; @@ -966,9 +940,8 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,  		goto out;  	fl_owner = lockowner->l_owner; -	fl_pid = lockowner->l_pid;  	spin_lock(&state->state_lock); -	lsp = __nfs4_find_lock_state(state, fl_owner, fl_pid, NFS4_ANY_LOCK_TYPE); +	lsp = __nfs4_find_lock_state(state, fl_owner);  	if (lsp && test_bit(NFS_LOCK_LOST, &lsp->ls_flags))  		ret = -EIO;  	else if (lsp != NULL && test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) { @@ -1251,8 +1224,8 @@ int nfs4_wait_clnt_recover(struct nfs_client *clp)  	might_sleep();  	atomic_inc(&clp->cl_count); -	res = wait_on_bit(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, -			nfs_wait_bit_killable, TASK_KILLABLE); +	res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, +				 nfs_wait_bit_killable, TASK_KILLABLE);  	if (res)  		goto out;  	if (clp->cl_cons_state < 0)  |