• Home
  • Raw
  • Download

Lines Matching refs:state

478 	struct nfs4_state *state = exception->state;  in nfs4_do_handle_exception()  local
488 if (stateid == NULL && state != NULL) in nfs4_do_handle_exception()
489 stateid = nfs4_recoverable_stateid(&state->stateid); in nfs4_do_handle_exception()
523 if (state == NULL) in nfs4_do_handle_exception()
525 ret = nfs4_schedule_stateid_recovery(server, state); in nfs4_do_handle_exception()
662 struct nfs4_state *state, long *timeout) in nfs4_async_handle_error() argument
665 .state = state, in nfs4_async_handle_error()
1454 if (p->state != NULL) in nfs4_opendata_free()
1455 nfs4_put_open_state(p->state); in nfs4_opendata_free()
1475 static bool nfs4_mode_match_open_stateid(struct nfs4_state *state, in nfs4_mode_match_open_stateid() argument
1480 return state->n_rdwr != 0; in nfs4_mode_match_open_stateid()
1482 return state->n_wronly != 0; in nfs4_mode_match_open_stateid()
1484 return state->n_rdonly != 0; in nfs4_mode_match_open_stateid()
1490 static int can_open_cached(struct nfs4_state *state, fmode_t mode, in can_open_cached() argument
1506 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 in can_open_cached()
1507 && state->n_rdonly != 0; in can_open_cached()
1510 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 in can_open_cached()
1511 && state->n_wronly != 0; in can_open_cached()
1514 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 in can_open_cached()
1515 && state->n_rdwr != 0; in can_open_cached()
1543 static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode) in update_open_stateflags() argument
1547 state->n_wronly++; in update_open_stateflags()
1550 state->n_rdonly++; in update_open_stateflags()
1553 state->n_rdwr++; in update_open_stateflags()
1555 nfs4_state_set_mode_locked(state, state->state | fmode); in update_open_stateflags()
1559 static bool nfs_open_stateid_recover_openmode(struct nfs4_state *state) in nfs_open_stateid_recover_openmode() argument
1561 if (state->n_rdonly && !test_bit(NFS_O_RDONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1563 if (state->n_wronly && !test_bit(NFS_O_WRONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1565 if (state->n_rdwr && !test_bit(NFS_O_RDWR_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1571 static void nfs_state_log_update_open_stateid(struct nfs4_state *state) in nfs_state_log_update_open_stateid() argument
1573 if (test_and_clear_bit(NFS_STATE_CHANGE_WAIT, &state->flags)) in nfs_state_log_update_open_stateid()
1574 wake_up_all(&state->waitq); in nfs_state_log_update_open_stateid()
1577 static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) in nfs_test_and_clear_all_open_stateid() argument
1579 struct nfs_client *clp = state->owner->so_server->nfs_client; in nfs_test_and_clear_all_open_stateid()
1582 if (test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags) && state->n_rdonly) in nfs_test_and_clear_all_open_stateid()
1584 if (test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags) && state->n_wronly) in nfs_test_and_clear_all_open_stateid()
1586 if (test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags) && state->n_rdwr) in nfs_test_and_clear_all_open_stateid()
1589 nfs4_state_mark_reclaim_nograce(clp, state); in nfs_test_and_clear_all_open_stateid()
1602 static bool nfs_stateid_is_sequential(struct nfs4_state *state, in nfs_stateid_is_sequential() argument
1605 if (test_bit(NFS_OPEN_STATE, &state->flags)) { in nfs_stateid_is_sequential()
1607 if (nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_stateid_is_sequential()
1608 if (nfs4_stateid_is_next(&state->open_stateid, stateid)) in nfs_stateid_is_sequential()
1620 static void nfs_resync_open_stateid_locked(struct nfs4_state *state) in nfs_resync_open_stateid_locked() argument
1622 if (!(state->n_wronly || state->n_rdonly || state->n_rdwr)) in nfs_resync_open_stateid_locked()
1624 if (state->n_wronly) in nfs_resync_open_stateid_locked()
1625 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1626 if (state->n_rdonly) in nfs_resync_open_stateid_locked()
1627 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1628 if (state->n_rdwr) in nfs_resync_open_stateid_locked()
1629 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1630 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1633 static void nfs_clear_open_stateid_locked(struct nfs4_state *state, in nfs_clear_open_stateid_locked() argument
1636 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1639 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1642 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1645 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1646 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1647 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1652 if (nfs4_stateid_match_other(stateid, &state->open_stateid) && in nfs_clear_open_stateid_locked()
1653 !nfs4_stateid_is_newer(stateid, &state->open_stateid)) { in nfs_clear_open_stateid_locked()
1654 nfs_resync_open_stateid_locked(state); in nfs_clear_open_stateid_locked()
1657 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_clear_open_stateid_locked()
1658 nfs4_stateid_copy(&state->stateid, stateid); in nfs_clear_open_stateid_locked()
1659 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_clear_open_stateid_locked()
1660 trace_nfs4_open_stateid_update(state->inode, stateid, 0); in nfs_clear_open_stateid_locked()
1662 nfs_state_log_update_open_stateid(state); in nfs_clear_open_stateid_locked()
1665 static void nfs_clear_open_stateid(struct nfs4_state *state, in nfs_clear_open_stateid() argument
1669 write_seqlock(&state->seqlock); in nfs_clear_open_stateid()
1671 if (nfs4_state_match_open_stateid_other(state, arg_stateid)) in nfs_clear_open_stateid()
1672 nfs_clear_open_stateid_locked(state, stateid, fmode); in nfs_clear_open_stateid()
1673 write_sequnlock(&state->seqlock); in nfs_clear_open_stateid()
1674 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in nfs_clear_open_stateid()
1675 nfs4_schedule_state_manager(state->owner->so_server->nfs_client); in nfs_clear_open_stateid()
1678 static void nfs_set_open_stateid_locked(struct nfs4_state *state, in nfs_set_open_stateid_locked() argument
1680 __must_hold(&state->owner->so_lock) in nfs_set_open_stateid_locked()
1681 __must_hold(&state->seqlock) in nfs_set_open_stateid_locked()
1689 if (nfs_stateid_is_sequential(state, stateid)) in nfs_set_open_stateid_locked()
1695 if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client)) in nfs_set_open_stateid_locked()
1698 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs_set_open_stateid_locked()
1699 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs_set_open_stateid_locked()
1705 write_sequnlock(&state->seqlock); in nfs_set_open_stateid_locked()
1706 spin_unlock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1708 trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); in nfs_set_open_stateid_locked()
1717 finish_wait(&state->waitq, &wait); in nfs_set_open_stateid_locked()
1719 spin_lock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1720 write_seqlock(&state->seqlock); in nfs_set_open_stateid_locked()
1723 if (test_bit(NFS_OPEN_STATE, &state->flags) && in nfs_set_open_stateid_locked()
1724 !nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_set_open_stateid_locked()
1725 nfs4_stateid_copy(freeme, &state->open_stateid); in nfs_set_open_stateid_locked()
1726 nfs_test_and_clear_all_open_stateid(state); in nfs_set_open_stateid_locked()
1729 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_set_open_stateid_locked()
1730 nfs4_stateid_copy(&state->stateid, stateid); in nfs_set_open_stateid_locked()
1731 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_set_open_stateid_locked()
1732 trace_nfs4_open_stateid_update(state->inode, stateid, status); in nfs_set_open_stateid_locked()
1733 nfs_state_log_update_open_stateid(state); in nfs_set_open_stateid_locked()
1736 static void nfs_state_set_open_stateid(struct nfs4_state *state, in nfs_state_set_open_stateid() argument
1745 write_seqlock(&state->seqlock); in nfs_state_set_open_stateid()
1746 nfs_set_open_stateid_locked(state, open_stateid, freeme); in nfs_state_set_open_stateid()
1749 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1752 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1755 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_set_open_stateid()
1757 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_set_open_stateid()
1758 write_sequnlock(&state->seqlock); in nfs_state_set_open_stateid()
1761 static void nfs_state_clear_open_state_flags(struct nfs4_state *state) in nfs_state_clear_open_state_flags() argument
1763 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1764 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1765 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1766 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1769 static void nfs_state_set_delegation(struct nfs4_state *state, in nfs_state_set_delegation() argument
1777 write_seqlock(&state->seqlock); in nfs_state_set_delegation()
1778 nfs4_stateid_copy(&state->stateid, deleg_stateid); in nfs_state_set_delegation()
1779 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_set_delegation()
1780 write_sequnlock(&state->seqlock); in nfs_state_set_delegation()
1783 static void nfs_state_clear_delegation(struct nfs4_state *state) in nfs_state_clear_delegation() argument
1785 write_seqlock(&state->seqlock); in nfs_state_clear_delegation()
1786 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs_state_clear_delegation()
1787 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_clear_delegation()
1788 write_sequnlock(&state->seqlock); in nfs_state_clear_delegation()
1791 int update_open_stateid(struct nfs4_state *state, in update_open_stateid() argument
1796 struct nfs_server *server = NFS_SERVER(state->inode); in update_open_stateid()
1798 struct nfs_inode *nfsi = NFS_I(state->inode); in update_open_stateid()
1806 spin_lock(&state->owner->so_lock); in update_open_stateid()
1808 nfs_state_set_open_stateid(state, open_stateid, fmode, &freeme); in update_open_stateid()
1812 deleg_cur = nfs4_get_valid_delegation(state->inode); in update_open_stateid()
1828 nfs_state_set_delegation(state, &deleg_cur->stateid, fmode); in update_open_stateid()
1834 update_open_stateflags(state, fmode); in update_open_stateid()
1835 spin_unlock(&state->owner->so_lock); in update_open_stateid()
1838 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in update_open_stateid()
1842 state->owner->so_cred); in update_open_stateid()
1850 struct nfs4_state *state = lsp->ls_state; in nfs4_update_lock_stateid() local
1853 spin_lock(&state->state_lock); in nfs4_update_lock_stateid()
1861 spin_unlock(&state->state_lock); in nfs4_update_lock_stateid()
1882 struct nfs4_state *state = opendata->state; in nfs4_try_open_cached() local
1891 spin_lock(&state->owner->so_lock); in nfs4_try_open_cached()
1892 if (can_open_cached(state, fmode, open_mode, claim)) { in nfs4_try_open_cached()
1893 update_open_stateflags(state, fmode); in nfs4_try_open_cached()
1894 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1897 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1899 delegation = nfs4_get_valid_delegation(state->inode); in nfs4_try_open_cached()
1909 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); in nfs4_try_open_cached()
1916 if (update_open_stateid(state, NULL, &stateid, fmode)) in nfs4_try_open_cached()
1922 refcount_inc(&state->count); in nfs4_try_open_cached()
1923 return state; in nfs4_try_open_cached()
1927 nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) in nfs4_opendata_check_deleg() argument
1929 struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client; in nfs4_opendata_check_deleg()
1934 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs4_opendata_check_deleg()
1950 nfs_inode_set_delegation(state->inode, in nfs4_opendata_check_deleg()
1956 nfs_inode_reclaim_delegation(state->inode, in nfs4_opendata_check_deleg()
1963 nfs_async_inode_return_delegation(state->inode, in nfs4_opendata_check_deleg()
1974 struct inode *inode = data->state->inode; in _nfs4_opendata_reclaim_to_nfs4_state()
1975 struct nfs4_state *state = data->state; in _nfs4_opendata_reclaim_to_nfs4_state() local
1989 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_reclaim_to_nfs4_state()
1991 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_reclaim_to_nfs4_state()
1994 refcount_inc(&state->count); in _nfs4_opendata_reclaim_to_nfs4_state()
1996 return state; in _nfs4_opendata_reclaim_to_nfs4_state()
2024 struct nfs4_state *state; in nfs4_opendata_find_nfs4_state() local
2030 if (data->state != NULL && data->state->inode == inode) { in nfs4_opendata_find_nfs4_state()
2031 state = data->state; in nfs4_opendata_find_nfs4_state()
2032 refcount_inc(&state->count); in nfs4_opendata_find_nfs4_state()
2034 state = nfs4_get_open_state(inode, data->owner); in nfs4_opendata_find_nfs4_state()
2036 if (state == NULL) in nfs4_opendata_find_nfs4_state()
2037 state = ERR_PTR(-ENOMEM); in nfs4_opendata_find_nfs4_state()
2038 return state; in nfs4_opendata_find_nfs4_state()
2044 struct nfs4_state *state; in _nfs4_opendata_to_nfs4_state() local
2047 state = nfs4_try_open_cached(data); in _nfs4_opendata_to_nfs4_state()
2048 trace_nfs4_cached_open(data->state); in _nfs4_opendata_to_nfs4_state()
2052 state = nfs4_opendata_find_nfs4_state(data); in _nfs4_opendata_to_nfs4_state()
2053 if (IS_ERR(state)) in _nfs4_opendata_to_nfs4_state()
2057 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_to_nfs4_state()
2058 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_to_nfs4_state()
2060 nfs4_put_open_state(state); in _nfs4_opendata_to_nfs4_state()
2061 state = ERR_PTR(-EAGAIN); in _nfs4_opendata_to_nfs4_state()
2065 return state; in _nfs4_opendata_to_nfs4_state()
2082 nfs4_state_find_open_context_mode(struct nfs4_state *state, fmode_t mode) in nfs4_state_find_open_context_mode() argument
2084 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_state_find_open_context_mode()
2089 if (ctx->state != state) in nfs4_state_find_open_context_mode()
2103 nfs4_state_find_open_context(struct nfs4_state *state) in nfs4_state_find_open_context() argument
2107 ctx = nfs4_state_find_open_context_mode(state, FMODE_READ|FMODE_WRITE); in nfs4_state_find_open_context()
2110 ctx = nfs4_state_find_open_context_mode(state, FMODE_WRITE); in nfs4_state_find_open_context()
2113 return nfs4_state_find_open_context_mode(state, FMODE_READ); in nfs4_state_find_open_context()
2117 struct nfs4_state *state, enum open_claim_type4 claim) in nfs4_open_recoverdata_alloc() argument
2121 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, in nfs4_open_recoverdata_alloc()
2125 opendata->state = state; in nfs4_open_recoverdata_alloc()
2126 refcount_inc(&state->count); in nfs4_open_recoverdata_alloc()
2138 if (!nfs4_mode_match_open_stateid(opendata->state, fmode)) in nfs4_open_recover_helper()
2152 if (newstate != opendata->state) in nfs4_open_recover_helper()
2158 static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state) in nfs4_open_recover() argument
2177 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 && in nfs4_open_recover()
2178 !nfs4_stateid_match(&state->stateid, &state->open_stateid)) { in nfs4_open_recover()
2179 write_seqlock(&state->seqlock); in nfs4_open_recover()
2180 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs4_open_recover()
2181 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs4_open_recover()
2182 write_sequnlock(&state->seqlock); in nfs4_open_recover()
2191 static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_do_open_reclaim() argument
2198 opendata = nfs4_open_recoverdata_alloc(ctx, state, in _nfs4_do_open_reclaim()
2203 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in _nfs4_do_open_reclaim()
2208 status = nfs4_open_recover(opendata, state); in _nfs4_do_open_reclaim()
2213 static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_reclaim() argument
2215 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_reclaim()
2219 err = _nfs4_do_open_reclaim(ctx, state); in nfs4_do_open_reclaim()
2230 static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_reclaim() argument
2235 ctx = nfs4_state_find_open_context(state); in nfs4_open_reclaim()
2238 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_reclaim()
2239 nfs_state_clear_open_state_flags(state); in nfs4_open_reclaim()
2240 ret = nfs4_do_open_reclaim(ctx, state); in nfs4_open_reclaim()
2245 static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state,… in nfs4_handle_delegation_recall_error() argument
2279 nfs_inode_find_state_and_recover(state->inode, in nfs4_handle_delegation_recall_error()
2281 nfs4_schedule_stateid_recovery(server, state); in nfs4_handle_delegation_recall_error()
2300 struct nfs4_state *state, const nfs4_stateid *stateid) in nfs4_open_delegation_recall() argument
2302 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_open_delegation_recall()
2306 opendata = nfs4_open_recoverdata_alloc(ctx, state, in nfs4_open_delegation_recall()
2311 if (!test_bit(NFS_O_RDWR_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2316 if (!test_bit(NFS_O_WRONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2321 if (!test_bit(NFS_O_RDONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2326 nfs_state_clear_delegation(state); in nfs4_open_delegation_recall()
2329 return nfs4_handle_delegation_recall_error(server, state, stateid, NULL, err); in nfs4_open_delegation_recall()
2358 struct nfs4_state *state = NULL; in nfs4_open_confirm_release() local
2366 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_confirm_release()
2367 if (!IS_ERR(state)) in nfs4_open_confirm_release()
2368 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_confirm_release()
2434 if (data->state != NULL) { in nfs4_open_prepare()
2437 if (can_open_cached(data->state, data->o_arg.fmode, in nfs4_open_prepare()
2441 delegation = nfs4_get_valid_delegation(data->state->inode); in nfs4_open_prepare()
2477 trace_nfs4_cached_open(data->state); in nfs4_open_prepare()
2519 struct nfs4_state *state = NULL; in nfs4_open_release() local
2530 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_release()
2531 if (!IS_ERR(state)) in nfs4_open_release()
2532 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_release()
2622 struct nfs4_state *state, fmode_t fmode, in nfs4_opendata_access() argument
2640 if (S_ISDIR(state->inode->i_mode)) in nfs4_opendata_access()
2649 nfs_access_add_cache(state->inode, &cache); in nfs4_opendata_access()
2713 static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_open_expired() argument
2718 opendata = nfs4_open_recoverdata_alloc(ctx, state, NFS4_OPEN_CLAIM_FH); in _nfs4_open_expired()
2727 ret = nfs4_open_recover(opendata, state); in _nfs4_open_expired()
2734 static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_expired() argument
2736 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_expired()
2741 err = _nfs4_open_expired(ctx, state); in nfs4_do_open_expired()
2758 static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_expired() argument
2763 ctx = nfs4_state_find_open_context(state); in nfs4_open_expired()
2766 ret = nfs4_do_open_expired(ctx, state); in nfs4_open_expired()
2771 static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state, in nfs_finish_clear_delegation_stateid() argument
2774 nfs_remove_bad_delegation(state->inode, stateid); in nfs_finish_clear_delegation_stateid()
2775 nfs_state_clear_delegation(state); in nfs_finish_clear_delegation_stateid()
2778 static void nfs40_clear_delegation_stateid(struct nfs4_state *state) in nfs40_clear_delegation_stateid() argument
2780 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL) in nfs40_clear_delegation_stateid()
2781 nfs_finish_clear_delegation_stateid(state, NULL); in nfs40_clear_delegation_stateid()
2784 static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs40_open_expired() argument
2787 nfs40_clear_delegation_stateid(state); in nfs40_open_expired()
2788 nfs_state_clear_open_state_flags(state); in nfs40_open_expired()
2789 return nfs4_open_expired(sp, state); in nfs40_open_expired()
2831 static int nfs41_check_delegation_stateid(struct nfs4_state *state) in nfs41_check_delegation_stateid() argument
2833 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_delegation_stateid()
2841 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs41_check_delegation_stateid()
2844 nfs_state_clear_delegation(state); in nfs41_check_delegation_stateid()
2863 trace_nfs4_test_delegation_stateid(state, NULL, status); in nfs41_check_delegation_stateid()
2865 nfs_finish_clear_delegation_stateid(state, &stateid); in nfs41_check_delegation_stateid()
2873 static void nfs41_delegation_recover_stateid(struct nfs4_state *state) in nfs41_delegation_recover_stateid() argument
2877 if (test_bit(NFS_DELEGATED_STATE, &state->flags) && in nfs41_delegation_recover_stateid()
2878 nfs4_copy_delegation_stateid(state->inode, state->state, in nfs41_delegation_recover_stateid()
2880 nfs4_stateid_match_other(&state->stateid, &tmp)) in nfs41_delegation_recover_stateid()
2881 nfs_state_set_delegation(state, &tmp, state->state); in nfs41_delegation_recover_stateid()
2883 nfs_state_clear_delegation(state); in nfs41_delegation_recover_stateid()
2894 static int nfs41_check_expired_locks(struct nfs4_state *state) in nfs41_check_expired_locks() argument
2898 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_expired_locks()
2900 if (!test_bit(LK_STATE_IN_USE, &state->flags)) in nfs41_check_expired_locks()
2903 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
2904 list_for_each_entry(lsp, &state->lock_states, ls_locks) { in nfs41_check_expired_locks()
2909 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
2917 trace_nfs4_test_lock_stateid(state, lsp, status); in nfs41_check_expired_locks()
2929 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
2932 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
2946 static int nfs41_check_open_stateid(struct nfs4_state *state) in nfs41_check_open_stateid() argument
2948 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_open_stateid()
2949 nfs4_stateid *stateid = &state->open_stateid; in nfs41_check_open_stateid()
2950 const struct cred *cred = state->owner->so_cred; in nfs41_check_open_stateid()
2953 if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) in nfs41_check_open_stateid()
2956 trace_nfs4_test_open_stateid(state, NULL, status); in nfs41_check_open_stateid()
2958 nfs_state_clear_open_state_flags(state); in nfs41_check_open_stateid()
2962 if (nfs_open_stateid_recover_openmode(state)) in nfs41_check_open_stateid()
2967 static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs41_open_expired() argument
2971 status = nfs41_check_delegation_stateid(state); in nfs41_open_expired()
2974 nfs41_delegation_recover_stateid(state); in nfs41_open_expired()
2976 status = nfs41_check_expired_locks(state); in nfs41_open_expired()
2979 status = nfs41_check_open_stateid(state); in nfs41_open_expired()
2981 status = nfs4_open_expired(sp, state); in nfs41_open_expired()
3033 struct nfs4_state *state; in _nfs4_open_and_get_state() local
3047 state = _nfs4_opendata_to_nfs4_state(opendata); in _nfs4_open_and_get_state()
3048 ret = PTR_ERR(state); in _nfs4_open_and_get_state()
3049 if (IS_ERR(state)) in _nfs4_open_and_get_state()
3051 ctx->state = state; in _nfs4_open_and_get_state()
3053 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); in _nfs4_open_and_get_state()
3055 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags); in _nfs4_open_and_get_state()
3061 alias = d_exact_alias(dentry, state->inode); in _nfs4_open_and_get_state()
3063 alias = d_splice_alias(igrab(state->inode), dentry); in _nfs4_open_and_get_state()
3085 pnfs_parse_lgopen(state->inode, opendata->lgp, ctx); in _nfs4_open_and_get_state()
3087 ret = nfs4_opendata_access(sp->so_cred, opendata, state, in _nfs4_open_and_get_state()
3092 if (d_inode(dentry) == state->inode) { in _nfs4_open_and_get_state()
3095 nfs4_schedule_stateid_recovery(server, state); in _nfs4_open_and_get_state()
3119 struct nfs4_state *state = NULL; in _nfs4_do_open() local
3169 opendata->state = nfs4_get_open_state(d_inode(dentry), sp); in _nfs4_do_open()
3174 state = ctx->state; in _nfs4_do_open()
3188 status = nfs4_do_setattr(state->inode, cred, in _nfs4_do_open()
3192 nfs_setattr_update_inode(state->inode, sattr, in _nfs4_do_open()
3194 nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); in _nfs4_do_open()
3247 res = ctx->state; in nfs4_do_open()
3326 } else if (ctx != NULL && ctx->state) { in _nfs4_do_setattr()
3328 if (!nfs4_valid_open_stateid(ctx->state)) in _nfs4_do_setattr()
3333 status = nfs4_select_rw_stateid(ctx->state, FMODE_WRITE, l_ctx, in _nfs4_do_setattr()
3363 struct nfs4_state *state = ctx ? ctx->state : NULL; in nfs4_do_setattr() local
3377 .state = state, in nfs4_do_setattr()
3398 if (state && !(state->state & FMODE_WRITE)) { in nfs4_do_setattr()
3424 struct nfs4_state *state) in nfs4_sync_open_stateid() argument
3431 if (!nfs4_valid_open_stateid(state)) in nfs4_sync_open_stateid()
3433 seq = read_seqbegin(&state->seqlock); in nfs4_sync_open_stateid()
3434 if (!nfs4_state_match_open_stateid_other(state, dst)) { in nfs4_sync_open_stateid()
3435 nfs4_stateid_copy(dst, &state->open_stateid); in nfs4_sync_open_stateid()
3436 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3440 seqid_open = state->open_stateid.seqid; in nfs4_sync_open_stateid()
3441 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3456 struct nfs4_state *state) in nfs4_refresh_open_old_stateid() argument
3466 if (!nfs4_valid_open_stateid(state)) in nfs4_refresh_open_old_stateid()
3468 seq = read_seqbegin(&state->seqlock); in nfs4_refresh_open_old_stateid()
3469 if (!nfs4_state_match_open_stateid_other(state, dst)) { in nfs4_refresh_open_old_stateid()
3470 if (read_seqretry(&state->seqlock, seq)) in nfs4_refresh_open_old_stateid()
3475 write_seqlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3476 seqid_open = state->open_stateid.seqid; in nfs4_refresh_open_old_stateid()
3483 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3489 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs4_refresh_open_old_stateid()
3490 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs4_refresh_open_old_stateid()
3491 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3492 trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); in nfs4_refresh_open_old_stateid()
3500 finish_wait(&state->waitq, &wait); in nfs4_refresh_open_old_stateid()
3518 struct nfs4_state *state; member
3535 struct nfs4_state_owner *sp = calldata->state->owner; in nfs4_free_closedata()
3536 struct super_block *sb = calldata->state->inode->i_sb; in nfs4_free_closedata()
3541 nfs4_put_open_state(calldata->state); in nfs4_free_closedata()
3551 struct nfs4_state *state = calldata->state; in nfs4_close_done() local
3555 .state = state, in nfs4_close_done()
3563 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); in nfs4_close_done()
3589 state)) in nfs4_close_done()
3609 nfs_clear_open_stateid(state, &calldata->arg.stateid, in nfs4_close_done()
3626 struct nfs4_state *state = calldata->state; in nfs4_close_prepare() local
3638 spin_lock(&state->owner->so_lock); in nfs4_close_prepare()
3639 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
3640 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_close_prepare()
3641 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_close_prepare()
3644 if (state->n_rdwr == 0) { in nfs4_close_prepare()
3645 if (state->n_rdonly == 0) in nfs4_close_prepare()
3649 if (state->n_wronly == 0) in nfs4_close_prepare()
3658 nfs4_sync_open_stateid(&calldata->arg.stateid, state); in nfs4_close_prepare()
3659 if (!nfs4_valid_open_stateid(state)) in nfs4_close_prepare()
3661 spin_unlock(&state->owner->so_lock); in nfs4_close_prepare()
3732 int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) in nfs4_do_close() argument
3734 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_close()
3737 struct nfs4_state_owner *sp = state->owner; in nfs4_do_close()
3741 .rpc_cred = state->owner->so_cred, in nfs4_do_close()
3759 calldata->inode = state->inode; in nfs4_do_close()
3760 calldata->state = state; in nfs4_do_close()
3761 calldata->arg.fh = NFS_FH(state->inode); in nfs4_do_close()
3762 if (!nfs4_copy_open_stateid(&calldata->arg.stateid, state)) in nfs4_do_close()
3766 calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask); in nfs4_do_close()
3776 calldata->lr.roc = pnfs_roc(state->inode, in nfs4_do_close()
3798 nfs4_put_open_state(state); in nfs4_do_close()
3807 struct nfs4_state *state; in nfs4_atomic_open() local
3813 state = nfs4_do_open(dir, ctx, open_flags, attr, label, opened); in nfs4_atomic_open()
3817 if (IS_ERR(state)) in nfs4_atomic_open()
3818 return ERR_CAST(state); in nfs4_atomic_open()
3819 return state->inode; in nfs4_atomic_open()
3824 if (ctx->state == NULL) in nfs4_close_context()
3827 nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
3829 nfs4_close_state(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
4574 struct nfs4_state *state; in nfs4_proc_create() local
4585 state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, NULL); in nfs4_proc_create()
4586 if (IS_ERR(state)) { in nfs4_proc_create()
4587 status = PTR_ERR(state); in nfs4_proc_create()
5246 return nfs4_select_rw_stateid(ctx->state, fmode, l_ctx, stateid, NULL); in nfs4_set_rw_stateid()
5286 .state = hdr->args.context->state, in nfs4_read_done_cb()
5399 .state = hdr->args.context->state, in nfs4_write_done_cb()
6620 static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_getlk() argument
6622 struct inode *inode = state->inode; in _nfs4_proc_getlk()
6636 .rpc_cred = state->owner->so_cred, in _nfs4_proc_getlk()
6642 status = nfs4_set_lock_state(state, request); in _nfs4_proc_getlk()
6662 static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_getlk() argument
6670 err = _nfs4_proc_getlk(state, cmd, request); in nfs4_proc_getlk()
6671 trace_nfs4_get_lock(request, state, cmd, err); in nfs4_proc_getlk()
6672 err = nfs4_handle_exception(NFS_SERVER(state->inode), err, in nfs4_proc_getlk()
6685 struct nfs4_state *state = lsp->ls_state; in nfs4_refresh_lock_old_stateid() local
6688 spin_lock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
6697 spin_unlock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
6704 struct nfs4_state *state = lsp->ls_state; in nfs4_sync_lock_stateid() local
6707 spin_lock(&state->state_lock); in nfs4_sync_lock_stateid()
6710 spin_unlock(&state->state_lock); in nfs4_sync_lock_stateid()
6731 struct nfs4_state *state = lsp->ls_state; in nfs4_alloc_unlockdata() local
6732 struct inode *inode = state->inode; in nfs4_alloc_unlockdata()
6748 spin_lock(&state->state_lock); in nfs4_alloc_unlockdata()
6750 spin_unlock(&state->state_lock); in nfs4_alloc_unlockdata()
6883 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_unlck() argument
6885 struct inode *inode = state->inode; in nfs4_proc_unlck()
6886 struct nfs4_state_owner *sp = state->owner; in nfs4_proc_unlck()
6895 status = nfs4_set_lock_state(state, request); in nfs4_proc_unlck()
6928 trace_nfs4_unlock(request, state, F_SETLK, status); in nfs4_proc_unlck()
6986 struct nfs4_state *state = data->lsp->ls_state; in nfs4_lock_prepare() local
6997 &state->open_stateid); in nfs4_lock_prepare()
7005 if (!nfs4_valid_open_stateid(state)) { in nfs4_lock_prepare()
7126 static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_typ… in _nfs4_do_setlk() argument
7132 .rpc_cred = state->owner->so_cred, in _nfs4_do_setlk()
7135 .rpc_client = NFS_CLIENT(state->inode), in _nfs4_do_setlk()
7172 trace_nfs4_set_lock(fl, state, &data->res.stateid, cmd, ret); in _nfs4_do_setlk()
7178 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_reclaim() argument
7180 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_reclaim()
7182 .inode = state->inode, in nfs4_lock_reclaim()
7188 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_reclaim()
7190 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM); in nfs4_lock_reclaim()
7198 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_expired() argument
7200 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_expired()
7202 .inode = state->inode, in nfs4_lock_expired()
7206 err = nfs4_set_lock_state(state, request); in nfs4_lock_expired()
7214 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_expired()
7216 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED); in nfs4_lock_expired()
7231 static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs41_lock_expired() argument
7236 status = nfs4_set_lock_state(state, request); in nfs41_lock_expired()
7243 return nfs4_lock_expired(state, request); in nfs41_lock_expired()
7247 static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_setlk() argument
7249 struct nfs_inode *nfsi = NFS_I(state->inode); in _nfs4_proc_setlk()
7250 struct nfs4_state_owner *sp = state->owner; in _nfs4_proc_setlk()
7255 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7260 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { in _nfs4_proc_setlk()
7264 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7271 status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW); in _nfs4_proc_setlk()
7277 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_setlk() argument
7280 .state = state, in nfs4_proc_setlk()
7281 .inode = state->inode, in nfs4_proc_setlk()
7287 err = _nfs4_proc_setlk(state, cmd, request); in nfs4_proc_setlk()
7290 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_setlk()
7300 nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd, in nfs4_retry_setlk_simple() argument
7307 status = nfs4_proc_setlk(state, cmd, request); in nfs4_retry_setlk_simple()
7356 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_retry_setlk() argument
7360 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_retry_setlk()
7367 .inode = state->inode, in nfs4_retry_setlk()
7372 if (!test_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags)) in nfs4_retry_setlk()
7373 return nfs4_retry_setlk_simple(state, cmd, request); in nfs4_retry_setlk()
7381 status = nfs4_proc_setlk(state, cmd, request); in nfs4_retry_setlk()
7398 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_retry_setlk() argument
7400 return nfs4_retry_setlk_simple(state, cmd, request); in nfs4_retry_setlk()
7408 struct nfs4_state *state; in nfs4_proc_lock() local
7413 state = ctx->state; in nfs4_proc_lock()
7416 if (state != NULL) in nfs4_proc_lock()
7417 return nfs4_proc_getlk(state, F_GETLK, request); in nfs4_proc_lock()
7425 if (state != NULL) in nfs4_proc_lock()
7426 return nfs4_proc_unlck(state, cmd, request); in nfs4_proc_lock()
7430 if (state == NULL) in nfs4_proc_lock()
7434 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags)) in nfs4_proc_lock()
7451 status = nfs4_set_lock_state(state, request); in nfs4_proc_lock()
7455 return nfs4_retry_setlk(state, cmd, request); in nfs4_proc_lock()
7458 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid … in nfs4_lock_delegation_recall() argument
7460 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_delegation_recall()
7463 err = nfs4_set_lock_state(state, fl); in nfs4_lock_delegation_recall()
7467 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); in nfs4_lock_delegation_recall()
7472 return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err); in nfs4_lock_delegation_recall()
9467 exception->state = lgp->args.ctx->state; in nfs4_layoutget_handle_exception()