• Home
  • Raw
  • Download

Lines Matching refs:state

476 	struct nfs4_state *state = exception->state;  in nfs4_do_handle_exception()  local
486 if (stateid == NULL && state != NULL) in nfs4_do_handle_exception()
487 stateid = nfs4_recoverable_stateid(&state->stateid); in nfs4_do_handle_exception()
521 if (state == NULL) in nfs4_do_handle_exception()
523 ret = nfs4_schedule_stateid_recovery(server, state); in nfs4_do_handle_exception()
660 struct nfs4_state *state, long *timeout) in nfs4_async_handle_error() argument
663 .state = state, in nfs4_async_handle_error()
1473 if (p->state != NULL) in nfs4_opendata_free()
1474 nfs4_put_open_state(p->state); in nfs4_opendata_free()
1494 static bool nfs4_mode_match_open_stateid(struct nfs4_state *state, in nfs4_mode_match_open_stateid() argument
1499 return state->n_rdwr != 0; in nfs4_mode_match_open_stateid()
1501 return state->n_wronly != 0; in nfs4_mode_match_open_stateid()
1503 return state->n_rdonly != 0; in nfs4_mode_match_open_stateid()
1509 static int can_open_cached(struct nfs4_state *state, fmode_t mode, in can_open_cached() argument
1525 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 in can_open_cached()
1526 && state->n_rdonly != 0; in can_open_cached()
1529 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 in can_open_cached()
1530 && state->n_wronly != 0; in can_open_cached()
1533 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 in can_open_cached()
1534 && state->n_rdwr != 0; in can_open_cached()
1562 static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode) in update_open_stateflags() argument
1566 state->n_wronly++; in update_open_stateflags()
1569 state->n_rdonly++; in update_open_stateflags()
1572 state->n_rdwr++; in update_open_stateflags()
1574 nfs4_state_set_mode_locked(state, state->state | fmode); in update_open_stateflags()
1578 static bool nfs_open_stateid_recover_openmode(struct nfs4_state *state) in nfs_open_stateid_recover_openmode() argument
1580 if (state->n_rdonly && !test_bit(NFS_O_RDONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1582 if (state->n_wronly && !test_bit(NFS_O_WRONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1584 if (state->n_rdwr && !test_bit(NFS_O_RDWR_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1590 static void nfs_state_log_update_open_stateid(struct nfs4_state *state) in nfs_state_log_update_open_stateid() argument
1592 if (test_and_clear_bit(NFS_STATE_CHANGE_WAIT, &state->flags)) in nfs_state_log_update_open_stateid()
1593 wake_up_all(&state->waitq); in nfs_state_log_update_open_stateid()
1596 static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) in nfs_test_and_clear_all_open_stateid() argument
1598 struct nfs_client *clp = state->owner->so_server->nfs_client; in nfs_test_and_clear_all_open_stateid()
1601 if (test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags) && state->n_rdonly) in nfs_test_and_clear_all_open_stateid()
1603 if (test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags) && state->n_wronly) in nfs_test_and_clear_all_open_stateid()
1605 if (test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags) && state->n_rdwr) in nfs_test_and_clear_all_open_stateid()
1608 nfs4_state_mark_reclaim_nograce(clp, state); in nfs_test_and_clear_all_open_stateid()
1621 static bool nfs_stateid_is_sequential(struct nfs4_state *state, in nfs_stateid_is_sequential() argument
1624 if (test_bit(NFS_OPEN_STATE, &state->flags)) { in nfs_stateid_is_sequential()
1626 if (nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_stateid_is_sequential()
1627 if (nfs4_stateid_is_next(&state->open_stateid, stateid)) in nfs_stateid_is_sequential()
1639 static void nfs_resync_open_stateid_locked(struct nfs4_state *state) in nfs_resync_open_stateid_locked() argument
1641 if (!(state->n_wronly || state->n_rdonly || state->n_rdwr)) in nfs_resync_open_stateid_locked()
1643 if (state->n_wronly) in nfs_resync_open_stateid_locked()
1644 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1645 if (state->n_rdonly) in nfs_resync_open_stateid_locked()
1646 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1647 if (state->n_rdwr) in nfs_resync_open_stateid_locked()
1648 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1649 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1652 static void nfs_clear_open_stateid_locked(struct nfs4_state *state, in nfs_clear_open_stateid_locked() argument
1655 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1658 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1661 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1664 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1665 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1666 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1671 if (nfs4_stateid_match_other(stateid, &state->open_stateid) && in nfs_clear_open_stateid_locked()
1672 !nfs4_stateid_is_newer(stateid, &state->open_stateid)) { in nfs_clear_open_stateid_locked()
1673 nfs_resync_open_stateid_locked(state); in nfs_clear_open_stateid_locked()
1676 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_clear_open_stateid_locked()
1677 nfs4_stateid_copy(&state->stateid, stateid); in nfs_clear_open_stateid_locked()
1678 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_clear_open_stateid_locked()
1679 trace_nfs4_open_stateid_update(state->inode, stateid, 0); in nfs_clear_open_stateid_locked()
1681 nfs_state_log_update_open_stateid(state); in nfs_clear_open_stateid_locked()
1684 static void nfs_clear_open_stateid(struct nfs4_state *state, in nfs_clear_open_stateid() argument
1688 write_seqlock(&state->seqlock); in nfs_clear_open_stateid()
1690 if (nfs4_state_match_open_stateid_other(state, arg_stateid)) in nfs_clear_open_stateid()
1691 nfs_clear_open_stateid_locked(state, stateid, fmode); in nfs_clear_open_stateid()
1692 write_sequnlock(&state->seqlock); in nfs_clear_open_stateid()
1693 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in nfs_clear_open_stateid()
1694 nfs4_schedule_state_manager(state->owner->so_server->nfs_client); in nfs_clear_open_stateid()
1697 static void nfs_set_open_stateid_locked(struct nfs4_state *state, in nfs_set_open_stateid_locked() argument
1699 __must_hold(&state->owner->so_lock) in nfs_set_open_stateid_locked()
1700 __must_hold(&state->seqlock) in nfs_set_open_stateid_locked()
1708 if (nfs_stateid_is_sequential(state, stateid)) in nfs_set_open_stateid_locked()
1714 if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client)) in nfs_set_open_stateid_locked()
1717 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs_set_open_stateid_locked()
1718 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs_set_open_stateid_locked()
1724 write_sequnlock(&state->seqlock); in nfs_set_open_stateid_locked()
1725 spin_unlock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1727 trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); in nfs_set_open_stateid_locked()
1736 finish_wait(&state->waitq, &wait); in nfs_set_open_stateid_locked()
1738 spin_lock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1739 write_seqlock(&state->seqlock); in nfs_set_open_stateid_locked()
1742 if (test_bit(NFS_OPEN_STATE, &state->flags) && in nfs_set_open_stateid_locked()
1743 !nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_set_open_stateid_locked()
1744 nfs4_stateid_copy(freeme, &state->open_stateid); in nfs_set_open_stateid_locked()
1745 nfs_test_and_clear_all_open_stateid(state); in nfs_set_open_stateid_locked()
1748 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_set_open_stateid_locked()
1749 nfs4_stateid_copy(&state->stateid, stateid); in nfs_set_open_stateid_locked()
1750 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_set_open_stateid_locked()
1751 trace_nfs4_open_stateid_update(state->inode, stateid, status); in nfs_set_open_stateid_locked()
1752 nfs_state_log_update_open_stateid(state); in nfs_set_open_stateid_locked()
1755 static void nfs_state_set_open_stateid(struct nfs4_state *state, in nfs_state_set_open_stateid() argument
1764 write_seqlock(&state->seqlock); in nfs_state_set_open_stateid()
1765 nfs_set_open_stateid_locked(state, open_stateid, freeme); in nfs_state_set_open_stateid()
1768 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1771 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1774 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_set_open_stateid()
1776 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_set_open_stateid()
1777 write_sequnlock(&state->seqlock); in nfs_state_set_open_stateid()
1780 static void nfs_state_clear_open_state_flags(struct nfs4_state *state) in nfs_state_clear_open_state_flags() argument
1782 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1783 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1784 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1785 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1788 static void nfs_state_set_delegation(struct nfs4_state *state, in nfs_state_set_delegation() argument
1796 write_seqlock(&state->seqlock); in nfs_state_set_delegation()
1797 nfs4_stateid_copy(&state->stateid, deleg_stateid); in nfs_state_set_delegation()
1798 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_set_delegation()
1799 write_sequnlock(&state->seqlock); in nfs_state_set_delegation()
1802 static void nfs_state_clear_delegation(struct nfs4_state *state) in nfs_state_clear_delegation() argument
1804 write_seqlock(&state->seqlock); in nfs_state_clear_delegation()
1805 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs_state_clear_delegation()
1806 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_clear_delegation()
1807 write_sequnlock(&state->seqlock); in nfs_state_clear_delegation()
1810 int update_open_stateid(struct nfs4_state *state, in update_open_stateid() argument
1815 struct nfs_server *server = NFS_SERVER(state->inode); in update_open_stateid()
1817 struct nfs_inode *nfsi = NFS_I(state->inode); in update_open_stateid()
1825 spin_lock(&state->owner->so_lock); in update_open_stateid()
1827 nfs_state_set_open_stateid(state, open_stateid, fmode, &freeme); in update_open_stateid()
1831 deleg_cur = nfs4_get_valid_delegation(state->inode); in update_open_stateid()
1847 nfs_state_set_delegation(state, &deleg_cur->stateid, fmode); in update_open_stateid()
1853 update_open_stateflags(state, fmode); in update_open_stateid()
1854 spin_unlock(&state->owner->so_lock); in update_open_stateid()
1857 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in update_open_stateid()
1861 state->owner->so_cred); in update_open_stateid()
1869 struct nfs4_state *state = lsp->ls_state; in nfs4_update_lock_stateid() local
1872 spin_lock(&state->state_lock); in nfs4_update_lock_stateid()
1880 spin_unlock(&state->state_lock); in nfs4_update_lock_stateid()
1901 struct nfs4_state *state = opendata->state; in nfs4_try_open_cached() local
1910 spin_lock(&state->owner->so_lock); in nfs4_try_open_cached()
1911 if (can_open_cached(state, fmode, open_mode, claim)) { in nfs4_try_open_cached()
1912 update_open_stateflags(state, fmode); in nfs4_try_open_cached()
1913 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1916 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1918 delegation = nfs4_get_valid_delegation(state->inode); in nfs4_try_open_cached()
1928 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); in nfs4_try_open_cached()
1935 if (update_open_stateid(state, NULL, &stateid, fmode)) in nfs4_try_open_cached()
1941 refcount_inc(&state->count); in nfs4_try_open_cached()
1942 return state; in nfs4_try_open_cached()
1946 nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) in nfs4_opendata_check_deleg() argument
1948 struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client; in nfs4_opendata_check_deleg()
1953 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs4_opendata_check_deleg()
1969 nfs_inode_set_delegation(state->inode, in nfs4_opendata_check_deleg()
1975 nfs_inode_reclaim_delegation(state->inode, in nfs4_opendata_check_deleg()
1982 nfs_async_inode_return_delegation(state->inode, in nfs4_opendata_check_deleg()
1993 struct inode *inode = data->state->inode; in _nfs4_opendata_reclaim_to_nfs4_state()
1994 struct nfs4_state *state = data->state; in _nfs4_opendata_reclaim_to_nfs4_state() local
2008 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_reclaim_to_nfs4_state()
2010 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_reclaim_to_nfs4_state()
2013 refcount_inc(&state->count); in _nfs4_opendata_reclaim_to_nfs4_state()
2015 return state; in _nfs4_opendata_reclaim_to_nfs4_state()
2043 struct nfs4_state *state; in nfs4_opendata_find_nfs4_state() local
2049 if (data->state != NULL && data->state->inode == inode) { in nfs4_opendata_find_nfs4_state()
2050 state = data->state; in nfs4_opendata_find_nfs4_state()
2051 refcount_inc(&state->count); in nfs4_opendata_find_nfs4_state()
2053 state = nfs4_get_open_state(inode, data->owner); in nfs4_opendata_find_nfs4_state()
2055 if (state == NULL) in nfs4_opendata_find_nfs4_state()
2056 state = ERR_PTR(-ENOMEM); in nfs4_opendata_find_nfs4_state()
2057 return state; in nfs4_opendata_find_nfs4_state()
2063 struct nfs4_state *state; in _nfs4_opendata_to_nfs4_state() local
2066 state = nfs4_try_open_cached(data); in _nfs4_opendata_to_nfs4_state()
2067 trace_nfs4_cached_open(data->state); in _nfs4_opendata_to_nfs4_state()
2071 state = nfs4_opendata_find_nfs4_state(data); in _nfs4_opendata_to_nfs4_state()
2072 if (IS_ERR(state)) in _nfs4_opendata_to_nfs4_state()
2076 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_to_nfs4_state()
2077 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_to_nfs4_state()
2079 nfs4_put_open_state(state); in _nfs4_opendata_to_nfs4_state()
2080 state = ERR_PTR(-EAGAIN); in _nfs4_opendata_to_nfs4_state()
2084 return state; in _nfs4_opendata_to_nfs4_state()
2101 nfs4_state_find_open_context_mode(struct nfs4_state *state, fmode_t mode) in nfs4_state_find_open_context_mode() argument
2103 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_state_find_open_context_mode()
2108 if (ctx->state != state) in nfs4_state_find_open_context_mode()
2122 nfs4_state_find_open_context(struct nfs4_state *state) in nfs4_state_find_open_context() argument
2126 ctx = nfs4_state_find_open_context_mode(state, FMODE_READ|FMODE_WRITE); in nfs4_state_find_open_context()
2129 ctx = nfs4_state_find_open_context_mode(state, FMODE_WRITE); in nfs4_state_find_open_context()
2132 return nfs4_state_find_open_context_mode(state, FMODE_READ); in nfs4_state_find_open_context()
2136 struct nfs4_state *state, enum open_claim_type4 claim) in nfs4_open_recoverdata_alloc() argument
2140 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, in nfs4_open_recoverdata_alloc()
2144 opendata->state = state; in nfs4_open_recoverdata_alloc()
2145 refcount_inc(&state->count); in nfs4_open_recoverdata_alloc()
2157 if (!nfs4_mode_match_open_stateid(opendata->state, fmode)) in nfs4_open_recover_helper()
2171 if (newstate != opendata->state) in nfs4_open_recover_helper()
2177 static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state) in nfs4_open_recover() argument
2196 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 && in nfs4_open_recover()
2197 !nfs4_stateid_match(&state->stateid, &state->open_stateid)) { in nfs4_open_recover()
2198 write_seqlock(&state->seqlock); in nfs4_open_recover()
2199 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs4_open_recover()
2200 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs4_open_recover()
2201 write_sequnlock(&state->seqlock); in nfs4_open_recover()
2210 static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_do_open_reclaim() argument
2217 opendata = nfs4_open_recoverdata_alloc(ctx, state, in _nfs4_do_open_reclaim()
2222 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in _nfs4_do_open_reclaim()
2227 status = nfs4_open_recover(opendata, state); in _nfs4_do_open_reclaim()
2232 static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_reclaim() argument
2234 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_reclaim()
2238 err = _nfs4_do_open_reclaim(ctx, state); in nfs4_do_open_reclaim()
2249 static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_reclaim() argument
2254 ctx = nfs4_state_find_open_context(state); in nfs4_open_reclaim()
2257 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_reclaim()
2258 nfs_state_clear_open_state_flags(state); in nfs4_open_reclaim()
2259 ret = nfs4_do_open_reclaim(ctx, state); in nfs4_open_reclaim()
2264 static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state,… in nfs4_handle_delegation_recall_error() argument
2299 nfs_inode_find_state_and_recover(state->inode, in nfs4_handle_delegation_recall_error()
2301 nfs4_schedule_stateid_recovery(server, state); in nfs4_handle_delegation_recall_error()
2320 struct nfs4_state *state, const nfs4_stateid *stateid) in nfs4_open_delegation_recall() argument
2322 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_open_delegation_recall()
2326 opendata = nfs4_open_recoverdata_alloc(ctx, state, in nfs4_open_delegation_recall()
2331 if (!test_bit(NFS_O_RDWR_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2336 if (!test_bit(NFS_O_WRONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2341 if (!test_bit(NFS_O_RDONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2346 nfs_state_clear_delegation(state); in nfs4_open_delegation_recall()
2349 return nfs4_handle_delegation_recall_error(server, state, stateid, NULL, err); in nfs4_open_delegation_recall()
2378 struct nfs4_state *state = NULL; in nfs4_open_confirm_release() local
2386 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_confirm_release()
2387 if (!IS_ERR(state)) in nfs4_open_confirm_release()
2388 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_confirm_release()
2454 if (data->state != NULL) { in nfs4_open_prepare()
2457 if (can_open_cached(data->state, data->o_arg.fmode, in nfs4_open_prepare()
2461 delegation = nfs4_get_valid_delegation(data->state->inode); in nfs4_open_prepare()
2497 trace_nfs4_cached_open(data->state); in nfs4_open_prepare()
2539 struct nfs4_state *state = NULL; in nfs4_open_release() local
2550 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_release()
2551 if (!IS_ERR(state)) in nfs4_open_release()
2552 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_release()
2645 struct nfs4_state *state, fmode_t fmode, in nfs4_opendata_access() argument
2663 if (S_ISDIR(state->inode->i_mode)) in nfs4_opendata_access()
2672 nfs_access_add_cache(state->inode, &cache); in nfs4_opendata_access()
2736 static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_open_expired() argument
2741 opendata = nfs4_open_recoverdata_alloc(ctx, state, NFS4_OPEN_CLAIM_FH); in _nfs4_open_expired()
2750 ret = nfs4_open_recover(opendata, state); in _nfs4_open_expired()
2757 static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_expired() argument
2759 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_expired()
2764 err = _nfs4_open_expired(ctx, state); in nfs4_do_open_expired()
2781 static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_expired() argument
2786 ctx = nfs4_state_find_open_context(state); in nfs4_open_expired()
2789 ret = nfs4_do_open_expired(ctx, state); in nfs4_open_expired()
2794 static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state, in nfs_finish_clear_delegation_stateid() argument
2797 nfs_remove_bad_delegation(state->inode, stateid); in nfs_finish_clear_delegation_stateid()
2798 nfs_state_clear_delegation(state); in nfs_finish_clear_delegation_stateid()
2801 static void nfs40_clear_delegation_stateid(struct nfs4_state *state) in nfs40_clear_delegation_stateid() argument
2803 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL) in nfs40_clear_delegation_stateid()
2804 nfs_finish_clear_delegation_stateid(state, NULL); in nfs40_clear_delegation_stateid()
2807 static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs40_open_expired() argument
2810 nfs40_clear_delegation_stateid(state); in nfs40_open_expired()
2811 nfs_state_clear_open_state_flags(state); in nfs40_open_expired()
2812 return nfs4_open_expired(sp, state); in nfs40_open_expired()
2854 static int nfs41_check_delegation_stateid(struct nfs4_state *state) in nfs41_check_delegation_stateid() argument
2856 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_delegation_stateid()
2864 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs41_check_delegation_stateid()
2867 nfs_state_clear_delegation(state); in nfs41_check_delegation_stateid()
2886 trace_nfs4_test_delegation_stateid(state, NULL, status); in nfs41_check_delegation_stateid()
2888 nfs_finish_clear_delegation_stateid(state, &stateid); in nfs41_check_delegation_stateid()
2896 static void nfs41_delegation_recover_stateid(struct nfs4_state *state) in nfs41_delegation_recover_stateid() argument
2900 if (test_bit(NFS_DELEGATED_STATE, &state->flags) && in nfs41_delegation_recover_stateid()
2901 nfs4_copy_delegation_stateid(state->inode, state->state, in nfs41_delegation_recover_stateid()
2903 nfs4_stateid_match_other(&state->stateid, &tmp)) in nfs41_delegation_recover_stateid()
2904 nfs_state_set_delegation(state, &tmp, state->state); in nfs41_delegation_recover_stateid()
2906 nfs_state_clear_delegation(state); in nfs41_delegation_recover_stateid()
2917 static int nfs41_check_expired_locks(struct nfs4_state *state) in nfs41_check_expired_locks() argument
2921 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_expired_locks()
2923 if (!test_bit(LK_STATE_IN_USE, &state->flags)) in nfs41_check_expired_locks()
2926 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
2927 list_for_each_entry(lsp, &state->lock_states, ls_locks) { in nfs41_check_expired_locks()
2932 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
2940 trace_nfs4_test_lock_stateid(state, lsp, status); in nfs41_check_expired_locks()
2952 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
2955 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
2969 static int nfs41_check_open_stateid(struct nfs4_state *state) in nfs41_check_open_stateid() argument
2971 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_open_stateid()
2972 nfs4_stateid *stateid = &state->open_stateid; in nfs41_check_open_stateid()
2973 const struct cred *cred = state->owner->so_cred; in nfs41_check_open_stateid()
2976 if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) in nfs41_check_open_stateid()
2979 trace_nfs4_test_open_stateid(state, NULL, status); in nfs41_check_open_stateid()
2981 nfs_state_clear_open_state_flags(state); in nfs41_check_open_stateid()
2985 if (nfs_open_stateid_recover_openmode(state)) in nfs41_check_open_stateid()
2990 static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs41_open_expired() argument
2994 status = nfs41_check_delegation_stateid(state); in nfs41_open_expired()
2997 nfs41_delegation_recover_stateid(state); in nfs41_open_expired()
2999 status = nfs41_check_expired_locks(state); in nfs41_open_expired()
3002 status = nfs41_check_open_stateid(state); in nfs41_open_expired()
3004 status = nfs4_open_expired(sp, state); in nfs41_open_expired()
3056 struct nfs4_state *state; in _nfs4_open_and_get_state() local
3070 state = _nfs4_opendata_to_nfs4_state(opendata); in _nfs4_open_and_get_state()
3071 ret = PTR_ERR(state); in _nfs4_open_and_get_state()
3072 if (IS_ERR(state)) in _nfs4_open_and_get_state()
3074 ctx->state = state; in _nfs4_open_and_get_state()
3076 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); in _nfs4_open_and_get_state()
3078 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags); in _nfs4_open_and_get_state()
3084 alias = d_exact_alias(dentry, state->inode); in _nfs4_open_and_get_state()
3086 alias = d_splice_alias(igrab(state->inode), dentry); in _nfs4_open_and_get_state()
3108 pnfs_parse_lgopen(state->inode, opendata->lgp, ctx); in _nfs4_open_and_get_state()
3110 ret = nfs4_opendata_access(sp->so_cred, opendata, state, in _nfs4_open_and_get_state()
3115 if (d_inode(dentry) == state->inode) { in _nfs4_open_and_get_state()
3118 nfs4_schedule_stateid_recovery(server, state); in _nfs4_open_and_get_state()
3142 struct nfs4_state *state = NULL; in _nfs4_do_open() local
3192 opendata->state = nfs4_get_open_state(d_inode(dentry), sp); in _nfs4_do_open()
3197 state = ctx->state; in _nfs4_do_open()
3211 status = nfs4_do_setattr(state->inode, cred, in _nfs4_do_open()
3215 nfs_setattr_update_inode(state->inode, sattr, in _nfs4_do_open()
3217 nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); in _nfs4_do_open()
3270 res = ctx->state; in nfs4_do_open()
3349 } else if (ctx != NULL && ctx->state) { in _nfs4_do_setattr()
3351 if (!nfs4_valid_open_stateid(ctx->state)) in _nfs4_do_setattr()
3356 status = nfs4_select_rw_stateid(ctx->state, FMODE_WRITE, l_ctx, in _nfs4_do_setattr()
3386 struct nfs4_state *state = ctx ? ctx->state : NULL; in nfs4_do_setattr() local
3400 .state = state, in nfs4_do_setattr()
3426 if (state && !(state->state & FMODE_WRITE)) { in nfs4_do_setattr()
3452 struct nfs4_state *state) in nfs4_sync_open_stateid() argument
3459 if (!nfs4_valid_open_stateid(state)) in nfs4_sync_open_stateid()
3461 seq = read_seqbegin(&state->seqlock); in nfs4_sync_open_stateid()
3462 if (!nfs4_state_match_open_stateid_other(state, dst)) { in nfs4_sync_open_stateid()
3463 nfs4_stateid_copy(dst, &state->open_stateid); in nfs4_sync_open_stateid()
3464 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3468 seqid_open = state->open_stateid.seqid; in nfs4_sync_open_stateid()
3469 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3484 struct nfs4_state *state) in nfs4_refresh_open_old_stateid() argument
3494 if (!nfs4_valid_open_stateid(state)) in nfs4_refresh_open_old_stateid()
3496 seq = read_seqbegin(&state->seqlock); in nfs4_refresh_open_old_stateid()
3497 if (!nfs4_state_match_open_stateid_other(state, dst)) { in nfs4_refresh_open_old_stateid()
3498 if (read_seqretry(&state->seqlock, seq)) in nfs4_refresh_open_old_stateid()
3503 write_seqlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3504 seqid_open = state->open_stateid.seqid; in nfs4_refresh_open_old_stateid()
3511 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3517 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs4_refresh_open_old_stateid()
3518 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs4_refresh_open_old_stateid()
3519 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3520 trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); in nfs4_refresh_open_old_stateid()
3528 finish_wait(&state->waitq, &wait); in nfs4_refresh_open_old_stateid()
3546 struct nfs4_state *state; member
3563 struct nfs4_state_owner *sp = calldata->state->owner; in nfs4_free_closedata()
3564 struct super_block *sb = calldata->state->inode->i_sb; in nfs4_free_closedata()
3569 nfs4_put_open_state(calldata->state); in nfs4_free_closedata()
3579 struct nfs4_state *state = calldata->state; in nfs4_close_done() local
3583 .state = state, in nfs4_close_done()
3591 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); in nfs4_close_done()
3617 state)) in nfs4_close_done()
3637 nfs_clear_open_stateid(state, &calldata->arg.stateid, in nfs4_close_done()
3654 struct nfs4_state *state = calldata->state; in nfs4_close_prepare() local
3666 spin_lock(&state->owner->so_lock); in nfs4_close_prepare()
3667 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
3668 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_close_prepare()
3669 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_close_prepare()
3672 if (state->n_rdwr == 0) { in nfs4_close_prepare()
3673 if (state->n_rdonly == 0) in nfs4_close_prepare()
3677 if (state->n_wronly == 0) in nfs4_close_prepare()
3686 nfs4_sync_open_stateid(&calldata->arg.stateid, state); in nfs4_close_prepare()
3687 if (!nfs4_valid_open_stateid(state)) in nfs4_close_prepare()
3689 spin_unlock(&state->owner->so_lock); in nfs4_close_prepare()
3760 int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) in nfs4_do_close() argument
3762 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_close()
3765 struct nfs4_state_owner *sp = state->owner; in nfs4_do_close()
3769 .rpc_cred = state->owner->so_cred, in nfs4_do_close()
3780 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE)) in nfs4_do_close()
3790 calldata->inode = state->inode; in nfs4_do_close()
3791 calldata->state = state; in nfs4_do_close()
3792 calldata->arg.fh = NFS_FH(state->inode); in nfs4_do_close()
3793 if (!nfs4_copy_open_stateid(&calldata->arg.stateid, state)) in nfs4_do_close()
3797 calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask); in nfs4_do_close()
3807 calldata->lr.roc = pnfs_roc(state->inode, in nfs4_do_close()
3829 nfs4_put_open_state(state); in nfs4_do_close()
3838 struct nfs4_state *state; in nfs4_atomic_open() local
3844 state = nfs4_do_open(dir, ctx, open_flags, attr, label, opened); in nfs4_atomic_open()
3848 if (IS_ERR(state)) in nfs4_atomic_open()
3849 return ERR_CAST(state); in nfs4_atomic_open()
3850 return state->inode; in nfs4_atomic_open()
3855 if (ctx->state == NULL) in nfs4_close_context()
3858 nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
3860 nfs4_close_state(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
4677 struct nfs4_state *state; in nfs4_proc_create() local
4688 state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, NULL); in nfs4_proc_create()
4689 if (IS_ERR(state)) { in nfs4_proc_create()
4690 status = PTR_ERR(state); in nfs4_proc_create()
5348 return nfs4_select_rw_stateid(ctx->state, fmode, l_ctx, stateid, NULL); in nfs4_set_rw_stateid()
5388 .state = hdr->args.context->state, in nfs4_read_done_cb()
5502 .state = hdr->args.context->state, in nfs4_write_done_cb()
6724 static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_getlk() argument
6726 struct inode *inode = state->inode; in _nfs4_proc_getlk()
6740 .rpc_cred = state->owner->so_cred, in _nfs4_proc_getlk()
6746 status = nfs4_set_lock_state(state, request); in _nfs4_proc_getlk()
6766 static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_getlk() argument
6774 err = _nfs4_proc_getlk(state, cmd, request); in nfs4_proc_getlk()
6775 trace_nfs4_get_lock(request, state, cmd, err); in nfs4_proc_getlk()
6776 err = nfs4_handle_exception(NFS_SERVER(state->inode), err, in nfs4_proc_getlk()
6789 struct nfs4_state *state = lsp->ls_state; in nfs4_refresh_lock_old_stateid() local
6792 spin_lock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
6801 spin_unlock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
6808 struct nfs4_state *state = lsp->ls_state; in nfs4_sync_lock_stateid() local
6811 spin_lock(&state->state_lock); in nfs4_sync_lock_stateid()
6814 spin_unlock(&state->state_lock); in nfs4_sync_lock_stateid()
6835 struct nfs4_state *state = lsp->ls_state; in nfs4_alloc_unlockdata() local
6836 struct inode *inode = state->inode; in nfs4_alloc_unlockdata()
6852 spin_lock(&state->state_lock); in nfs4_alloc_unlockdata()
6854 spin_unlock(&state->state_lock); in nfs4_alloc_unlockdata()
6990 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_unlck() argument
6992 struct inode *inode = state->inode; in nfs4_proc_unlck()
6993 struct nfs4_state_owner *sp = state->owner; in nfs4_proc_unlck()
7002 status = nfs4_set_lock_state(state, request); in nfs4_proc_unlck()
7035 trace_nfs4_unlock(request, state, F_SETLK, status); in nfs4_proc_unlck()
7093 struct nfs4_state *state = data->lsp->ls_state; in nfs4_lock_prepare() local
7104 &state->open_stateid); in nfs4_lock_prepare()
7112 if (!nfs4_valid_open_stateid(state)) { in nfs4_lock_prepare()
7233 static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_typ… in _nfs4_do_setlk() argument
7239 .rpc_cred = state->owner->so_cred, in _nfs4_do_setlk()
7242 .rpc_client = NFS_CLIENT(state->inode), in _nfs4_do_setlk()
7250 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE)) in _nfs4_do_setlk()
7281 trace_nfs4_set_lock(fl, state, &data->res.stateid, cmd, ret); in _nfs4_do_setlk()
7287 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_reclaim() argument
7289 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_reclaim()
7291 .inode = state->inode, in nfs4_lock_reclaim()
7297 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_reclaim()
7299 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM); in nfs4_lock_reclaim()
7307 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_expired() argument
7309 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_expired()
7311 .inode = state->inode, in nfs4_lock_expired()
7315 err = nfs4_set_lock_state(state, request); in nfs4_lock_expired()
7323 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_expired()
7325 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED); in nfs4_lock_expired()
7340 static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs41_lock_expired() argument
7345 status = nfs4_set_lock_state(state, request); in nfs41_lock_expired()
7352 return nfs4_lock_expired(state, request); in nfs41_lock_expired()
7356 static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_setlk() argument
7358 struct nfs_inode *nfsi = NFS_I(state->inode); in _nfs4_proc_setlk()
7359 struct nfs4_state_owner *sp = state->owner; in _nfs4_proc_setlk()
7364 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7369 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { in _nfs4_proc_setlk()
7373 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7380 status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW); in _nfs4_proc_setlk()
7386 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_setlk() argument
7389 .state = state, in nfs4_proc_setlk()
7390 .inode = state->inode, in nfs4_proc_setlk()
7396 err = _nfs4_proc_setlk(state, cmd, request); in nfs4_proc_setlk()
7399 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_setlk()
7409 nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd, in nfs4_retry_setlk_simple() argument
7416 status = nfs4_proc_setlk(state, cmd, request); in nfs4_retry_setlk_simple()
7459 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_retry_setlk() argument
7462 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_retry_setlk()
7466 .inode = state->inode, in nfs4_retry_setlk()
7474 if (!test_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags)) in nfs4_retry_setlk()
7475 return nfs4_retry_setlk_simple(state, cmd, request); in nfs4_retry_setlk()
7482 status = nfs4_proc_setlk(state, cmd, request); in nfs4_retry_setlk()
7499 nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_retry_setlk() argument
7501 return nfs4_retry_setlk_simple(state, cmd, request); in nfs4_retry_setlk()
7509 struct nfs4_state *state; in nfs4_proc_lock() local
7514 state = ctx->state; in nfs4_proc_lock()
7517 if (state != NULL) in nfs4_proc_lock()
7518 return nfs4_proc_getlk(state, F_GETLK, request); in nfs4_proc_lock()
7526 if (state != NULL) in nfs4_proc_lock()
7527 return nfs4_proc_unlck(state, cmd, request); in nfs4_proc_lock()
7531 if (state == NULL) in nfs4_proc_lock()
7535 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags)) in nfs4_proc_lock()
7552 status = nfs4_set_lock_state(state, request); in nfs4_proc_lock()
7556 return nfs4_retry_setlk(state, cmd, request); in nfs4_proc_lock()
7596 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid … in nfs4_lock_delegation_recall() argument
7598 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_delegation_recall()
7601 err = nfs4_set_lock_state(state, fl); in nfs4_lock_delegation_recall()
7605 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); in nfs4_lock_delegation_recall()
7610 return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err); in nfs4_lock_delegation_recall()
9607 exception->state = lgp->args.ctx->state; in nfs4_layoutget_handle_exception()