• Home
  • Raw
  • Download

Lines Matching refs:state

238 	struct nfs4_state *state = exception->state;  in nfs4_handle_exception()  local
248 if (state == NULL) in nfs4_handle_exception()
250 nfs4_state_mark_reclaim_nograce(clp, state); in nfs4_handle_exception()
305 struct nfs4_state *state; member
381 if (p->state != NULL) in nfs4_opendata_free()
382 nfs4_put_open_state(p->state); in nfs4_opendata_free()
403 static int can_open_cached(struct nfs4_state *state, fmode_t mode, int open_mode) in can_open_cached() argument
411 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0; in can_open_cached()
414 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0; in can_open_cached()
417 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0; in can_open_cached()
433 static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode) in update_open_stateflags() argument
437 state->n_wronly++; in update_open_stateflags()
440 state->n_rdonly++; in update_open_stateflags()
443 state->n_rdwr++; in update_open_stateflags()
445 nfs4_state_set_mode_locked(state, state->state | fmode); in update_open_stateflags()
448 static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fm… in nfs_set_open_stateid_locked() argument
450 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_set_open_stateid_locked()
451 memcpy(state->stateid.data, stateid->data, sizeof(state->stateid.data)); in nfs_set_open_stateid_locked()
452 memcpy(state->open_stateid.data, stateid->data, sizeof(state->open_stateid.data)); in nfs_set_open_stateid_locked()
455 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_set_open_stateid_locked()
458 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_set_open_stateid_locked()
461 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_set_open_stateid_locked()
465 static void nfs_set_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode) in nfs_set_open_stateid() argument
467 write_seqlock(&state->seqlock); in nfs_set_open_stateid()
468 nfs_set_open_stateid_locked(state, stateid, fmode); in nfs_set_open_stateid()
469 write_sequnlock(&state->seqlock); in nfs_set_open_stateid()
472 static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, const nfs4_… in __update_open_stateid() argument
478 write_seqlock(&state->seqlock); in __update_open_stateid()
480 memcpy(state->stateid.data, deleg_stateid->data, sizeof(state->stateid.data)); in __update_open_stateid()
481 set_bit(NFS_DELEGATED_STATE, &state->flags); in __update_open_stateid()
484 nfs_set_open_stateid_locked(state, open_stateid, fmode); in __update_open_stateid()
485 write_sequnlock(&state->seqlock); in __update_open_stateid()
486 spin_lock(&state->owner->so_lock); in __update_open_stateid()
487 update_open_stateflags(state, fmode); in __update_open_stateid()
488 spin_unlock(&state->owner->so_lock); in __update_open_stateid()
491 static int update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stateid, nfs4_stateid *… in update_open_stateid() argument
493 struct nfs_inode *nfsi = NFS_I(state->inode); in update_open_stateid()
515 __update_open_stateid(state, open_stateid, &deleg_cur->stateid, fmode); in update_open_stateid()
523 __update_open_stateid(state, open_stateid, NULL, fmode); in update_open_stateid()
547 struct nfs4_state *state = opendata->state; in nfs4_try_open_cached() local
548 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_try_open_cached()
556 if (can_open_cached(state, fmode, open_mode)) { in nfs4_try_open_cached()
557 spin_lock(&state->owner->so_lock); in nfs4_try_open_cached()
558 if (can_open_cached(state, fmode, open_mode)) { in nfs4_try_open_cached()
559 update_open_stateflags(state, fmode); in nfs4_try_open_cached()
560 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
563 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
575 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); in nfs4_try_open_cached()
581 if (update_open_stateid(state, NULL, &stateid, fmode)) in nfs4_try_open_cached()
587 atomic_inc(&state->count); in nfs4_try_open_cached()
588 return state; in nfs4_try_open_cached()
594 struct nfs4_state *state = NULL; in nfs4_opendata_to_nfs4_state() local
599 state = nfs4_try_open_cached(data); in nfs4_opendata_to_nfs4_state()
611 state = nfs4_get_open_state(inode, data->owner); in nfs4_opendata_to_nfs4_state()
612 if (state == NULL) in nfs4_opendata_to_nfs4_state()
623 nfs_inode_set_delegation(state->inode, in nfs4_opendata_to_nfs4_state()
627 nfs_inode_reclaim_delegation(state->inode, in nfs4_opendata_to_nfs4_state()
632 update_open_stateid(state, &data->o_res.stateid, NULL, in nfs4_opendata_to_nfs4_state()
636 return state; in nfs4_opendata_to_nfs4_state()
643 static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) in nfs4_state_find_open_context() argument
645 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_state_find_open_context()
648 spin_lock(&state->inode->i_lock); in nfs4_state_find_open_context()
650 if (ctx->state != state) in nfs4_state_find_open_context()
653 spin_unlock(&state->inode->i_lock); in nfs4_state_find_open_context()
656 spin_unlock(&state->inode->i_lock); in nfs4_state_find_open_context()
660 … nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_open_recoverdata_alloc() argument
664 opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, 0, NULL); in nfs4_open_recoverdata_alloc()
667 opendata->state = state; in nfs4_open_recoverdata_alloc()
668 atomic_inc(&state->count); in nfs4_open_recoverdata_alloc()
693 static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state) in nfs4_open_recover() argument
699 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_recover()
701 if (state->n_rdwr != 0) { in nfs4_open_recover()
705 if (newstate != state) in nfs4_open_recover()
708 if (state->n_wronly != 0) { in nfs4_open_recover()
712 if (newstate != state) in nfs4_open_recover()
715 if (state->n_rdonly != 0) { in nfs4_open_recover()
719 if (newstate != state) in nfs4_open_recover()
726 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 && in nfs4_open_recover()
727 memcmp(state->stateid.data, state->open_stateid.data, sizeof(state->stateid.data)) != 0) { in nfs4_open_recover()
728 write_seqlock(&state->seqlock); in nfs4_open_recover()
729 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs4_open_recover()
730 memcpy(state->stateid.data, state->open_stateid.data, sizeof(state->stateid.data)); in nfs4_open_recover()
731 write_sequnlock(&state->seqlock); in nfs4_open_recover()
740 static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_do_open_reclaim() argument
747 opendata = nfs4_open_recoverdata_alloc(ctx, state); in _nfs4_do_open_reclaim()
751 opendata->o_arg.fh = NFS_FH(state->inode); in _nfs4_do_open_reclaim()
753 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in _nfs4_do_open_reclaim()
758 status = nfs4_open_recover(opendata, state); in _nfs4_do_open_reclaim()
763 static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_reclaim() argument
765 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_reclaim()
769 err = _nfs4_do_open_reclaim(ctx, state); in nfs4_do_open_reclaim()
777 static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_reclaim() argument
782 ctx = nfs4_state_find_open_context(state); in nfs4_open_reclaim()
785 ret = nfs4_do_open_reclaim(ctx, state); in nfs4_open_reclaim()
790 static int _nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, con… in _nfs4_open_delegation_recall() argument
795 opendata = nfs4_open_recoverdata_alloc(ctx, state); in _nfs4_open_delegation_recall()
801 ret = nfs4_open_recover(opendata, state); in _nfs4_open_delegation_recall()
806 int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_… in nfs4_open_delegation_recall() argument
809 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_open_delegation_recall()
812 err = _nfs4_open_delegation_recall(ctx, state, stateid); in nfs4_open_delegation_recall()
847 struct nfs4_state *state = NULL; in nfs4_open_confirm_release() local
855 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_confirm_release()
856 if (!IS_ERR(state)) in nfs4_open_confirm_release()
857 nfs4_close_state(&data->path, state, data->o_arg.fmode); in nfs4_open_confirm_release()
918 if (data->state != NULL) { in nfs4_open_prepare()
921 if (can_open_cached(data->state, data->o_arg.fmode, data->o_arg.open_flags)) in nfs4_open_prepare()
924 delegation = rcu_dereference(NFS_I(data->state->inode)->delegation); in nfs4_open_prepare()
977 struct nfs4_state *state = NULL; in nfs4_open_release() local
988 state = nfs4_opendata_to_nfs4_state(data); in nfs4_open_release()
989 if (!IS_ERR(state)) in nfs4_open_release()
990 nfs4_close_state(&data->path, state, data->o_arg.fmode); in nfs4_open_release()
1084 static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in _nfs4_open_expired() argument
1089 opendata = nfs4_open_recoverdata_alloc(ctx, state); in _nfs4_open_expired()
1092 ret = nfs4_open_recover(opendata, state); in _nfs4_open_expired()
1099 static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) in nfs4_do_open_expired() argument
1101 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_expired()
1106 err = _nfs4_open_expired(ctx, state); in nfs4_do_open_expired()
1114 static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) in nfs4_open_expired() argument
1119 ctx = nfs4_state_find_open_context(state); in nfs4_open_expired()
1122 ret = nfs4_do_open_expired(ctx, state); in nfs4_open_expired()
1149 struct nfs4_state *state = NULL; in _nfs4_do_open() local
1171 opendata->state = nfs4_get_open_state(path->dentry->d_inode, sp); in _nfs4_do_open()
1180 state = nfs4_opendata_to_nfs4_state(opendata); in _nfs4_do_open()
1181 status = PTR_ERR(state); in _nfs4_do_open()
1182 if (IS_ERR(state)) in _nfs4_do_open()
1186 *res = state; in _nfs4_do_open()
1249 struct nfs4_state *state) in _nfs4_do_setattr() argument
1275 } else if (state != NULL) { in _nfs4_do_setattr()
1276 nfs4_copy_stateid(&arg.stateid, state, current->files); in _nfs4_do_setattr()
1281 if (status == 0 && state != NULL) in _nfs4_do_setattr()
1288 struct nfs4_state *state) in nfs4_do_setattr() argument
1295 _nfs4_do_setattr(inode, cred, fattr, sattr, state), in nfs4_do_setattr()
1304 struct nfs4_state *state; member
1314 struct nfs4_state_owner *sp = calldata->state->owner; in nfs4_free_closedata()
1316 nfs4_put_open_state(calldata->state); in nfs4_free_closedata()
1326 struct nfs4_state *state = calldata->state; in nfs4_close_done() local
1336 nfs_set_open_stateid(state, &calldata->res.stateid, 0); in nfs4_close_done()
1346 if (nfs4_async_handle_error(task, server, state) == -EAGAIN) { in nfs4_close_done()
1357 struct nfs4_state *state = calldata->state; in nfs4_close_prepare() local
1364 spin_lock(&state->owner->so_lock); in nfs4_close_prepare()
1366 if (state->n_rdwr == 0) { in nfs4_close_prepare()
1367 if (state->n_rdonly == 0) { in nfs4_close_prepare()
1368 clear_rd |= test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_close_prepare()
1369 clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
1371 if (state->n_wronly == 0) { in nfs4_close_prepare()
1372 clear_wr |= test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_close_prepare()
1373 clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
1376 spin_unlock(&state->owner->so_lock); in nfs4_close_prepare()
1383 if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) { in nfs4_close_prepare()
1386 } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) { in nfs4_close_prepare()
1411 int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) in nfs4_do_close() argument
1413 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_close()
1415 struct nfs4_state_owner *sp = state->owner; in nfs4_do_close()
1419 .rpc_cred = state->owner->so_cred, in nfs4_do_close()
1433 calldata->inode = state->inode; in nfs4_do_close()
1434 calldata->state = state; in nfs4_do_close()
1435 calldata->arg.fh = NFS_FH(state->inode); in nfs4_do_close()
1436 calldata->arg.stateid = &state->open_stateid; in nfs4_do_close()
1438 calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid); in nfs4_do_close()
1463 nfs4_put_open_state(state); in nfs4_do_close()
1468 static int nfs4_intent_set_file(struct nameidata *nd, struct path *path, struct nfs4_state *state, … in nfs4_intent_set_file() argument
1475 ret = nfs_may_open(state->inode, in nfs4_intent_set_file()
1476 state->owner->so_cred, in nfs4_intent_set_file()
1485 ctx->state = state; in nfs4_intent_set_file()
1490 nfs4_close_sync(path, state, fmode & (FMODE_READ|FMODE_WRITE)); in nfs4_intent_set_file()
1504 struct nfs4_state *state; in nfs4_atomic_open() local
1524 state = nfs4_do_open(dir, &path, fmode, nd->intent.open.flags, &attr, cred); in nfs4_atomic_open()
1526 if (IS_ERR(state)) { in nfs4_atomic_open()
1527 if (PTR_ERR(state) == -ENOENT) { in nfs4_atomic_open()
1532 return (struct dentry *)state; in nfs4_atomic_open()
1534 res = d_add_unique(dentry, igrab(state->inode)); in nfs4_atomic_open()
1539 nfs4_intent_set_file(nd, &path, state, fmode); in nfs4_atomic_open()
1551 struct nfs4_state *state; in nfs4_open_revalidate() local
1557 state = nfs4_do_open(dir, &path, fmode, openflags, NULL, cred); in nfs4_open_revalidate()
1559 if (IS_ERR(state)) { in nfs4_open_revalidate()
1560 switch (PTR_ERR(state)) { in nfs4_open_revalidate()
1566 lookup_instantiate_filp(nd, (struct dentry *)state, NULL); in nfs4_open_revalidate()
1572 if (state->inode == dentry->d_inode) { in nfs4_open_revalidate()
1574 nfs4_intent_set_file(nd, &path, state, fmode); in nfs4_open_revalidate()
1577 nfs4_close_sync(&path, state, fmode); in nfs4_open_revalidate()
1765 struct nfs4_state *state = NULL; in nfs4_proc_setattr() local
1777 state = ctx->state; in nfs4_proc_setattr()
1781 status = nfs4_do_setattr(inode, cred, fattr, sattr, state); in nfs4_proc_setattr()
2001 struct nfs4_state *state; in nfs4_proc_create() local
2011 state = nfs4_do_open(dir, &path, fmode, flags, sattr, cred); in nfs4_proc_create()
2013 if (IS_ERR(state)) { in nfs4_proc_create()
2014 status = PTR_ERR(state); in nfs4_proc_create()
2017 d_add(dentry, igrab(state->inode)); in nfs4_proc_create()
2021 status = nfs4_do_setattr(state->inode, cred, &fattr, sattr, state); in nfs4_proc_create()
2023 nfs_setattr_update_inode(state->inode, sattr); in nfs4_proc_create()
2024 nfs_post_op_update_inode(state->inode, &fattr); in nfs4_proc_create()
2027 status = nfs4_intent_set_file(nd, &path, state, fmode); in nfs4_proc_create()
2029 nfs4_close_sync(&path, state, fmode); in nfs4_proc_create()
2519 if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { in nfs4_read_done()
2540 if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { in nfs4_write_done()
2859 …sync_handle_error(struct rpc_task *task, const struct nfs_server *server, struct nfs4_state *state) in nfs4_async_handle_error() argument
2869 if (state == NULL) in nfs4_async_handle_error()
2871 nfs4_state_mark_reclaim_nograce(clp, state); in nfs4_async_handle_error()
3102 static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_getlk() argument
3104 struct inode *inode = state->inode; in _nfs4_proc_getlk()
3118 .rpc_cred = state->owner->so_cred, in _nfs4_proc_getlk()
3124 status = nfs4_set_lock_state(state, request); in _nfs4_proc_getlk()
3142 static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_getlk() argument
3148 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_getlk()
3149 _nfs4_proc_getlk(state, cmd, request), in nfs4_proc_getlk()
3295 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_unlck() argument
3297 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_proc_unlck()
3304 status = nfs4_set_lock_state(state, request); in nfs4_proc_unlck()
3316 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) in nfs4_proc_unlck()
3383 struct nfs4_state *state = data->lsp->ls_state; in nfs4_lock_prepare() local
3392 data->arg.open_stateid = &state->stateid; in nfs4_lock_prepare()
3454 static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int reclaim) in _nfs4_do_setlk() argument
3460 .rpc_cred = state->owner->so_cred, in _nfs4_do_setlk()
3463 .rpc_client = NFS_CLIENT(state->inode), in _nfs4_do_setlk()
3498 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_reclaim() argument
3500 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_reclaim()
3506 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_reclaim()
3508 err = _nfs4_do_setlk(state, F_SETLK, request, 1); in nfs4_lock_reclaim()
3516 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) in nfs4_lock_expired() argument
3518 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_expired()
3522 err = nfs4_set_lock_state(state, request); in nfs4_lock_expired()
3526 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_expired()
3528 err = _nfs4_do_setlk(state, F_SETLK, request, 0); in nfs4_lock_expired()
3536 static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in _nfs4_proc_setlk() argument
3538 struct nfs_inode *nfsi = NFS_I(state->inode); in _nfs4_proc_setlk()
3543 status = nfs4_set_lock_state(state, request); in _nfs4_proc_setlk()
3551 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { in _nfs4_proc_setlk()
3558 status = _nfs4_do_setlk(state, cmd, request, 0); in _nfs4_proc_setlk()
3572 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) in nfs4_proc_setlk() argument
3578 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_setlk()
3579 _nfs4_proc_setlk(state, cmd, request), in nfs4_proc_setlk()
3589 struct nfs4_state *state; in nfs4_proc_lock() local
3595 state = ctx->state; in nfs4_proc_lock()
3601 return nfs4_proc_getlk(state, F_GETLK, request); in nfs4_proc_lock()
3607 return nfs4_proc_unlck(state, cmd, request); in nfs4_proc_lock()
3610 status = nfs4_proc_setlk(state, cmd, request); in nfs4_proc_lock()
3621 int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) in nfs4_lock_delegation_recall() argument
3623 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_delegation_recall()
3627 err = nfs4_set_lock_state(state, fl); in nfs4_lock_delegation_recall()
3631 err = _nfs4_do_setlk(state, F_SETLK, fl, 0); in nfs4_lock_delegation_recall()