NFSv4: Convert struct nfs4_state to use refcount_t
[ Upstream commitace9fad43a
] Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Stable-dep-of:6165a16a5a
("NFSv4: Fix hangs when recovering open state after a server reboot") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c65a5e3bec
commit
ca2e3cdcc4
@ -190,7 +190,7 @@ struct nfs4_state {
|
|||||||
unsigned int n_wronly; /* Number of write-only references */
|
unsigned int n_wronly; /* Number of write-only references */
|
||||||
unsigned int n_rdwr; /* Number of read/write references */
|
unsigned int n_rdwr; /* Number of read/write references */
|
||||||
fmode_t state; /* State on the server (R,W, or RW) */
|
fmode_t state; /* State on the server (R,W, or RW) */
|
||||||
atomic_t count;
|
refcount_t count;
|
||||||
|
|
||||||
wait_queue_head_t waitq;
|
wait_queue_head_t waitq;
|
||||||
};
|
};
|
||||||
|
@ -1792,7 +1792,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
|
|||||||
out:
|
out:
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
out_return_state:
|
out_return_state:
|
||||||
atomic_inc(&state->count);
|
refcount_inc(&state->count);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1864,7 +1864,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
|
|||||||
update:
|
update:
|
||||||
update_open_stateid(state, &data->o_res.stateid, NULL,
|
update_open_stateid(state, &data->o_res.stateid, NULL,
|
||||||
data->o_arg.fmode);
|
data->o_arg.fmode);
|
||||||
atomic_inc(&state->count);
|
refcount_inc(&state->count);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -1902,7 +1902,7 @@ nfs4_opendata_find_nfs4_state(struct nfs4_opendata *data)
|
|||||||
return ERR_CAST(inode);
|
return ERR_CAST(inode);
|
||||||
if (data->state != NULL && data->state->inode == inode) {
|
if (data->state != NULL && data->state->inode == inode) {
|
||||||
state = data->state;
|
state = data->state;
|
||||||
atomic_inc(&state->count);
|
refcount_inc(&state->count);
|
||||||
} else
|
} else
|
||||||
state = nfs4_get_open_state(inode, data->owner);
|
state = nfs4_get_open_state(inode, data->owner);
|
||||||
iput(inode);
|
iput(inode);
|
||||||
@ -1975,7 +1975,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
|
|||||||
if (opendata == NULL)
|
if (opendata == NULL)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
opendata->state = state;
|
opendata->state = state;
|
||||||
atomic_inc(&state->count);
|
refcount_inc(&state->count);
|
||||||
return opendata;
|
return opendata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ nfs4_alloc_open_state(void)
|
|||||||
state = kzalloc(sizeof(*state), GFP_NOFS);
|
state = kzalloc(sizeof(*state), GFP_NOFS);
|
||||||
if (!state)
|
if (!state)
|
||||||
return NULL;
|
return NULL;
|
||||||
atomic_set(&state->count, 1);
|
refcount_set(&state->count, 1);
|
||||||
INIT_LIST_HEAD(&state->lock_states);
|
INIT_LIST_HEAD(&state->lock_states);
|
||||||
spin_lock_init(&state->state_lock);
|
spin_lock_init(&state->state_lock);
|
||||||
seqlock_init(&state->seqlock);
|
seqlock_init(&state->seqlock);
|
||||||
@ -709,7 +709,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
|
|||||||
continue;
|
continue;
|
||||||
if (!nfs4_valid_open_stateid(state))
|
if (!nfs4_valid_open_stateid(state))
|
||||||
continue;
|
continue;
|
||||||
if (atomic_inc_not_zero(&state->count))
|
if (refcount_inc_not_zero(&state->count))
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -763,7 +763,7 @@ void nfs4_put_open_state(struct nfs4_state *state)
|
|||||||
struct inode *inode = state->inode;
|
struct inode *inode = state->inode;
|
||||||
struct nfs4_state_owner *owner = state->owner;
|
struct nfs4_state_owner *owner = state->owner;
|
||||||
|
|
||||||
if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
|
if (!refcount_dec_and_lock(&state->count, &owner->so_lock))
|
||||||
return;
|
return;
|
||||||
spin_lock(&inode->i_lock);
|
spin_lock(&inode->i_lock);
|
||||||
list_del(&state->inode_states);
|
list_del(&state->inode_states);
|
||||||
@ -1596,7 +1596,7 @@ restart:
|
|||||||
continue;
|
continue;
|
||||||
if (state->state == 0)
|
if (state->state == 0)
|
||||||
continue;
|
continue;
|
||||||
atomic_inc(&state->count);
|
refcount_inc(&state->count);
|
||||||
spin_unlock(&sp->so_lock);
|
spin_unlock(&sp->so_lock);
|
||||||
status = ops->recover_open(sp, state);
|
status = ops->recover_open(sp, state);
|
||||||
if (status >= 0) {
|
if (status >= 0) {
|
||||||
|
Reference in New Issue
Block a user