Lines Matching refs:state
85 struct nfs4_state *state, struct nfs4_label *ilabel,
347 struct nfs4_state *state = exception->state; in nfs4_do_handle_exception() local
364 if (state == NULL) in nfs4_do_handle_exception()
366 ret = nfs4_schedule_stateid_recovery(server, state); in nfs4_do_handle_exception()
371 if (state != NULL) { in nfs4_do_handle_exception()
372 ret = nfs4_schedule_stateid_recovery(server, state); in nfs4_do_handle_exception()
494 struct nfs4_state *state, long *timeout) in nfs4_async_handle_error() argument
497 .state = state, in nfs4_async_handle_error()
990 struct nfs4_state *state; member
1172 if (p->state != NULL) in nfs4_opendata_free()
1173 nfs4_put_open_state(p->state); in nfs4_opendata_free()
1201 static bool nfs4_mode_match_open_stateid(struct nfs4_state *state, in nfs4_mode_match_open_stateid() argument
1206 return state->n_rdwr != 0; in nfs4_mode_match_open_stateid()
1208 return state->n_wronly != 0; in nfs4_mode_match_open_stateid()
1210 return state->n_rdonly != 0; in nfs4_mode_match_open_stateid()
1216 static int can_open_cached(struct nfs4_state *state, fmode_t mode, int open_mode) in can_open_cached() argument
1224 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 in can_open_cached()
1225 && state->n_rdonly != 0; in can_open_cached()
1228 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 in can_open_cached()
1229 && state->n_wronly != 0; in can_open_cached()
1232 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 in can_open_cached()
1233 && state->n_rdwr != 0; in can_open_cached()
1260 static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode) in update_open_stateflags() argument
1264 state->n_wronly++; in update_open_stateflags()
1267 state->n_rdonly++; in update_open_stateflags()
1270 state->n_rdwr++; in update_open_stateflags()
1272 nfs4_state_set_mode_locked(state, state->state | fmode); in update_open_stateflags()
1275 static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) in nfs_test_and_clear_all_open_stateid() argument
1277 struct nfs_client *clp = state->owner->so_server->nfs_client; in nfs_test_and_clear_all_open_stateid()
1280 if (test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags) && state->n_rdonly) in nfs_test_and_clear_all_open_stateid()
1282 if (test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags) && state->n_wronly) in nfs_test_and_clear_all_open_stateid()
1284 if (test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags) && state->n_rdwr) in nfs_test_and_clear_all_open_stateid()
1287 nfs4_state_mark_reclaim_nograce(clp, state); in nfs_test_and_clear_all_open_stateid()
1290 static bool nfs_need_update_open_stateid(struct nfs4_state *state, in nfs_need_update_open_stateid() argument
1293 if (test_and_set_bit(NFS_OPEN_STATE, &state->flags) == 0) in nfs_need_update_open_stateid()
1295 if (!nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_need_update_open_stateid()
1296 nfs_test_and_clear_all_open_stateid(state); in nfs_need_update_open_stateid()
1299 if (nfs4_stateid_is_newer(stateid, &state->open_stateid)) in nfs_need_update_open_stateid()
1304 static void nfs_resync_open_stateid_locked(struct nfs4_state *state) in nfs_resync_open_stateid_locked() argument
1306 if (!(state->n_wronly || state->n_rdonly || state->n_rdwr)) in nfs_resync_open_stateid_locked()
1308 if (state->n_wronly) in nfs_resync_open_stateid_locked()
1309 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1310 if (state->n_rdonly) in nfs_resync_open_stateid_locked()
1311 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1312 if (state->n_rdwr) in nfs_resync_open_stateid_locked()
1313 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1314 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1317 static void nfs_clear_open_stateid_locked(struct nfs4_state *state, in nfs_clear_open_stateid_locked() argument
1321 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1324 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1327 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1330 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1331 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1332 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1337 if (!nfs4_stateid_match_other(arg_stateid, &state->open_stateid) || in nfs_clear_open_stateid_locked()
1338 (nfs4_stateid_match_other(stateid, &state->open_stateid) && in nfs_clear_open_stateid_locked()
1339 !nfs4_stateid_is_newer(stateid, &state->open_stateid))) { in nfs_clear_open_stateid_locked()
1340 nfs_resync_open_stateid_locked(state); in nfs_clear_open_stateid_locked()
1343 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_clear_open_stateid_locked()
1344 nfs4_stateid_copy(&state->stateid, stateid); in nfs_clear_open_stateid_locked()
1345 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_clear_open_stateid_locked()
1348 static void nfs_clear_open_stateid(struct nfs4_state *state, in nfs_clear_open_stateid() argument
1352 write_seqlock(&state->seqlock); in nfs_clear_open_stateid()
1353 nfs_clear_open_stateid_locked(state, arg_stateid, stateid, fmode); in nfs_clear_open_stateid()
1354 write_sequnlock(&state->seqlock); in nfs_clear_open_stateid()
1355 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in nfs_clear_open_stateid()
1356 nfs4_schedule_state_manager(state->owner->so_server->nfs_client); in nfs_clear_open_stateid()
1359 static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fm… in nfs_set_open_stateid_locked() argument
1363 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_set_open_stateid_locked()
1366 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_set_open_stateid_locked()
1369 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_set_open_stateid_locked()
1371 if (!nfs_need_update_open_stateid(state, stateid)) in nfs_set_open_stateid_locked()
1373 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_set_open_stateid_locked()
1374 nfs4_stateid_copy(&state->stateid, stateid); in nfs_set_open_stateid_locked()
1375 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_set_open_stateid_locked()
1378 static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, const nfs4_… in __update_open_stateid() argument
1384 spin_lock(&state->owner->so_lock); in __update_open_stateid()
1385 write_seqlock(&state->seqlock); in __update_open_stateid()
1387 nfs4_stateid_copy(&state->stateid, deleg_stateid); in __update_open_stateid()
1388 set_bit(NFS_DELEGATED_STATE, &state->flags); in __update_open_stateid()
1391 nfs_set_open_stateid_locked(state, open_stateid, fmode); in __update_open_stateid()
1392 write_sequnlock(&state->seqlock); in __update_open_stateid()
1393 update_open_stateflags(state, fmode); in __update_open_stateid()
1394 spin_unlock(&state->owner->so_lock); in __update_open_stateid()
1397 static int update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, nfs4_stateid *… in update_open_stateid() argument
1399 struct nfs_inode *nfsi = NFS_I(state->inode); in update_open_stateid()
1422 __update_open_stateid(state, open_stateid, &deleg_cur->stateid, fmode); in update_open_stateid()
1430 __update_open_stateid(state, open_stateid, NULL, fmode); in update_open_stateid()
1433 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in update_open_stateid()
1434 nfs4_schedule_state_manager(state->owner->so_server->nfs_client); in update_open_stateid()
1442 struct nfs4_state *state = lsp->ls_state; in nfs4_update_lock_stateid() local
1445 spin_lock(&state->state_lock); in nfs4_update_lock_stateid()
1453 spin_unlock(&state->state_lock); in nfs4_update_lock_stateid()
1473 struct nfs4_state *state = opendata->state; in nfs4_try_open_cached() local
1482 spin_lock(&state->owner->so_lock); in nfs4_try_open_cached()
1483 if (can_open_cached(state, fmode, open_mode)) { in nfs4_try_open_cached()
1484 update_open_stateflags(state, fmode); in nfs4_try_open_cached()
1485 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1488 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1490 delegation = nfs4_get_valid_delegation(state->inode); in nfs4_try_open_cached()
1500 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); in nfs4_try_open_cached()
1507 if (update_open_stateid(state, NULL, &stateid, fmode)) in nfs4_try_open_cached()
1513 atomic_inc(&state->count); in nfs4_try_open_cached()
1514 return state; in nfs4_try_open_cached()
1518 nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) in nfs4_opendata_check_deleg() argument
1520 struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client; in nfs4_opendata_check_deleg()
1525 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs4_opendata_check_deleg()
1541 nfs_inode_set_delegation(state->inode, in nfs4_opendata_check_deleg()
1545 nfs_inode_reclaim_delegation(state->inode, in nfs4_opendata_check_deleg()
1557 struct inode *inode = data->state->inode; in _nfs4_opendata_reclaim_to_nfs4_state()
1558 struct nfs4_state *state = data->state; in _nfs4_opendata_reclaim_to_nfs4_state() local
1575 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_reclaim_to_nfs4_state()
1577 update_open_stateid(state, &data->o_res.stateid, NULL, in _nfs4_opendata_reclaim_to_nfs4_state()
1579 atomic_inc(&state->count); in _nfs4_opendata_reclaim_to_nfs4_state()
1581 return state; in _nfs4_opendata_reclaim_to_nfs4_state()
1591 struct nfs4_state *state = NULL; in _nfs4_opendata_to_nfs4_state() local
1595 state = nfs4_try_open_cached(data); in _nfs4_opendata_to_nfs4_state()
1607 state = nfs4_get_open_state(inode, data->owner); in _nfs4_opendata_to_nfs4_state()
1608 if (state == NULL) in _nfs4_opendata_to_nfs4_state()
1611 nfs4_opendata_check_deleg(data, state); in _nfs4_opendata_to_nfs4_state()
1612 update_open_stateid(state, &data->o_res.stateid, NULL, in _nfs4_opendata_to_nfs4_state()
1617 return state; in _nfs4_opendata_to_nfs4_state()
1632 static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) in nfs4_state_find_open_context() argument
1634 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_state_find_open_context()
1637 spin_lock(&state->inode->i_lock); in nfs4_state_find_open_context()
1639 if (ctx->state != state) in nfs4_state_find_open_context()
1642 spin_unlock(&state->inode->i_lock); in nfs4_state_find_open_context()
1645 spin_unlock(&state->inode->i_lock); in nfs4_state_find_open_context()
1650 struct nfs4_state *state, enum open_claim_type4 claim) in nfs4_open_recoverdata_alloc() argument
1654 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, in nfs4_open_recoverdata_alloc()
1658 opendata->state = state; in nfs4_open_recoverdata_alloc()
1659 atomic_inc(&state->count); in nfs4_open_recoverdata_alloc()
1669 if (!nfs4_mode_match_open_stateid(opendata->state, fmode)) in nfs4_open_recover_helper()
1685 if (newstate != opendata->state) in nfs4_open_recover_helper()
1691 static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state) in nfs4_open_recover() argument
1696 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_open_recover()
1697 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_open_recover()
1698 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_open_recover()
1700 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_recover()
1701 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs4_open_recover()
1716 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 && in nfs4_open_recover()
1717 !nfs4_stateid_match(&state->stateid, &state->open_stateid)) { in nfs4_open_recover()
1718 write_seqlock(&state->seqlock); in nfs4_open_recover()
1719 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs4_open_recover()
1720 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs4_open_recover()
1721 write_sequnlock(&state->seqlock); in nfs4_open_recover()
1730 static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_do_open_reclaim() argument
1737 opendata = nfs4_open_recoverdata_alloc(ctx, state, in _nfs4_do_open_reclaim()
1742 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in _nfs4_do_open_reclaim()
1747 status = nfs4_open_recover(opendata, state); in _nfs4_do_open_reclaim()
1752 static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_reclaim() argument
1754 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_reclaim()
1758 err = _nfs4_do_open_reclaim(ctx, state); in nfs4_do_open_reclaim()
1769 static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_reclaim() argument
1774 ctx = nfs4_state_find_open_context(state); in nfs4_open_reclaim()
1777 ret = nfs4_do_open_reclaim(ctx, state); in nfs4_open_reclaim()
1782 static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state,… in nfs4_handle_delegation_recall_error() argument
1798 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_handle_delegation_recall_error()
1803 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_handle_delegation_recall_error()
1818 nfs_inode_find_state_and_recover(state->inode, in nfs4_handle_delegation_recall_error()
1820 nfs4_schedule_stateid_recovery(server, state); in nfs4_handle_delegation_recall_error()
1824 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_handle_delegation_recall_error()
1840 struct nfs4_state *state, const nfs4_stateid *stateid, in nfs4_open_delegation_recall() argument
1843 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_open_delegation_recall()
1847 opendata = nfs4_open_recoverdata_alloc(ctx, state, in nfs4_open_delegation_recall()
1852 write_seqlock(&state->seqlock); in nfs4_open_delegation_recall()
1853 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs4_open_delegation_recall()
1854 write_sequnlock(&state->seqlock); in nfs4_open_delegation_recall()
1855 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_delegation_recall()
1869 return nfs4_handle_delegation_recall_error(server, state, stateid, NULL, err); in nfs4_open_delegation_recall()
1898 struct nfs4_state *state = NULL; in nfs4_open_confirm_release() local
1906 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_confirm_release()
1907 if (!IS_ERR(state)) in nfs4_open_confirm_release()
1908 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_confirm_release()
1975 if (data->state != NULL) { in nfs4_open_prepare()
1978 if (can_open_cached(data->state, data->o_arg.fmode, data->o_arg.open_flags)) in nfs4_open_prepare()
1981 delegation = nfs4_get_valid_delegation(data->state->inode); in nfs4_open_prepare()
2058 struct nfs4_state *state = NULL; in nfs4_open_release() local
2069 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_release()
2070 if (!IS_ERR(state)) in nfs4_open_release()
2071 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_release()
2160 struct nfs4_state *state, fmode_t fmode, in nfs4_opendata_access() argument
2185 nfs_access_add_cache(state->inode, &cache); in nfs4_opendata_access()
2245 static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_open_expired() argument
2250 opendata = nfs4_open_recoverdata_alloc(ctx, state, in _nfs4_open_expired()
2254 ret = nfs4_open_recover(opendata, state); in _nfs4_open_expired()
2261 static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_expired() argument
2263 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_expired()
2268 err = _nfs4_open_expired(ctx, state); in nfs4_do_open_expired()
2285 static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_expired() argument
2290 ctx = nfs4_state_find_open_context(state); in nfs4_open_expired()
2293 ret = nfs4_do_open_expired(ctx, state); in nfs4_open_expired()
2298 static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state) in nfs_finish_clear_delegation_stateid() argument
2300 nfs_remove_bad_delegation(state->inode); in nfs_finish_clear_delegation_stateid()
2301 write_seqlock(&state->seqlock); in nfs_finish_clear_delegation_stateid()
2302 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs_finish_clear_delegation_stateid()
2303 write_sequnlock(&state->seqlock); in nfs_finish_clear_delegation_stateid()
2304 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_finish_clear_delegation_stateid()
2307 static void nfs40_clear_delegation_stateid(struct nfs4_state *state) in nfs40_clear_delegation_stateid() argument
2309 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL) in nfs40_clear_delegation_stateid()
2310 nfs_finish_clear_delegation_stateid(state); in nfs40_clear_delegation_stateid()
2313 static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs40_open_expired() argument
2316 nfs40_clear_delegation_stateid(state); in nfs40_open_expired()
2317 return nfs4_open_expired(sp, state); in nfs40_open_expired()
2321 static void nfs41_check_delegation_stateid(struct nfs4_state *state) in nfs41_check_delegation_stateid() argument
2323 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_delegation_stateid()
2331 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs41_check_delegation_stateid()
2341 trace_nfs4_test_delegation_stateid(state, NULL, status); in nfs41_check_delegation_stateid()
2348 nfs_finish_clear_delegation_stateid(state); in nfs41_check_delegation_stateid()
2362 static int nfs41_check_open_stateid(struct nfs4_state *state) in nfs41_check_open_stateid() argument
2364 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_open_stateid()
2365 nfs4_stateid *stateid = &state->open_stateid; in nfs41_check_open_stateid()
2366 struct rpc_cred *cred = state->owner->so_cred; in nfs41_check_open_stateid()
2370 if ((test_bit(NFS_O_RDONLY_STATE, &state->flags) == 0) && in nfs41_check_open_stateid()
2371 (test_bit(NFS_O_WRONLY_STATE, &state->flags) == 0) && in nfs41_check_open_stateid()
2372 (test_bit(NFS_O_RDWR_STATE, &state->flags) == 0)) in nfs41_check_open_stateid()
2376 trace_nfs4_test_open_stateid(state, NULL, status); in nfs41_check_open_stateid()
2383 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs41_check_open_stateid()
2384 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs41_check_open_stateid()
2385 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs41_check_open_stateid()
2386 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs41_check_open_stateid()
2391 static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs41_open_expired() argument
2395 nfs41_check_delegation_stateid(state); in nfs41_open_expired()
2396 status = nfs41_check_open_stateid(state); in nfs41_open_expired()
2398 status = nfs4_open_expired(sp, state); in nfs41_open_expired()
2438 struct nfs4_state *state; in _nfs4_open_and_get_state() local
2448 state = nfs4_opendata_to_nfs4_state(opendata); in _nfs4_open_and_get_state()
2449 ret = PTR_ERR(state); in _nfs4_open_and_get_state()
2450 if (IS_ERR(state)) in _nfs4_open_and_get_state()
2452 ctx->state = state; in _nfs4_open_and_get_state()
2454 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); in _nfs4_open_and_get_state()
2460 dentry = d_add_unique(dentry, igrab(state->inode)); in _nfs4_open_and_get_state()
2471 ret = nfs4_opendata_access(sp->so_cred, opendata, state, fmode, flags); in _nfs4_open_and_get_state()
2475 if (d_inode(dentry) == state->inode) { in _nfs4_open_and_get_state()
2478 nfs4_schedule_stateid_recovery(server, state); in _nfs4_open_and_get_state()
2494 struct nfs4_state *state = NULL; in _nfs4_do_open() local
2544 opendata->state = nfs4_get_open_state(d_inode(dentry), sp); in _nfs4_do_open()
2549 state = ctx->state; in _nfs4_do_open()
2556 status = nfs4_do_setattr(state->inode, cred, in _nfs4_do_open()
2558 state, label, olabel); in _nfs4_do_open()
2560 nfs_setattr_update_inode(state->inode, sattr, in _nfs4_do_open()
2562 nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); in _nfs4_do_open()
2611 res = ctx->state; in nfs4_do_open()
2658 struct nfs4_state *state, struct nfs4_label *ilabel, in _nfs4_do_setattr() argument
2697 } else if (truncate && state != NULL) { in _nfs4_do_setattr()
2702 if (!nfs4_valid_open_stateid(state)) in _nfs4_do_setattr()
2704 if (nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, in _nfs4_do_setattr()
2711 if (status == 0 && state != NULL) in _nfs4_do_setattr()
2718 struct nfs4_state *state, struct nfs4_label *ilabel, in nfs4_do_setattr() argument
2723 .state = state, in nfs4_do_setattr()
2728 err = _nfs4_do_setattr(inode, cred, fattr, sattr, state, ilabel, olabel); in nfs4_do_setattr()
2739 if (state && !(state->state & FMODE_WRITE)) { in nfs4_do_setattr()
2763 struct nfs4_state *state; member
2775 struct nfs4_state_owner *sp = calldata->state->owner; in nfs4_free_closedata()
2776 struct super_block *sb = calldata->state->inode->i_sb; in nfs4_free_closedata()
2779 pnfs_roc_release(calldata->state->inode); in nfs4_free_closedata()
2780 nfs4_put_open_state(calldata->state); in nfs4_free_closedata()
2790 struct nfs4_state *state = calldata->state; in nfs4_close_done() local
2797 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); in nfs4_close_done()
2805 pnfs_roc_set_barrier(state->inode, in nfs4_close_done()
2815 &state->open_stateid)) { in nfs4_close_done()
2822 if (nfs4_async_handle_error(task, server, state, NULL) == -EAGAIN) { in nfs4_close_done()
2827 nfs_clear_open_stateid(state, &calldata->arg.stateid, in nfs4_close_done()
2838 struct nfs4_state *state = calldata->state; in nfs4_close_prepare() local
2848 spin_lock(&state->owner->so_lock); in nfs4_close_prepare()
2849 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
2850 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_close_prepare()
2851 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_close_prepare()
2852 nfs4_stateid_copy(&calldata->arg.stateid, &state->open_stateid); in nfs4_close_prepare()
2855 if (state->n_rdwr == 0) { in nfs4_close_prepare()
2856 if (state->n_rdonly == 0) in nfs4_close_prepare()
2860 if (state->n_wronly == 0) in nfs4_close_prepare()
2869 if (!nfs4_valid_open_stateid(state)) in nfs4_close_prepare()
2871 spin_unlock(&state->owner->so_lock); in nfs4_close_prepare()
2931 int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) in nfs4_do_close() argument
2933 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_close()
2936 struct nfs4_state_owner *sp = state->owner; in nfs4_do_close()
2940 .rpc_cred = state->owner->so_cred, in nfs4_do_close()
2958 calldata->inode = state->inode; in nfs4_do_close()
2959 calldata->state = state; in nfs4_do_close()
2960 calldata->arg.fh = NFS_FH(state->inode); in nfs4_do_close()
2963 calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask); in nfs4_do_close()
2971 calldata->roc = nfs4_roc(state->inode); in nfs4_do_close()
2988 nfs4_put_open_state(state); in nfs4_do_close()
2997 struct nfs4_state *state; in nfs4_atomic_open() local
3003 state = nfs4_do_open(dir, ctx, open_flags, attr, label, opened); in nfs4_atomic_open()
3007 if (IS_ERR(state)) in nfs4_atomic_open()
3008 return ERR_CAST(state); in nfs4_atomic_open()
3009 return state->inode; in nfs4_atomic_open()
3014 if (ctx->state == NULL) in nfs4_close_context()
3017 nfs4_close_sync(ctx->state, ctx->mode); in nfs4_close_context()
3019 nfs4_close_state(ctx->state, ctx->mode); in nfs4_close_context()
3433 struct nfs4_state *state = NULL; in nfs4_proc_setattr() local
3459 state = ctx->state; in nfs4_proc_setattr()
3467 status = nfs4_do_setattr(inode, cred, fattr, sattr, state, NULL, label); in nfs4_proc_setattr()
3714 struct nfs4_state *state; in nfs4_proc_create() local
3724 state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, NULL); in nfs4_proc_create()
3725 if (IS_ERR(state)) { in nfs4_proc_create()
3726 status = PTR_ERR(state); in nfs4_proc_create()
4300 return nfs4_select_rw_stateid(stateid, ctx->state, fmode, lockowner); in nfs4_set_rw_stateid()
4343 hdr->args.context->state, in nfs4_read_done_cb()
4415 hdr->args.context->state, in nfs4_write_done_cb()
5481 static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_getlk() argument
5483 struct inode *inode = state->inode; in _nfs4_proc_getlk()
5497 .rpc_cred = state->owner->so_cred, in _nfs4_proc_getlk()
5503 status = nfs4_set_lock_state(state, request); in _nfs4_proc_getlk()
5523 static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_getlk() argument
5529 err = _nfs4_proc_getlk(state, cmd, request); in nfs4_proc_getlk()
5530 trace_nfs4_get_lock(request, state, cmd, err); in nfs4_proc_getlk()
5531 err = nfs4_handle_exception(NFS_SERVER(state->inode), err, in nfs4_proc_getlk()
5683 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_unlck() argument
5685 struct inode *inode = state->inode; in nfs4_proc_unlck()
5686 struct nfs4_state_owner *sp = state->owner; in nfs4_proc_unlck()
5695 status = nfs4_set_lock_state(state, request); in nfs4_proc_unlck()
5728 trace_nfs4_unlock(request, state, F_SETLK, status); in nfs4_proc_unlck()
5786 struct nfs4_state *state = data->lsp->ls_state; in nfs4_lock_prepare() local
5797 &state->open_stateid); in nfs4_lock_prepare()
5805 if (!nfs4_valid_open_stateid(state)) { in nfs4_lock_prepare()
5913 static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_typ… in _nfs4_do_setlk() argument
5919 .rpc_cred = state->owner->so_cred, in _nfs4_do_setlk()
5922 .rpc_client = NFS_CLIENT(state->inode), in _nfs4_do_setlk()
5964 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_reclaim() argument
5966 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_reclaim()
5968 .inode = state->inode, in nfs4_lock_reclaim()
5974 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_reclaim()
5976 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM); in nfs4_lock_reclaim()
5977 trace_nfs4_lock_reclaim(request, state, F_SETLK, err); in nfs4_lock_reclaim()
5985 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_expired() argument
5987 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_expired()
5989 .inode = state->inode, in nfs4_lock_expired()
5993 err = nfs4_set_lock_state(state, request); in nfs4_lock_expired()
6001 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_expired()
6003 err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED); in nfs4_lock_expired()
6004 trace_nfs4_lock_expired(request, state, F_SETLK, err); in nfs4_lock_expired()
6027 static int nfs41_check_expired_locks(struct nfs4_state *state) in nfs41_check_expired_locks() argument
6031 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_expired_locks()
6033 list_for_each_entry(lsp, &state->lock_states, ls_locks) { in nfs41_check_expired_locks()
6040 trace_nfs4_test_lock_stateid(state, lsp, status); in nfs41_check_expired_locks()
6057 static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs41_lock_expired() argument
6061 if (test_bit(LK_STATE_IN_USE, &state->flags)) in nfs41_lock_expired()
6062 status = nfs41_check_expired_locks(state); in nfs41_lock_expired()
6064 status = nfs4_lock_expired(state, request); in nfs41_lock_expired()
6069 static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_setlk() argument
6071 struct nfs_inode *nfsi = NFS_I(state->inode); in _nfs4_proc_setlk()
6072 struct nfs4_state_owner *sp = state->owner; in _nfs4_proc_setlk()
6077 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags)) in _nfs4_proc_setlk()
6080 status = nfs4_set_lock_state(state, request); in _nfs4_proc_setlk()
6084 status = do_vfs_lock(state->inode, request); in _nfs4_proc_setlk()
6089 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { in _nfs4_proc_setlk()
6093 status = do_vfs_lock(state->inode, request); in _nfs4_proc_setlk()
6100 status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW); in _nfs4_proc_setlk()
6106 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_setlk() argument
6109 .state = state, in nfs4_proc_setlk()
6110 .inode = state->inode, in nfs4_proc_setlk()
6115 err = _nfs4_proc_setlk(state, cmd, request); in nfs4_proc_setlk()
6116 trace_nfs4_set_lock(request, state, cmd, err); in nfs4_proc_setlk()
6119 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_setlk()
6129 struct nfs4_state *state; in nfs4_proc_lock() local
6135 state = ctx->state; in nfs4_proc_lock()
6141 if (state != NULL) in nfs4_proc_lock()
6142 return nfs4_proc_getlk(state, F_GETLK, request); in nfs4_proc_lock()
6150 if (state != NULL) in nfs4_proc_lock()
6151 return nfs4_proc_unlck(state, cmd, request); in nfs4_proc_lock()
6155 if (state == NULL) in nfs4_proc_lock()
6172 status = nfs4_proc_setlk(state, cmd, request); in nfs4_proc_lock()
6183 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid … in nfs4_lock_delegation_recall() argument
6185 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_delegation_recall()
6188 err = nfs4_set_lock_state(state, fl); in nfs4_lock_delegation_recall()
6192 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); in nfs4_lock_delegation_recall()
6197 return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err); in nfs4_lock_delegation_recall()
7825 lgp->args.ctx->state)) { in nfs4_layoutget_prepare()
7836 struct nfs4_state *state = NULL; in nfs4_layoutget_done() local
7892 &lgp->args.ctx->state->stateid)) { in nfs4_layoutget_done()
7895 state = lgp->args.ctx->state; in nfs4_layoutget_done()
7915 if (nfs4_async_handle_error(task, server, state, &lgp->timeout) == -EAGAIN) in nfs4_layoutget_done()