Lines Matching defs:state
473 struct nfs4_state *state = exception->state;
483 if (stateid == NULL && state != NULL)
484 stateid = nfs4_recoverable_stateid(&state->stateid);
518 if (state == NULL)
520 ret = nfs4_schedule_stateid_recovery(server, state);
657 struct nfs4_state *state, long *timeout)
660 .state = state,
1068 /* The state manager will wait until the slot table is empty */
1459 if (p->state != NULL)
1460 nfs4_put_open_state(p->state);
1480 static bool nfs4_mode_match_open_stateid(struct nfs4_state *state,
1485 return state->n_rdwr != 0;
1487 return state->n_wronly != 0;
1489 return state->n_rdonly != 0;
1495 static int can_open_cached(struct nfs4_state *state, fmode_t mode,
1511 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0
1512 && state->n_rdonly != 0;
1515 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0
1516 && state->n_wronly != 0;
1519 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0
1520 && state->n_rdwr != 0;
1548 static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode)
1552 state->n_wronly++;
1555 state->n_rdonly++;
1558 state->n_rdwr++;
1560 nfs4_state_set_mode_locked(state, state->state | fmode);
1564 static bool nfs_open_stateid_recover_openmode(struct nfs4_state *state)
1566 if (state->n_rdonly && !test_bit(NFS_O_RDONLY_STATE, &state->flags))
1568 if (state->n_wronly && !test_bit(NFS_O_WRONLY_STATE, &state->flags))
1570 if (state->n_rdwr && !test_bit(NFS_O_RDWR_STATE, &state->flags))
1576 static void nfs_state_log_update_open_stateid(struct nfs4_state *state)
1578 if (test_and_clear_bit(NFS_STATE_CHANGE_WAIT, &state->flags))
1579 wake_up_all(&state->waitq);
1582 static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state)
1584 struct nfs_client *clp = state->owner->so_server->nfs_client;
1587 if (test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags) && state->n_rdonly)
1589 if (test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags) && state->n_wronly)
1591 if (test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags) && state->n_rdwr)
1594 nfs4_state_mark_reclaim_nograce(clp, state);
1605 * are then incremented on every state transition.
1607 static bool nfs_stateid_is_sequential(struct nfs4_state *state,
1610 if (test_bit(NFS_OPEN_STATE, &state->flags)) {
1612 if (nfs4_stateid_match_other(stateid, &state->open_stateid)) {
1613 if (nfs4_stateid_is_next(&state->open_stateid, stateid))
1625 static void nfs_resync_open_stateid_locked(struct nfs4_state *state)
1627 if (!(state->n_wronly || state->n_rdonly || state->n_rdwr))
1629 if (state->n_wronly)
1630 set_bit(NFS_O_WRONLY_STATE, &state->flags);
1631 if (state->n_rdonly)
1632 set_bit(NFS_O_RDONLY_STATE, &state->flags);
1633 if (state->n_rdwr)
1634 set_bit(NFS_O_RDWR_STATE, &state->flags);
1635 set_bit(NFS_OPEN_STATE, &state->flags);
1638 static void nfs_clear_open_stateid_locked(struct nfs4_state *state,
1641 clear_bit(NFS_O_RDWR_STATE, &state->flags);
1644 clear_bit(NFS_O_RDONLY_STATE, &state->flags);
1647 clear_bit(NFS_O_WRONLY_STATE, &state->flags);
1650 clear_bit(NFS_O_RDONLY_STATE, &state->flags);
1651 clear_bit(NFS_O_WRONLY_STATE, &state->flags);
1652 clear_bit(NFS_OPEN_STATE, &state->flags);
1657 if (nfs4_stateid_match_other(stateid, &state->open_stateid) &&
1658 !nfs4_stateid_is_newer(stateid, &state->open_stateid)) {
1659 nfs_resync_open_stateid_locked(state);
1662 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
1663 nfs4_stateid_copy(&state->stateid, stateid);
1664 nfs4_stateid_copy(&state->open_stateid, stateid);
1665 trace_nfs4_open_stateid_update(state->inode, stateid, 0);
1667 nfs_state_log_update_open_stateid(state);
1670 static void nfs_clear_open_stateid(struct nfs4_state *state,
1674 write_seqlock(&state->seqlock);
1676 if (nfs4_state_match_open_stateid_other(state, arg_stateid))
1677 nfs_clear_open_stateid_locked(state, stateid, fmode);
1678 write_sequnlock(&state->seqlock);
1679 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags))
1680 nfs4_schedule_state_manager(state->owner->so_server->nfs_client);
1683 static void nfs_set_open_stateid_locked(struct nfs4_state *state,
1685 __must_hold(&state->owner->so_lock)
1686 __must_hold(&state->seqlock)
1694 if (nfs_stateid_is_sequential(state, stateid))
1700 if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client))
1703 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags);
1704 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE);
1706 * Ensure we process the state changes in the same order
1710 write_sequnlock(&state->seqlock);
1711 spin_unlock(&state->owner->so_lock);
1713 trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0);
1722 finish_wait(&state->waitq, &wait);
1724 spin_lock(&state->owner->so_lock);
1725 write_seqlock(&state->seqlock);
1728 if (test_bit(NFS_OPEN_STATE, &state->flags) &&
1729 !nfs4_stateid_match_other(stateid, &state->open_stateid)) {
1730 nfs4_stateid_copy(freeme, &state->open_stateid);
1731 nfs_test_and_clear_all_open_stateid(state);
1734 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
1735 nfs4_stateid_copy(&state->stateid, stateid);
1736 nfs4_stateid_copy(&state->open_stateid, stateid);
1737 trace_nfs4_open_stateid_update(state->inode, stateid, status);
1738 nfs_state_log_update_open_stateid(state);
1741 static void nfs_state_set_open_stateid(struct nfs4_state *state,
1750 write_seqlock(&state->seqlock);
1751 nfs_set_open_stateid_locked(state, open_stateid, freeme);
1754 set_bit(NFS_O_RDONLY_STATE, &state->flags);
1757 set_bit(NFS_O_WRONLY_STATE, &state->flags);
1760 set_bit(NFS_O_RDWR_STATE, &state->flags);
1762 set_bit(NFS_OPEN_STATE, &state->flags);
1763 write_sequnlock(&state->seqlock);
1766 static void nfs_state_clear_open_state_flags(struct nfs4_state *state)
1768 clear_bit(NFS_O_RDWR_STATE, &state->flags);
1769 clear_bit(NFS_O_WRONLY_STATE, &state->flags);
1770 clear_bit(NFS_O_RDONLY_STATE, &state->flags);
1771 clear_bit(NFS_OPEN_STATE, &state->flags);
1774 static void nfs_state_set_delegation(struct nfs4_state *state,
1782 write_seqlock(&state->seqlock);
1783 nfs4_stateid_copy(&state->stateid, deleg_stateid);
1784 set_bit(NFS_DELEGATED_STATE, &state->flags);
1785 write_sequnlock(&state->seqlock);
1788 static void nfs_state_clear_delegation(struct nfs4_state *state)
1790 write_seqlock(&state->seqlock);
1791 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
1792 clear_bit(NFS_DELEGATED_STATE, &state->flags);
1793 write_sequnlock(&state->seqlock);
1796 int update_open_stateid(struct nfs4_state *state,
1801 struct nfs_server *server = NFS_SERVER(state->inode);
1803 struct nfs_inode *nfsi = NFS_I(state->inode);
1811 spin_lock(&state->owner->so_lock);
1813 nfs_state_set_open_stateid(state, open_stateid, fmode, &freeme);
1817 deleg_cur = nfs4_get_valid_delegation(state->inode);
1833 nfs_state_set_delegation(state, &deleg_cur->stateid, fmode);
1839 update_open_stateflags(state, fmode);
1840 spin_unlock(&state->owner->so_lock);
1843 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags))
1847 state->owner->so_cred);
1855 struct nfs4_state *state = lsp->ls_state;
1858 spin_lock(&state->state_lock);
1866 spin_unlock(&state->state_lock);
1887 struct nfs4_state *state = opendata->state;
1896 spin_lock(&state->owner->so_lock);
1897 if (can_open_cached(state, fmode, open_mode, claim)) {
1898 update_open_stateflags(state, fmode);
1899 spin_unlock(&state->owner->so_lock);
1902 spin_unlock(&state->owner->so_lock);
1904 delegation = nfs4_get_valid_delegation(state->inode);
1914 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode);
1921 if (update_open_stateid(state, NULL, &stateid, fmode))
1927 refcount_inc(&state->count);
1928 return state;
1932 nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state)
1934 struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client;
1939 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
1955 nfs_inode_set_delegation(state->inode,
1961 nfs_inode_reclaim_delegation(state->inode,
1968 nfs_async_inode_return_delegation(state->inode,
1979 struct inode *inode = data->state->inode;
1980 struct nfs4_state *state = data->state;
1994 nfs4_opendata_check_deleg(data, state);
1996 if (!update_open_stateid(state, &data->o_res.stateid,
1999 refcount_inc(&state->count);
2001 return state;
2029 struct nfs4_state *state;
2035 if (data->state != NULL && data->state->inode == inode) {
2036 state = data->state;
2037 refcount_inc(&state->count);
2039 state = nfs4_get_open_state(inode, data->owner);
2041 if (state == NULL)
2042 state = ERR_PTR(-ENOMEM);
2043 return state;
2049 struct nfs4_state *state;
2052 state = nfs4_try_open_cached(data);
2053 trace_nfs4_cached_open(data->state);
2057 state = nfs4_opendata_find_nfs4_state(data);
2058 if (IS_ERR(state))
2062 nfs4_opendata_check_deleg(data, state);
2063 if (!update_open_stateid(state, &data->o_res.stateid,
2065 nfs4_put_open_state(state);
2066 state = ERR_PTR(-EAGAIN);
2070 return state;
2087 nfs4_state_find_open_context_mode(struct nfs4_state *state, fmode_t mode)
2089 struct nfs_inode *nfsi = NFS_I(state->inode);
2094 if (ctx->state != state)
2108 nfs4_state_find_open_context(struct nfs4_state *state)
2112 ctx = nfs4_state_find_open_context_mode(state, FMODE_READ|FMODE_WRITE);
2115 ctx = nfs4_state_find_open_context_mode(state, FMODE_WRITE);
2118 return nfs4_state_find_open_context_mode(state, FMODE_READ);
2122 struct nfs4_state *state, enum open_claim_type4 claim)
2126 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0,
2130 opendata->state = state;
2131 refcount_inc(&state->count);
2143 if (!nfs4_mode_match_open_stateid(opendata->state, fmode))
2157 if (newstate != opendata->state)
2163 static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state)
2167 /* memory barrier prior to reading state->n_* */
2182 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 &&
2183 !nfs4_stateid_match(&state->stateid, &state->open_stateid)) {
2184 write_seqlock(&state->seqlock);
2185 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
2186 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2187 write_sequnlock(&state->seqlock);
2194 * reclaim state on the server after a reboot.
2196 static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state)
2203 opendata = nfs4_open_recoverdata_alloc(ctx, state,
2208 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
2213 status = nfs4_open_recover(opendata, state);
2218 static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state)
2220 struct nfs_server *server = NFS_SERVER(state->inode);
2224 err = _nfs4_do_open_reclaim(ctx, state);
2235 static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state)
2240 ctx = nfs4_state_find_open_context(state);
2243 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2244 nfs_state_clear_open_state_flags(state);
2245 ret = nfs4_do_open_reclaim(ctx, state);
2250 static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, struct file_lock *fl, int err)
2285 nfs_inode_find_state_and_recover(state->inode,
2287 nfs4_schedule_stateid_recovery(server, state);
2306 struct nfs4_state *state, const nfs4_stateid *stateid)
2308 struct nfs_server *server = NFS_SERVER(state->inode);
2312 opendata = nfs4_open_recoverdata_alloc(ctx, state,
2317 if (!test_bit(NFS_O_RDWR_STATE, &state->flags)) {
2322 if (!test_bit(NFS_O_WRONLY_STATE, &state->flags)) {
2327 if (!test_bit(NFS_O_RDONLY_STATE, &state->flags)) {
2332 nfs_state_clear_delegation(state);
2335 return nfs4_handle_delegation_recall_error(server, state, stateid, NULL, err);
2364 struct nfs4_state *state = NULL;
2372 state = nfs4_opendata_to_nfs4_state(data);
2373 if (!IS_ERR(state))
2374 nfs4_close_state(state, data->o_arg.fmode);
2440 if (data->state != NULL) {
2443 if (can_open_cached(data->state, data->o_arg.fmode,
2447 delegation = nfs4_get_valid_delegation(data->state->inode);
2487 trace_nfs4_cached_open(data->state);
2529 struct nfs4_state *state = NULL;
2540 state = nfs4_opendata_to_nfs4_state(data);
2541 if (!IS_ERR(state))
2542 nfs4_close_state(state, data->o_arg.fmode);
2635 struct nfs4_state *state, fmode_t fmode)
2648 if (S_ISDIR(state->inode->i_mode))
2656 nfs_access_add_cache(state->inode, &cache, cred);
2720 * reclaim state on the server after a network partition.
2723 static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state)
2728 opendata = nfs4_open_recoverdata_alloc(ctx, state, NFS4_OPEN_CLAIM_FH);
2737 ret = nfs4_open_recover(opendata, state);
2744 static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state)
2746 struct nfs_server *server = NFS_SERVER(state->inode);
2751 err = _nfs4_open_expired(ctx, state);
2768 static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
2773 ctx = nfs4_state_find_open_context(state);
2776 ret = nfs4_do_open_expired(ctx, state);
2781 static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
2784 nfs_remove_bad_delegation(state->inode, stateid);
2785 nfs_state_clear_delegation(state);
2788 static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
2790 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
2791 nfs_finish_clear_delegation_stateid(state, NULL);
2794 static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
2797 nfs40_clear_delegation_stateid(state);
2798 nfs_state_clear_open_state_flags(state);
2799 return nfs4_open_expired(sp, state);
2836 /* Ack the revoked state to the server */
2841 static int nfs41_check_delegation_stateid(struct nfs4_state *state)
2843 struct nfs_server *server = NFS_SERVER(state->inode);
2851 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
2854 nfs_state_clear_delegation(state);
2873 trace_nfs4_test_delegation_stateid(state, NULL, status);
2875 nfs_finish_clear_delegation_stateid(state, &stateid);
2883 static void nfs41_delegation_recover_stateid(struct nfs4_state *state)
2887 if (test_bit(NFS_DELEGATED_STATE, &state->flags) &&
2888 nfs4_copy_delegation_stateid(state->inode, state->state,
2890 nfs4_stateid_match_other(&state->stateid, &tmp))
2891 nfs_state_set_delegation(state, &tmp, state->state);
2893 nfs_state_clear_delegation(state);
2899 * @state: NFSv4 state for an inode
2904 static int nfs41_check_expired_locks(struct nfs4_state *state)
2908 struct nfs_server *server = NFS_SERVER(state->inode);
2910 if (!test_bit(LK_STATE_IN_USE, &state->flags))
2913 spin_lock(&state->state_lock);
2914 list_for_each_entry(lsp, &state->lock_states, ls_locks) {
2919 spin_unlock(&state->state_lock);
2927 trace_nfs4_test_lock_stateid(state, lsp, status);
2939 spin_lock(&state->state_lock);
2942 spin_unlock(&state->state_lock);
2951 * @state: NFSv4 state for an inode
2956 static int nfs41_check_open_stateid(struct nfs4_state *state)
2958 struct nfs_server *server = NFS_SERVER(state->inode);
2959 nfs4_stateid *stateid = &state->open_stateid;
2960 const struct cred *cred = state->owner->so_cred;
2963 if (test_bit(NFS_OPEN_STATE, &state->flags) == 0)
2966 trace_nfs4_test_open_stateid(state, NULL, status);
2968 nfs_state_clear_open_state_flags(state);
2972 if (nfs_open_stateid_recover_openmode(state))
2977 static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
2981 status = nfs41_check_delegation_stateid(state);
2984 nfs41_delegation_recover_stateid(state);
2986 status = nfs41_check_expired_locks(state);
2989 status = nfs41_check_open_stateid(state);
2991 status = nfs4_open_expired(sp, state);
3043 struct nfs4_state *state;
3057 state = _nfs4_opendata_to_nfs4_state(opendata);
3058 ret = PTR_ERR(state);
3059 if (IS_ERR(state))
3061 ctx->state = state;
3063 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
3065 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags);
3067 set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
3073 alias = d_exact_alias(dentry, state->inode);
3075 alias = d_splice_alias(igrab(state->inode), dentry);
3097 pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
3099 ret = nfs4_opendata_access(sp->so_cred, opendata, state, acc_mode);
3103 if (d_inode(dentry) == state->inode) {
3106 nfs4_schedule_stateid_recovery(server, state);
3130 struct nfs4_state *state = NULL;
3171 opendata->state = nfs4_get_open_state(d_inode(dentry), sp);
3176 state = ctx->state;
3190 status = nfs4_do_setattr(state->inode, cred,
3194 nfs_setattr_update_inode(state->inode, sattr,
3196 nfs_setsecurity(state->inode, opendata->o_res.f_attr);
3245 res = ctx->state;
3250 * book-keeping w.r.t. state-changing operations
3269 * state before it received the OPEN_CONFIRM.
3324 } else if (ctx != NULL && ctx->state) {
3326 if (!nfs4_valid_open_stateid(ctx->state))
3331 status = nfs4_select_rw_stateid(ctx->state, FMODE_WRITE, l_ctx,
3360 struct nfs4_state *state = ctx ? ctx->state : NULL;
3373 .state = state,
3399 if (state && !(state->state & FMODE_WRITE)) {
3425 struct nfs4_state *state)
3432 if (!nfs4_valid_open_stateid(state))
3434 seq = read_seqbegin(&state->seqlock);
3435 if (!nfs4_state_match_open_stateid_other(state, dst)) {
3436 nfs4_stateid_copy(dst, &state->open_stateid);
3437 if (read_seqretry(&state->seqlock, seq))
3441 seqid_open = state->open_stateid.seqid;
3442 if (read_seqretry(&state->seqlock, seq))
3457 struct nfs4_state *state)
3467 if (!nfs4_valid_open_stateid(state))
3469 seq = read_seqbegin(&state->seqlock);
3470 if (!nfs4_state_match_open_stateid_other(state, dst)) {
3471 if (read_seqretry(&state->seqlock, seq))
3476 write_seqlock(&state->seqlock);
3477 seqid_open = state->open_stateid.seqid;
3481 /* Did another OPEN bump the state's seqid? try again: */
3484 write_sequnlock(&state->seqlock);
3490 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags);
3491 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE);
3492 write_sequnlock(&state->seqlock);
3493 trace_nfs4_close_stateid_update_wait(state->inode, dst, 0);
3501 finish_wait(&state->waitq, &wait);
3519 struct nfs4_state *state;
3536 struct nfs4_state_owner *sp = calldata->state->owner;
3537 struct super_block *sb = calldata->state->inode->i_sb;
3542 nfs4_put_open_state(calldata->state);
3552 struct nfs4_state *state = calldata->state;
3556 .state = state,
3563 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status);
3589 state))
3609 nfs_clear_open_stateid(state, &calldata->arg.stateid,
3626 struct nfs4_state *state = calldata->state;
3637 spin_lock(&state->owner->so_lock);
3638 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
3639 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
3640 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
3643 if (state->n_rdwr == 0) {
3644 if (state->n_rdonly == 0)
3648 if (state->n_wronly == 0)
3657 nfs4_sync_open_stateid(&calldata->arg.stateid, state);
3658 if (!nfs4_valid_open_stateid(state))
3660 spin_unlock(&state->owner->so_lock);
3725 * share state even when we are done with one of the three share
3730 int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
3732 struct nfs_server *server = NFS_SERVER(state->inode);
3735 struct nfs4_state_owner *sp = state->owner;
3739 .rpc_cred = state->owner->so_cred,
3750 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE))
3760 calldata->inode = state->inode;
3761 calldata->state = state;
3762 calldata->arg.fh = NFS_FH(state->inode);
3763 if (!nfs4_copy_open_stateid(&calldata->arg.stateid, state))
3767 calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask);
3777 calldata->lr.roc = pnfs_roc(state->inode,
3799 nfs4_put_open_state(state);
3808 struct nfs4_state *state;
3814 state = nfs4_do_open(dir, ctx, open_flags, attr, label, opened);
3818 if (IS_ERR(state))
3819 return ERR_CAST(state);
3820 return state->inode;
3825 if (ctx->state == NULL)
3828 nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx));
3830 nfs4_close_state(ctx->state, _nfs4_ctx_to_openmode(ctx));
4699 struct nfs4_state *state;
4710 state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, NULL);
4711 if (IS_ERR(state)) {
4712 status = PTR_ERR(state);
5361 return nfs4_select_rw_stateid(ctx->state, fmode, l_ctx, stateid, NULL);
5401 .state = hdr->args.context->state,
5517 .state = hdr->args.context->state,
5740 /* Unless we're shutting down, schedule state recovery! */
6420 * @clp: state data structure
6495 * @clp: state data structure
6746 static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request)
6748 struct inode *inode = state->inode;
6762 .rpc_cred = state->owner->so_cred,
6768 status = nfs4_set_lock_state(state, request);
6788 static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request)
6796 err = _nfs4_proc_getlk(state, cmd, request);
6797 trace_nfs4_get_lock(request, state, cmd, err);
6798 err = nfs4_handle_exception(NFS_SERVER(state->inode), err,
6811 struct nfs4_state *state = lsp->ls_state;
6814 spin_lock(&state->state_lock);
6823 spin_unlock(&state->state_lock);
6830 struct nfs4_state *state = lsp->ls_state;
6833 spin_lock(&state->state_lock);
6836 spin_unlock(&state->state_lock);
6857 struct nfs4_state *state = lsp->ls_state;
6858 struct inode *inode = state->inode;
6874 spin_lock(&state->state_lock);
6876 spin_unlock(&state->state_lock);
7012 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
7014 struct inode *inode = state->inode;
7015 struct nfs4_state_owner *sp = state->owner;
7024 status = nfs4_set_lock_state(state, request);
7058 trace_nfs4_unlock(request, state, F_SETLK, status);
7116 struct nfs4_state *state = data->lsp->ls_state;
7126 &state->open_stateid);
7134 if (!nfs4_valid_open_stateid(state)) {
7249 static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_type)
7255 .rpc_cred = state->owner->so_cred,
7258 .rpc_client = NFS_CLIENT(state->inode),
7266 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE))
7296 trace_nfs4_set_lock(fl, state, &data->res.stateid, cmd, ret);
7302 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
7304 struct nfs_server *server = NFS_SERVER(state->inode);
7306 .inode = state->inode,
7312 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
7314 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM);
7322 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
7324 struct nfs_server *server = NFS_SERVER(state->inode);
7326 .inode = state->inode,
7330 err = nfs4_set_lock_state(state, request);
7338 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
7340 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED);
7355 static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request)
7360 status = nfs4_set_lock_state(state, request);
7367 return nfs4_lock_expired(state, request);
7371 static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
7373 struct nfs_inode *nfsi = NFS_I(state->inode);
7374 struct nfs4_state_owner *sp = state->owner;
7379 status = locks_lock_inode_wait(state->inode, request);
7384 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) {
7388 status = locks_lock_inode_wait(state->inode, request);
7395 status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW);
7401 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
7404 .state = state,
7405 .inode = state->inode,
7411 err = _nfs4_proc_setlk(state, cmd, request);
7414 err = nfs4_handle_exception(NFS_SERVER(state->inode),
7424 nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd,
7431 status = nfs4_proc_setlk(state, cmd, request);
7475 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
7478 struct nfs_server *server = NFS_SERVER(state->inode);
7482 .inode = state->inode,
7490 if (!test_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags))
7491 return nfs4_retry_setlk_simple(state, cmd, request);
7498 status = nfs4_proc_setlk(state, cmd, request);
7513 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
7515 return nfs4_retry_setlk_simple(state, cmd, request);
7523 struct nfs4_state *state;
7526 /* verify open state */
7528 state = ctx->state;
7531 if (state != NULL)
7532 return nfs4_proc_getlk(state, F_GETLK, request);
7540 if (state != NULL)
7541 return nfs4_proc_unlck(state, cmd, request);
7545 if (state == NULL)
7549 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
7566 status = nfs4_set_lock_state(state, request);
7570 return nfs4_retry_setlk(state, cmd, request);
7610 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid)
7612 struct nfs_server *server = NFS_SERVER(state->inode);
7615 err = nfs4_set_lock_state(state, fl);
7619 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW);
7624 return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err);
8329 * If 'use_integrity' is true and the state managment nfs_client
8598 * Select the state protection mode for client `clp' given the server results
8618 /* Print state protect result */
8637 * Minimal mode - state operations are allowed to use machine
9680 exception->state = lgp->args.ctx->state;
9686 * Mark the bad layout state as invalid, then retry
10061 * Use the state managment nfs_client cl_rpcclient, which uses krb5i (if
10273 * @stateid: state ID to test
10278 * failed or the state ID is not currently valid.
10342 * @stateid: state ID to release
10621 /* The state manager thread must always be running.
10631 /* The state manager thread will now exit once it is