Lines Matching +full:set +full:- +full:aces

4  *  Client-side procedure declarations for NFSv4.
125 label->lfs = 0; in nfs4_label_init_security()
126 label->pi = 0; in nfs4_label_init_security()
127 label->len = 0; in nfs4_label_init_security()
128 label->label = NULL; in nfs4_label_init_security()
130 err = security_dentry_init_security(dentry, sattr->ia_mode, in nfs4_label_init_security()
131 &dentry->d_name, NULL, in nfs4_label_init_security()
132 (void **)&label->label, &label->len); in nfs4_label_init_security()
142 security_release_secctx(label->label, label->len); in nfs4_label_release_security()
147 return server->attr_bitmask; in nfs4_bitmask()
149 return server->attr_bitmask_nl; in nfs4_bitmask()
161 { return server->attr_bitmask; } in nfs4_bitmask()
167 if (err >= -1000) in nfs4_map_errors()
170 case -NFS4ERR_RESOURCE: in nfs4_map_errors()
171 case -NFS4ERR_LAYOUTTRYLATER: in nfs4_map_errors()
172 case -NFS4ERR_RECALLCONFLICT: in nfs4_map_errors()
173 case -NFS4ERR_RETURNCONFLICT: in nfs4_map_errors()
174 return -EREMOTEIO; in nfs4_map_errors()
175 case -NFS4ERR_WRONGSEC: in nfs4_map_errors()
176 case -NFS4ERR_WRONG_CRED: in nfs4_map_errors()
177 return -EPERM; in nfs4_map_errors()
178 case -NFS4ERR_BADOWNER: in nfs4_map_errors()
179 case -NFS4ERR_BADNAME: in nfs4_map_errors()
180 return -EINVAL; in nfs4_map_errors()
181 case -NFS4ERR_SHARE_DENIED: in nfs4_map_errors()
182 return -EACCES; in nfs4_map_errors()
183 case -NFS4ERR_MINOR_VERS_MISMATCH: in nfs4_map_errors()
184 return -EPROTONOSUPPORT; in nfs4_map_errors()
185 case -NFS4ERR_FILE_OPEN: in nfs4_map_errors()
186 return -EBUSY; in nfs4_map_errors()
187 case -NFS4ERR_NOT_SAME: in nfs4_map_errors()
188 return -ENOTSYNC; in nfs4_map_errors()
191 __func__, -err); in nfs4_map_errors()
194 return -EIO; in nfs4_map_errors()
299 cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags; in nfs4_bitmap_copy_adjust()
334 readdir->cookie = cookie; in nfs4_setup_readdir()
335 memcpy(&readdir->verifier, verifier, sizeof(readdir->verifier)); in nfs4_setup_readdir()
339 readdir->cookie = 0; in nfs4_setup_readdir()
340 memset(&readdir->verifier, 0, sizeof(readdir->verifier)); in nfs4_setup_readdir()
351 start = p = kmap_atomic(*readdir->pages); in nfs4_setup_readdir()
377 p = xdr_encode_hyper(p, NFS_FILEID(d_inode(dentry->d_parent))); in nfs4_setup_readdir()
379 readdir->pgbase = (char *)p - (char *)start; in nfs4_setup_readdir()
380 readdir->count -= readdir->pgbase; in nfs4_setup_readdir()
386 if (!(fattr->valid & NFS_ATTR_FATTR_PRECHANGE)) { in nfs4_fattr_set_prechange()
387 fattr->pre_change_attr = version; in nfs4_fattr_set_prechange()
388 fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; in nfs4_fattr_set_prechange()
396 const struct nfs4_minor_version_ops *ops = server->nfs_client->cl_mvops; in nfs4_test_and_free_stateid()
398 ops->test_and_free_expired(server, stateid, cred); in nfs4_test_and_free_stateid()
405 stateid->type = NFS4_REVOKED_STATEID_TYPE; in __nfs4_free_revoked_stateid()
441 return -EINTR; in nfs4_delay_killable()
452 return __fatal_signal_pending(current) ? -EINTR :-ERESTARTSYS; in nfs4_delay_interruptible()
467 switch (stateid->type) { in nfs4_recoverable_stateid()
484 struct nfs_client *clp = server->nfs_client; in nfs4_do_handle_exception()
485 struct nfs4_state *state = exception->state; in nfs4_do_handle_exception()
487 struct inode *inode = exception->inode; in nfs4_do_handle_exception()
490 exception->delay = 0; in nfs4_do_handle_exception()
491 exception->recovering = 0; in nfs4_do_handle_exception()
492 exception->retry = 0; in nfs4_do_handle_exception()
494 stateid = nfs4_recoverable_stateid(exception->stateid); in nfs4_do_handle_exception()
496 stateid = nfs4_recoverable_stateid(&state->stateid); in nfs4_do_handle_exception()
501 case -NFS4ERR_BADHANDLE: in nfs4_do_handle_exception()
502 case -ESTALE: in nfs4_do_handle_exception()
503 if (inode != NULL && S_ISREG(inode->i_mode)) in nfs4_do_handle_exception()
506 case -NFS4ERR_DELEG_REVOKED: in nfs4_do_handle_exception()
507 case -NFS4ERR_ADMIN_REVOKED: in nfs4_do_handle_exception()
508 case -NFS4ERR_EXPIRED: in nfs4_do_handle_exception()
509 case -NFS4ERR_BAD_STATEID: in nfs4_do_handle_exception()
510 case -NFS4ERR_PARTNER_NO_AUTH: in nfs4_do_handle_exception()
517 case -NFS4ERR_OPENMODE: in nfs4_do_handle_exception()
525 if (stateid != NULL && stateid->type == NFS4_DELEGATION_STATEID_TYPE) { in nfs4_do_handle_exception()
526 exception->retry = 1; in nfs4_do_handle_exception()
536 case -NFS4ERR_STALE_STATEID: in nfs4_do_handle_exception()
537 case -NFS4ERR_STALE_CLIENTID: in nfs4_do_handle_exception()
540 case -NFS4ERR_MOVED: in nfs4_do_handle_exception()
545 case -NFS4ERR_LEASE_MOVED: in nfs4_do_handle_exception()
549 case -NFS4ERR_BADSESSION: in nfs4_do_handle_exception()
550 case -NFS4ERR_BADSLOT: in nfs4_do_handle_exception()
551 case -NFS4ERR_BAD_HIGH_SLOT: in nfs4_do_handle_exception()
552 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs4_do_handle_exception()
553 case -NFS4ERR_DEADSESSION: in nfs4_do_handle_exception()
554 case -NFS4ERR_SEQ_FALSE_RETRY: in nfs4_do_handle_exception()
555 case -NFS4ERR_SEQ_MISORDERED: in nfs4_do_handle_exception()
559 case -NFS4ERR_FILE_OPEN: in nfs4_do_handle_exception()
560 if (exception->timeout > HZ) { in nfs4_do_handle_exception()
564 ret = -EBUSY; in nfs4_do_handle_exception()
568 case -NFS4ERR_DELAY: in nfs4_do_handle_exception()
571 case -NFS4ERR_GRACE: in nfs4_do_handle_exception()
572 case -NFS4ERR_LAYOUTTRYLATER: in nfs4_do_handle_exception()
573 case -NFS4ERR_RECALLCONFLICT: in nfs4_do_handle_exception()
574 case -NFS4ERR_RETURNCONFLICT: in nfs4_do_handle_exception()
575 exception->delay = 1; in nfs4_do_handle_exception()
578 case -NFS4ERR_RETRY_UNCACHED_REP: in nfs4_do_handle_exception()
579 case -NFS4ERR_OLD_STATEID: in nfs4_do_handle_exception()
580 exception->retry = 1; in nfs4_do_handle_exception()
582 case -NFS4ERR_BADOWNER: in nfs4_do_handle_exception()
584 case -NFS4ERR_BADNAME: in nfs4_do_handle_exception()
585 if (server->caps & NFS_CAP_UIDGID_NOMAP) { in nfs4_do_handle_exception()
586 server->caps &= ~NFS_CAP_UIDGID_NOMAP; in nfs4_do_handle_exception()
587 exception->retry = 1; in nfs4_do_handle_exception()
592 server->nfs_client->cl_hostname); in nfs4_do_handle_exception()
598 exception->recovering = 1; in nfs4_do_handle_exception()
604 * EAGAIN if the 'softerr' mount option is set, and we've exceeded the limit
605 * set by 'nfs_delay_retrans'.
610 if (server->flags & NFS_MOUNT_SOFTERR && nfs_delay_retrans >= 0) { in nfs4_exception_should_retrans()
611 if (exception->retrans++ >= (unsigned short)nfs_delay_retrans) in nfs4_exception_should_retrans()
612 return -EAGAIN; in nfs4_exception_should_retrans()
622 struct nfs_client *clp = server->nfs_client; in nfs4_handle_exception()
626 if (exception->delay) { in nfs4_handle_exception()
629 exception->retry = 0; in nfs4_handle_exception()
632 ret = nfs4_delay(&exception->timeout, in nfs4_handle_exception()
633 exception->interruptible); in nfs4_handle_exception()
636 if (exception->recovering) { in nfs4_handle_exception()
637 if (exception->task_is_privileged) in nfs4_handle_exception()
638 return -EDEADLOCK; in nfs4_handle_exception()
640 if (test_bit(NFS_MIG_FAILED, &server->mig_status)) in nfs4_handle_exception()
641 return -EIO; in nfs4_handle_exception()
647 exception->retry = 1; in nfs4_handle_exception()
655 struct nfs_client *clp = server->nfs_client; in nfs4_async_handle_exception()
659 if (exception->delay) { in nfs4_async_handle_exception()
662 exception->retry = 0; in nfs4_async_handle_exception()
665 rpc_delay(task, nfs4_update_delay(&exception->timeout)); in nfs4_async_handle_exception()
668 if (exception->recovering) { in nfs4_async_handle_exception()
669 if (exception->task_is_privileged) in nfs4_async_handle_exception()
670 return -EDEADLOCK; in nfs4_async_handle_exception()
671 rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL); in nfs4_async_handle_exception()
672 if (test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) == 0) in nfs4_async_handle_exception()
673 rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task); in nfs4_async_handle_exception()
676 if (test_bit(NFS_MIG_FAILED, &server->mig_status)) in nfs4_async_handle_exception()
677 ret = -EIO; in nfs4_async_handle_exception()
681 exception->retry = 1; in nfs4_async_handle_exception()
686 if (errorcode == -NFS4ERR_MOVED) in nfs4_async_handle_exception()
700 if (task->tk_status >= 0) in nfs4_async_handle_error()
704 task->tk_status = nfs4_async_handle_exception(task, server, in nfs4_async_handle_error()
705 task->tk_status, in nfs4_async_handle_error()
710 return -EAGAIN; in nfs4_async_handle_error()
720 rpc_authflavor_t flavor = clp->cl_rpcclient->cl_auth->au_flavor; in _nfs4_is_integrity_protected()
726 spin_lock(&clp->cl_lock); in do_renew_lease()
727 if (time_before(clp->cl_last_renewal,timestamp)) in do_renew_lease()
728 clp->cl_last_renewal = timestamp; in do_renew_lease()
729 spin_unlock(&clp->cl_lock); in do_renew_lease()
734 struct nfs_client *clp = server->nfs_client; in renew_lease()
750 args->sa_slot = NULL; in nfs4_init_sequence()
751 args->sa_cache_this = cache_reply; in nfs4_init_sequence()
752 args->sa_privileged = privileged; in nfs4_init_sequence()
754 res->sr_slot = NULL; in nfs4_init_sequence()
759 struct nfs4_slot *slot = res->sr_slot; in nfs40_sequence_free_slot()
762 tbl = slot->table; in nfs40_sequence_free_slot()
763 spin_lock(&tbl->slot_tbl_lock); in nfs40_sequence_free_slot()
766 spin_unlock(&tbl->slot_tbl_lock); in nfs40_sequence_free_slot()
768 res->sr_slot = NULL; in nfs40_sequence_free_slot()
774 if (res->sr_slot != NULL) in nfs40_sequence_done()
789 tbl = slot->table; in nfs41_release_slot()
790 session = tbl->session; in nfs41_release_slot()
793 if (slot->seq_done) in nfs41_release_slot()
794 slot->seq_nr++; in nfs41_release_slot()
795 slot->seq_done = 0; in nfs41_release_slot()
797 spin_lock(&tbl->slot_tbl_lock); in nfs41_release_slot()
801 if (tbl->highest_used_slotid > tbl->target_highest_slotid) in nfs41_release_slot()
810 if (tbl->highest_used_slotid != NFS4_NO_SLOT) in nfs41_release_slot()
813 spin_unlock(&tbl->slot_tbl_lock); in nfs41_release_slot()
815 nfs41_notify_server(session->clp); in nfs41_release_slot()
816 if (waitqueue_active(&tbl->slot_waitq)) in nfs41_release_slot()
817 wake_up_all(&tbl->slot_waitq); in nfs41_release_slot()
822 nfs41_release_slot(res->sr_slot); in nfs41_sequence_free_slot()
823 res->sr_slot = NULL; in nfs41_sequence_free_slot()
829 if ((s32)(seqnr - slot->seq_nr_highest_sent) > 0) in nfs4_slot_sequence_record_sent()
830 slot->seq_nr_highest_sent = seqnr; in nfs4_slot_sequence_record_sent()
835 slot->seq_nr_last_acked = seqnr; in nfs4_slot_sequence_acked()
850 struct nfs4_slot *slot = res->sr_slot; in nfs41_sequence_process()
858 if (!RPC_WAS_SENT(task) || slot->seq_done) in nfs41_sequence_process()
861 session = slot->table->session; in nfs41_sequence_process()
862 clp = session->clp; in nfs41_sequence_process()
866 status = res->sr_status; in nfs41_sequence_process()
867 if (task->tk_status == -NFS4ERR_DEADSESSION) in nfs41_sequence_process()
868 status = -NFS4ERR_DEADSESSION; in nfs41_sequence_process()
874 nfs4_slot_sequence_acked(slot, slot->seq_nr); in nfs41_sequence_process()
876 slot->seq_done = 1; in nfs41_sequence_process()
877 do_renew_lease(clp, res->sr_timestamp); in nfs41_sequence_process()
879 nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags, in nfs41_sequence_process()
880 !!slot->privileged); in nfs41_sequence_process()
881 nfs41_update_target_slotid(slot->table, slot, res); in nfs41_sequence_process()
889 nfs4_slot_sequence_record_sent(slot, slot->seq_nr); in nfs41_sequence_process()
890 slot->seq_done = 1; in nfs41_sequence_process()
892 case -NFS4ERR_DELAY: in nfs41_sequence_process()
899 slot->slot_nr, in nfs41_sequence_process()
900 slot->seq_nr); in nfs41_sequence_process()
902 case -NFS4ERR_RETRY_UNCACHED_REP: in nfs41_sequence_process()
903 case -NFS4ERR_SEQ_FALSE_RETRY: in nfs41_sequence_process()
908 nfs4_slot_sequence_acked(slot, slot->seq_nr); in nfs41_sequence_process()
910 case -NFS4ERR_BADSLOT: in nfs41_sequence_process()
915 if (slot->slot_nr < slot->table->target_highest_slotid) in nfs41_sequence_process()
918 case -NFS4ERR_SEQ_MISORDERED: in nfs41_sequence_process()
919 nfs4_slot_sequence_record_sent(slot, slot->seq_nr); in nfs41_sequence_process()
929 if ((s32)(slot->seq_nr - slot->seq_nr_last_acked) > 1) { in nfs41_sequence_process()
930 slot->seq_nr--; in nfs41_sequence_process()
931 if (task->tk_msg.rpc_proc != &nfs4_procedures[NFSPROC4_CLNT_SEQUENCE]) { in nfs41_sequence_process()
932 nfs4_probe_sequence(clp, task->tk_msg.rpc_cred, slot); in nfs41_sequence_process()
933 res->sr_slot = NULL; in nfs41_sequence_process()
947 slot->seq_nr = slot->seq_nr_highest_sent; in nfs41_sequence_process()
949 case -NFS4ERR_BADSESSION: in nfs41_sequence_process()
950 case -NFS4ERR_DEADSESSION: in nfs41_sequence_process()
951 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs41_sequence_process()
955 slot->seq_done = 1; in nfs41_sequence_process()
959 dprintk("%s: Error %d free the slot \n", __func__, res->sr_status); in nfs41_sequence_process()
963 set_bit(NFS4_SLOT_TBL_DRAINING, &session->fc_slot_table.slot_tbl_state); in nfs41_sequence_process()
969 ++slot->seq_nr; in nfs41_sequence_process()
973 task->tk_status = 0; in nfs41_sequence_process()
988 if (res->sr_slot != NULL) in nfs41_sequence_done()
997 if (res->sr_slot == NULL) in nfs4_sequence_process()
999 if (res->sr_slot->table->session != NULL) in nfs4_sequence_process()
1006 if (res->sr_slot != NULL) { in nfs4_sequence_free_slot()
1007 if (res->sr_slot->table->session != NULL) in nfs4_sequence_free_slot()
1016 if (res->sr_slot == NULL) in nfs4_sequence_done()
1018 if (!res->sr_slot->table->session) in nfs4_sequence_done()
1028 dprintk("--> %s data->seq_server %p\n", __func__, data->seq_server); in nfs41_call_sync_prepare()
1030 nfs4_setup_sequence(data->seq_server->nfs_client, in nfs41_call_sync_prepare()
1031 data->seq_args, data->seq_res, task); in nfs41_call_sync_prepare()
1038 nfs41_sequence_done(task, data->seq_res); in nfs41_call_sync_done()
1055 if (res->sr_slot != NULL) in nfs4_sequence_free_slot()
1070 res->sr_timestamp = jiffies; in nfs41_sequence_res_init()
1071 res->sr_status_flags = 0; in nfs41_sequence_res_init()
1072 res->sr_status = 1; in nfs41_sequence_res_init()
1082 slot->privileged = args->sa_privileged ? 1 : 0; in nfs4_sequence_attach_slot()
1083 args->sa_slot = slot; in nfs4_sequence_attach_slot()
1085 res->sr_slot = slot; in nfs4_sequence_attach_slot()
1094 struct nfs4_slot_table *tbl = client->cl_slot_tbl; in nfs4_setup_sequence()
1098 if (res->sr_slot != NULL) in nfs4_setup_sequence()
1102 tbl = &session->fc_slot_table; in nfs4_setup_sequence()
1104 spin_lock(&tbl->slot_tbl_lock); in nfs4_setup_sequence()
1106 if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) in nfs4_setup_sequence()
1111 if (slot == ERR_PTR(-ENOMEM)) in nfs4_setup_sequence()
1115 spin_unlock(&tbl->slot_tbl_lock); in nfs4_setup_sequence()
1126 if (args->sa_privileged) in nfs4_setup_sequence()
1127 rpc_sleep_on_priority_timeout(&tbl->slot_tbl_waitq, task, in nfs4_setup_sequence()
1130 rpc_sleep_on_timeout(&tbl->slot_tbl_waitq, task, in nfs4_setup_sequence()
1132 spin_unlock(&tbl->slot_tbl_lock); in nfs4_setup_sequence()
1133 return -EAGAIN; in nfs4_setup_sequence()
1135 if (args->sa_privileged) in nfs4_setup_sequence()
1136 rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task, in nfs4_setup_sequence()
1139 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); in nfs4_setup_sequence()
1140 spin_unlock(&tbl->slot_tbl_lock); in nfs4_setup_sequence()
1141 return -EAGAIN; in nfs4_setup_sequence()
1148 nfs4_setup_sequence(data->seq_server->nfs_client, in nfs40_call_sync_prepare()
1149 data->seq_args, data->seq_res, task); in nfs40_call_sync_prepare()
1155 nfs4_sequence_done(task, data->seq_res); in nfs40_call_sync_done()
1172 ret = task->tk_status; in nfs4_call_sync_custom()
1184 struct nfs_client *clp = server->nfs_client; in nfs4_do_call_sync()
1193 .callback_ops = clp->cl_mvops->call_sync_ops, in nfs4_do_call_sync()
1209 if (server->caps & NFS_CAP_MOVEABLE) in nfs4_call_sync_sequence()
1238 spin_lock(&inode->i_lock); in nfs4_inc_nlink()
1240 spin_unlock(&inode->i_lock); in nfs4_inc_nlink()
1262 if (S_ISDIR(inode->i_mode)) in nfs4_update_changeattr_locked()
1265 switch (NFS_SERVER(inode)->change_attr_type) { in nfs4_update_changeattr_locked()
1267 if (cinfo->after == change_attr) in nfs4_update_changeattr_locked()
1271 if ((s64)(change_attr - cinfo->after) >= 0) in nfs4_update_changeattr_locked()
1275 inode_set_iversion_raw(inode, cinfo->after); in nfs4_update_changeattr_locked()
1276 if (!cinfo->atomic || cinfo->before != change_attr) { in nfs4_update_changeattr_locked()
1277 if (S_ISDIR(inode->i_mode)) in nfs4_update_changeattr_locked()
1286 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); in nfs4_update_changeattr_locked()
1288 nfsi->attrtimeo_timestamp = jiffies; in nfs4_update_changeattr_locked()
1289 nfsi->read_cache_jiffies = timestamp; in nfs4_update_changeattr_locked()
1290 nfsi->attr_gencount = nfs_inc_attr_generation_counter(); in nfs4_update_changeattr_locked()
1291 nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE; in nfs4_update_changeattr_locked()
1300 spin_lock(&dir->i_lock); in nfs4_update_changeattr()
1302 spin_unlock(&dir->i_lock); in nfs4_update_changeattr()
1314 if (err != -EINVAL) in nfs4_clear_cap_atomic_open_v1()
1316 if (!(server->caps & NFS_CAP_ATOMIC_OPEN_V1)) in nfs4_clear_cap_atomic_open_v1()
1318 server->caps &= ~NFS_CAP_ATOMIC_OPEN_V1; in nfs4_clear_cap_atomic_open_v1()
1319 exception->retry = 1; in nfs4_clear_cap_atomic_open_v1()
1325 return ctx->mode & (FMODE_READ|FMODE_WRITE|FMODE_EXEC); in _nfs4_ctx_to_accessmode()
1330 fmode_t ret = ctx->mode & (FMODE_READ|FMODE_WRITE); in _nfs4_ctx_to_openmode()
1332 return (ctx->mode & FMODE_EXEC) ? FMODE_READ | ret : ret; in _nfs4_ctx_to_openmode()
1359 if (!(server->caps & NFS_CAP_ATOMIC_OPEN_V1)) in nfs4_map_atomic_open_share()
1367 if (server->caps & NFS_CAP_DELEGTIME) in nfs4_map_atomic_open_share()
1369 if (server->caps & NFS_CAP_OPEN_XOR) in nfs4_map_atomic_open_share()
1379 if (server->caps & NFS_CAP_ATOMIC_OPEN_V1) in nfs4_map_atomic_open_claim()
1395 p->o_res.f_attr = &p->f_attr; in nfs4_init_opendata_res()
1396 p->o_res.seqid = p->o_arg.seqid; in nfs4_init_opendata_res()
1397 p->c_res.seqid = p->c_arg.seqid; in nfs4_init_opendata_res()
1398 p->o_res.server = p->o_arg.server; in nfs4_init_opendata_res()
1399 p->o_res.access_request = p->o_arg.access; in nfs4_init_opendata_res()
1400 nfs_fattr_init(&p->f_attr); in nfs4_init_opendata_res()
1401 nfs_fattr_init_names(&p->f_attr, &p->owner_name, &p->group_name); in nfs4_init_opendata_res()
1414 struct nfs4_label *label = (c != NULL) ? c->label : NULL; in nfs4_opendata_alloc()
1421 p->f_attr.label = nfs4_label_alloc(server, gfp_mask); in nfs4_opendata_alloc()
1422 if (IS_ERR(p->f_attr.label)) in nfs4_opendata_alloc()
1425 p->a_label = nfs4_label_alloc(server, gfp_mask); in nfs4_opendata_alloc()
1426 if (IS_ERR(p->a_label)) in nfs4_opendata_alloc()
1429 alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid; in nfs4_opendata_alloc()
1430 p->o_arg.seqid = alloc_seqid(&sp->so_seqid, gfp_mask); in nfs4_opendata_alloc()
1431 if (IS_ERR(p->o_arg.seqid)) in nfs4_opendata_alloc()
1433 nfs_sb_active(dentry->d_sb); in nfs4_opendata_alloc()
1434 p->dentry = dget(dentry); in nfs4_opendata_alloc()
1435 p->dir = parent; in nfs4_opendata_alloc()
1436 p->owner = sp; in nfs4_opendata_alloc()
1437 atomic_inc(&sp->so_count); in nfs4_opendata_alloc()
1438 p->o_arg.open_flags = flags; in nfs4_opendata_alloc()
1439 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); in nfs4_opendata_alloc()
1440 p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim); in nfs4_opendata_alloc()
1441 p->o_arg.share_access = nfs4_map_atomic_open_share(server, in nfs4_opendata_alloc()
1444 p->o_arg.umask = current_umask(); in nfs4_opendata_alloc()
1445 p->o_arg.label = nfs4_label_copy(p->a_label, label); in nfs4_opendata_alloc()
1446 if (c->sattr != NULL && c->sattr->ia_valid != 0) { in nfs4_opendata_alloc()
1447 p->o_arg.u.attrs = &p->attrs; in nfs4_opendata_alloc()
1448 memcpy(&p->attrs, c->sattr, sizeof(p->attrs)); in nfs4_opendata_alloc()
1450 memcpy(p->o_arg.u.verifier.data, c->verf, in nfs4_opendata_alloc()
1451 sizeof(p->o_arg.u.verifier.data)); in nfs4_opendata_alloc()
1456 switch (p->o_arg.claim) { in nfs4_opendata_alloc()
1461 p->o_arg.access = NFS4_ACCESS_READ | NFS4_ACCESS_MODIFY | in nfs4_opendata_alloc()
1466 p->o_arg.clientid = server->nfs_client->cl_clientid; in nfs4_opendata_alloc()
1467 p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time); in nfs4_opendata_alloc()
1468 p->o_arg.id.uniquifier = sp->so_seqid.owner_id; in nfs4_opendata_alloc()
1469 p->o_arg.name = &dentry->d_name; in nfs4_opendata_alloc()
1470 p->o_arg.server = server; in nfs4_opendata_alloc()
1471 p->o_arg.bitmask = nfs4_bitmask(server, label); in nfs4_opendata_alloc()
1472 p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0]; in nfs4_opendata_alloc()
1473 switch (p->o_arg.claim) { in nfs4_opendata_alloc()
1477 p->o_arg.fh = NFS_FH(dir); in nfs4_opendata_alloc()
1483 p->o_arg.fh = NFS_FH(d_inode(dentry)); in nfs4_opendata_alloc()
1485 p->c_arg.fh = &p->o_res.fh; in nfs4_opendata_alloc()
1486 p->c_arg.stateid = &p->o_res.stateid; in nfs4_opendata_alloc()
1487 p->c_arg.seqid = p->o_arg.seqid; in nfs4_opendata_alloc()
1489 kref_init(&p->kref); in nfs4_opendata_alloc()
1493 nfs4_label_free(p->a_label); in nfs4_opendata_alloc()
1495 nfs4_label_free(p->f_attr.label); in nfs4_opendata_alloc()
1507 struct super_block *sb = p->dentry->d_sb; in nfs4_opendata_free()
1509 nfs4_lgopen_release(p->lgp); in nfs4_opendata_free()
1510 nfs_free_seqid(p->o_arg.seqid); in nfs4_opendata_free()
1511 nfs4_sequence_free_slot(&p->o_res.seq_res); in nfs4_opendata_free()
1512 if (p->state != NULL) in nfs4_opendata_free()
1513 nfs4_put_open_state(p->state); in nfs4_opendata_free()
1514 nfs4_put_state_owner(p->owner); in nfs4_opendata_free()
1516 nfs4_label_free(p->a_label); in nfs4_opendata_free()
1517 nfs4_label_free(p->f_attr.label); in nfs4_opendata_free()
1519 dput(p->dir); in nfs4_opendata_free()
1520 dput(p->dentry); in nfs4_opendata_free()
1522 nfs_fattr_free_names(&p->f_attr); in nfs4_opendata_free()
1523 kfree(p->f_attr.mdsthreshold); in nfs4_opendata_free()
1530 kref_put(&p->kref, nfs4_opendata_free); in nfs4_opendata_put()
1538 return state->n_rdwr != 0; in nfs4_mode_match_open_stateid()
1540 return state->n_wronly != 0; in nfs4_mode_match_open_stateid()
1542 return state->n_rdonly != 0; in nfs4_mode_match_open_stateid()
1564 ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 in can_open_cached()
1565 && state->n_rdonly != 0; in can_open_cached()
1568 ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 in can_open_cached()
1569 && state->n_wronly != 0; in can_open_cached()
1572 ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 in can_open_cached()
1573 && state->n_rdwr != 0; in can_open_cached()
1584 if ((delegation->type & fmode) != fmode) in can_open_delegated()
1591 if (!test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags)) in can_open_delegated()
1605 state->n_wronly++; in update_open_stateflags()
1608 state->n_rdonly++; in update_open_stateflags()
1611 state->n_rdwr++; in update_open_stateflags()
1613 nfs4_state_set_mode_locked(state, state->state | fmode); in update_open_stateflags()
1619 if (state->n_rdonly && !test_bit(NFS_O_RDONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1621 if (state->n_wronly && !test_bit(NFS_O_WRONLY_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1623 if (state->n_rdwr && !test_bit(NFS_O_RDWR_STATE, &state->flags)) in nfs_open_stateid_recover_openmode()
1631 if (test_and_clear_bit(NFS_STATE_CHANGE_WAIT, &state->flags)) in nfs_state_log_update_open_stateid()
1632 wake_up_all(&state->waitq); in nfs_state_log_update_open_stateid()
1637 struct nfs_client *clp = state->owner->so_server->nfs_client; in nfs_test_and_clear_all_open_stateid()
1640 if (test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags) && state->n_rdonly) in nfs_test_and_clear_all_open_stateid()
1642 if (test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags) && state->n_wronly) in nfs_test_and_clear_all_open_stateid()
1644 if (test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags) && state->n_rdwr) in nfs_test_and_clear_all_open_stateid()
1663 if (test_bit(NFS_OPEN_STATE, &state->flags)) { in nfs_stateid_is_sequential()
1664 /* The common case - we're updating to a new sequence number */ in nfs_stateid_is_sequential()
1665 if (nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_stateid_is_sequential()
1666 if (nfs4_stateid_is_next(&state->open_stateid, stateid)) in nfs_stateid_is_sequential()
1673 if (stateid->seqid == cpu_to_be32(1)) in nfs_stateid_is_sequential()
1680 if (!(state->n_wronly || state->n_rdonly || state->n_rdwr)) in nfs_resync_open_stateid_locked()
1682 if (state->n_wronly) in nfs_resync_open_stateid_locked()
1683 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1684 if (state->n_rdonly) in nfs_resync_open_stateid_locked()
1685 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1686 if (state->n_rdwr) in nfs_resync_open_stateid_locked()
1687 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1688 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_resync_open_stateid_locked()
1694 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1697 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1700 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1703 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1704 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1705 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_clear_open_stateid_locked()
1710 if (nfs4_stateid_match_other(stateid, &state->open_stateid) && in nfs_clear_open_stateid_locked()
1711 !nfs4_stateid_is_newer(stateid, &state->open_stateid)) { in nfs_clear_open_stateid_locked()
1715 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_clear_open_stateid_locked()
1716 nfs4_stateid_copy(&state->stateid, stateid); in nfs_clear_open_stateid_locked()
1717 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_clear_open_stateid_locked()
1718 trace_nfs4_open_stateid_update(state->inode, stateid, 0); in nfs_clear_open_stateid_locked()
1727 write_seqlock(&state->seqlock); in nfs_clear_open_stateid()
1731 write_sequnlock(&state->seqlock); in nfs_clear_open_stateid()
1732 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in nfs_clear_open_stateid()
1733 nfs4_schedule_state_manager(state->owner->so_server->nfs_client); in nfs_clear_open_stateid()
1738 __must_hold(&state->owner->so_lock) in nfs_set_open_stateid_locked()
1739 __must_hold(&state->seqlock) in nfs_set_open_stateid_locked()
1753 if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client)) in nfs_set_open_stateid_locked()
1756 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs_set_open_stateid_locked()
1757 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs_set_open_stateid_locked()
1763 write_sequnlock(&state->seqlock); in nfs_set_open_stateid_locked()
1764 spin_unlock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1766 trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); in nfs_set_open_stateid_locked()
1770 status = -EAGAIN; in nfs_set_open_stateid_locked()
1774 status = -EINTR; in nfs_set_open_stateid_locked()
1775 finish_wait(&state->waitq, &wait); in nfs_set_open_stateid_locked()
1777 spin_lock(&state->owner->so_lock); in nfs_set_open_stateid_locked()
1778 write_seqlock(&state->seqlock); in nfs_set_open_stateid_locked()
1781 if (test_bit(NFS_OPEN_STATE, &state->flags) && in nfs_set_open_stateid_locked()
1782 !nfs4_stateid_match_other(stateid, &state->open_stateid)) { in nfs_set_open_stateid_locked()
1783 nfs4_stateid_copy(freeme, &state->open_stateid); in nfs_set_open_stateid_locked()
1787 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs_set_open_stateid_locked()
1788 nfs4_stateid_copy(&state->stateid, stateid); in nfs_set_open_stateid_locked()
1789 nfs4_stateid_copy(&state->open_stateid, stateid); in nfs_set_open_stateid_locked()
1790 trace_nfs4_open_stateid_update(state->inode, stateid, status); in nfs_set_open_stateid_locked()
1803 write_seqlock(&state->seqlock); in nfs_state_set_open_stateid()
1807 set_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1810 set_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_set_open_stateid()
1813 set_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_set_open_stateid()
1815 set_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_set_open_stateid()
1816 write_sequnlock(&state->seqlock); in nfs_state_set_open_stateid()
1821 clear_bit(NFS_O_RDWR_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1822 clear_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1823 clear_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1824 clear_bit(NFS_OPEN_STATE, &state->flags); in nfs_state_clear_open_state_flags()
1835 write_seqlock(&state->seqlock); in nfs_state_set_delegation()
1836 nfs4_stateid_copy(&state->stateid, deleg_stateid); in nfs_state_set_delegation()
1837 set_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_set_delegation()
1838 write_sequnlock(&state->seqlock); in nfs_state_set_delegation()
1843 write_seqlock(&state->seqlock); in nfs_state_clear_delegation()
1844 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs_state_clear_delegation()
1845 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs_state_clear_delegation()
1846 write_sequnlock(&state->seqlock); in nfs_state_clear_delegation()
1854 struct nfs_server *server = NFS_SERVER(state->inode); in update_open_stateid()
1855 struct nfs_client *clp = server->nfs_client; in update_open_stateid()
1856 struct nfs_inode *nfsi = NFS_I(state->inode); in update_open_stateid()
1864 spin_lock(&state->owner->so_lock); in update_open_stateid()
1870 deleg_cur = nfs4_get_valid_delegation(state->inode); in update_open_stateid()
1874 spin_lock(&deleg_cur->lock); in update_open_stateid()
1875 if (rcu_dereference(nfsi->delegation) != deleg_cur || in update_open_stateid()
1876 test_bit(NFS_DELEGATION_RETURNING, &deleg_cur->flags) || in update_open_stateid()
1877 (deleg_cur->type & fmode) != fmode) in update_open_stateid()
1881 delegation = &deleg_cur->stateid; in update_open_stateid()
1882 else if (!nfs4_stateid_match_other(&deleg_cur->stateid, delegation)) in update_open_stateid()
1886 nfs_state_set_delegation(state, &deleg_cur->stateid, fmode); in update_open_stateid()
1889 spin_unlock(&deleg_cur->lock); in update_open_stateid()
1893 spin_unlock(&state->owner->so_lock); in update_open_stateid()
1896 if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) in update_open_stateid()
1900 state->owner->so_cred); in update_open_stateid()
1908 struct nfs4_state *state = lsp->ls_state; in nfs4_update_lock_stateid()
1911 spin_lock(&state->state_lock); in nfs4_update_lock_stateid()
1912 if (!nfs4_stateid_match_other(stateid, &lsp->ls_stateid)) in nfs4_update_lock_stateid()
1914 if (!nfs4_stateid_is_newer(stateid, &lsp->ls_stateid)) in nfs4_update_lock_stateid()
1916 nfs4_stateid_copy(&lsp->ls_stateid, stateid); in nfs4_update_lock_stateid()
1919 spin_unlock(&state->state_lock); in nfs4_update_lock_stateid()
1930 if (delegation == NULL || (delegation->type & fmode) == fmode) { in nfs4_return_incompatible_delegation()
1940 struct nfs4_state *state = opendata->state; in nfs4_try_open_cached()
1942 int open_mode = opendata->o_arg.open_flags; in nfs4_try_open_cached()
1943 fmode_t fmode = opendata->o_arg.fmode; in nfs4_try_open_cached()
1944 enum open_claim_type4 claim = opendata->o_arg.claim; in nfs4_try_open_cached()
1946 int ret = -EAGAIN; in nfs4_try_open_cached()
1949 spin_lock(&state->owner->so_lock); in nfs4_try_open_cached()
1952 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1955 spin_unlock(&state->owner->so_lock); in nfs4_try_open_cached()
1957 delegation = nfs4_get_valid_delegation(state->inode); in nfs4_try_open_cached()
1963 nfs4_stateid_copy(&stateid, &delegation->stateid); in nfs4_try_open_cached()
1965 nfs_release_seqid(opendata->o_arg.seqid); in nfs4_try_open_cached()
1966 if (!opendata->is_recover) { in nfs4_try_open_cached()
1967 ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); in nfs4_try_open_cached()
1971 ret = -EAGAIN; in nfs4_try_open_cached()
1980 refcount_inc(&state->count); in nfs4_try_open_cached()
1989 switch (delegation->open_delegation_type) { in nfs4_process_delegation()
2004 NFS_SERVER(inode)->nfs_client->cl_hostname); in nfs4_process_delegation()
2007 nfs_inode_reclaim_delegation(inode, cred, delegation->type, in nfs4_process_delegation()
2008 &delegation->stateid, in nfs4_process_delegation()
2009 delegation->pagemod_limit, in nfs4_process_delegation()
2010 delegation->open_delegation_type); in nfs4_process_delegation()
2013 nfs_inode_set_delegation(inode, cred, delegation->type, in nfs4_process_delegation()
2014 &delegation->stateid, in nfs4_process_delegation()
2015 delegation->pagemod_limit, in nfs4_process_delegation()
2016 delegation->open_delegation_type); in nfs4_process_delegation()
2018 if (delegation->do_recall) in nfs4_process_delegation()
2019 nfs_async_inode_return_delegation(inode, &delegation->stateid); in nfs4_process_delegation()
2029 struct inode *inode = data->state->inode; in _nfs4_opendata_reclaim_to_nfs4_state()
2030 struct nfs4_state *state = data->state; in _nfs4_opendata_reclaim_to_nfs4_state()
2033 if (!data->rpc_done) { in _nfs4_opendata_reclaim_to_nfs4_state()
2034 if (data->rpc_status) in _nfs4_opendata_reclaim_to_nfs4_state()
2035 return ERR_PTR(data->rpc_status); in _nfs4_opendata_reclaim_to_nfs4_state()
2039 ret = nfs_refresh_inode(inode, &data->f_attr); in _nfs4_opendata_reclaim_to_nfs4_state()
2043 nfs4_process_delegation(state->inode, in _nfs4_opendata_reclaim_to_nfs4_state()
2044 data->owner->so_cred, in _nfs4_opendata_reclaim_to_nfs4_state()
2045 data->o_arg.claim, in _nfs4_opendata_reclaim_to_nfs4_state()
2046 &data->o_res.delegation); in _nfs4_opendata_reclaim_to_nfs4_state()
2048 if (!(data->o_res.rflags & NFS4_OPEN_RESULT_NO_OPEN_STATEID)) { in _nfs4_opendata_reclaim_to_nfs4_state()
2049 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_reclaim_to_nfs4_state()
2050 NULL, data->o_arg.fmode)) in _nfs4_opendata_reclaim_to_nfs4_state()
2051 return ERR_PTR(-EAGAIN); in _nfs4_opendata_reclaim_to_nfs4_state()
2052 } else if (!update_open_stateid(state, NULL, NULL, data->o_arg.fmode)) in _nfs4_opendata_reclaim_to_nfs4_state()
2053 return ERR_PTR(-EAGAIN); in _nfs4_opendata_reclaim_to_nfs4_state()
2054 refcount_inc(&state->count); in _nfs4_opendata_reclaim_to_nfs4_state()
2064 switch (data->o_arg.claim) { in nfs4_opendata_get_inode()
2068 if (!(data->f_attr.valid & NFS_ATTR_FATTR)) in nfs4_opendata_get_inode()
2069 return ERR_PTR(-EAGAIN); in nfs4_opendata_get_inode()
2070 inode = nfs_fhget(data->dir->d_sb, &data->o_res.fh, in nfs4_opendata_get_inode()
2071 &data->f_attr); in nfs4_opendata_get_inode()
2074 inode = d_inode(data->dentry); in nfs4_opendata_get_inode()
2076 nfs_refresh_inode(inode, &data->f_attr); in nfs4_opendata_get_inode()
2090 if (data->state != NULL && data->state->inode == inode) { in nfs4_opendata_find_nfs4_state()
2091 state = data->state; in nfs4_opendata_find_nfs4_state()
2092 refcount_inc(&state->count); in nfs4_opendata_find_nfs4_state()
2094 state = nfs4_get_open_state(inode, data->owner); in nfs4_opendata_find_nfs4_state()
2097 state = ERR_PTR(-ENOMEM); in nfs4_opendata_find_nfs4_state()
2106 if (!data->rpc_done) { in _nfs4_opendata_to_nfs4_state()
2108 trace_nfs4_cached_open(data->state); in _nfs4_opendata_to_nfs4_state()
2116 nfs4_process_delegation(state->inode, in _nfs4_opendata_to_nfs4_state()
2117 data->owner->so_cred, in _nfs4_opendata_to_nfs4_state()
2118 data->o_arg.claim, in _nfs4_opendata_to_nfs4_state()
2119 &data->o_res.delegation); in _nfs4_opendata_to_nfs4_state()
2121 if (!(data->o_res.rflags & NFS4_OPEN_RESULT_NO_OPEN_STATEID)) { in _nfs4_opendata_to_nfs4_state()
2122 if (!update_open_stateid(state, &data->o_res.stateid, in _nfs4_opendata_to_nfs4_state()
2123 NULL, data->o_arg.fmode)) { in _nfs4_opendata_to_nfs4_state()
2125 state = ERR_PTR(-EAGAIN); in _nfs4_opendata_to_nfs4_state()
2127 } else if (!update_open_stateid(state, NULL, NULL, data->o_arg.fmode)) { in _nfs4_opendata_to_nfs4_state()
2129 state = ERR_PTR(-EAGAIN); in _nfs4_opendata_to_nfs4_state()
2132 nfs_release_seqid(data->o_arg.seqid); in _nfs4_opendata_to_nfs4_state()
2141 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) in nfs4_opendata_to_nfs4_state()
2145 nfs4_sequence_free_slot(&data->o_res.seq_res); in nfs4_opendata_to_nfs4_state()
2152 struct nfs_inode *nfsi = NFS_I(state->inode); in nfs4_state_find_open_context_mode()
2156 list_for_each_entry_rcu(ctx, &nfsi->open_files, list) { in nfs4_state_find_open_context_mode()
2157 if (ctx->state != state) in nfs4_state_find_open_context_mode()
2159 if ((ctx->mode & mode) != mode) in nfs4_state_find_open_context_mode()
2167 return ERR_PTR(-ENOENT); in nfs4_state_find_open_context_mode()
2189 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, in nfs4_open_recoverdata_alloc()
2192 return ERR_PTR(-ENOMEM); in nfs4_open_recoverdata_alloc()
2193 opendata->state = state; in nfs4_open_recoverdata_alloc()
2194 refcount_inc(&state->count); in nfs4_open_recoverdata_alloc()
2202 struct nfs_server *server = NFS_SB(opendata->dentry->d_sb); in nfs4_open_recover_helper()
2203 int openflags = opendata->o_arg.open_flags; in nfs4_open_recover_helper()
2206 if (!nfs4_mode_match_open_stateid(opendata->state, fmode)) in nfs4_open_recover_helper()
2208 opendata->o_arg.fmode = fmode; in nfs4_open_recover_helper()
2209 opendata->o_arg.share_access = in nfs4_open_recover_helper()
2211 memset(&opendata->o_res, 0, sizeof(opendata->o_res)); in nfs4_open_recover_helper()
2212 memset(&opendata->c_res, 0, sizeof(opendata->c_res)); in nfs4_open_recover_helper()
2220 if (newstate != opendata->state) in nfs4_open_recover_helper()
2221 ret = -ESTALE; in nfs4_open_recover_helper()
2230 /* memory barrier prior to reading state->n_* */ in nfs4_open_recover()
2245 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0 && in nfs4_open_recover()
2246 !nfs4_stateid_match(&state->stateid, &state->open_stateid)) { in nfs4_open_recover()
2247 write_seqlock(&state->seqlock); in nfs4_open_recover()
2248 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) in nfs4_open_recover()
2249 nfs4_stateid_copy(&state->stateid, &state->open_stateid); in nfs4_open_recover()
2250 write_sequnlock(&state->seqlock); in nfs4_open_recover()
2271 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in _nfs4_do_open_reclaim()
2272 if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0) { in _nfs4_do_open_reclaim()
2273 switch(delegation->type) { in _nfs4_do_open_reclaim()
2276 if (test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) in _nfs4_do_open_reclaim()
2282 if (test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) in _nfs4_do_open_reclaim()
2287 opendata->o_arg.u.delegation_type = delegation_type; in _nfs4_do_open_reclaim()
2295 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_reclaim()
2303 if (err != -NFS4ERR_DELAY) in nfs4_do_open_reclaim()
2317 return -EAGAIN; in nfs4_open_reclaim()
2318 clear_bit(NFS_DELEGATED_STATE, &state->flags); in nfs4_open_reclaim()
2333 case -ENOENT: in nfs4_handle_delegation_recall_error()
2334 case -EAGAIN: in nfs4_handle_delegation_recall_error()
2335 case -ESTALE: in nfs4_handle_delegation_recall_error()
2336 case -ETIMEDOUT: in nfs4_handle_delegation_recall_error()
2338 case -NFS4ERR_BADSESSION: in nfs4_handle_delegation_recall_error()
2339 case -NFS4ERR_BADSLOT: in nfs4_handle_delegation_recall_error()
2340 case -NFS4ERR_BAD_HIGH_SLOT: in nfs4_handle_delegation_recall_error()
2341 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs4_handle_delegation_recall_error()
2342 case -NFS4ERR_DEADSESSION: in nfs4_handle_delegation_recall_error()
2343 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2344 case -NFS4ERR_STALE_CLIENTID: in nfs4_handle_delegation_recall_error()
2345 case -NFS4ERR_STALE_STATEID: in nfs4_handle_delegation_recall_error()
2347 nfs4_schedule_lease_recovery(server->nfs_client); in nfs4_handle_delegation_recall_error()
2348 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2349 case -NFS4ERR_MOVED: in nfs4_handle_delegation_recall_error()
2351 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2352 case -NFS4ERR_LEASE_MOVED: in nfs4_handle_delegation_recall_error()
2353 nfs4_schedule_lease_moved_recovery(server->nfs_client); in nfs4_handle_delegation_recall_error()
2354 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2355 case -NFS4ERR_DELEG_REVOKED: in nfs4_handle_delegation_recall_error()
2356 case -NFS4ERR_ADMIN_REVOKED: in nfs4_handle_delegation_recall_error()
2357 case -NFS4ERR_EXPIRED: in nfs4_handle_delegation_recall_error()
2358 case -NFS4ERR_BAD_STATEID: in nfs4_handle_delegation_recall_error()
2359 case -NFS4ERR_OPENMODE: in nfs4_handle_delegation_recall_error()
2360 nfs_inode_find_state_and_recover(state->inode, in nfs4_handle_delegation_recall_error()
2363 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2364 case -NFS4ERR_DELAY: in nfs4_handle_delegation_recall_error()
2365 case -NFS4ERR_GRACE: in nfs4_handle_delegation_recall_error()
2367 return -EAGAIN; in nfs4_handle_delegation_recall_error()
2368 case -ENOMEM: in nfs4_handle_delegation_recall_error()
2369 case -NFS4ERR_DENIED: in nfs4_handle_delegation_recall_error()
2371 struct nfs4_lock_state *lsp = fl->fl_u.nfs4_fl.owner; in nfs4_handle_delegation_recall_error()
2373 set_bit(NFS_LOCK_LOST, &lsp->ls_flags); in nfs4_handle_delegation_recall_error()
2383 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_open_delegation_recall()
2391 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); in nfs4_open_delegation_recall()
2392 if (!test_bit(NFS_O_RDWR_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2397 if (!test_bit(NFS_O_WRONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2402 if (!test_bit(NFS_O_RDONLY_STATE, &state->flags)) { in nfs4_open_delegation_recall()
2417 nfs4_setup_sequence(data->o_arg.server->nfs_client, in nfs4_open_confirm_prepare()
2418 &data->c_arg.seq_args, &data->c_res.seq_res, task); in nfs4_open_confirm_prepare()
2425 nfs40_sequence_done(task, &data->c_res.seq_res); in nfs4_open_confirm_done()
2427 data->rpc_status = task->tk_status; in nfs4_open_confirm_done()
2428 if (data->rpc_status == 0) { in nfs4_open_confirm_done()
2429 nfs4_stateid_copy(&data->o_res.stateid, &data->c_res.stateid); in nfs4_open_confirm_done()
2430 nfs_confirm_seqid(&data->owner->so_seqid, 0); in nfs4_open_confirm_done()
2431 renew_lease(data->o_res.server, data->timestamp); in nfs4_open_confirm_done()
2432 data->rpc_done = true; in nfs4_open_confirm_done()
2442 if (!data->cancelled) in nfs4_open_confirm_release()
2445 if (!data->rpc_done) in nfs4_open_confirm_release()
2449 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_confirm_release()
2465 struct nfs_server *server = NFS_SERVER(d_inode(data->dir)); in _nfs4_proc_open_confirm()
2469 .rpc_argp = &data->c_arg, in _nfs4_proc_open_confirm()
2470 .rpc_resp = &data->c_res, in _nfs4_proc_open_confirm()
2471 .rpc_cred = data->owner->so_cred, in _nfs4_proc_open_confirm()
2474 .rpc_client = server->client, in _nfs4_proc_open_confirm()
2483 nfs4_init_sequence(&data->c_arg.seq_args, &data->c_res.seq_res, 1, in _nfs4_proc_open_confirm()
2484 data->is_recover); in _nfs4_proc_open_confirm()
2485 kref_get(&data->kref); in _nfs4_proc_open_confirm()
2486 data->rpc_done = false; in _nfs4_proc_open_confirm()
2487 data->rpc_status = 0; in _nfs4_proc_open_confirm()
2488 data->timestamp = jiffies; in _nfs4_proc_open_confirm()
2494 data->cancelled = true; in _nfs4_proc_open_confirm()
2497 status = data->rpc_status; in _nfs4_proc_open_confirm()
2505 struct nfs4_state_owner *sp = data->owner; in nfs4_open_prepare()
2506 struct nfs_client *clp = sp->so_server->nfs_client; in nfs4_open_prepare()
2507 enum open_claim_type4 claim = data->o_arg.claim; in nfs4_open_prepare()
2509 if (nfs_wait_on_sequence(data->o_arg.seqid, task) != 0) in nfs4_open_prepare()
2515 if (data->state != NULL) { in nfs4_open_prepare()
2518 if (can_open_cached(data->state, data->o_arg.fmode, in nfs4_open_prepare()
2519 data->o_arg.open_flags, claim)) in nfs4_open_prepare()
2522 delegation = nfs4_get_valid_delegation(data->state->inode); in nfs4_open_prepare()
2523 if (can_open_delegated(delegation, data->o_arg.fmode, claim)) in nfs4_open_prepare()
2528 data->o_arg.clientid = clp->cl_clientid; in nfs4_open_prepare()
2535 data->o_arg.open_bitmap = &nfs4_open_noattr_bitmap[0]; in nfs4_open_prepare()
2538 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; in nfs4_open_prepare()
2540 data->timestamp = jiffies; in nfs4_open_prepare()
2541 if (nfs4_setup_sequence(data->o_arg.server->nfs_client, in nfs4_open_prepare()
2542 &data->o_arg.seq_args, in nfs4_open_prepare()
2543 &data->o_res.seq_res, in nfs4_open_prepare()
2545 nfs_release_seqid(data->o_arg.seqid); in nfs4_open_prepare()
2547 /* Set the create mode (note dependency on the session type) */ in nfs4_open_prepare()
2548 data->o_arg.createmode = NFS4_CREATE_UNCHECKED; in nfs4_open_prepare()
2549 if (data->o_arg.open_flags & O_EXCL) { in nfs4_open_prepare()
2550 data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE4_1; in nfs4_open_prepare()
2551 if (clp->cl_mvops->minor_version == 0) { in nfs4_open_prepare()
2552 data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE; in nfs4_open_prepare()
2556 data->o_res.access_request = data->o_arg.access = 0; in nfs4_open_prepare()
2558 data->o_arg.createmode = NFS4_CREATE_GUARDED; in nfs4_open_prepare()
2562 trace_nfs4_cached_open(data->state); in nfs4_open_prepare()
2565 task->tk_action = NULL; in nfs4_open_prepare()
2567 nfs4_sequence_done(task, &data->o_res.seq_res); in nfs4_open_prepare()
2574 data->rpc_status = task->tk_status; in nfs4_open_done()
2576 if (!nfs4_sequence_process(task, &data->o_res.seq_res)) in nfs4_open_done()
2579 if (task->tk_status == 0) { in nfs4_open_done()
2580 if (data->o_res.f_attr->valid & NFS_ATTR_FATTR_TYPE) { in nfs4_open_done()
2581 switch (data->o_res.f_attr->mode & S_IFMT) { in nfs4_open_done()
2585 data->rpc_status = -ELOOP; in nfs4_open_done()
2588 data->rpc_status = -EISDIR; in nfs4_open_done()
2591 data->rpc_status = -ENOTDIR; in nfs4_open_done()
2594 renew_lease(data->o_res.server, data->timestamp); in nfs4_open_done()
2595 if (!(data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM)) in nfs4_open_done()
2596 nfs_confirm_seqid(&data->owner->so_seqid, 0); in nfs4_open_done()
2598 data->rpc_done = true; in nfs4_open_done()
2607 if (!data->cancelled) in nfs4_open_release()
2610 if (data->rpc_status != 0 || !data->rpc_done) in nfs4_open_release()
2613 if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) in nfs4_open_release()
2617 nfs4_close_state(state, data->o_arg.fmode); in nfs4_open_release()
2631 struct inode *dir = d_inode(data->dir); in nfs4_run_open_task()
2633 struct nfs_openargs *o_arg = &data->o_arg; in nfs4_run_open_task()
2634 struct nfs_openres *o_res = &data->o_res; in nfs4_run_open_task()
2640 .rpc_cred = data->owner->so_cred, in nfs4_run_open_task()
2643 .rpc_client = server->client, in nfs4_run_open_task()
2655 kref_get(&data->kref); in nfs4_run_open_task()
2656 data->rpc_done = false; in nfs4_run_open_task()
2657 data->rpc_status = 0; in nfs4_run_open_task()
2658 data->cancelled = false; in nfs4_run_open_task()
2659 data->is_recover = false; in nfs4_run_open_task()
2661 nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 1); in nfs4_run_open_task()
2662 data->is_recover = true; in nfs4_run_open_task()
2665 nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 0); in nfs4_run_open_task()
2673 data->cancelled = true; in nfs4_run_open_task()
2676 status = data->rpc_status; in nfs4_run_open_task()
2684 struct inode *dir = d_inode(data->dir); in _nfs4_recover_proc_open()
2685 struct nfs_openres *o_res = &data->o_res; in _nfs4_recover_proc_open()
2689 if (status != 0 || !data->rpc_done) in _nfs4_recover_proc_open()
2692 nfs_fattr_map_and_free_names(NFS_SERVER(dir), &data->f_attr); in _nfs4_recover_proc_open()
2694 if (o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) in _nfs4_recover_proc_open()
2705 * Note that in the non-execute case, we want to turn off permission
2716 * support any access modes -- defer access call until later */ in nfs4_opendata_access()
2717 if (opendata->o_res.access_supported == 0) in nfs4_opendata_access()
2723 if (S_ISDIR(state->inode->i_mode)) in nfs4_opendata_access()
2727 } else if ((fmode & FMODE_READ) && !opendata->file_created) in nfs4_opendata_access()
2730 nfs_access_set_mask(&cache, opendata->o_res.access_result); in nfs4_opendata_access()
2731 nfs_access_add_cache(state->inode, &cache, cred); in nfs4_opendata_access()
2737 return -EACCES; in nfs4_opendata_access()
2746 struct inode *dir = d_inode(data->dir); in _nfs4_proc_open()
2748 struct nfs_openargs *o_arg = &data->o_arg; in _nfs4_proc_open()
2749 struct nfs_openres *o_res = &data->o_res; in _nfs4_proc_open()
2753 if (!data->rpc_done) in _nfs4_proc_open()
2756 if (status == -NFS4ERR_BADNAME && in _nfs4_proc_open()
2757 !(o_arg->open_flags & O_CREAT)) in _nfs4_proc_open()
2758 return -ENOENT; in _nfs4_proc_open()
2762 nfs_fattr_map_and_free_names(server, &data->f_attr); in _nfs4_proc_open()
2764 if (o_arg->open_flags & O_CREAT) { in _nfs4_proc_open()
2765 if (o_arg->open_flags & O_EXCL) in _nfs4_proc_open()
2766 data->file_created = true; in _nfs4_proc_open()
2767 else if (o_res->cinfo.before != o_res->cinfo.after) in _nfs4_proc_open()
2768 data->file_created = true; in _nfs4_proc_open()
2769 if (data->file_created || in _nfs4_proc_open()
2770 inode_peek_iversion_raw(dir) != o_res->cinfo.after) in _nfs4_proc_open()
2771 nfs4_update_changeattr(dir, &o_res->cinfo, in _nfs4_proc_open()
2772 o_res->f_attr->time_start, in _nfs4_proc_open()
2775 if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) in _nfs4_proc_open()
2776 server->caps &= ~NFS_CAP_POSIX_LOCK; in _nfs4_proc_open()
2777 if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { in _nfs4_proc_open()
2782 if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) { in _nfs4_proc_open()
2783 struct nfs_fh *fh = &o_res->fh; in _nfs4_proc_open()
2785 nfs4_sequence_free_slot(&o_res->seq_res); in _nfs4_proc_open()
2786 if (o_arg->claim == NFS4_OPEN_CLAIM_FH) in _nfs4_proc_open()
2787 fh = NFS_FH(d_inode(data->dentry)); in _nfs4_proc_open()
2788 nfs4_proc_getattr(server, fh, o_res->f_attr, NULL); in _nfs4_proc_open()
2811 opendata->o_arg.open_flags = O_DIRECT; in _nfs4_open_expired()
2813 if (ret == -ESTALE) in _nfs4_open_expired()
2814 d_drop(ctx->dentry); in _nfs4_open_expired()
2821 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_open_expired()
2833 case -NFS4ERR_GRACE: in nfs4_do_open_expired()
2834 case -NFS4ERR_DELAY: in nfs4_do_open_expired()
2850 return -EAGAIN; in nfs4_open_expired()
2859 nfs_remove_bad_delegation(state->inode, stateid); in nfs_finish_clear_delegation_stateid()
2865 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL) in nfs40_clear_delegation_stateid()
2881 return -NFS4ERR_BAD_STATEID; in nfs40_test_and_free_expired_stateid()
2891 switch (stateid->type) { in nfs41_test_and_free_expired_stateid()
2896 return -NFS4ERR_BAD_STATEID; in nfs41_test_and_free_expired_stateid()
2903 case -NFS4ERR_EXPIRED: in nfs41_test_and_free_expired_stateid()
2904 case -NFS4ERR_ADMIN_REVOKED: in nfs41_test_and_free_expired_stateid()
2905 case -NFS4ERR_DELEG_REVOKED: in nfs41_test_and_free_expired_stateid()
2913 return -NFS4ERR_EXPIRED; in nfs41_test_and_free_expired_stateid()
2918 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_delegation_stateid()
2926 delegation = rcu_dereference(NFS_I(state->inode)->delegation); in nfs41_check_delegation_stateid()
2933 spin_lock(&delegation->lock); in nfs41_check_delegation_stateid()
2934 nfs4_stateid_copy(&stateid, &delegation->stateid); in nfs41_check_delegation_stateid()
2937 &delegation->flags)) { in nfs41_check_delegation_stateid()
2938 spin_unlock(&delegation->lock); in nfs41_check_delegation_stateid()
2943 if (delegation->cred) in nfs41_check_delegation_stateid()
2944 cred = get_cred(delegation->cred); in nfs41_check_delegation_stateid()
2945 spin_unlock(&delegation->lock); in nfs41_check_delegation_stateid()
2949 if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) in nfs41_check_delegation_stateid()
2962 if (test_bit(NFS_DELEGATED_STATE, &state->flags) && in nfs41_delegation_recover_stateid()
2963 nfs4_copy_delegation_stateid(state->inode, state->state, in nfs41_delegation_recover_stateid()
2965 nfs4_stateid_match_other(&state->stateid, &tmp)) in nfs41_delegation_recover_stateid()
2966 nfs_state_set_delegation(state, &tmp, state->state); in nfs41_delegation_recover_stateid()
2972 * nfs41_check_expired_locks - possibly free a lock stateid
2983 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_expired_locks()
2985 if (!test_bit(LK_STATE_IN_USE, &state->flags)) in nfs41_check_expired_locks()
2988 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
2989 list_for_each_entry(lsp, &state->lock_states, ls_locks) { in nfs41_check_expired_locks()
2990 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags)) { in nfs41_check_expired_locks()
2991 const struct cred *cred = lsp->ls_state->owner->so_cred; in nfs41_check_expired_locks()
2993 refcount_inc(&lsp->ls_count); in nfs41_check_expired_locks()
2994 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
3000 &lsp->ls_stateid, in nfs41_check_expired_locks()
3003 if (status == -NFS4ERR_EXPIRED || in nfs41_check_expired_locks()
3004 status == -NFS4ERR_BAD_STATEID) { in nfs41_check_expired_locks()
3005 clear_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags); in nfs41_check_expired_locks()
3006 lsp->ls_stateid.type = NFS4_INVALID_STATEID_TYPE; in nfs41_check_expired_locks()
3008 set_bit(NFS_LOCK_LOST, &lsp->ls_flags); in nfs41_check_expired_locks()
3014 spin_lock(&state->state_lock); in nfs41_check_expired_locks()
3017 spin_unlock(&state->state_lock); in nfs41_check_expired_locks()
3024 * nfs41_check_open_stateid - possibly free an open stateid
3033 struct nfs_server *server = NFS_SERVER(state->inode); in nfs41_check_open_stateid()
3034 nfs4_stateid *stateid = &state->open_stateid; in nfs41_check_open_stateid()
3035 const struct cred *cred = state->owner->so_cred; in nfs41_check_open_stateid()
3038 if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) in nfs41_check_open_stateid()
3039 return -NFS4ERR_BAD_STATEID; in nfs41_check_open_stateid()
3042 if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) { in nfs41_check_open_stateid()
3044 stateid->type = NFS4_INVALID_STATEID_TYPE; in nfs41_check_open_stateid()
3048 return -NFS4ERR_OPENMODE; in nfs41_check_open_stateid()
3072 * on an EXCLUSIVE create, the server should send back a bitmask with FATTR4-*
3079 const __u32 *bitmask = opendata->o_arg.server->exclcreat_bitmask; in nfs4_exclusive_attrset()
3085 attrset[i] = opendata->o_res.attrset[i]; in nfs4_exclusive_attrset()
3086 if (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE4_1) in nfs4_exclusive_attrset()
3090 ret = (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE) ? in nfs4_exclusive_attrset()
3091 sattr->ia_valid : 0; in nfs4_exclusive_attrset()
3094 if (sattr->ia_valid & ATTR_ATIME_SET) in nfs4_exclusive_attrset()
3101 if (sattr->ia_valid & ATTR_MTIME_SET) in nfs4_exclusive_attrset()
3115 struct nfs4_state_owner *sp = opendata->owner; in _nfs4_open_and_get_state()
3116 struct nfs_server *server = sp->so_server; in _nfs4_open_and_get_state()
3120 struct inode *dir = d_inode(opendata->dir); in _nfs4_open_and_get_state()
3134 ctx->state = state; in _nfs4_open_and_get_state()
3135 if (server->caps & NFS_CAP_POSIX_LOCK) in _nfs4_open_and_get_state()
3136 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); in _nfs4_open_and_get_state()
3137 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK) in _nfs4_open_and_get_state()
3138 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags); in _nfs4_open_and_get_state()
3139 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED) in _nfs4_open_and_get_state()
3140 set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags); in _nfs4_open_and_get_state()
3142 dentry = opendata->dentry; in _nfs4_open_and_get_state()
3146 alias = d_exact_alias(dentry, state->inode); in _nfs4_open_and_get_state()
3148 alias = d_splice_alias(igrab(state->inode), dentry); in _nfs4_open_and_get_state()
3149 /* d_splice_alias() can't fail here - it's a non-directory */ in _nfs4_open_and_get_state()
3151 dput(ctx->dentry); in _nfs4_open_and_get_state()
3152 ctx->dentry = dentry = alias; in _nfs4_open_and_get_state()
3156 switch(opendata->o_arg.claim) { in _nfs4_open_and_get_state()
3162 if (!opendata->rpc_done) in _nfs4_open_and_get_state()
3164 if (opendata->o_res.delegation.type != 0) in _nfs4_open_and_get_state()
3170 pnfs_parse_lgopen(state->inode, opendata->lgp, ctx); in _nfs4_open_and_get_state()
3172 ret = nfs4_opendata_access(sp->so_cred, opendata, state, acc_mode); in _nfs4_open_and_get_state()
3176 if (d_inode(dentry) == state->inode) in _nfs4_open_and_get_state()
3180 if (!opendata->cancelled) { in _nfs4_open_and_get_state()
3181 if (opendata->lgp) { in _nfs4_open_and_get_state()
3182 nfs4_lgopen_release(opendata->lgp); in _nfs4_open_and_get_state()
3183 opendata->lgp = NULL; in _nfs4_open_and_get_state()
3185 nfs4_sequence_free_slot(&opendata->o_res.seq_res); in _nfs4_open_and_get_state()
3203 struct dentry *dentry = ctx->dentry; in _nfs4_do_open()
3204 const struct cred *cred = ctx->cred; in _nfs4_do_open()
3205 struct nfs4_threshold **ctx_th = &ctx->mdsthreshold; in _nfs4_do_open()
3208 struct iattr *sattr = c->sattr; in _nfs4_do_open()
3209 struct nfs4_label *label = c->label; in _nfs4_do_open()
3213 status = -ENOMEM; in _nfs4_do_open()
3219 status = nfs4_client_recover_expired_lease(server->nfs_client); in _nfs4_do_open()
3224 status = -ENOMEM; in _nfs4_do_open()
3232 if (server->attr_bitmask[2] & FATTR4_WORD2_MDSTHRESHOLD) { in _nfs4_do_open()
3233 if (!opendata->f_attr.mdsthreshold) { in _nfs4_do_open()
3234 opendata->f_attr.mdsthreshold = pnfs_mdsthreshold_alloc(); in _nfs4_do_open()
3235 if (!opendata->f_attr.mdsthreshold) in _nfs4_do_open()
3238 opendata->o_arg.open_bitmap = &nfs4_pnfs_open_bitmap[0]; in _nfs4_do_open()
3241 opendata->state = nfs4_get_open_state(d_inode(dentry), sp); in _nfs4_do_open()
3246 state = ctx->state; in _nfs4_do_open()
3248 if ((opendata->o_arg.open_flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) && in _nfs4_do_open()
3249 (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) { in _nfs4_do_open()
3252 * send create attributes which was not set by open in _nfs4_do_open()
3256 unsigned ia_old = sattr->ia_valid; in _nfs4_do_open()
3258 sattr->ia_valid = attrs; in _nfs4_do_open()
3259 nfs_fattr_init(opendata->o_res.f_attr); in _nfs4_do_open()
3260 status = nfs4_do_setattr(state->inode, cred, in _nfs4_do_open()
3261 opendata->o_res.f_attr, sattr, in _nfs4_do_open()
3264 nfs_setattr_update_inode(state->inode, sattr, in _nfs4_do_open()
3265 opendata->o_res.f_attr); in _nfs4_do_open()
3266 nfs_setsecurity(state->inode, opendata->o_res.f_attr); in _nfs4_do_open()
3268 sattr->ia_valid = ia_old; in _nfs4_do_open()
3271 if (opened && opendata->file_created) in _nfs4_do_open()
3274 if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server)) { in _nfs4_do_open()
3275 *ctx_th = opendata->f_attr.mdsthreshold; in _nfs4_do_open()
3276 opendata->f_attr.mdsthreshold = NULL; in _nfs4_do_open()
3308 [1] = (__u32)current->pid, in nfs4_do_open()
3315 res = ctx->state; in nfs4_do_open()
3320 * book-keeping w.r.t. state-changing operations in nfs4_do_open()
3330 if (status == -NFS4ERR_BAD_SEQID) { in nfs4_do_open()
3332 " returned a bad sequence-id error!\n", in nfs4_do_open()
3333 NFS_SERVER(dir)->nfs_client->cl_hostname); in nfs4_do_open()
3343 if (status == -NFS4ERR_BAD_STATEID) { in nfs4_do_open()
3347 if (status == -NFS4ERR_EXPIRED) { in nfs4_do_open()
3348 nfs4_schedule_lease_recovery(server->nfs_client); in nfs4_do_open()
3352 if (status == -EAGAIN) { in nfs4_do_open()
3383 nfs_fattr_init(res->fattr); in _nfs4_do_setattr()
3386 truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; in _nfs4_do_setattr()
3392 if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) { in _nfs4_do_setattr()
3394 } else if (ctx != NULL && ctx->state) { in _nfs4_do_setattr()
3396 if (!nfs4_valid_open_stateid(ctx->state)) in _nfs4_do_setattr()
3397 return -EBADF; in _nfs4_do_setattr()
3401 status = nfs4_select_rw_stateid(ctx->state, FMODE_WRITE, l_ctx, in _nfs4_do_setattr()
3402 &arg->stateid, &delegation_cred); in _nfs4_do_setattr()
3404 if (status == -EIO) in _nfs4_do_setattr()
3405 return -EBADF; in _nfs4_do_setattr()
3406 else if (status == -EAGAIN) in _nfs4_do_setattr()
3410 nfs4_stateid_copy(&arg->stateid, &zero_stateid); in _nfs4_do_setattr()
3415 status = nfs4_call_sync(server->client, server, &msg, &arg->seq_args, &res->seq_res, 1); in _nfs4_do_setattr()
3420 trace_nfs4_setattr(inode, &arg->stateid, status); in _nfs4_do_setattr()
3430 struct nfs4_state *state = ctx ? ctx->state : NULL; in nfs4_do_setattr()
3451 if (sattr->ia_valid & (ATTR_MODE | ATTR_KILL_SUID | ATTR_KILL_SGID)) in nfs4_do_setattr()
3453 if (sattr->ia_valid & (ATTR_UID | ATTR_GID)) in nfs4_do_setattr()
3455 if (sattr->ia_valid & ATTR_ATIME) in nfs4_do_setattr()
3457 if (sattr->ia_valid & ATTR_MTIME) in nfs4_do_setattr()
3461 nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, fattr->label), in nfs4_do_setattr()
3466 case -NFS4ERR_OPENMODE: in nfs4_do_setattr()
3467 if (!(sattr->ia_valid & ATTR_SIZE)) { in nfs4_do_setattr()
3472 server->nfs_client->cl_hostname); in nfs4_do_setattr()
3474 if (state && !(state->state & FMODE_WRITE)) { in nfs4_do_setattr()
3475 err = -EBADF; in nfs4_do_setattr()
3476 if (sattr->ia_valid & ATTR_OPEN) in nfs4_do_setattr()
3477 err = -EACCES; in nfs4_do_setattr()
3509 seq = read_seqbegin(&state->seqlock); in nfs4_sync_open_stateid()
3511 nfs4_stateid_copy(dst, &state->open_stateid); in nfs4_sync_open_stateid()
3512 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3516 seqid_open = state->open_stateid.seqid; in nfs4_sync_open_stateid()
3517 if (read_seqretry(&state->seqlock, seq)) in nfs4_sync_open_stateid()
3520 dst_seqid = be32_to_cpu(dst->seqid); in nfs4_sync_open_stateid()
3521 if ((s32)(dst_seqid - be32_to_cpu(seqid_open)) < 0) in nfs4_sync_open_stateid()
3522 dst->seqid = seqid_open; in nfs4_sync_open_stateid()
3537 int seq, status = -EAGAIN; in nfs4_refresh_open_old_stateid()
3544 seq = read_seqbegin(&state->seqlock); in nfs4_refresh_open_old_stateid()
3546 if (read_seqretry(&state->seqlock, seq)) in nfs4_refresh_open_old_stateid()
3551 write_seqlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3552 seqid_open = state->open_stateid.seqid; in nfs4_refresh_open_old_stateid()
3554 dst_seqid = be32_to_cpu(dst->seqid); in nfs4_refresh_open_old_stateid()
3557 if ((s32)(be32_to_cpu(seqid_open) - dst_seqid) > 0) { in nfs4_refresh_open_old_stateid()
3558 dst->seqid = seqid_open; in nfs4_refresh_open_old_stateid()
3559 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3565 set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); in nfs4_refresh_open_old_stateid()
3566 prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); in nfs4_refresh_open_old_stateid()
3567 write_sequnlock(&state->seqlock); in nfs4_refresh_open_old_stateid()
3568 trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); in nfs4_refresh_open_old_stateid()
3571 status = -EINTR; in nfs4_refresh_open_old_stateid()
3576 finish_wait(&state->waitq, &wait); in nfs4_refresh_open_old_stateid()
3580 if (status == -EINTR) in nfs4_refresh_open_old_stateid()
3584 dst->seqid = cpu_to_be32(dst_seqid + 1); in nfs4_refresh_open_old_stateid()
3611 struct nfs4_state_owner *sp = calldata->state->owner; in nfs4_free_closedata()
3612 struct super_block *sb = calldata->state->inode->i_sb; in nfs4_free_closedata()
3614 if (calldata->lr.roc) in nfs4_free_closedata()
3615 pnfs_roc_release(&calldata->lr.arg, &calldata->lr.res, in nfs4_free_closedata()
3616 calldata->res.lr_ret); in nfs4_free_closedata()
3617 nfs4_put_open_state(calldata->state); in nfs4_free_closedata()
3618 nfs_free_seqid(calldata->arg.seqid); in nfs4_free_closedata()
3627 struct nfs4_state *state = calldata->state; in nfs4_close_done()
3628 struct nfs_server *server = NFS_SERVER(calldata->inode); in nfs4_close_done()
3632 .inode = calldata->inode, in nfs4_close_done()
3633 .stateid = &calldata->arg.stateid, in nfs4_close_done()
3636 if (!nfs4_sequence_done(task, &calldata->res.seq_res)) in nfs4_close_done()
3638 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); in nfs4_close_done()
3641 if (pnfs_roc_done(task, &calldata->arg.lr_args, &calldata->res.lr_res, in nfs4_close_done()
3642 &calldata->res.lr_ret) == -EAGAIN) in nfs4_close_done()
3648 switch (task->tk_status) { in nfs4_close_done()
3650 res_stateid = &calldata->res.stateid; in nfs4_close_done()
3651 renew_lease(server, calldata->timestamp); in nfs4_close_done()
3653 case -NFS4ERR_ACCESS: in nfs4_close_done()
3654 if (calldata->arg.bitmask != NULL) { in nfs4_close_done()
3655 calldata->arg.bitmask = NULL; in nfs4_close_done()
3656 calldata->res.fattr = NULL; in nfs4_close_done()
3661 case -NFS4ERR_OLD_STATEID: in nfs4_close_done()
3663 if (nfs4_refresh_open_old_stateid(&calldata->arg.stateid, in nfs4_close_done()
3667 case -NFS4ERR_ADMIN_REVOKED: in nfs4_close_done()
3668 case -NFS4ERR_STALE_STATEID: in nfs4_close_done()
3669 case -NFS4ERR_EXPIRED: in nfs4_close_done()
3671 &calldata->arg.stateid, in nfs4_close_done()
3672 task->tk_msg.rpc_cred); in nfs4_close_done()
3674 case -NFS4ERR_BAD_STATEID: in nfs4_close_done()
3675 if (calldata->arg.fmode == 0) in nfs4_close_done()
3679 task->tk_status = nfs4_async_handle_exception(task, in nfs4_close_done()
3680 server, task->tk_status, &exception); in nfs4_close_done()
3684 nfs_clear_open_stateid(state, &calldata->arg.stateid, in nfs4_close_done()
3685 res_stateid, calldata->arg.fmode); in nfs4_close_done()
3687 task->tk_status = 0; in nfs4_close_done()
3688 nfs_release_seqid(calldata->arg.seqid); in nfs4_close_done()
3689 nfs_refresh_inode(calldata->inode, &calldata->fattr); in nfs4_close_done()
3690 dprintk("%s: ret = %d\n", __func__, task->tk_status); in nfs4_close_done()
3693 task->tk_status = 0; in nfs4_close_done()
3701 struct nfs4_state *state = calldata->state; in nfs4_close_prepare()
3702 struct inode *inode = calldata->inode; in nfs4_close_prepare()
3708 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) in nfs4_close_prepare()
3711 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; in nfs4_close_prepare()
3712 spin_lock(&state->owner->so_lock); in nfs4_close_prepare()
3713 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags); in nfs4_close_prepare()
3714 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags); in nfs4_close_prepare()
3715 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags); in nfs4_close_prepare()
3717 calldata->arg.fmode = 0; in nfs4_close_prepare()
3718 if (state->n_rdwr == 0) { in nfs4_close_prepare()
3719 if (state->n_rdonly == 0) in nfs4_close_prepare()
3722 calldata->arg.fmode |= FMODE_READ; in nfs4_close_prepare()
3723 if (state->n_wronly == 0) in nfs4_close_prepare()
3726 calldata->arg.fmode |= FMODE_WRITE; in nfs4_close_prepare()
3727 if (calldata->arg.fmode != (FMODE_READ|FMODE_WRITE)) in nfs4_close_prepare()
3730 calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; in nfs4_close_prepare()
3732 nfs4_sync_open_stateid(&calldata->arg.stateid, state); in nfs4_close_prepare()
3735 spin_unlock(&state->owner->so_lock); in nfs4_close_prepare()
3742 if (!calldata->lr.roc && nfs4_wait_on_layoutreturn(inode, task)) { in nfs4_close_prepare()
3743 nfs_release_seqid(calldata->arg.seqid); in nfs4_close_prepare()
3747 lo = calldata->arg.lr_args ? calldata->arg.lr_args->layout : NULL; in nfs4_close_prepare()
3749 calldata->arg.lr_args = NULL; in nfs4_close_prepare()
3750 calldata->res.lr_res = NULL; in nfs4_close_prepare()
3753 if (calldata->arg.fmode == 0) in nfs4_close_prepare()
3754 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE]; in nfs4_close_prepare()
3756 if (calldata->arg.fmode == 0 || calldata->arg.fmode == FMODE_READ) { in nfs4_close_prepare()
3757 /* Close-to-open cache consistency revalidation */ in nfs4_close_prepare()
3759 nfs4_bitmask_set(calldata->arg.bitmask_store, in nfs4_close_prepare()
3760 server->cache_consistency_bitmask, in nfs4_close_prepare()
3762 calldata->arg.bitmask = calldata->arg.bitmask_store; in nfs4_close_prepare()
3764 calldata->arg.bitmask = NULL; in nfs4_close_prepare()
3767 calldata->arg.share_access = in nfs4_close_prepare()
3768 nfs4_fmode_to_share_access(calldata->arg.fmode); in nfs4_close_prepare()
3770 if (calldata->res.fattr == NULL) in nfs4_close_prepare()
3771 calldata->arg.bitmask = NULL; in nfs4_close_prepare()
3772 else if (calldata->arg.bitmask == NULL) in nfs4_close_prepare()
3773 calldata->res.fattr = NULL; in nfs4_close_prepare()
3774 calldata->timestamp = jiffies; in nfs4_close_prepare()
3775 if (nfs4_setup_sequence(NFS_SERVER(inode)->nfs_client, in nfs4_close_prepare()
3776 &calldata->arg.seq_args, in nfs4_close_prepare()
3777 &calldata->res.seq_res, in nfs4_close_prepare()
3779 nfs_release_seqid(calldata->arg.seqid); in nfs4_close_prepare()
3782 task->tk_action = NULL; in nfs4_close_prepare()
3784 nfs4_sequence_done(task, &calldata->res.seq_res); in nfs4_close_prepare()
3794 * It is possible for data to be read/written from a mem-mapped file
3798 * NFSv4 citizens - we do not indicate to the server to update the file's
3802 * NOTE: Caller must be holding the sp->so_owner semaphore!
3806 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_do_close()
3809 struct nfs4_state_owner *sp = state->owner; in nfs4_do_close()
3813 .rpc_cred = state->owner->so_cred, in nfs4_do_close()
3816 .rpc_client = server->client, in nfs4_do_close()
3822 int status = -ENOMEM; in nfs4_do_close()
3824 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE)) in nfs4_do_close()
3827 nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_CLEANUP, in nfs4_do_close()
3833 nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1, 0); in nfs4_do_close()
3834 calldata->inode = state->inode; in nfs4_do_close()
3835 calldata->state = state; in nfs4_do_close()
3836 calldata->arg.fh = NFS_FH(state->inode); in nfs4_do_close()
3837 if (!nfs4_copy_open_stateid(&calldata->arg.stateid, state)) in nfs4_do_close()
3840 alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid; in nfs4_do_close()
3841 calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask); in nfs4_do_close()
3842 if (IS_ERR(calldata->arg.seqid)) in nfs4_do_close()
3844 nfs_fattr_init(&calldata->fattr); in nfs4_do_close()
3845 calldata->arg.fmode = 0; in nfs4_do_close()
3846 calldata->lr.arg.ld_private = &calldata->lr.ld_private; in nfs4_do_close()
3847 calldata->res.fattr = &calldata->fattr; in nfs4_do_close()
3848 calldata->res.seqid = calldata->arg.seqid; in nfs4_do_close()
3849 calldata->res.server = server; in nfs4_do_close()
3850 calldata->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; in nfs4_do_close()
3851 calldata->lr.roc = pnfs_roc(state->inode, in nfs4_do_close()
3852 &calldata->lr.arg, &calldata->lr.res, msg.rpc_cred); in nfs4_do_close()
3853 if (calldata->lr.roc) { in nfs4_do_close()
3854 calldata->arg.lr_args = &calldata->lr.arg; in nfs4_do_close()
3855 calldata->res.lr_res = &calldata->lr.res; in nfs4_do_close()
3857 nfs_sb_active(calldata->inode->i_sb); in nfs4_do_close()
3859 msg.rpc_argp = &calldata->arg; in nfs4_do_close()
3860 msg.rpc_resp = &calldata->res; in nfs4_do_close()
3885 label = nfs4_label_init_security(dir, ctx->dentry, attr, &l); in nfs4_atomic_open()
3894 return state->inode; in nfs4_atomic_open()
3899 if (ctx->state == NULL) in nfs4_close_context()
3902 nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
3904 nfs4_close_state(ctx->state, _nfs4_ctx_to_openmode(ctx)); in nfs4_close_context()
3907 #define FATTR4_WORD1_NFS40_MASK (2*FATTR4_WORD1_MOUNTED_ON_FILEID - 1UL)
3908 #define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL)
3909 #define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_OPEN_ARGUMENTS - 1UL)
3915 u32 share_access_want = res->open_caps.oa_share_access_want[0]; in nfs4_server_delegtime_capable()
3916 u32 attr_bitmask = res->attr_bitmask[2]; in nfs4_server_delegtime_capable()
3925 u32 minorversion = server->nfs_client->cl_minorversion; in _nfs4_server_capabilities()
3953 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_server_capabilities()
3980 memcpy(server->attr_bitmask, res.attr_bitmask, sizeof(server->attr_bitmask)); in _nfs4_server_capabilities()
3981 server->caps &= ~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | in _nfs4_server_capabilities()
3983 server->fattr_valid = NFS_ATTR_FATTR_V4; in _nfs4_server_capabilities()
3986 server->caps |= NFS_CAP_ACLS; in _nfs4_server_capabilities()
3988 server->caps |= NFS_CAP_HARDLINKS; in _nfs4_server_capabilities()
3990 server->caps |= NFS_CAP_SYMLINKS; in _nfs4_server_capabilities()
3992 server->caps |= NFS_CAP_CASE_INSENSITIVE; in _nfs4_server_capabilities()
3994 server->caps |= NFS_CAP_CASE_PRESERVING; in _nfs4_server_capabilities()
3997 server->caps |= NFS_CAP_SECURITY_LABEL; in _nfs4_server_capabilities()
4000 server->caps |= NFS_CAP_FS_LOCATIONS; in _nfs4_server_capabilities()
4002 server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; in _nfs4_server_capabilities()
4004 server->fattr_valid &= ~NFS_ATTR_FATTR_MODE; in _nfs4_server_capabilities()
4006 server->fattr_valid &= ~NFS_ATTR_FATTR_NLINK; in _nfs4_server_capabilities()
4008 server->fattr_valid &= ~(NFS_ATTR_FATTR_OWNER | in _nfs4_server_capabilities()
4011 server->fattr_valid &= ~(NFS_ATTR_FATTR_GROUP | in _nfs4_server_capabilities()
4014 server->fattr_valid &= ~NFS_ATTR_FATTR_SPACE_USED; in _nfs4_server_capabilities()
4016 server->fattr_valid &= ~NFS_ATTR_FATTR_ATIME; in _nfs4_server_capabilities()
4018 server->fattr_valid &= ~NFS_ATTR_FATTR_CTIME; in _nfs4_server_capabilities()
4020 server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME; in _nfs4_server_capabilities()
4021 memcpy(server->attr_bitmask_nl, res.attr_bitmask, in _nfs4_server_capabilities()
4022 sizeof(server->attr_bitmask)); in _nfs4_server_capabilities()
4023 server->attr_bitmask_nl[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in _nfs4_server_capabilities()
4027 server->caps |= NFS_CAP_OPEN_XOR; in _nfs4_server_capabilities()
4029 server->caps |= NFS_CAP_DELEGTIME; in _nfs4_server_capabilities()
4031 …memcpy(server->cache_consistency_bitmask, res.attr_bitmask, sizeof(server->cache_consistency_bitma… in _nfs4_server_capabilities()
4032 server->cache_consistency_bitmask[0] &= FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE; in _nfs4_server_capabilities()
4033 server->cache_consistency_bitmask[1] &= FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; in _nfs4_server_capabilities()
4034 server->cache_consistency_bitmask[2] = 0; in _nfs4_server_capabilities()
4039 memcpy(server->exclcreat_bitmask, res.exclcreat_bitmask, in _nfs4_server_capabilities()
4040 sizeof(server->exclcreat_bitmask)); in _nfs4_server_capabilities()
4042 server->acl_bitmask = res.acl_bitmask; in _nfs4_server_capabilities()
4043 server->fh_expire_type = res.fh_expire_type; in _nfs4_server_capabilities()
4071 for (i = 0; i < location->nservers; i++) { in test_fs_location_for_trunking()
4072 struct nfs4_string *srv_loc = &location->servers[i]; in test_fs_location_for_trunking()
4077 .net = clp->cl_net, in test_fs_location_for_trunking()
4083 .add_xprt_test = clp->cl_mvops->session_trunk, in test_fs_location_for_trunking()
4088 if (!srv_loc->len) in test_fs_location_for_trunking()
4091 addrlen = nfs_parse_server_name(srv_loc->data, srv_loc->len, in test_fs_location_for_trunking()
4093 clp->cl_net, server->port); in test_fs_location_for_trunking()
4098 servername = kmalloc(srv_loc->len + 1, GFP_KERNEL); in test_fs_location_for_trunking()
4101 memcpy(servername, srv_loc->data, srv_loc->len); in test_fs_location_for_trunking()
4102 servername[srv_loc->len] = '\0'; in test_fs_location_for_trunking()
4106 rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args, in test_fs_location_for_trunking()
4120 if (path1->ncomponents != path2->ncomponents) in _is_same_nfs4_pathname()
4122 for (i = 0; i < path1->ncomponents; i++) { in _is_same_nfs4_pathname()
4123 if (path1->components[i].len != path2->components[i].len) in _is_same_nfs4_pathname()
4125 if (memcmp(path1->components[i].data, path2->components[i].data, in _is_same_nfs4_pathname()
4126 path1->components[i].len)) in _is_same_nfs4_pathname()
4138 struct nfs_client *clp = server->nfs_client; in _nfs4_discover_trunking()
4140 clp->cl_mvops->state_renewal_ops; in _nfs4_discover_trunking()
4141 int status = -ENOMEM, i; in _nfs4_discover_trunking()
4143 cred = ops->get_state_renewal_cred(clp); in _nfs4_discover_trunking()
4147 return -ENOKEY; in _nfs4_discover_trunking()
4156 locations->fattr = nfs_alloc_fattr(); in _nfs4_discover_trunking()
4157 if (!locations->fattr) in _nfs4_discover_trunking()
4165 for (i = 0; i < locations->nlocations; i++) { in _nfs4_discover_trunking()
4166 if (!_is_same_nfs4_pathname(&locations->fs_path, in _nfs4_discover_trunking()
4167 &locations->locations[i].rootpath)) in _nfs4_discover_trunking()
4169 test_fs_location_for_trunking(&locations->locations[i], clp, in _nfs4_discover_trunking()
4173 kfree(locations->fattr); in _nfs4_discover_trunking()
4189 struct nfs_client *clp = server->nfs_client; in nfs4_discover_trunking()
4212 .fattr = info->fattr, in _nfs4_lookup_root()
4228 nfs_fattr_init(info->fattr); in _nfs4_lookup_root()
4229 return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_lookup_root()
4241 trace_nfs4_lookup_root(server, fhandle, info->fattr, err); in nfs4_lookup_root()
4244 case -NFS4ERR_WRONGSEC: in nfs4_lookup_root()
4262 auth = rpcauth_create(&auth_args, server->client); in nfs4_lookup_root_sec()
4264 return -EACCES; in nfs4_lookup_root_sec()
4288 int status = -EPERM; in nfs4_find_root_sec()
4291 if (server->auth_info.flavor_len > 0) { in nfs4_find_root_sec()
4293 for (i = 0; i < server->auth_info.flavor_len; i++) { in nfs4_find_root_sec()
4295 server->auth_info.flavors[i]); in nfs4_find_root_sec()
4296 if (status == -NFS4ERR_WRONGSEC || status == -EACCES) in nfs4_find_root_sec()
4305 if (status == -NFS4ERR_WRONGSEC || status == -EACCES) in nfs4_find_root_sec()
4312 * -EACCES could mean that the user doesn't have correct permissions in nfs4_find_root_sec()
4315 * existing mount programs don't handle -EACCES very well so it should in nfs4_find_root_sec()
4316 * be mapped to -EPERM instead. in nfs4_find_root_sec()
4318 if (status == -EACCES) in nfs4_find_root_sec()
4319 status = -EPERM; in nfs4_find_root_sec()
4324 * nfs4_proc_get_rootfh - get file handle for server's pseudoroot
4326 * @fhandle: we fill in the pseudo-fs root file handle
4342 status = server->nfs_client->cl_mvops->find_root_sec(server, in nfs4_proc_get_rootfh()
4357 struct nfs_fattr *fattr = info->fattr; in nfs4_proc_get_root()
4361 dprintk("nfs4_get_root: getcaps error = %d\n", -error); in nfs4_proc_get_root()
4367 dprintk("nfs4_get_root: getattr error = %d\n", -error); in nfs4_proc_get_root()
4371 if (fattr->valid & NFS_ATTR_FATTR_FSID && in nfs4_proc_get_root()
4372 !nfs_fsid_equal(&server->fsid, &fattr->fsid)) in nfs4_proc_get_root()
4373 memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid)); in nfs4_proc_get_root()
4388 int status = -ENOMEM; in nfs4_get_referral()
4399 locations->fattr = fattr; in nfs4_get_referral()
4410 if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &fattr->fsid)) { in nfs4_get_referral()
4412 " a referral at %s\n", __func__, name->name); in nfs4_get_referral()
4413 status = -NFS4ERR_MOVED; in nfs4_get_referral()
4445 if (nfs4_has_session(server->nfs_client)) in _nfs4_proc_getattr()
4449 if (inode && (server->flags & NFS_MOUNT_SOFTREVAL)) in _nfs4_proc_getattr()
4452 nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, fattr->label), inode, 0); in _nfs4_proc_getattr()
4455 return nfs4_do_call_sync(server->client, server, &msg, in _nfs4_proc_getattr()
4478 * VFS layer lookup-intents are implemented.
4490 * This will be fixed with VFS changes (lookup-intent).
4502 sattr->ia_valid & ATTR_SIZE && in nfs4_proc_setattr()
4503 sattr->ia_size < i_size_read(inode)) in nfs4_proc_setattr()
4509 if (sattr->ia_valid & ATTR_OPEN) in nfs4_proc_setattr()
4510 sattr->ia_valid &= ~(ATTR_MTIME|ATTR_CTIME); in nfs4_proc_setattr()
4513 if ((sattr->ia_valid & ~(ATTR_FILE|ATTR_OPEN)) == 0) in nfs4_proc_setattr()
4517 if (sattr->ia_valid & ATTR_FILE) { in nfs4_proc_setattr()
4519 ctx = nfs_file_open_context(sattr->ia_file); in nfs4_proc_setattr()
4521 cred = ctx->cred; in nfs4_proc_setattr()
4525 if ((sattr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) in nfs4_proc_setattr()
4543 .bitmask = server->attr_bitmask, in _nfs4_proc_lookup()
4545 .name = &dentry->d_name, in _nfs4_proc_lookup()
4566 args.bitmask = nfs4_bitmask(server, fattr->label); in _nfs4_proc_lookup()
4580 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | in nfs_fixup_secinfo_attributes()
4582 fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO; in nfs_fixup_secinfo_attributes()
4583 fattr->nlink = 2; in nfs_fixup_secinfo_attributes()
4594 const struct qstr *name = &dentry->d_name; in nfs4_proc_lookup_common()
4600 case -NFS4ERR_BADNAME: in nfs4_proc_lookup_common()
4601 err = -ENOENT; in nfs4_proc_lookup_common()
4603 case -NFS4ERR_MOVED: in nfs4_proc_lookup_common()
4605 if (err == -NFS4ERR_MOVED) in nfs4_proc_lookup_common()
4608 case -NFS4ERR_WRONGSEC: in nfs4_proc_lookup_common()
4609 err = -EPERM; in nfs4_proc_lookup_common()
4666 .bitmask = server->attr_bitmask, in _nfs4_proc_lookupp()
4681 if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL) in _nfs4_proc_lookupp()
4684 args.bitmask = nfs4_bitmask(server, fattr->label); in _nfs4_proc_lookupp()
4688 dprintk("NFS call lookupp ino=0x%lx\n", inode->i_ino); in _nfs4_proc_lookupp()
4717 .access = entry->mask, in _nfs4_proc_access()
4733 return -ENOMEM; in _nfs4_proc_access()
4734 args.bitmask = server->cache_consistency_bitmask; in _nfs4_proc_access()
4736 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_proc_access()
4764 * along with any of the zero-copy operations READ, READDIR,
4768 * after the read-type operation -- this is because it is hard
4778 * the operation -- in this case because we want to make sure
4779 * we get the post-operation mtime and size.
4800 …return nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode), &msg, &args.seq_args, &res.seq… in _nfs4_proc_readlink()
4820 * This is just for mknod. open(O_CREAT) will always do ->open_context().
4838 if (!(server->attr_bitmask[2] & FATTR4_WORD2_MODE_UMASK)) in nfs4_proc_create()
4839 sattr->ia_mode &= ~current_umask(); in nfs4_proc_create()
4870 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1); in _nfs4_proc_remove()
4872 spin_lock(&dir->i_lock); in _nfs4_proc_remove()
4874 if (ftype == NF4DIR && dir->i_nlink > 2) in _nfs4_proc_remove()
4878 spin_unlock(&dir->i_lock); in _nfs4_proc_remove()
4892 if (inode->i_nlink == 1) in nfs4_proc_remove()
4898 err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG); in nfs4_proc_remove()
4899 trace_nfs4_remove(dir, &dentry->d_name, err); in nfs4_proc_remove()
4926 struct nfs_removeargs *args = msg->rpc_argp; in nfs4_proc_unlink_setup()
4927 struct nfs_removeres *res = msg->rpc_resp; in nfs4_proc_unlink_setup()
4929 res->server = NFS_SB(dentry->d_sb); in nfs4_proc_unlink_setup()
4930 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; in nfs4_proc_unlink_setup()
4931 nfs4_init_sequence(&args->seq_args, &res->seq_res, 1, 0); in nfs4_proc_unlink_setup()
4933 nfs_fattr_init(res->dir_attr); in nfs4_proc_unlink_setup()
4943 nfs4_setup_sequence(NFS_SB(data->dentry->d_sb)->nfs_client, in nfs4_proc_unlink_rpc_prepare()
4944 &data->args.seq_args, in nfs4_proc_unlink_rpc_prepare()
4945 &data->res.seq_res, in nfs4_proc_unlink_rpc_prepare()
4951 struct nfs_unlinkdata *data = task->tk_calldata; in nfs4_proc_unlink_done()
4952 struct nfs_removeres *res = &data->res; in nfs4_proc_unlink_done()
4954 if (!nfs4_sequence_done(task, &res->seq_res)) in nfs4_proc_unlink_done()
4956 if (nfs4_async_handle_error(task, res->server, NULL, in nfs4_proc_unlink_done()
4957 &data->timeout) == -EAGAIN) in nfs4_proc_unlink_done()
4959 if (task->tk_status == 0) in nfs4_proc_unlink_done()
4960 nfs4_update_changeattr(dir, &res->cinfo, in nfs4_proc_unlink_done()
4961 res->dir_attr->time_start, in nfs4_proc_unlink_done()
4970 struct nfs_renameargs *arg = msg->rpc_argp; in nfs4_proc_rename_setup()
4971 struct nfs_renameres *res = msg->rpc_resp; in nfs4_proc_rename_setup()
4979 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME]; in nfs4_proc_rename_setup()
4980 res->server = NFS_SB(old_dentry->d_sb); in nfs4_proc_rename_setup()
4981 nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1, 0); in nfs4_proc_rename_setup()
4986 nfs4_setup_sequence(NFS_SERVER(data->old_dir)->nfs_client, in nfs4_proc_rename_rpc_prepare()
4987 &data->args.seq_args, in nfs4_proc_rename_rpc_prepare()
4988 &data->res.seq_res, in nfs4_proc_rename_rpc_prepare()
4995 struct nfs_renamedata *data = task->tk_calldata; in nfs4_proc_rename_done()
4996 struct nfs_renameres *res = &data->res; in nfs4_proc_rename_done()
4998 if (!nfs4_sequence_done(task, &res->seq_res)) in nfs4_proc_rename_done()
5000 if (nfs4_async_handle_error(task, res->server, NULL, &data->timeout) == -EAGAIN) in nfs4_proc_rename_done()
5003 if (task->tk_status == 0) { in nfs4_proc_rename_done()
5004 nfs_d_prune_case_insensitive_aliases(d_inode(data->old_dentry)); in nfs4_proc_rename_done()
5007 nfs4_update_changeattr(old_dir, &res->old_cinfo, in nfs4_proc_rename_done()
5008 res->old_fattr->time_start, in nfs4_proc_rename_done()
5011 nfs4_update_changeattr(new_dir, &res->new_cinfo, in nfs4_proc_rename_done()
5012 res->new_fattr->time_start, in nfs4_proc_rename_done()
5016 nfs4_update_changeattr(old_dir, &res->old_cinfo, in nfs4_proc_rename_done()
5017 res->old_fattr->time_start, in nfs4_proc_rename_done()
5041 int status = -ENOMEM; in _nfs4_proc_link()
5048 nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, res.fattr->label), in _nfs4_proc_link()
5051 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); in _nfs4_proc_link()
5053 nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start, in _nfs4_proc_link()
5097 data->fattr.label = nfs4_label_alloc(server, GFP_KERNEL); in nfs4_alloc_createdata()
5098 if (IS_ERR(data->fattr.label)) in nfs4_alloc_createdata()
5101 data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE]; in nfs4_alloc_createdata()
5102 data->msg.rpc_argp = &data->arg; in nfs4_alloc_createdata()
5103 data->msg.rpc_resp = &data->res; in nfs4_alloc_createdata()
5104 data->arg.dir_fh = NFS_FH(dir); in nfs4_alloc_createdata()
5105 data->arg.server = server; in nfs4_alloc_createdata()
5106 data->arg.name = name; in nfs4_alloc_createdata()
5107 data->arg.attrs = sattr; in nfs4_alloc_createdata()
5108 data->arg.ftype = ftype; in nfs4_alloc_createdata()
5109 data->arg.bitmask = nfs4_bitmask(server, data->fattr.label); in nfs4_alloc_createdata()
5110 data->arg.umask = current_umask(); in nfs4_alloc_createdata()
5111 data->res.server = server; in nfs4_alloc_createdata()
5112 data->res.fh = &data->fh; in nfs4_alloc_createdata()
5113 data->res.fattr = &data->fattr; in nfs4_alloc_createdata()
5114 nfs_fattr_init(data->res.fattr); in nfs4_alloc_createdata()
5124 int status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &data->msg, in nfs4_do_create()
5125 &data->arg.seq_args, &data->res.seq_res, 1); in nfs4_do_create()
5127 spin_lock(&dir->i_lock); in nfs4_do_create()
5129 if (data->arg.ftype == NF4DIR) in nfs4_do_create()
5131 nfs4_update_changeattr_locked(dir, &data->res.dir_cinfo, in nfs4_do_create()
5132 data->res.fattr->time_start, in nfs4_do_create()
5134 spin_unlock(&dir->i_lock); in nfs4_do_create()
5135 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); in nfs4_do_create()
5142 nfs4_label_free(data->fattr.label); in nfs4_free_createdata()
5150 struct page *page = &folio->page; in _nfs4_proc_symlink()
5152 int status = -ENAMETOOLONG; in _nfs4_proc_symlink()
5157 status = -ENOMEM; in _nfs4_proc_symlink()
5158 data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4LNK); in _nfs4_proc_symlink()
5162 data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK]; in _nfs4_proc_symlink()
5163 data->arg.u.symlink.pages = &page; in _nfs4_proc_symlink()
5164 data->arg.u.symlink.len = len; in _nfs4_proc_symlink()
5165 data->arg.label = label; in _nfs4_proc_symlink()
5187 trace_nfs4_symlink(dir, &dentry->d_name, err); in nfs4_proc_symlink()
5200 int status = -ENOMEM; in _nfs4_proc_mkdir()
5202 data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4DIR); in _nfs4_proc_mkdir()
5206 data->arg.label = label; in _nfs4_proc_mkdir()
5226 if (!(server->attr_bitmask[2] & FATTR4_WORD2_MODE_UMASK)) in nfs4_proc_mkdir()
5227 sattr->ia_mode &= ~current_umask(); in nfs4_proc_mkdir()
5230 trace_nfs4_mkdir(dir, &dentry->d_name, err); in nfs4_proc_mkdir()
5242 struct inode *dir = d_inode(nr_arg->dentry); in _nfs4_proc_readdir()
5246 .pages = nr_arg->pages, in _nfs4_proc_readdir()
5248 .count = nr_arg->page_len, in _nfs4_proc_readdir()
5249 .plus = nr_arg->plus, in _nfs4_proc_readdir()
5256 .rpc_cred = nr_arg->cred, in _nfs4_proc_readdir()
5261 nr_arg->dentry, (unsigned long long)nr_arg->cookie); in _nfs4_proc_readdir()
5262 if (!(server->caps & NFS_CAP_SECURITY_LABEL)) in _nfs4_proc_readdir()
5263 args.bitmask = server->attr_bitmask_nl; in _nfs4_proc_readdir()
5265 args.bitmask = server->attr_bitmask; in _nfs4_proc_readdir()
5267 nfs4_setup_readdir(nr_arg->cookie, nr_arg->verf, nr_arg->dentry, &args); in _nfs4_proc_readdir()
5269 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, in _nfs4_proc_readdir()
5272 memcpy(nr_res->verf, res.verifier.data, NFS4_VERIFIER_SIZE); in _nfs4_proc_readdir()
5291 trace_nfs4_readdir(d_inode(arg->dentry), err); in nfs4_proc_readdir()
5292 err = nfs4_handle_exception(NFS_SERVER(d_inode(arg->dentry)), in nfs4_proc_readdir()
5302 int mode = sattr->ia_mode; in _nfs4_proc_mknod()
5303 int status = -ENOMEM; in _nfs4_proc_mknod()
5305 data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4SOCK); in _nfs4_proc_mknod()
5310 data->arg.ftype = NF4FIFO; in _nfs4_proc_mknod()
5312 data->arg.ftype = NF4BLK; in _nfs4_proc_mknod()
5313 data->arg.u.device.specdata1 = MAJOR(rdev); in _nfs4_proc_mknod()
5314 data->arg.u.device.specdata2 = MINOR(rdev); in _nfs4_proc_mknod()
5317 data->arg.ftype = NF4CHR; in _nfs4_proc_mknod()
5318 data->arg.u.device.specdata1 = MAJOR(rdev); in _nfs4_proc_mknod()
5319 data->arg.u.device.specdata2 = MINOR(rdev); in _nfs4_proc_mknod()
5321 status = -EINVAL; in _nfs4_proc_mknod()
5325 data->arg.label = label; in _nfs4_proc_mknod()
5345 if (!(server->attr_bitmask[2] & FATTR4_WORD2_MODE_UMASK)) in nfs4_proc_mknod()
5346 sattr->ia_mode &= ~current_umask(); in nfs4_proc_mknod()
5349 trace_nfs4_mknod(dir, &dentry->d_name, err); in nfs4_proc_mknod()
5364 .bitmask = server->attr_bitmask, in _nfs4_proc_statfs()
5375 nfs_fattr_init(fsstat->fattr); in _nfs4_proc_statfs()
5376 return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_proc_statfs()
5398 .bitmask = server->attr_bitmask, in _nfs4_do_fsinfo()
5409 return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_do_fsinfo()
5421 trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err); in nfs4_do_fsinfo()
5423 nfs4_set_lease_period(server->nfs_client, fsinfo->lease_time * HZ); in nfs4_do_fsinfo()
5435 nfs_fattr_init(fsinfo->fattr); in nfs4_proc_fsinfo()
5439 server->pnfs_blksize = fsinfo->blksize; in nfs4_proc_fsinfo()
5451 .bitmask = server->attr_bitmask, in _nfs4_proc_pathconf()
5468 nfs_fattr_init(pathconf->fattr); in _nfs4_proc_pathconf()
5469 return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_proc_pathconf()
5493 return nfs4_select_rw_stateid(ctx->state, fmode, l_ctx, stateid, NULL); in nfs4_set_rw_stateid()
5505 if (nfs4_set_rw_stateid(&_current_stateid, ctx, l_ctx, fmode) == -EIO) in nfs4_stateid_is_current()
5513 case -NFS4ERR_DELEG_REVOKED: in nfs4_error_stateid_expired()
5514 case -NFS4ERR_ADMIN_REVOKED: in nfs4_error_stateid_expired()
5515 case -NFS4ERR_BAD_STATEID: in nfs4_error_stateid_expired()
5516 case -NFS4ERR_STALE_STATEID: in nfs4_error_stateid_expired()
5517 case -NFS4ERR_OLD_STATEID: in nfs4_error_stateid_expired()
5518 case -NFS4ERR_OPENMODE: in nfs4_error_stateid_expired()
5519 case -NFS4ERR_EXPIRED: in nfs4_error_stateid_expired()
5527 struct nfs_server *server = NFS_SERVER(hdr->inode); in nfs4_read_done_cb()
5529 trace_nfs4_read(hdr, task->tk_status); in nfs4_read_done_cb()
5530 if (task->tk_status < 0) { in nfs4_read_done_cb()
5532 .inode = hdr->inode, in nfs4_read_done_cb()
5533 .state = hdr->args.context->state, in nfs4_read_done_cb()
5534 .stateid = &hdr->args.stateid, in nfs4_read_done_cb()
5536 task->tk_status = nfs4_async_handle_exception(task, in nfs4_read_done_cb()
5537 server, task->tk_status, &exception); in nfs4_read_done_cb()
5540 return -EAGAIN; in nfs4_read_done_cb()
5544 if (task->tk_status > 0) in nfs4_read_done_cb()
5545 renew_lease(server, hdr->timestamp); in nfs4_read_done_cb()
5553 if (!nfs4_error_stateid_expired(task->tk_status) || in nfs4_read_stateid_changed()
5554 nfs4_stateid_is_current(&args->stateid, in nfs4_read_stateid_changed()
5555 args->context, in nfs4_read_stateid_changed()
5556 args->lock_context, in nfs4_read_stateid_changed()
5566 struct nfs_server *server = NFS_SERVER(hdr->inode); in nfs4_read_plus_not_supported()
5567 struct rpc_message *msg = &task->tk_msg; in nfs4_read_plus_not_supported()
5569 if (msg->rpc_proc == &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS] && in nfs4_read_plus_not_supported()
5570 task->tk_status == -ENOTSUPP) { in nfs4_read_plus_not_supported()
5571 server->caps &= ~NFS_CAP_READ_PLUS; in nfs4_read_plus_not_supported()
5572 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; in nfs4_read_plus_not_supported()
5581 if (!nfs4_sequence_done(task, &hdr->res.seq_res)) in nfs4_read_done()
5582 return -EAGAIN; in nfs4_read_done()
5583 if (nfs4_read_stateid_changed(task, &hdr->args)) in nfs4_read_done()
5584 return -EAGAIN; in nfs4_read_done()
5586 return -EAGAIN; in nfs4_read_done()
5587 if (task->tk_status > 0) in nfs4_read_done()
5588 nfs_invalidate_atime(hdr->inode); in nfs4_read_done()
5589 return hdr->pgio_done_cb ? hdr->pgio_done_cb(task, hdr) : in nfs4_read_done()
5598 if (nfs_server_capable(hdr->inode, NFS_CAP_READ_PLUS) && !hdr->ds_clp) { in nfs42_read_plus_support()
5599 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS]; in nfs42_read_plus_support()
5615 hdr->timestamp = jiffies; in nfs4_proc_read_setup()
5616 if (!hdr->pgio_done_cb) in nfs4_proc_read_setup()
5617 hdr->pgio_done_cb = nfs4_read_done_cb; in nfs4_proc_read_setup()
5619 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; in nfs4_proc_read_setup()
5620 nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); in nfs4_proc_read_setup()
5626 if (nfs4_setup_sequence(NFS_SERVER(hdr->inode)->nfs_client, in nfs4_proc_pgio_rpc_prepare()
5627 &hdr->args.seq_args, in nfs4_proc_pgio_rpc_prepare()
5628 &hdr->res.seq_res, in nfs4_proc_pgio_rpc_prepare()
5631 if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, in nfs4_proc_pgio_rpc_prepare()
5632 hdr->args.lock_context, in nfs4_proc_pgio_rpc_prepare()
5633 hdr->rw_mode) == -EIO) in nfs4_proc_pgio_rpc_prepare()
5634 return -EIO; in nfs4_proc_pgio_rpc_prepare()
5635 if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) in nfs4_proc_pgio_rpc_prepare()
5636 return -EIO; in nfs4_proc_pgio_rpc_prepare()
5643 struct inode *inode = hdr->inode; in nfs4_write_done_cb()
5645 trace_nfs4_write(hdr, task->tk_status); in nfs4_write_done_cb()
5646 if (task->tk_status < 0) { in nfs4_write_done_cb()
5648 .inode = hdr->inode, in nfs4_write_done_cb()
5649 .state = hdr->args.context->state, in nfs4_write_done_cb()
5650 .stateid = &hdr->args.stateid, in nfs4_write_done_cb()
5652 task->tk_status = nfs4_async_handle_exception(task, in nfs4_write_done_cb()
5653 NFS_SERVER(inode), task->tk_status, in nfs4_write_done_cb()
5657 return -EAGAIN; in nfs4_write_done_cb()
5660 if (task->tk_status >= 0) { in nfs4_write_done_cb()
5661 renew_lease(NFS_SERVER(inode), hdr->timestamp); in nfs4_write_done_cb()
5671 if (!nfs4_error_stateid_expired(task->tk_status) || in nfs4_write_stateid_changed()
5672 nfs4_stateid_is_current(&args->stateid, in nfs4_write_stateid_changed()
5673 args->context, in nfs4_write_stateid_changed()
5674 args->lock_context, in nfs4_write_stateid_changed()
5683 if (!nfs4_sequence_done(task, &hdr->res.seq_res)) in nfs4_write_done()
5684 return -EAGAIN; in nfs4_write_done()
5685 if (nfs4_write_stateid_changed(task, &hdr->args)) in nfs4_write_done()
5686 return -EAGAIN; in nfs4_write_done()
5687 return hdr->pgio_done_cb ? hdr->pgio_done_cb(task, hdr) : in nfs4_write_done()
5695 if (hdr->ds_clp != NULL || hdr->dreq != NULL) in nfs4_write_need_cache_consistency_data()
5700 return nfs4_have_delegation(hdr->inode, FMODE_READ, 0) == 0; in nfs4_write_need_cache_consistency_data()
5710 cache_validity |= READ_ONCE(NFS_I(inode)->cache_validity); in nfs4_bitmask_set()
5733 bitmask[i] &= server->attr_bitmask[i]; in nfs4_bitmask_set()
5740 struct nfs_server *server = NFS_SERVER(hdr->inode); in nfs4_proc_write_setup()
5743 hdr->args.bitmask = NULL; in nfs4_proc_write_setup()
5744 hdr->res.fattr = NULL; in nfs4_proc_write_setup()
5746 nfs4_bitmask_set(hdr->args.bitmask_store, in nfs4_proc_write_setup()
5747 server->cache_consistency_bitmask, in nfs4_proc_write_setup()
5748 hdr->inode, NFS_INO_INVALID_BLOCKS); in nfs4_proc_write_setup()
5749 hdr->args.bitmask = hdr->args.bitmask_store; in nfs4_proc_write_setup()
5752 if (!hdr->pgio_done_cb) in nfs4_proc_write_setup()
5753 hdr->pgio_done_cb = nfs4_write_done_cb; in nfs4_proc_write_setup()
5754 hdr->res.server = server; in nfs4_proc_write_setup()
5755 hdr->timestamp = jiffies; in nfs4_proc_write_setup()
5757 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; in nfs4_proc_write_setup()
5758 nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); in nfs4_proc_write_setup()
5759 nfs4_state_protect_write(hdr->ds_clp ? hdr->ds_clp : server->nfs_client, clnt, msg, hdr); in nfs4_proc_write_setup()
5764 nfs4_setup_sequence(NFS_SERVER(data->inode)->nfs_client, in nfs4_proc_commit_rpc_prepare()
5765 &data->args.seq_args, in nfs4_proc_commit_rpc_prepare()
5766 &data->res.seq_res, in nfs4_proc_commit_rpc_prepare()
5772 struct inode *inode = data->inode; in nfs4_commit_done_cb()
5774 trace_nfs4_commit(data, task->tk_status); in nfs4_commit_done_cb()
5776 NULL, NULL) == -EAGAIN) { in nfs4_commit_done_cb()
5778 return -EAGAIN; in nfs4_commit_done_cb()
5785 if (!nfs4_sequence_done(task, &data->res.seq_res)) in nfs4_commit_done()
5786 return -EAGAIN; in nfs4_commit_done()
5787 return data->commit_done_cb(task, data); in nfs4_commit_done()
5793 struct nfs_server *server = NFS_SERVER(data->inode); in nfs4_proc_commit_setup()
5795 if (data->commit_done_cb == NULL) in nfs4_proc_commit_setup()
5796 data->commit_done_cb = nfs4_commit_done_cb; in nfs4_proc_commit_setup()
5797 data->res.server = server; in nfs4_proc_commit_setup()
5798 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; in nfs4_proc_commit_setup()
5799 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); in nfs4_proc_commit_setup()
5800 nfs4_state_protect(data->ds_clp ? data->ds_clp : server->nfs_client, in nfs4_proc_commit_setup()
5815 args->fh = NFS_FH(dst_inode); in _nfs4_proc_commit()
5816 return nfs4_call_sync(server->client, server, &msg, in _nfs4_proc_commit()
5817 &args->seq_args, &res->seq_res, 1); in _nfs4_proc_commit()
5850 struct nfs_client *clp = data->client; in nfs4_renew_release()
5852 if (refcount_read(&clp->cl_count) > 1) in nfs4_renew_release()
5861 struct nfs_client *clp = data->client; in nfs4_renew_done()
5862 unsigned long timestamp = data->timestamp; in nfs4_renew_done()
5864 trace_nfs4_renew_async(clp, task->tk_status); in nfs4_renew_done()
5865 switch (task->tk_status) { in nfs4_renew_done()
5868 case -NFS4ERR_LEASE_MOVED: in nfs4_renew_done()
5873 if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) == 0) in nfs4_renew_done()
5875 if (task->tk_status != NFS4ERR_CB_PATH_DOWN) { in nfs4_renew_done()
5900 if (!refcount_inc_not_zero(&clp->cl_count)) in nfs4_proc_async_renew()
5901 return -EIO; in nfs4_proc_async_renew()
5905 return -ENOMEM; in nfs4_proc_async_renew()
5907 data->client = clp; in nfs4_proc_async_renew()
5908 data->timestamp = jiffies; in nfs4_proc_async_renew()
5909 return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT, in nfs4_proc_async_renew()
5923 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); in nfs4_proc_renew()
5935 return server->attr_bitmask[0] & FATTR4_WORD0_ACL; in nfs4_server_supports_acls()
5937 return server->attr_bitmask[1] & FATTR4_WORD1_DACL; in nfs4_server_supports_acls()
5939 return server->attr_bitmask[1] & FATTR4_WORD1_SACL; in nfs4_server_supports_acls()
5965 buflen -= len; in nfs4_buf_to_pages_noslab()
5973 for(; rc > 0; rc--) in nfs4_buf_to_pages_noslab()
5974 __free_page(spages[rc-1]); in nfs4_buf_to_pages_noslab()
5975 return -ENOMEM; in nfs4_buf_to_pages_noslab()
5989 spin_lock(&inode->i_lock); in nfs4_set_cached_acl()
5990 kfree(nfsi->nfs4_acl); in nfs4_set_cached_acl()
5991 nfsi->nfs4_acl = acl; in nfs4_set_cached_acl()
5992 spin_unlock(&inode->i_lock); in nfs4_set_cached_acl()
6005 int ret = -ENOENT; in nfs4_read_cached_acl()
6007 spin_lock(&inode->i_lock); in nfs4_read_cached_acl()
6008 acl = nfsi->nfs4_acl; in nfs4_read_cached_acl()
6011 if (acl->type != type) in nfs4_read_cached_acl()
6015 if (acl->cached == 0) in nfs4_read_cached_acl()
6017 ret = -ERANGE; /* see getxattr(2) man page */ in nfs4_read_cached_acl()
6018 if (acl->len > buflen) in nfs4_read_cached_acl()
6020 memcpy(buf, acl->data, acl->len); in nfs4_read_cached_acl()
6022 ret = acl->len; in nfs4_read_cached_acl()
6024 spin_unlock(&inode->i_lock); in nfs4_read_cached_acl()
6039 acl->cached = 1; in nfs4_write_cached_acl()
6040 _copy_from_pages(acl->data, pages, pgbase, acl_len); in nfs4_write_cached_acl()
6045 acl->cached = 0; in nfs4_write_cached_acl()
6047 acl->type = type; in nfs4_write_cached_acl()
6048 acl->len = acl_len; in nfs4_write_cached_acl()
6082 int ret = -ENOMEM, i; in __nfs4_get_acl_uncached()
6086 buflen = server->rsize; in __nfs4_get_acl_uncached()
6091 return -ENOMEM; in __nfs4_get_acl_uncached()
6110 ret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode), in __nfs4_get_acl_uncached()
6115 /* Handle the case where the passed-in buffer is too short */ in __nfs4_get_acl_uncached()
6120 ret = -ERANGE; in __nfs4_get_acl_uncached()
6127 ret = -ERANGE; in __nfs4_get_acl_uncached()
6135 while (--i >= 0) in __nfs4_get_acl_uncached()
6167 return -EOPNOTSUPP; in nfs4_proc_get_acl()
6171 if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) in nfs4_proc_get_acl()
6174 if (ret != -ENOENT) in nfs4_proc_get_acl()
6175 /* -ENOENT is returned if there is no ACL or if there is an ACL in nfs4_proc_get_acl()
6203 return -EINVAL; in __nfs4_proc_set_acl()
6205 return -EOPNOTSUPP; in __nfs4_proc_set_acl()
6207 return -ERANGE; in __nfs4_proc_set_acl()
6212 ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); in __nfs4_proc_set_acl()
6218 for (; i > 0; i--) in __nfs4_proc_set_acl()
6219 put_page(pages[i-1]); in __nfs4_proc_set_acl()
6225 spin_lock(&inode->i_lock); in __nfs4_proc_set_acl()
6229 spin_unlock(&inode->i_lock); in __nfs4_proc_set_acl()
6243 if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME) { in nfs4_proc_set_acl()
6246 * isn't involved in encoding the ACEs. in nfs4_proc_set_acl()
6248 err = -EINVAL; in nfs4_proc_set_acl()
6285 ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 0); in _nfs4_get_security_label()
6289 return -ENOENT; in _nfs4_get_security_label()
6302 return -EOPNOTSUPP; in nfs4_get_security_label()
6341 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); in _nfs4_do_set_security_label()
6372 return -EOPNOTSUPP; in nfs4_set_security_label()
6376 return -ENOMEM; in nfs4_set_security_label()
6393 if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) { in nfs4_init_boot_verifier()
6399 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); in nfs4_init_boot_verifier()
6400 u64 ns = ktime_to_ns(nn->boot_time); in nfs4_init_boot_verifier()
6405 memcpy(bootverf->data, verf, sizeof(bootverf->data)); in nfs4_init_boot_verifier()
6411 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); in nfs4_get_uniquifier()
6412 struct nfs_netns_client *nn_clp = nn->nfs_client; in nfs4_get_uniquifier()
6419 id = rcu_dereference(nn_clp->identifier); in nfs4_get_uniquifier()
6439 if (clp->cl_owner_id != NULL) in nfs4_init_nonuniform_client_string()
6444 strlen(clp->cl_rpcclient->cl_nodename) + in nfs4_init_nonuniform_client_string()
6446 strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) + in nfs4_init_nonuniform_client_string()
6455 return -EINVAL; in nfs4_init_nonuniform_client_string()
6460 * about a memory-reclaim deadlock. in nfs4_init_nonuniform_client_string()
6464 return -ENOMEM; in nfs4_init_nonuniform_client_string()
6469 clp->cl_rpcclient->cl_nodename, buf, in nfs4_init_nonuniform_client_string()
6470 rpc_peeraddr2str(clp->cl_rpcclient, in nfs4_init_nonuniform_client_string()
6474 clp->cl_rpcclient->cl_nodename, in nfs4_init_nonuniform_client_string()
6475 rpc_peeraddr2str(clp->cl_rpcclient, in nfs4_init_nonuniform_client_string()
6479 clp->cl_owner_id = str; in nfs4_init_nonuniform_client_string()
6491 if (clp->cl_owner_id != NULL) in nfs4_init_uniform_client_string()
6495 strlen(clp->cl_rpcclient->cl_nodename) + 1; in nfs4_init_uniform_client_string()
6502 return -EINVAL; in nfs4_init_uniform_client_string()
6507 * about a memory-reclaim deadlock. in nfs4_init_uniform_client_string()
6511 return -ENOMEM; in nfs4_init_uniform_client_string()
6515 clp->rpc_ops->version, clp->cl_minorversion, in nfs4_init_uniform_client_string()
6516 buf, clp->cl_rpcclient->cl_nodename); in nfs4_init_uniform_client_string()
6519 clp->rpc_ops->version, clp->cl_minorversion, in nfs4_init_uniform_client_string()
6520 clp->cl_rpcclient->cl_nodename); in nfs4_init_uniform_client_string()
6521 clp->cl_owner_id = str; in nfs4_init_uniform_client_string()
6533 if (strchr(clp->cl_ipaddr, ':') != NULL) in nfs4_init_callback_netid()
6543 if (task->tk_status == 0) in nfs4_setclientid_done()
6544 sc->sc_cred = get_rpccred(task->tk_rqstp->rq_cred); in nfs4_setclientid_done()
6552 * nfs4_proc_setclientid - Negotiate client ID
6578 .rpc_client = clp->cl_rpcclient, in nfs4_proc_setclientid()
6590 if (test_bit(NFS_CS_MIGRATION, &clp->cl_flags)) in nfs4_proc_setclientid()
6605 clp->cl_ipaddr, port >> 8, port & 255); in nfs4_proc_setclientid()
6608 clp->cl_rpcclient->cl_auth->au_ops->au_name, in nfs4_proc_setclientid()
6609 clp->cl_owner_id); in nfs4_proc_setclientid()
6613 kfree(clp->cl_acceptor); in nfs4_proc_setclientid()
6614 clp->cl_acceptor = rpcauth_stringify_acceptor(setclientid.sc_cred); in nfs4_proc_setclientid()
6627 * nfs4_proc_setclientid_confirm - Confirm client ID
6646 clp->cl_rpcclient->cl_auth->au_ops->au_name, in nfs4_proc_setclientid_confirm()
6647 clp->cl_clientid); in nfs4_proc_setclientid_confirm()
6648 status = rpc_call_sync(clp->cl_rpcclient, &msg, in nfs4_proc_setclientid_confirm()
6678 .inode = data->inode, in nfs4_delegreturn_done()
6679 .stateid = &data->stateid, in nfs4_delegreturn_done()
6680 .task_is_privileged = data->args.seq_args.sa_privileged, in nfs4_delegreturn_done()
6683 if (!nfs4_sequence_done(task, &data->res.seq_res)) in nfs4_delegreturn_done()
6686 trace_nfs4_delegreturn_exit(&data->args, &data->res, task->tk_status); in nfs4_delegreturn_done()
6689 if (pnfs_roc_done(task, &data->args.lr_args, &data->res.lr_res, in nfs4_delegreturn_done()
6690 &data->res.lr_ret) == -EAGAIN) in nfs4_delegreturn_done()
6693 if (data->args.sattr_args && task->tk_status != 0) { in nfs4_delegreturn_done()
6694 switch(data->res.sattr_ret) { in nfs4_delegreturn_done()
6696 data->args.sattr_args = NULL; in nfs4_delegreturn_done()
6697 data->res.sattr_res = false; in nfs4_delegreturn_done()
6699 case -NFS4ERR_ADMIN_REVOKED: in nfs4_delegreturn_done()
6700 case -NFS4ERR_DELEG_REVOKED: in nfs4_delegreturn_done()
6701 case -NFS4ERR_EXPIRED: in nfs4_delegreturn_done()
6702 case -NFS4ERR_BAD_STATEID: in nfs4_delegreturn_done()
6705 case -NFS4ERR_OLD_STATEID: in nfs4_delegreturn_done()
6706 if (nfs4_refresh_delegation_stateid(&data->stateid, in nfs4_delegreturn_done()
6707 data->inode)) in nfs4_delegreturn_done()
6711 data->args.sattr_args = NULL; in nfs4_delegreturn_done()
6712 data->res.sattr_res = false; in nfs4_delegreturn_done()
6717 switch (task->tk_status) { in nfs4_delegreturn_done()
6719 renew_lease(data->res.server, data->timestamp); in nfs4_delegreturn_done()
6721 case -NFS4ERR_ADMIN_REVOKED: in nfs4_delegreturn_done()
6722 case -NFS4ERR_DELEG_REVOKED: in nfs4_delegreturn_done()
6723 case -NFS4ERR_EXPIRED: in nfs4_delegreturn_done()
6724 nfs4_free_revoked_stateid(data->res.server, in nfs4_delegreturn_done()
6725 data->args.stateid, in nfs4_delegreturn_done()
6726 task->tk_msg.rpc_cred); in nfs4_delegreturn_done()
6728 case -NFS4ERR_BAD_STATEID: in nfs4_delegreturn_done()
6729 case -NFS4ERR_STALE_STATEID: in nfs4_delegreturn_done()
6730 case -ETIMEDOUT: in nfs4_delegreturn_done()
6731 task->tk_status = 0; in nfs4_delegreturn_done()
6733 case -NFS4ERR_OLD_STATEID: in nfs4_delegreturn_done()
6734 if (!nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) in nfs4_delegreturn_done()
6735 nfs4_stateid_seqid_inc(&data->stateid); in nfs4_delegreturn_done()
6736 if (data->args.bitmask) { in nfs4_delegreturn_done()
6737 data->args.bitmask = NULL; in nfs4_delegreturn_done()
6738 data->res.fattr = NULL; in nfs4_delegreturn_done()
6741 case -NFS4ERR_ACCESS: in nfs4_delegreturn_done()
6742 if (data->args.bitmask) { in nfs4_delegreturn_done()
6743 data->args.bitmask = NULL; in nfs4_delegreturn_done()
6744 data->res.fattr = NULL; in nfs4_delegreturn_done()
6749 task->tk_status = nfs4_async_handle_exception(task, in nfs4_delegreturn_done()
6750 data->res.server, task->tk_status, in nfs4_delegreturn_done()
6755 nfs_delegation_mark_returned(data->inode, data->args.stateid); in nfs4_delegreturn_done()
6756 data->rpc_status = task->tk_status; in nfs4_delegreturn_done()
6759 task->tk_status = 0; in nfs4_delegreturn_done()
6766 struct inode *inode = data->inode; in nfs4_delegreturn_release()
6768 if (data->lr.roc) in nfs4_delegreturn_release()
6769 pnfs_roc_release(&data->lr.arg, &data->lr.res, in nfs4_delegreturn_release()
6770 data->res.lr_ret); in nfs4_delegreturn_release()
6772 nfs4_fattr_set_prechange(&data->fattr, in nfs4_delegreturn_release()
6774 nfs_refresh_inode(inode, &data->fattr); in nfs4_delegreturn_release()
6787 if (!d_data->lr.roc && nfs4_wait_on_layoutreturn(d_data->inode, task)) { in nfs4_delegreturn_prepare()
6788 nfs4_sequence_done(task, &d_data->res.seq_res); in nfs4_delegreturn_prepare()
6792 lo = d_data->args.lr_args ? d_data->args.lr_args->layout : NULL; in nfs4_delegreturn_prepare()
6794 d_data->args.lr_args = NULL; in nfs4_delegreturn_prepare()
6795 d_data->res.lr_res = NULL; in nfs4_delegreturn_prepare()
6798 nfs4_setup_sequence(d_data->res.server->nfs_client, in nfs4_delegreturn_prepare()
6799 &d_data->args.seq_args, in nfs4_delegreturn_prepare()
6800 &d_data->res.seq_res, in nfs4_delegreturn_prepare()
6823 .rpc_client = server->client, in _nfs4_proc_delegreturn()
6835 return -ENOMEM; in _nfs4_proc_delegreturn()
6837 nfs4_state_protect(server->nfs_client, in _nfs4_proc_delegreturn()
6841 data->args.fhandle = &data->fh; in _nfs4_proc_delegreturn()
6842 data->args.stateid = &data->stateid; in _nfs4_proc_delegreturn()
6843 nfs4_bitmask_set(data->args.bitmask_store, in _nfs4_proc_delegreturn()
6844 server->cache_consistency_bitmask, inode, 0); in _nfs4_proc_delegreturn()
6845 data->args.bitmask = data->args.bitmask_store; in _nfs4_proc_delegreturn()
6846 nfs_copy_fh(&data->fh, NFS_FH(inode)); in _nfs4_proc_delegreturn()
6847 nfs4_stateid_copy(&data->stateid, stateid); in _nfs4_proc_delegreturn()
6848 data->res.fattr = &data->fattr; in _nfs4_proc_delegreturn()
6849 data->res.server = server; in _nfs4_proc_delegreturn()
6850 data->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; in _nfs4_proc_delegreturn()
6851 data->lr.arg.ld_private = &data->lr.ld_private; in _nfs4_proc_delegreturn()
6852 nfs_fattr_init(data->res.fattr); in _nfs4_proc_delegreturn()
6853 data->timestamp = jiffies; in _nfs4_proc_delegreturn()
6854 data->rpc_status = 0; in _nfs4_proc_delegreturn()
6855 data->inode = nfs_igrab_and_active(inode); in _nfs4_proc_delegreturn()
6856 if (data->inode || issync) { in _nfs4_proc_delegreturn()
6857 data->lr.roc = pnfs_roc(inode, &data->lr.arg, &data->lr.res, in _nfs4_proc_delegreturn()
6859 if (data->lr.roc) { in _nfs4_proc_delegreturn()
6860 data->args.lr_args = &data->lr.arg; in _nfs4_proc_delegreturn()
6861 data->res.lr_res = &data->lr.res; in _nfs4_proc_delegreturn()
6866 test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) { in _nfs4_proc_delegreturn()
6867 if (delegation->type & FMODE_READ) { in _nfs4_proc_delegreturn()
6868 data->sattr.atime = inode_get_atime(inode); in _nfs4_proc_delegreturn()
6869 data->sattr.atime_set = true; in _nfs4_proc_delegreturn()
6871 if (delegation->type & FMODE_WRITE) { in _nfs4_proc_delegreturn()
6872 data->sattr.mtime = inode_get_mtime(inode); in _nfs4_proc_delegreturn()
6873 data->sattr.mtime_set = true; in _nfs4_proc_delegreturn()
6875 data->args.sattr_args = &data->sattr; in _nfs4_proc_delegreturn()
6876 data->res.sattr_res = true; in _nfs4_proc_delegreturn()
6879 if (!data->inode) in _nfs4_proc_delegreturn()
6880 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, in _nfs4_proc_delegreturn()
6883 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, in _nfs4_proc_delegreturn()
6887 msg.rpc_argp = &data->args; in _nfs4_proc_delegreturn()
6888 msg.rpc_resp = &data->res; in _nfs4_proc_delegreturn()
6897 status = data->rpc_status; in _nfs4_proc_delegreturn()
6915 case -NFS4ERR_STALE_STATEID: in nfs4_proc_delegreturn()
6916 case -NFS4ERR_EXPIRED: in nfs4_proc_delegreturn()
6927 struct inode *inode = state->inode; in _nfs4_proc_getlk()
6929 struct nfs_client *clp = server->nfs_client; in _nfs4_proc_getlk()
6941 .rpc_cred = state->owner->so_cred, in _nfs4_proc_getlk()
6946 arg.lock_owner.clientid = clp->cl_clientid; in _nfs4_proc_getlk()
6950 lsp = request->fl_u.nfs4_fl.owner; in _nfs4_proc_getlk()
6951 arg.lock_owner.id = lsp->ls_seqid.owner_id; in _nfs4_proc_getlk()
6952 arg.lock_owner.s_dev = server->s_dev; in _nfs4_proc_getlk()
6953 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); in _nfs4_proc_getlk()
6956 request->c.flc_type = F_UNLCK; in _nfs4_proc_getlk()
6958 case -NFS4ERR_DENIED: in _nfs4_proc_getlk()
6961 request->fl_ops->fl_release_private(request); in _nfs4_proc_getlk()
6962 request->fl_ops = NULL; in _nfs4_proc_getlk()
6977 err = nfs4_handle_exception(NFS_SERVER(state->inode), err, in nfs4_proc_getlk()
6990 struct nfs4_state *state = lsp->ls_state; in nfs4_refresh_lock_old_stateid()
6993 spin_lock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
6994 if (!nfs4_stateid_match_other(dst, &lsp->ls_stateid)) in nfs4_refresh_lock_old_stateid()
6996 if (!nfs4_stateid_is_newer(&lsp->ls_stateid, dst)) in nfs4_refresh_lock_old_stateid()
6999 dst->seqid = lsp->ls_stateid.seqid; in nfs4_refresh_lock_old_stateid()
7002 spin_unlock(&state->state_lock); in nfs4_refresh_lock_old_stateid()
7009 struct nfs4_state *state = lsp->ls_state; in nfs4_sync_lock_stateid()
7012 spin_lock(&state->state_lock); in nfs4_sync_lock_stateid()
7013 ret = !nfs4_stateid_match_other(dst, &lsp->ls_stateid); in nfs4_sync_lock_stateid()
7014 nfs4_stateid_copy(dst, &lsp->ls_stateid); in nfs4_sync_lock_stateid()
7015 spin_unlock(&state->state_lock); in nfs4_sync_lock_stateid()
7036 struct nfs4_state *state = lsp->ls_state; in nfs4_alloc_unlockdata()
7037 struct inode *inode = state->inode; in nfs4_alloc_unlockdata()
7042 p->arg.fh = NFS_FH(inode); in nfs4_alloc_unlockdata()
7043 p->arg.fl = &p->fl; in nfs4_alloc_unlockdata()
7044 p->arg.seqid = seqid; in nfs4_alloc_unlockdata()
7045 p->res.seqid = seqid; in nfs4_alloc_unlockdata()
7046 p->lsp = lsp; in nfs4_alloc_unlockdata()
7048 p->ctx = get_nfs_open_context(ctx); in nfs4_alloc_unlockdata()
7049 p->l_ctx = nfs_get_lock_context(ctx); in nfs4_alloc_unlockdata()
7050 locks_init_lock(&p->fl); in nfs4_alloc_unlockdata()
7051 locks_copy_lock(&p->fl, fl); in nfs4_alloc_unlockdata()
7052 p->server = NFS_SERVER(inode); in nfs4_alloc_unlockdata()
7053 spin_lock(&state->state_lock); in nfs4_alloc_unlockdata()
7054 nfs4_stateid_copy(&p->arg.stateid, &lsp->ls_stateid); in nfs4_alloc_unlockdata()
7055 spin_unlock(&state->state_lock); in nfs4_alloc_unlockdata()
7062 nfs_free_seqid(calldata->arg.seqid); in nfs4_locku_release_calldata()
7063 nfs4_put_lock_state(calldata->lsp); in nfs4_locku_release_calldata()
7064 nfs_put_lock_context(calldata->l_ctx); in nfs4_locku_release_calldata()
7065 put_nfs_open_context(calldata->ctx); in nfs4_locku_release_calldata()
7073 .inode = calldata->lsp->ls_state->inode, in nfs4_locku_done()
7074 .stateid = &calldata->arg.stateid, in nfs4_locku_done()
7077 if (!nfs4_sequence_done(task, &calldata->res.seq_res)) in nfs4_locku_done()
7079 switch (task->tk_status) { in nfs4_locku_done()
7081 renew_lease(calldata->server, calldata->timestamp); in nfs4_locku_done()
7082 locks_lock_inode_wait(calldata->lsp->ls_state->inode, &calldata->fl); in nfs4_locku_done()
7083 if (nfs4_update_lock_stateid(calldata->lsp, in nfs4_locku_done()
7084 &calldata->res.stateid)) in nfs4_locku_done()
7087 case -NFS4ERR_ADMIN_REVOKED: in nfs4_locku_done()
7088 case -NFS4ERR_EXPIRED: in nfs4_locku_done()
7089 nfs4_free_revoked_stateid(calldata->server, in nfs4_locku_done()
7090 &calldata->arg.stateid, in nfs4_locku_done()
7091 task->tk_msg.rpc_cred); in nfs4_locku_done()
7093 case -NFS4ERR_BAD_STATEID: in nfs4_locku_done()
7094 case -NFS4ERR_STALE_STATEID: in nfs4_locku_done()
7095 if (nfs4_sync_lock_stateid(&calldata->arg.stateid, in nfs4_locku_done()
7096 calldata->lsp)) in nfs4_locku_done()
7099 case -NFS4ERR_OLD_STATEID: in nfs4_locku_done()
7100 if (nfs4_refresh_lock_old_stateid(&calldata->arg.stateid, in nfs4_locku_done()
7101 calldata->lsp)) in nfs4_locku_done()
7105 task->tk_status = nfs4_async_handle_exception(task, in nfs4_locku_done()
7106 calldata->server, task->tk_status, in nfs4_locku_done()
7111 nfs_release_seqid(calldata->arg.seqid); in nfs4_locku_done()
7118 if (test_bit(NFS_CONTEXT_UNLOCK, &calldata->l_ctx->open_context->flags) && in nfs4_locku_prepare()
7119 nfs_async_iocounter_wait(task, calldata->l_ctx)) in nfs4_locku_prepare()
7122 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) in nfs4_locku_prepare()
7124 if (test_bit(NFS_LOCK_INITIALIZED, &calldata->lsp->ls_flags) == 0) { in nfs4_locku_prepare()
7128 calldata->timestamp = jiffies; in nfs4_locku_prepare()
7129 if (nfs4_setup_sequence(calldata->server->nfs_client, in nfs4_locku_prepare()
7130 &calldata->arg.seq_args, in nfs4_locku_prepare()
7131 &calldata->res.seq_res, in nfs4_locku_prepare()
7133 nfs_release_seqid(calldata->arg.seqid); in nfs4_locku_prepare()
7136 task->tk_action = NULL; in nfs4_locku_prepare()
7138 nfs4_sequence_done(task, &calldata->res.seq_res); in nfs4_locku_prepare()
7155 .rpc_cred = ctx->cred, in nfs4_do_unlck()
7158 .rpc_client = NFS_CLIENT(lsp->ls_state->inode), in nfs4_do_unlck()
7165 if (nfs_server_capable(lsp->ls_state->inode, NFS_CAP_MOVEABLE)) in nfs4_do_unlck()
7168 nfs4_state_protect(NFS_SERVER(lsp->ls_state->inode)->nfs_client, in nfs4_do_unlck()
7171 /* Ensure this is an unlock - when canceling a lock, the in nfs4_do_unlck()
7174 fl->c.flc_type = F_UNLCK; in nfs4_do_unlck()
7175 if (fl->c.flc_flags & FL_CLOSE) in nfs4_do_unlck()
7176 set_bit(NFS_CONTEXT_UNLOCK, &ctx->flags); in nfs4_do_unlck()
7181 return ERR_PTR(-ENOMEM); in nfs4_do_unlck()
7184 nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, 0); in nfs4_do_unlck()
7185 msg.rpc_argp = &data->arg; in nfs4_do_unlck()
7186 msg.rpc_resp = &data->res; in nfs4_do_unlck()
7193 struct inode *inode = state->inode; in nfs4_proc_unlck()
7194 struct nfs4_state_owner *sp = state->owner; in nfs4_proc_unlck()
7201 unsigned char saved_flags = request->c.flc_flags; in nfs4_proc_unlck()
7205 request->c.flc_flags |= FL_EXISTS; in nfs4_proc_unlck()
7207 mutex_lock(&sp->so_delegreturn_mutex); in nfs4_proc_unlck()
7208 /* Exclude nfs4_reclaim_open_stateid() - note nesting! */ in nfs4_proc_unlck()
7209 down_read(&nfsi->rwsem); in nfs4_proc_unlck()
7210 if (locks_lock_inode_wait(inode, request) == -ENOENT) { in nfs4_proc_unlck()
7211 up_read(&nfsi->rwsem); in nfs4_proc_unlck()
7212 mutex_unlock(&sp->so_delegreturn_mutex); in nfs4_proc_unlck()
7215 lsp = request->fl_u.nfs4_fl.owner; in nfs4_proc_unlck()
7216 set_bit(NFS_LOCK_UNLOCKING, &lsp->ls_flags); in nfs4_proc_unlck()
7217 up_read(&nfsi->rwsem); in nfs4_proc_unlck()
7218 mutex_unlock(&sp->so_delegreturn_mutex); in nfs4_proc_unlck()
7222 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0) in nfs4_proc_unlck()
7224 alloc_seqid = NFS_SERVER(inode)->nfs_client->cl_mvops->alloc_seqid; in nfs4_proc_unlck()
7225 seqid = alloc_seqid(&lsp->ls_seqid, GFP_KERNEL); in nfs4_proc_unlck()
7226 status = -ENOMEM; in nfs4_proc_unlck()
7230 nfs_file_open_context(request->c.flc_file), in nfs4_proc_unlck()
7238 request->c.flc_flags = saved_flags; in nfs4_proc_unlck()
7260 struct inode *inode = lsp->ls_state->inode; in nfs4_alloc_lockdata()
7268 p->arg.fh = NFS_FH(inode); in nfs4_alloc_lockdata()
7269 p->arg.fl = &p->fl; in nfs4_alloc_lockdata()
7270 p->arg.open_seqid = nfs_alloc_seqid(&lsp->ls_state->owner->so_seqid, gfp_mask); in nfs4_alloc_lockdata()
7271 if (IS_ERR(p->arg.open_seqid)) in nfs4_alloc_lockdata()
7273 alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid; in nfs4_alloc_lockdata()
7274 p->arg.lock_seqid = alloc_seqid(&lsp->ls_seqid, gfp_mask); in nfs4_alloc_lockdata()
7275 if (IS_ERR(p->arg.lock_seqid)) in nfs4_alloc_lockdata()
7277 p->arg.lock_owner.clientid = server->nfs_client->cl_clientid; in nfs4_alloc_lockdata()
7278 p->arg.lock_owner.id = lsp->ls_seqid.owner_id; in nfs4_alloc_lockdata()
7279 p->arg.lock_owner.s_dev = server->s_dev; in nfs4_alloc_lockdata()
7280 p->res.lock_seqid = p->arg.lock_seqid; in nfs4_alloc_lockdata()
7281 p->lsp = lsp; in nfs4_alloc_lockdata()
7282 p->server = server; in nfs4_alloc_lockdata()
7283 p->ctx = get_nfs_open_context(ctx); in nfs4_alloc_lockdata()
7284 locks_init_lock(&p->fl); in nfs4_alloc_lockdata()
7285 locks_copy_lock(&p->fl, fl); in nfs4_alloc_lockdata()
7288 nfs_free_seqid(p->arg.open_seqid); in nfs4_alloc_lockdata()
7297 struct nfs4_state *state = data->lsp->ls_state; in nfs4_lock_prepare()
7299 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) in nfs4_lock_prepare()
7302 if (!test_bit(NFS_LOCK_INITIALIZED, &data->lsp->ls_flags)) { in nfs4_lock_prepare()
7303 if (nfs_wait_on_sequence(data->arg.open_seqid, task) != 0) { in nfs4_lock_prepare()
7306 nfs4_stateid_copy(&data->arg.open_stateid, in nfs4_lock_prepare()
7307 &state->open_stateid); in nfs4_lock_prepare()
7308 data->arg.new_lock_owner = 1; in nfs4_lock_prepare()
7309 data->res.open_seqid = data->arg.open_seqid; in nfs4_lock_prepare()
7311 data->arg.new_lock_owner = 0; in nfs4_lock_prepare()
7312 nfs4_stateid_copy(&data->arg.lock_stateid, in nfs4_lock_prepare()
7313 &data->lsp->ls_stateid); in nfs4_lock_prepare()
7316 data->rpc_status = -EBADF; in nfs4_lock_prepare()
7317 task->tk_action = NULL; in nfs4_lock_prepare()
7320 data->timestamp = jiffies; in nfs4_lock_prepare()
7321 if (nfs4_setup_sequence(data->server->nfs_client, in nfs4_lock_prepare()
7322 &data->arg.seq_args, in nfs4_lock_prepare()
7323 &data->res.seq_res, in nfs4_lock_prepare()
7327 nfs_release_seqid(data->arg.open_seqid); in nfs4_lock_prepare()
7329 nfs_release_seqid(data->arg.lock_seqid); in nfs4_lock_prepare()
7331 nfs4_sequence_done(task, &data->res.seq_res); in nfs4_lock_prepare()
7332 dprintk("%s: ret = %d\n", __func__, data->rpc_status); in nfs4_lock_prepare()
7338 struct nfs4_lock_state *lsp = data->lsp; in nfs4_lock_done()
7340 if (!nfs4_sequence_done(task, &data->res.seq_res)) in nfs4_lock_done()
7343 data->rpc_status = task->tk_status; in nfs4_lock_done()
7344 switch (task->tk_status) { in nfs4_lock_done()
7346 renew_lease(NFS_SERVER(d_inode(data->ctx->dentry)), in nfs4_lock_done()
7347 data->timestamp); in nfs4_lock_done()
7348 if (data->arg.new_lock && !data->cancelled) { in nfs4_lock_done()
7349 data->fl.c.flc_flags &= ~(FL_SLEEP | FL_ACCESS); in nfs4_lock_done()
7350 if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0) in nfs4_lock_done()
7353 if (data->arg.new_lock_owner != 0) { in nfs4_lock_done()
7354 nfs_confirm_seqid(&lsp->ls_seqid, 0); in nfs4_lock_done()
7355 nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid); in nfs4_lock_done()
7356 set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags); in nfs4_lock_done()
7357 } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid)) in nfs4_lock_done()
7360 case -NFS4ERR_OLD_STATEID: in nfs4_lock_done()
7361 if (data->arg.new_lock_owner != 0 && in nfs4_lock_done()
7362 nfs4_refresh_open_old_stateid(&data->arg.open_stateid, in nfs4_lock_done()
7363 lsp->ls_state)) in nfs4_lock_done()
7365 if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp)) in nfs4_lock_done()
7368 case -NFS4ERR_BAD_STATEID: in nfs4_lock_done()
7369 case -NFS4ERR_STALE_STATEID: in nfs4_lock_done()
7370 case -NFS4ERR_EXPIRED: in nfs4_lock_done()
7371 if (data->arg.new_lock_owner != 0) { in nfs4_lock_done()
7372 if (!nfs4_stateid_match(&data->arg.open_stateid, in nfs4_lock_done()
7373 &lsp->ls_state->open_stateid)) in nfs4_lock_done()
7375 } else if (!nfs4_stateid_match(&data->arg.lock_stateid, in nfs4_lock_done()
7376 &lsp->ls_stateid)) in nfs4_lock_done()
7380 dprintk("%s: ret = %d!\n", __func__, data->rpc_status); in nfs4_lock_done()
7383 if (!data->cancelled) in nfs4_lock_done()
7392 nfs_free_seqid(data->arg.open_seqid); in nfs4_lock_release()
7393 if (data->cancelled && data->rpc_status == 0) { in nfs4_lock_release()
7395 task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, in nfs4_lock_release()
7396 data->arg.lock_seqid); in nfs4_lock_release()
7401 nfs_free_seqid(data->arg.lock_seqid); in nfs4_lock_release()
7402 nfs4_put_lock_state(data->lsp); in nfs4_lock_release()
7403 put_nfs_open_context(data->ctx); in nfs4_lock_release()
7416 case -NFS4ERR_ADMIN_REVOKED: in nfs4_handle_setlk_error()
7417 case -NFS4ERR_EXPIRED: in nfs4_handle_setlk_error()
7418 case -NFS4ERR_BAD_STATEID: in nfs4_handle_setlk_error()
7419 lsp->ls_seqid.flags &= ~NFS_SEQID_CONFIRMED; in nfs4_handle_setlk_error()
7421 test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) in nfs4_handle_setlk_error()
7422 nfs4_schedule_stateid_recovery(server, lsp->ls_state); in nfs4_handle_setlk_error()
7424 case -NFS4ERR_STALE_STATEID: in nfs4_handle_setlk_error()
7425 lsp->ls_seqid.flags &= ~NFS_SEQID_CONFIRMED; in nfs4_handle_setlk_error()
7426 nfs4_schedule_lease_recovery(server->nfs_client); in nfs4_handle_setlk_error()
7436 .rpc_cred = state->owner->so_cred, in _nfs4_do_setlk()
7439 .rpc_client = NFS_CLIENT(state->inode), in _nfs4_do_setlk()
7447 if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE)) in _nfs4_do_setlk()
7451 nfs_file_open_context(fl->c.flc_file), in _nfs4_do_setlk()
7452 fl->fl_u.nfs4_fl.owner, GFP_KERNEL); in _nfs4_do_setlk()
7454 return -ENOMEM; in _nfs4_do_setlk()
7456 data->arg.block = 1; in _nfs4_do_setlk()
7457 nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, in _nfs4_do_setlk()
7459 msg.rpc_argp = &data->arg; in _nfs4_do_setlk()
7460 msg.rpc_resp = &data->res; in _nfs4_do_setlk()
7464 data->arg.reclaim = NFS_LOCK_RECLAIM; in _nfs4_do_setlk()
7466 data->arg.new_lock = 1; in _nfs4_do_setlk()
7472 ret = data->rpc_status; in _nfs4_do_setlk()
7474 nfs4_handle_setlk_error(data->server, data->lsp, in _nfs4_do_setlk()
7475 data->arg.new_lock_owner, ret); in _nfs4_do_setlk()
7477 data->cancelled = true; in _nfs4_do_setlk()
7478 trace_nfs4_set_lock(fl, state, &data->res.stateid, cmd, ret); in _nfs4_do_setlk()
7486 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_reclaim()
7488 .inode = state->inode, in nfs4_lock_reclaim()
7494 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_reclaim()
7497 if (err != -NFS4ERR_DELAY) in nfs4_lock_reclaim()
7506 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_expired()
7508 .inode = state->inode, in nfs4_lock_expired()
7516 set_bit(NFS_LOCK_LOST, &request->fl_u.nfs4_fl.owner->ls_flags); in nfs4_lock_expired()
7520 if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) in nfs4_lock_expired()
7526 case -NFS4ERR_GRACE: in nfs4_lock_expired()
7527 case -NFS4ERR_DELAY: in nfs4_lock_expired()
7545 lsp = request->fl_u.nfs4_fl.owner; in nfs41_lock_expired()
7546 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) || in nfs41_lock_expired()
7547 test_bit(NFS_LOCK_LOST, &lsp->ls_flags)) in nfs41_lock_expired()
7555 struct nfs_inode *nfsi = NFS_I(state->inode); in _nfs4_proc_setlk()
7556 struct nfs4_state_owner *sp = state->owner; in _nfs4_proc_setlk()
7557 unsigned char flags = request->c.flc_flags; in _nfs4_proc_setlk()
7560 request->c.flc_flags |= FL_ACCESS; in _nfs4_proc_setlk()
7561 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7564 mutex_lock(&sp->so_delegreturn_mutex); in _nfs4_proc_setlk()
7565 down_read(&nfsi->rwsem); in _nfs4_proc_setlk()
7566 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { in _nfs4_proc_setlk()
7569 request->c.flc_flags = flags & ~FL_SLEEP; in _nfs4_proc_setlk()
7570 status = locks_lock_inode_wait(state->inode, request); in _nfs4_proc_setlk()
7571 up_read(&nfsi->rwsem); in _nfs4_proc_setlk()
7572 mutex_unlock(&sp->so_delegreturn_mutex); in _nfs4_proc_setlk()
7575 up_read(&nfsi->rwsem); in _nfs4_proc_setlk()
7576 mutex_unlock(&sp->so_delegreturn_mutex); in _nfs4_proc_setlk()
7579 request->c.flc_flags = flags; in _nfs4_proc_setlk()
7587 .inode = state->inode, in nfs4_proc_setlk()
7594 if (err == -NFS4ERR_DENIED) in nfs4_proc_setlk()
7595 err = -EAGAIN; in nfs4_proc_setlk()
7596 err = nfs4_handle_exception(NFS_SERVER(state->inode), in nfs4_proc_setlk()
7609 int status = -ERESTARTSYS; in nfs4_retry_setlk_simple()
7614 if ((status != -EAGAIN) || IS_SETLK(cmd)) in nfs4_retry_setlk_simple()
7620 status = -ERESTARTSYS; in nfs4_retry_setlk_simple()
7641 struct nfs_lowner *lowner = &cbnl->cbnl_owner, in nfs4_wake_lock_waiter()
7642 *wowner = &waiter->owner; in nfs4_wake_lock_waiter()
7645 if (lowner->id != wowner->id || lowner->s_dev != wowner->s_dev) in nfs4_wake_lock_waiter()
7649 if (nfs_compare_fh(NFS_FH(waiter->inode), &cbnl->cbnl_fh)) in nfs4_wake_lock_waiter()
7659 struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; in nfs4_retry_setlk()
7660 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_retry_setlk()
7661 struct nfs_client *clp = server->nfs_client; in nfs4_retry_setlk()
7662 wait_queue_head_t *q = &clp->cl_lock_waitq; in nfs4_retry_setlk()
7664 .inode = state->inode, in nfs4_retry_setlk()
7665 .owner = { .clientid = clp->cl_clientid, in nfs4_retry_setlk()
7666 .id = lsp->ls_seqid.owner_id, in nfs4_retry_setlk()
7667 .s_dev = server->s_dev }, in nfs4_retry_setlk()
7672 if (!test_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags)) in nfs4_retry_setlk()
7681 if (status != -EAGAIN || IS_SETLK(cmd)) in nfs4_retry_setlk()
7684 status = -ERESTARTSYS; in nfs4_retry_setlk()
7710 state = ctx->state; in nfs4_proc_lock()
7719 return -EINVAL; in nfs4_proc_lock()
7728 return -ENOLCK; in nfs4_proc_lock()
7730 if ((request->c.flc_flags & FL_POSIX) && in nfs4_proc_lock()
7731 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags)) in nfs4_proc_lock()
7732 return -ENOLCK; in nfs4_proc_lock()
7738 switch (request->c.flc_type) { in nfs4_proc_lock()
7740 if (!(filp->f_mode & FMODE_READ)) in nfs4_proc_lock()
7741 return -EBADF; in nfs4_proc_lock()
7744 if (!(filp->f_mode & FMODE_WRITE)) in nfs4_proc_lock()
7745 return -EBADF; in nfs4_proc_lock()
7769 return -EAGAIN; in nfs4_add_lease()
7775 return -EAGAIN; in nfs4_add_lease()
7788 return -EINVAL; in nfs4_proc_setlease()
7794 struct nfs_server *server = NFS_SERVER(state->inode); in nfs4_lock_delegation_recall()
7802 if (err != -NFS4ERR_DELAY) in nfs4_lock_delegation_recall()
7805 } while (err == -NFS4ERR_DELAY); in nfs4_lock_delegation_recall()
7820 struct nfs_server *server = data->server; in nfs4_release_lockowner_prepare()
7821 nfs4_setup_sequence(server->nfs_client, &data->args.seq_args, in nfs4_release_lockowner_prepare()
7822 &data->res.seq_res, task); in nfs4_release_lockowner_prepare()
7823 data->args.lock_owner.clientid = server->nfs_client->cl_clientid; in nfs4_release_lockowner_prepare()
7824 data->timestamp = jiffies; in nfs4_release_lockowner_prepare()
7830 struct nfs_server *server = data->server; in nfs4_release_lockowner_done()
7832 nfs40_sequence_done(task, &data->res.seq_res); in nfs4_release_lockowner_done()
7834 switch (task->tk_status) { in nfs4_release_lockowner_done()
7836 renew_lease(server, data->timestamp); in nfs4_release_lockowner_done()
7838 case -NFS4ERR_STALE_CLIENTID: in nfs4_release_lockowner_done()
7839 case -NFS4ERR_EXPIRED: in nfs4_release_lockowner_done()
7840 nfs4_schedule_lease_recovery(server->nfs_client); in nfs4_release_lockowner_done()
7842 case -NFS4ERR_LEASE_MOVED: in nfs4_release_lockowner_done()
7843 case -NFS4ERR_DELAY: in nfs4_release_lockowner_done()
7845 NULL, NULL) == -EAGAIN) in nfs4_release_lockowner_done()
7853 nfs4_free_lock_state(data->server, data->lsp); in nfs4_release_lockowner_release()
7871 if (server->nfs_client->cl_mvops->minor_version != 0) in nfs4_release_lockowner()
7877 data->lsp = lsp; in nfs4_release_lockowner()
7878 data->server = server; in nfs4_release_lockowner()
7879 data->args.lock_owner.clientid = server->nfs_client->cl_clientid; in nfs4_release_lockowner()
7880 data->args.lock_owner.id = lsp->ls_seqid.owner_id; in nfs4_release_lockowner()
7881 data->args.lock_owner.s_dev = server->s_dev; in nfs4_release_lockowner()
7883 msg.rpc_argp = &data->args; in nfs4_release_lockowner()
7884 msg.rpc_resp = &data->res; in nfs4_release_lockowner()
7885 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0); in nfs4_release_lockowner()
7886 rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data); in nfs4_release_lockowner()
7909 return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_ACL); in nfs4_xattr_list_nfs4_acl()
7933 return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_DACL); in nfs4_xattr_list_nfs4_dacl()
7956 return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_SACL); in nfs4_xattr_list_nfs4_sacl()
7972 return -EOPNOTSUPP; in nfs4_xattr_set_nfs4_label()
7981 return -EOPNOTSUPP; in nfs4_xattr_get_nfs4_label()
7992 return -ERANGE; in nfs4_listxattr_nfs4_label()
8000 .set = nfs4_xattr_set_nfs4_label,
8024 return -EOPNOTSUPP; in nfs4_xattr_set_nfs4_user()
8037 return -EACCES; in nfs4_xattr_set_nfs4_user()
8061 return -EOPNOTSUPP; in nfs4_xattr_get_nfs4_user()
8065 return -EACCES; in nfs4_xattr_get_nfs4_user()
8073 if (ret >= 0 || (ret < 0 && ret != -ENOENT)) in nfs4_xattr_get_nfs4_user()
8104 if (ret >= 0 || (ret < 0 && ret != -ENOENT)) in nfs4_listxattr_nfs4_user()
8121 buflen -= ret; in nfs4_listxattr_nfs4_user()
8146 if (!(((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) || in nfs_fixup_referral_attributes()
8147 (fattr->valid & NFS_ATTR_FATTR_FILEID)) && in nfs_fixup_referral_attributes()
8148 (fattr->valid & NFS_ATTR_FATTR_FSID) && in nfs_fixup_referral_attributes()
8149 (fattr->valid & NFS_ATTR_FATTR_V4_LOCATIONS))) in nfs_fixup_referral_attributes()
8152 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | in nfs_fixup_referral_attributes()
8154 fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO; in nfs_fixup_referral_attributes()
8155 fattr->nlink = 2; in nfs_fixup_referral_attributes()
8188 if (NFS_SERVER(dir)->attr_bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID) in _nfs4_proc_fs_locations()
8193 nfs_fattr_init(fs_locations->fattr); in _nfs4_proc_fs_locations()
8194 fs_locations->server = server; in _nfs4_proc_fs_locations()
8195 fs_locations->nlocations = 0; in _nfs4_proc_fs_locations()
8232 struct rpc_clnt *clnt = server->client; in _nfs40_proc_get_locations()
8237 .clientid = server->nfs_client->cl_clientid, in _nfs40_proc_get_locations()
8258 nfs_fattr_init(locations->fattr); in _nfs40_proc_get_locations()
8259 locations->server = server; in _nfs40_proc_get_locations()
8260 locations->nlocations = 0; in _nfs40_proc_get_locations()
8289 struct rpc_clnt *clnt = server->client; in _nfs41_proc_get_locations()
8317 .callback_ops = server->nfs_client->cl_mvops->call_sync_ops, in _nfs41_proc_get_locations()
8323 nfs_fattr_init(locations->fattr); in _nfs41_proc_get_locations()
8324 locations->server = server; in _nfs41_proc_get_locations()
8325 locations->nlocations = 0; in _nfs41_proc_get_locations()
8331 status = -NFS4ERR_LEASE_MOVED; in _nfs41_proc_get_locations()
8338 * nfs4_proc_get_locations - discover locations for a migrated FSID
8352 * -NFS4ERR_LEASE_MOVED is returned if the server still has leases
8360 struct nfs_client *clp = server->nfs_client; in nfs4_proc_get_locations()
8362 clp->cl_mvops->mig_recovery_ops; in nfs4_proc_get_locations()
8369 (unsigned long long)server->fsid.major, in nfs4_proc_get_locations()
8370 (unsigned long long)server->fsid.minor, in nfs4_proc_get_locations()
8371 clp->cl_hostname); in nfs4_proc_get_locations()
8375 status = ops->get_locations(server, fhandle, locations, page, in nfs4_proc_get_locations()
8377 if (status != -NFS4ERR_DELAY) in nfs4_proc_get_locations()
8394 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; in _nfs40_proc_fsid_present()
8395 struct rpc_clnt *clnt = server->client; in _nfs40_proc_fsid_present()
8398 .clientid = clp->cl_clientid, in _nfs40_proc_fsid_present()
8415 return -ENOMEM; in _nfs40_proc_fsid_present()
8440 struct rpc_clnt *clnt = server->client; in _nfs41_proc_fsid_present()
8456 return -ENOMEM; in _nfs41_proc_fsid_present()
8464 status = -NFS4ERR_LEASE_MOVED; in _nfs41_proc_fsid_present()
8471 * nfs4_proc_fsid_present - Is this FSID present or absent on server?
8480 * -NFS4ERR_MOVED if the FSID is no longer present, a negative
8487 struct nfs_client *clp = server->nfs_client; in nfs4_proc_fsid_present()
8489 clp->cl_mvops->mig_recovery_ops; in nfs4_proc_fsid_present()
8496 (unsigned long long)server->fsid.major, in nfs4_proc_fsid_present()
8497 (unsigned long long)server->fsid.minor, in nfs4_proc_fsid_present()
8498 clp->cl_hostname); in nfs4_proc_fsid_present()
8502 status = ops->fsid_present(inode, cred); in nfs4_proc_fsid_present()
8503 if (status != -NFS4ERR_DELAY) in nfs4_proc_fsid_present()
8520 struct rpc_clnt *clnt = NFS_SERVER(dir)->client; in _nfs4_proc_secinfo()
8521 struct nfs_client *clp = NFS_SERVER(dir)->nfs_client; in _nfs4_proc_secinfo()
8542 .callback_ops = clp->cl_mvops->call_sync_ops, in _nfs4_proc_secinfo()
8549 clnt = clp->cl_rpcclient; in _nfs4_proc_secinfo()
8556 dprintk("NFS call secinfo %s\n", name->name); in _nfs4_proc_secinfo()
8576 err = -NFS4ERR_WRONGSEC; in nfs4_proc_secinfo()
8579 if (_nfs4_is_integrity_protected(NFS_SERVER(dir)->nfs_client)) in nfs4_proc_secinfo()
8588 if (err == -NFS4ERR_WRONGSEC) in nfs4_proc_secinfo()
8601 * both PNFS and NON_PNFS flags set, and not having one of NON_PNFS, PNFS, or
8602 * DS flags set.
8617 return -NFS4ERR_INVAL; in nfs4_check_cl_exchange_flags()
8624 if (a->server_scope_sz != b->server_scope_sz) in nfs41_same_server_scope()
8626 return memcmp(a->server_scope, b->server_scope, a->server_scope_sz) == 0; in nfs41_same_server_scope()
8632 struct nfs41_bind_conn_to_session_args *args = task->tk_msg.rpc_argp; in nfs4_bind_one_conn_to_session_done()
8633 struct nfs41_bind_conn_to_session_res *res = task->tk_msg.rpc_resp; in nfs4_bind_one_conn_to_session_done()
8634 struct nfs_client *clp = args->client; in nfs4_bind_one_conn_to_session_done()
8636 switch (task->tk_status) { in nfs4_bind_one_conn_to_session_done()
8637 case -NFS4ERR_BADSESSION: in nfs4_bind_one_conn_to_session_done()
8638 case -NFS4ERR_DEADSESSION: in nfs4_bind_one_conn_to_session_done()
8639 nfs4_schedule_session_recovery(clp->cl_session, in nfs4_bind_one_conn_to_session_done()
8640 task->tk_status); in nfs4_bind_one_conn_to_session_done()
8643 if (args->dir == NFS4_CDFC4_FORE_OR_BOTH && in nfs4_bind_one_conn_to_session_done()
8644 res->dir != NFS4_CDFS4_BOTH) { in nfs4_bind_one_conn_to_session_done()
8646 if (args->retries++ < MAX_BIND_CONN_TO_SESSION_RETRIES) in nfs4_bind_one_conn_to_session_done()
8690 nfs4_copy_sessionid(&args.sessionid, &clp->cl_session->sess_id); in nfs4_proc_bind_one_conn_to_session()
8691 if (!(clp->cl_session->flags & SESSION4_BACK_CHAN)) in nfs4_proc_bind_one_conn_to_session()
8694 /* Do not set the backchannel flag unless this is clnt->cl_xprt */ in nfs4_proc_bind_one_conn_to_session()
8695 if (xprt != rcu_access_pointer(clnt->cl_xprt)) in nfs4_proc_bind_one_conn_to_session()
8700 status = task->tk_status; in nfs4_proc_bind_one_conn_to_session()
8707 clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) { in nfs4_proc_bind_one_conn_to_session()
8709 return -EIO; in nfs4_proc_bind_one_conn_to_session()
8714 return -EIO; in nfs4_proc_bind_one_conn_to_session()
8719 return -EIO; in nfs4_proc_bind_one_conn_to_session()
8738 return nfs4_proc_bind_one_conn_to_session(clnt, xprt, p->clp, p->cred); in nfs4_proc_bind_conn_to_session_callback()
8747 return rpc_clnt_iterate_for_each_xprt(clp->cl_rpcclient, in nfs4_proc_bind_conn_to_session()
8752 * Minimum set of SP4_MACH_CRED operations from RFC 5661 in the enforce map
8758 [1] = 1 << (OP_BIND_CONN_TO_SESSION - 32) |
8759 1 << (OP_EXCHANGE_ID - 32) |
8760 1 << (OP_CREATE_SESSION - 32) |
8761 1 << (OP_DESTROY_SESSION - 32) |
8762 1 << (OP_DESTROY_CLIENTID - 32)
8770 [1] = 1 << (OP_SECINFO - 32) |
8771 1 << (OP_SECINFO_NO_NAME - 32) |
8772 1 << (OP_LAYOUTRETURN - 32) |
8773 1 << (OP_TEST_STATEID - 32) |
8774 1 << (OP_FREE_STATEID - 32) |
8775 1 << (OP_WRITE - 32)
8789 [1] = 1 << (OP_BIND_CONN_TO_SESSION - 32) | in nfs4_sp4_select_mode()
8790 1 << (OP_EXCHANGE_ID - 32) | in nfs4_sp4_select_mode()
8791 1 << (OP_CREATE_SESSION - 32) | in nfs4_sp4_select_mode()
8792 1 << (OP_DESTROY_SESSION - 32) | in nfs4_sp4_select_mode()
8793 1 << (OP_DESTROY_CLIENTID - 32) in nfs4_sp4_select_mode()
8799 if (sp->how == SP4_MACH_CRED) { in nfs4_sp4_select_mode()
8803 if (test_bit(i, sp->enforce.u.longs)) in nfs4_sp4_select_mode()
8805 if (test_bit(i, sp->allow.u.longs)) in nfs4_sp4_select_mode()
8811 if (sp->enforce.u.words[i] & ~supported_enforce[i]) { in nfs4_sp4_select_mode()
8813 ret = -EINVAL; in nfs4_sp4_select_mode()
8819 * Minimal mode - state operations are allowed to use machine in nfs4_sp4_select_mode()
8823 * NOTE: we don't care if EXCHANGE_ID is in the list - in nfs4_sp4_select_mode()
8827 if (test_bit(OP_BIND_CONN_TO_SESSION, sp->enforce.u.longs) && in nfs4_sp4_select_mode()
8828 test_bit(OP_CREATE_SESSION, sp->enforce.u.longs) && in nfs4_sp4_select_mode()
8829 test_bit(OP_DESTROY_SESSION, sp->enforce.u.longs) && in nfs4_sp4_select_mode()
8830 test_bit(OP_DESTROY_CLIENTID, sp->enforce.u.longs)) { in nfs4_sp4_select_mode()
8836 ret = -EINVAL; in nfs4_sp4_select_mode()
8840 if (test_bit(OP_CLOSE, sp->allow.u.longs) && in nfs4_sp4_select_mode()
8841 test_bit(OP_OPEN_DOWNGRADE, sp->allow.u.longs) && in nfs4_sp4_select_mode()
8842 test_bit(OP_DELEGRETURN, sp->allow.u.longs) && in nfs4_sp4_select_mode()
8843 test_bit(OP_LOCKU, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8848 if (test_bit(OP_LAYOUTRETURN, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8853 if (test_bit(OP_SECINFO, sp->allow.u.longs) && in nfs4_sp4_select_mode()
8854 test_bit(OP_SECINFO_NO_NAME, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8859 if (test_bit(OP_TEST_STATEID, sp->allow.u.longs) && in nfs4_sp4_select_mode()
8860 test_bit(OP_FREE_STATEID, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8865 if (test_bit(OP_WRITE, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8870 if (test_bit(OP_COMMIT, sp->allow.u.longs)) { in nfs4_sp4_select_mode()
8876 clp->cl_sp4_flags = flags; in nfs4_sp4_select_mode()
8890 nfs_put_client(cdata->args.client); in nfs4_exchange_id_release()
8891 kfree(cdata->res.impl_id); in nfs4_exchange_id_release()
8892 kfree(cdata->res.server_scope); in nfs4_exchange_id_release()
8893 kfree(cdata->res.server_owner); in nfs4_exchange_id_release()
8915 .rpc_client = clp->cl_rpcclient, in nfs4_run_exchange_id()
8923 if (!refcount_inc_not_zero(&clp->cl_count)) in nfs4_run_exchange_id()
8924 return ERR_PTR(-EIO); in nfs4_run_exchange_id()
8926 status = -ENOMEM; in nfs4_run_exchange_id()
8931 nfs4_init_boot_verifier(clp, &calldata->args.verifier); in nfs4_run_exchange_id()
8937 calldata->res.server_owner = kzalloc(sizeof(struct nfs41_server_owner), in nfs4_run_exchange_id()
8939 status = -ENOMEM; in nfs4_run_exchange_id()
8940 if (unlikely(calldata->res.server_owner == NULL)) in nfs4_run_exchange_id()
8943 calldata->res.server_scope = kzalloc(sizeof(struct nfs41_server_scope), in nfs4_run_exchange_id()
8945 if (unlikely(calldata->res.server_scope == NULL)) in nfs4_run_exchange_id()
8948 calldata->res.impl_id = kzalloc(sizeof(struct nfs41_impl_id), GFP_NOFS); in nfs4_run_exchange_id()
8949 if (unlikely(calldata->res.impl_id == NULL)) in nfs4_run_exchange_id()
8954 calldata->args.state_protect.how = SP4_NONE; in nfs4_run_exchange_id()
8958 calldata->args.state_protect = nfs4_sp4_mach_cred_request; in nfs4_run_exchange_id()
8964 status = -EINVAL; in nfs4_run_exchange_id()
8970 memcpy(calldata->args.verifier.data, clp->cl_confirm.data, in nfs4_run_exchange_id()
8971 sizeof(calldata->args.verifier.data)); in nfs4_run_exchange_id()
8973 calldata->args.client = clp; in nfs4_run_exchange_id()
8974 calldata->args.flags = EXCHGID4_FLAG_SUPP_MOVED_REFER | in nfs4_run_exchange_id()
8977 calldata->args.flags |= EXCHGID4_FLAG_SUPP_MOVED_MIGR; in nfs4_run_exchange_id()
8979 if (test_bit(NFS_CS_PNFS, &clp->cl_flags)) in nfs4_run_exchange_id()
8980 calldata->args.flags |= EXCHGID4_FLAG_USE_PNFS_DS; in nfs4_run_exchange_id()
8981 msg.rpc_argp = &calldata->args; in nfs4_run_exchange_id()
8982 msg.rpc_resp = &calldata->res; in nfs4_run_exchange_id()
8988 kfree(calldata->res.impl_id); in nfs4_run_exchange_id()
8990 kfree(calldata->res.server_scope); in nfs4_run_exchange_id()
8992 kfree(calldata->res.server_owner); in nfs4_run_exchange_id()
9018 argp = task->tk_msg.rpc_argp; in _nfs4_proc_exchange_id()
9019 resp = task->tk_msg.rpc_resp; in _nfs4_proc_exchange_id()
9020 status = task->tk_status; in _nfs4_proc_exchange_id()
9024 status = nfs4_check_cl_exchange_flags(resp->flags, in _nfs4_proc_exchange_id()
9025 clp->cl_mvops->minor_version); in _nfs4_proc_exchange_id()
9029 status = nfs4_sp4_select_mode(clp, &resp->state_protect); in _nfs4_proc_exchange_id()
9035 clp->cl_clientid = resp->clientid; in _nfs4_proc_exchange_id()
9036 clp->cl_exchange_flags = resp->flags; in _nfs4_proc_exchange_id()
9037 clp->cl_seqid = resp->seqid; in _nfs4_proc_exchange_id()
9039 if (!(resp->flags & EXCHGID4_FLAG_CONFIRMED_R)) in _nfs4_proc_exchange_id()
9041 &clp->cl_session->session_state); in _nfs4_proc_exchange_id()
9043 if (clp->cl_serverscope != NULL && in _nfs4_proc_exchange_id()
9044 !nfs41_same_server_scope(clp->cl_serverscope, in _nfs4_proc_exchange_id()
9045 resp->server_scope)) { in _nfs4_proc_exchange_id()
9048 set_bit(NFS4CLNT_SERVER_SCOPE_MISMATCH, &clp->cl_state); in _nfs4_proc_exchange_id()
9051 swap(clp->cl_serverowner, resp->server_owner); in _nfs4_proc_exchange_id()
9052 swap(clp->cl_serverscope, resp->server_scope); in _nfs4_proc_exchange_id()
9053 swap(clp->cl_implid, resp->impl_id); in _nfs4_proc_exchange_id()
9056 memcpy(clp->cl_confirm.data, argp->verifier.data, in _nfs4_proc_exchange_id()
9057 sizeof(clp->cl_confirm.data)); in _nfs4_proc_exchange_id()
9078 rpc_authflavor_t authflavor = clp->cl_rpcclient->cl_auth->au_flavor; in nfs4_proc_exchange_id()
9117 dprintk("--> %s try %s\n", __func__, in nfs4_test_session_trunk()
9118 xprt->address_strings[RPC_DISPLAY_ADDR]); in nfs4_test_session_trunk()
9120 sp4_how = (adata->clp->cl_sp4_flags == 0 ? SP4_NONE : SP4_MACH_CRED); in nfs4_test_session_trunk()
9124 task = nfs4_run_exchange_id(adata->clp, adata->cred, sp4_how, xprt); in nfs4_test_session_trunk()
9128 status = task->tk_status; in nfs4_test_session_trunk()
9130 status = nfs4_detect_session_trunking(adata->clp, in nfs4_test_session_trunk()
9131 task->tk_msg.rpc_resp, xprt); in nfs4_test_session_trunk()
9132 trace_nfs4_trunked_exchange_id(adata->clp, in nfs4_test_session_trunk()
9133 xprt->address_strings[RPC_DISPLAY_ADDR], status); in nfs4_test_session_trunk()
9137 else if (status != -NFS4ERR_DELAY && rpc_clnt_xprt_switch_has_addr(clnt, in nfs4_test_session_trunk()
9138 (struct sockaddr *)&xprt->addr)) in nfs4_test_session_trunk()
9142 if (status == -NFS4ERR_DELAY) { in nfs4_test_session_trunk()
9159 status = rpc_call_sync(clp->cl_rpcclient, &msg, in _nfs4_proc_destroy_clientid()
9164 "DESTROY_CLIENTID.", status, clp->cl_hostname); in _nfs4_proc_destroy_clientid()
9174 for (loop = NFS4_MAX_LOOP_ON_RECOVER; loop != 0; loop--) { in nfs4_proc_destroy_clientid()
9177 case -NFS4ERR_DELAY: in nfs4_proc_destroy_clientid()
9178 case -NFS4ERR_CLIENTID_BUSY: in nfs4_proc_destroy_clientid()
9193 if (clp->cl_mvops->minor_version < 1) in nfs4_destroy_clientid()
9195 if (clp->cl_exchange_flags == 0) in nfs4_destroy_clientid()
9197 if (clp->cl_preserve_clid) in nfs4_destroy_clientid()
9204 case -NFS4ERR_STALE_CLIENTID: in nfs4_destroy_clientid()
9205 clp->cl_exchange_flags = 0; in nfs4_destroy_clientid()
9227 nfs4_setup_sequence(data->clp, in nfs4_get_lease_time_prepare()
9228 &data->args->la_seq_args, in nfs4_get_lease_time_prepare()
9229 &data->res->lr_seq_res, in nfs4_get_lease_time_prepare()
9242 if (!nfs4_sequence_done(task, &data->res->lr_seq_res)) in nfs4_get_lease_time_done()
9244 switch (task->tk_status) { in nfs4_get_lease_time_done()
9245 case -NFS4ERR_DELAY: in nfs4_get_lease_time_done()
9246 case -NFS4ERR_GRACE: in nfs4_get_lease_time_done()
9248 task->tk_status = 0; in nfs4_get_lease_time_done()
9250 case -NFS4ERR_RETRY_UNCACHED_REP: in nfs4_get_lease_time_done()
9278 .rpc_client = clp->cl_rpcclient, in nfs4_proc_get_lease_time()
9293 * If nfs4_init_session set the fore channel request and response sizes,
9296 * Set the back channel max_resp_sz_cached to zero to force the client to
9297 * always set csa_cachethis to FALSE because the current implementation
9311 args->fc_attrs.max_rqst_sz = max_rqst_sz; in nfs4_init_channel_attrs()
9312 args->fc_attrs.max_resp_sz = max_resp_sz; in nfs4_init_channel_attrs()
9313 args->fc_attrs.max_ops = NFS4_MAX_OPS; in nfs4_init_channel_attrs()
9314 args->fc_attrs.max_reqs = max_session_slots; in nfs4_init_channel_attrs()
9319 args->fc_attrs.max_rqst_sz, args->fc_attrs.max_resp_sz, in nfs4_init_channel_attrs()
9320 args->fc_attrs.max_ops, args->fc_attrs.max_reqs); in nfs4_init_channel_attrs()
9323 args->bc_attrs.max_rqst_sz = max_bc_payload; in nfs4_init_channel_attrs()
9324 args->bc_attrs.max_resp_sz = max_bc_payload; in nfs4_init_channel_attrs()
9325 args->bc_attrs.max_resp_sz_cached = 0; in nfs4_init_channel_attrs()
9326 args->bc_attrs.max_ops = NFS4_MAX_BACK_CHANNEL_OPS; in nfs4_init_channel_attrs()
9327 args->bc_attrs.max_reqs = max_t(unsigned short, max_session_cb_slots, 1); in nfs4_init_channel_attrs()
9328 if (args->bc_attrs.max_reqs > max_bc_slots) in nfs4_init_channel_attrs()
9329 args->bc_attrs.max_reqs = max_bc_slots; in nfs4_init_channel_attrs()
9334 args->bc_attrs.max_rqst_sz, args->bc_attrs.max_resp_sz, in nfs4_init_channel_attrs()
9335 args->bc_attrs.max_resp_sz_cached, args->bc_attrs.max_ops, in nfs4_init_channel_attrs()
9336 args->bc_attrs.max_reqs); in nfs4_init_channel_attrs()
9342 struct nfs4_channel_attrs *sent = &args->fc_attrs; in nfs4_verify_fore_channel_attrs()
9343 struct nfs4_channel_attrs *rcvd = &res->fc_attrs; in nfs4_verify_fore_channel_attrs()
9345 if (rcvd->max_resp_sz > sent->max_resp_sz) in nfs4_verify_fore_channel_attrs()
9346 return -EINVAL; in nfs4_verify_fore_channel_attrs()
9353 if (rcvd->max_ops < sent->max_ops) in nfs4_verify_fore_channel_attrs()
9354 return -EINVAL; in nfs4_verify_fore_channel_attrs()
9355 if (rcvd->max_reqs == 0) in nfs4_verify_fore_channel_attrs()
9356 return -EINVAL; in nfs4_verify_fore_channel_attrs()
9357 if (rcvd->max_reqs > NFS4_MAX_SLOT_TABLE) in nfs4_verify_fore_channel_attrs()
9358 rcvd->max_reqs = NFS4_MAX_SLOT_TABLE; in nfs4_verify_fore_channel_attrs()
9365 struct nfs4_channel_attrs *sent = &args->bc_attrs; in nfs4_verify_back_channel_attrs()
9366 struct nfs4_channel_attrs *rcvd = &res->bc_attrs; in nfs4_verify_back_channel_attrs()
9368 if (!(res->flags & SESSION4_BACK_CHAN)) in nfs4_verify_back_channel_attrs()
9370 if (rcvd->max_rqst_sz > sent->max_rqst_sz) in nfs4_verify_back_channel_attrs()
9371 return -EINVAL; in nfs4_verify_back_channel_attrs()
9372 if (rcvd->max_resp_sz < sent->max_resp_sz) in nfs4_verify_back_channel_attrs()
9373 return -EINVAL; in nfs4_verify_back_channel_attrs()
9374 if (rcvd->max_resp_sz_cached > sent->max_resp_sz_cached) in nfs4_verify_back_channel_attrs()
9375 return -EINVAL; in nfs4_verify_back_channel_attrs()
9376 if (rcvd->max_ops > sent->max_ops) in nfs4_verify_back_channel_attrs()
9377 return -EINVAL; in nfs4_verify_back_channel_attrs()
9378 if (rcvd->max_reqs > sent->max_reqs) in nfs4_verify_back_channel_attrs()
9379 return -EINVAL; in nfs4_verify_back_channel_attrs()
9398 nfs4_copy_sessionid(&session->sess_id, &res->sessionid); in nfs4_update_session()
9400 session->clp->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R; in nfs4_update_session()
9401 set_bit(NFS4_SESSION_ESTABLISHED, &session->session_state); in nfs4_update_session()
9402 session->flags = res->flags; in nfs4_update_session()
9403 memcpy(&session->fc_attrs, &res->fc_attrs, sizeof(session->fc_attrs)); in nfs4_update_session()
9404 if (res->flags & SESSION4_BACK_CHAN) in nfs4_update_session()
9405 memcpy(&session->bc_attrs, &res->bc_attrs, in nfs4_update_session()
9406 sizeof(session->bc_attrs)); in nfs4_update_session()
9412 struct nfs4_session *session = clp->cl_session; in _nfs4_proc_create_session()
9415 .clientid = clp->cl_clientid, in _nfs4_proc_create_session()
9416 .seqid = clp->cl_seqid, in _nfs4_proc_create_session()
9429 nfs4_init_channel_attrs(&args, clp->cl_rpcclient); in _nfs4_proc_create_session()
9432 status = rpc_call_sync(session->clp->cl_rpcclient, &msg, in _nfs4_proc_create_session()
9437 case -NFS4ERR_STALE_CLIENTID: in _nfs4_proc_create_session()
9438 case -NFS4ERR_DELAY: in _nfs4_proc_create_session()
9439 case -ETIMEDOUT: in _nfs4_proc_create_session()
9440 case -EACCES: in _nfs4_proc_create_session()
9441 case -EAGAIN: in _nfs4_proc_create_session()
9445 clp->cl_seqid++; in _nfs4_proc_create_session()
9467 struct nfs4_session *session = clp->cl_session; in nfs4_proc_create_session()
9472 .add_xprt_test = clp->cl_mvops->session_trunk, in nfs4_proc_create_session()
9476 dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); in nfs4_proc_create_session()
9488 ptr = (unsigned *)&session->sess_id.data[0]; in nfs4_proc_create_session()
9490 clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); in nfs4_proc_create_session()
9491 rpc_clnt_probe_trunked_xprts(clp->cl_rpcclient, &rpcdata); in nfs4_proc_create_session()
9497 * Issue the over-the-wire RPC DESTROY_SESSION.
9511 if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state)) in nfs4_proc_destroy_session()
9514 status = rpc_call_sync(session->clp->cl_rpcclient, &msg, in nfs4_proc_destroy_session()
9516 trace_nfs4_destroy_session(session->clp, status); in nfs4_proc_destroy_session()
9521 rpc_clnt_manage_trunked_xprts(session->clp->cl_rpcclient); in nfs4_proc_destroy_session()
9537 struct nfs_client *clp = calldata->clp; in nfs41_sequence_release()
9539 if (refcount_read(&clp->cl_count) > 1) in nfs41_sequence_release()
9547 switch(task->tk_status) { in nfs41_sequence_handle_errors()
9548 case -NFS4ERR_DELAY: in nfs41_sequence_handle_errors()
9550 return -EAGAIN; in nfs41_sequence_handle_errors()
9560 struct nfs_client *clp = calldata->clp; in nfs41_sequence_call_done()
9562 if (!nfs41_sequence_done(task, task->tk_msg.rpc_resp)) in nfs41_sequence_call_done()
9565 trace_nfs4_sequence(clp, task->tk_status); in nfs41_sequence_call_done()
9566 if (task->tk_status < 0 && !task->tk_client->cl_shutdown) { in nfs41_sequence_call_done()
9567 dprintk("%s ERROR %d\n", __func__, task->tk_status); in nfs41_sequence_call_done()
9568 if (refcount_read(&clp->cl_count) == 1) in nfs41_sequence_call_done()
9571 if (nfs41_sequence_handle_errors(task, clp) == -EAGAIN) { in nfs41_sequence_call_done()
9576 dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); in nfs41_sequence_call_done()
9582 struct nfs_client *clp = calldata->clp; in nfs41_sequence_prepare()
9586 args = task->tk_msg.rpc_argp; in nfs41_sequence_prepare()
9587 res = task->tk_msg.rpc_resp; in nfs41_sequence_prepare()
9609 .rpc_client = clp->cl_rpcclient, in _nfs41_proc_sequence()
9616 ret = ERR_PTR(-EIO); in _nfs41_proc_sequence()
9617 if (!refcount_inc_not_zero(&clp->cl_count)) in _nfs41_proc_sequence()
9620 ret = ERR_PTR(-ENOMEM); in _nfs41_proc_sequence()
9624 nfs4_init_sequence(&calldata->args, &calldata->res, 0, is_privileged); in _nfs41_proc_sequence()
9625 nfs4_sequence_attach_slot(&calldata->args, &calldata->res, slot); in _nfs41_proc_sequence()
9626 msg.rpc_argp = &calldata->args; in _nfs41_proc_sequence()
9627 msg.rpc_resp = &calldata->res; in _nfs41_proc_sequence()
9628 calldata->clp = clp; in _nfs41_proc_sequence()
9648 return -EAGAIN; in nfs41_proc_async_sequence()
9654 dprintk("<-- %s status=%d\n", __func__, ret); in nfs41_proc_async_sequence()
9670 ret = task->tk_status; in nfs4_proc_sequence()
9673 dprintk("<-- %s status=%d\n", __func__, ret); in nfs4_proc_sequence()
9687 nfs4_setup_sequence(calldata->clp, in nfs4_reclaim_complete_prepare()
9688 &calldata->arg.seq_args, in nfs4_reclaim_complete_prepare()
9689 &calldata->res.seq_res, in nfs4_reclaim_complete_prepare()
9695 switch(task->tk_status) { in nfs41_reclaim_complete_handle_errors()
9697 wake_up_all(&clp->cl_lock_waitq); in nfs41_reclaim_complete_handle_errors()
9699 case -NFS4ERR_COMPLETE_ALREADY: in nfs41_reclaim_complete_handle_errors()
9700 case -NFS4ERR_WRONG_CRED: /* What to do here? */ in nfs41_reclaim_complete_handle_errors()
9702 case -NFS4ERR_DELAY: in nfs41_reclaim_complete_handle_errors()
9705 case -NFS4ERR_RETRY_UNCACHED_REP: in nfs41_reclaim_complete_handle_errors()
9706 case -EACCES: in nfs41_reclaim_complete_handle_errors()
9708 __func__, task->tk_status, clp->cl_hostname); in nfs41_reclaim_complete_handle_errors()
9709 return -EAGAIN; in nfs41_reclaim_complete_handle_errors()
9710 case -NFS4ERR_BADSESSION: in nfs41_reclaim_complete_handle_errors()
9711 case -NFS4ERR_DEADSESSION: in nfs41_reclaim_complete_handle_errors()
9712 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs41_reclaim_complete_handle_errors()
9723 struct nfs_client *clp = calldata->clp; in nfs4_reclaim_complete_done()
9724 struct nfs4_sequence_res *res = &calldata->res.seq_res; in nfs4_reclaim_complete_done()
9729 trace_nfs4_reclaim_complete(clp, task->tk_status); in nfs4_reclaim_complete_done()
9730 if (nfs41_reclaim_complete_handle_errors(task, clp) == -EAGAIN) { in nfs4_reclaim_complete_done()
9761 .rpc_client = clp->cl_rpcclient, in nfs41_proc_reclaim_complete()
9766 int status = -ENOMEM; in nfs41_proc_reclaim_complete()
9771 calldata->clp = clp; in nfs41_proc_reclaim_complete()
9772 calldata->arg.one_fs = 0; in nfs41_proc_reclaim_complete()
9774 nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0, 1); in nfs41_proc_reclaim_complete()
9775 msg.rpc_argp = &calldata->arg; in nfs41_proc_reclaim_complete()
9776 msg.rpc_resp = &calldata->res; in nfs41_proc_reclaim_complete()
9780 dprintk("<-- %s status=%d\n", __func__, status); in nfs41_proc_reclaim_complete()
9788 struct nfs_server *server = NFS_SERVER(lgp->args.inode); in nfs4_layoutget_prepare()
9790 nfs4_setup_sequence(server->nfs_client, &lgp->args.seq_args, in nfs4_layoutget_prepare()
9791 &lgp->res.seq_res, task); in nfs4_layoutget_prepare()
9798 nfs41_sequence_process(task, &lgp->res.seq_res); in nfs4_layoutget_done()
9805 struct inode *inode = lgp->args.inode; in nfs4_layoutget_handle_exception()
9807 struct pnfs_layout_hdr *lo = lgp->lo; in nfs4_layoutget_handle_exception()
9808 int nfs4err = task->tk_status; in nfs4_layoutget_handle_exception()
9812 dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status); in nfs4_layoutget_handle_exception()
9814 nfs4_sequence_free_slot(&lgp->res.seq_res); in nfs4_layoutget_handle_exception()
9816 exception->state = NULL; in nfs4_layoutget_handle_exception()
9817 exception->stateid = NULL; in nfs4_layoutget_handle_exception()
9825 * on the file. set tk_status to -ENODATA to tell upper layer to in nfs4_layoutget_handle_exception()
9828 case -NFS4ERR_LAYOUTUNAVAILABLE: in nfs4_layoutget_handle_exception()
9829 status = -ENODATA; in nfs4_layoutget_handle_exception()
9833 * length lgp->args.minlength != 0 (see RFC5661 section 18.43.3). in nfs4_layoutget_handle_exception()
9835 case -NFS4ERR_BADLAYOUT: in nfs4_layoutget_handle_exception()
9836 status = -EOVERFLOW; in nfs4_layoutget_handle_exception()
9843 * Treat it like we would RECALLCONFLICT -- we retry for a little in nfs4_layoutget_handle_exception()
9846 case -NFS4ERR_LAYOUTTRYLATER: in nfs4_layoutget_handle_exception()
9847 if (lgp->args.minlength == 0) { in nfs4_layoutget_handle_exception()
9848 status = -EOVERFLOW; in nfs4_layoutget_handle_exception()
9851 status = -EBUSY; in nfs4_layoutget_handle_exception()
9853 case -NFS4ERR_RECALLCONFLICT: in nfs4_layoutget_handle_exception()
9854 case -NFS4ERR_RETURNCONFLICT: in nfs4_layoutget_handle_exception()
9855 status = -ERECALLCONFLICT; in nfs4_layoutget_handle_exception()
9857 case -NFS4ERR_DELEG_REVOKED: in nfs4_layoutget_handle_exception()
9858 case -NFS4ERR_ADMIN_REVOKED: in nfs4_layoutget_handle_exception()
9859 case -NFS4ERR_EXPIRED: in nfs4_layoutget_handle_exception()
9860 case -NFS4ERR_BAD_STATEID: in nfs4_layoutget_handle_exception()
9861 exception->timeout = 0; in nfs4_layoutget_handle_exception()
9862 spin_lock(&inode->i_lock); in nfs4_layoutget_handle_exception()
9864 if (!lo || test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) || in nfs4_layoutget_handle_exception()
9865 !nfs4_stateid_match_other(&lgp->args.stateid, &lo->plh_stateid)) { in nfs4_layoutget_handle_exception()
9866 spin_unlock(&inode->i_lock); in nfs4_layoutget_handle_exception()
9867 exception->state = lgp->args.ctx->state; in nfs4_layoutget_handle_exception()
9868 exception->stateid = &lgp->args.stateid; in nfs4_layoutget_handle_exception()
9876 spin_unlock(&inode->i_lock); in nfs4_layoutget_handle_exception()
9879 status = -EAGAIN; in nfs4_layoutget_handle_exception()
9885 if (exception->retry) in nfs4_layoutget_handle_exception()
9886 status = -EAGAIN; in nfs4_layoutget_handle_exception()
9896 u32 max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz; in max_response_pages()
9904 nfs4_sequence_free_slot(&lgp->res.seq_res); in nfs4_layoutget_release()
9918 struct inode *inode = lgp->args.inode; in nfs4_proc_layoutget()
9923 .rpc_argp = &lgp->args, in nfs4_proc_layoutget()
9924 .rpc_resp = &lgp->res, in nfs4_proc_layoutget()
9925 .rpc_cred = lgp->cred, in nfs4_proc_layoutget()
9928 .rpc_client = server->client, in nfs4_proc_layoutget()
9938 nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0, 0); in nfs4_proc_layoutget()
9939 exception->retry = 0; in nfs4_proc_layoutget()
9949 if (task->tk_status < 0) { in nfs4_proc_layoutget()
9950 exception->retry = 1; in nfs4_proc_layoutget()
9952 } else if (lgp->res.layoutp->len == 0) { in nfs4_proc_layoutget()
9953 exception->retry = 1; in nfs4_proc_layoutget()
9954 status = -EAGAIN; in nfs4_proc_layoutget()
9955 nfs4_update_delay(&exception->timeout); in nfs4_proc_layoutget()
9959 trace_nfs4_layoutget(lgp->args.ctx, in nfs4_proc_layoutget()
9960 &lgp->args.range, in nfs4_proc_layoutget()
9961 &lgp->res.range, in nfs4_proc_layoutget()
9962 &lgp->res.stateid, in nfs4_proc_layoutget()
9966 dprintk("<-- %s status=%d\n", __func__, status); in nfs4_proc_layoutget()
9977 nfs4_setup_sequence(lrp->clp, in nfs4_layoutreturn_prepare()
9978 &lrp->args.seq_args, in nfs4_layoutreturn_prepare()
9979 &lrp->res.seq_res, in nfs4_layoutreturn_prepare()
9981 if (!pnfs_layout_is_valid(lrp->args.layout)) in nfs4_layoutreturn_prepare()
9990 if (!nfs41_sequence_process(task, &lrp->res.seq_res)) in nfs4_layoutreturn_done()
9993 if (task->tk_rpc_status == -ETIMEDOUT) { in nfs4_layoutreturn_done()
9994 lrp->rpc_status = -EAGAIN; in nfs4_layoutreturn_done()
9995 lrp->res.lrs_present = 0; in nfs4_layoutreturn_done()
10002 if (task->tk_rpc_status != 0 && RPC_WAS_SENT(task)) { in nfs4_layoutreturn_done()
10003 lrp->res.lrs_present = 0; in nfs4_layoutreturn_done()
10007 server = NFS_SERVER(lrp->args.inode); in nfs4_layoutreturn_done()
10008 switch (task->tk_status) { in nfs4_layoutreturn_done()
10009 case -NFS4ERR_OLD_STATEID: in nfs4_layoutreturn_done()
10010 if (nfs4_layout_refresh_old_stateid(&lrp->args.stateid, in nfs4_layoutreturn_done()
10011 &lrp->args.range, in nfs4_layoutreturn_done()
10012 lrp->args.inode)) in nfs4_layoutreturn_done()
10016 task->tk_status = 0; in nfs4_layoutreturn_done()
10017 lrp->res.lrs_present = 0; in nfs4_layoutreturn_done()
10021 case -NFS4ERR_BADSESSION: in nfs4_layoutreturn_done()
10022 case -NFS4ERR_DEADSESSION: in nfs4_layoutreturn_done()
10023 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs4_layoutreturn_done()
10024 nfs4_schedule_session_recovery(server->nfs_client->cl_session, in nfs4_layoutreturn_done()
10025 task->tk_status); in nfs4_layoutreturn_done()
10026 lrp->res.lrs_present = 0; in nfs4_layoutreturn_done()
10027 lrp->rpc_status = -EAGAIN; in nfs4_layoutreturn_done()
10028 task->tk_status = 0; in nfs4_layoutreturn_done()
10030 case -NFS4ERR_DELAY: in nfs4_layoutreturn_done()
10032 -EAGAIN) in nfs4_layoutreturn_done()
10034 lrp->res.lrs_present = 0; in nfs4_layoutreturn_done()
10039 task->tk_status = 0; in nfs4_layoutreturn_done()
10040 nfs4_sequence_free_slot(&lrp->res.seq_res); in nfs4_layoutreturn_done()
10047 struct pnfs_layout_hdr *lo = lrp->args.layout; in nfs4_layoutreturn_release()
10049 if (lrp->rpc_status == 0 || !lrp->inode) in nfs4_layoutreturn_release()
10051 lo, &lrp->args.stateid, &lrp->args.range, in nfs4_layoutreturn_release()
10052 lrp->res.lrs_present ? &lrp->res.stateid : NULL); in nfs4_layoutreturn_release()
10054 pnfs_layoutreturn_retry_later(lo, &lrp->args.stateid, in nfs4_layoutreturn_release()
10055 &lrp->args.range); in nfs4_layoutreturn_release()
10056 nfs4_sequence_free_slot(&lrp->res.seq_res); in nfs4_layoutreturn_release()
10057 if (lrp->ld_private.ops && lrp->ld_private.ops->free) in nfs4_layoutreturn_release()
10058 lrp->ld_private.ops->free(&lrp->ld_private); in nfs4_layoutreturn_release()
10059 pnfs_put_layout_hdr(lrp->args.layout); in nfs4_layoutreturn_release()
10060 nfs_iput_and_deactive(lrp->inode); in nfs4_layoutreturn_release()
10061 put_cred(lrp->cred); in nfs4_layoutreturn_release()
10076 .rpc_argp = &lrp->args, in nfs4_proc_layoutreturn()
10077 .rpc_resp = &lrp->res, in nfs4_proc_layoutreturn()
10078 .rpc_cred = lrp->cred, in nfs4_proc_layoutreturn()
10081 .rpc_client = NFS_SERVER(lrp->args.inode)->client, in nfs4_proc_layoutreturn()
10089 nfs4_state_protect(NFS_SERVER(lrp->args.inode)->nfs_client, in nfs4_proc_layoutreturn()
10093 lrp->inode = nfs_igrab_and_active(lrp->args.inode); in nfs4_proc_layoutreturn()
10095 if (!lrp->inode) { in nfs4_proc_layoutreturn()
10097 return -EAGAIN; in nfs4_proc_layoutreturn()
10101 if (!lrp->inode) in nfs4_proc_layoutreturn()
10104 nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, in nfs4_proc_layoutreturn()
10107 nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, in nfs4_proc_layoutreturn()
10113 status = task->tk_status; in nfs4_proc_layoutreturn()
10114 trace_nfs4_layoutreturn(lrp->args.inode, &lrp->args.stateid, status); in nfs4_proc_layoutreturn()
10115 dprintk("<-- %s status=%d\n", __func__, status); in nfs4_proc_layoutreturn()
10141 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); in _nfs4_proc_getdeviceinfo()
10145 pdev->nocache = 1; in _nfs4_proc_getdeviceinfo()
10147 trace_nfs4_getdeviceinfo(server, &pdev->dev_id, status); in _nfs4_proc_getdeviceinfo()
10149 dprintk("<-- %s status=%d\n", __func__, status); in _nfs4_proc_getdeviceinfo()
10173 struct nfs_server *server = NFS_SERVER(data->args.inode); in nfs4_layoutcommit_prepare()
10175 nfs4_setup_sequence(server->nfs_client, in nfs4_layoutcommit_prepare()
10176 &data->args.seq_args, in nfs4_layoutcommit_prepare()
10177 &data->res.seq_res, in nfs4_layoutcommit_prepare()
10185 struct nfs_server *server = NFS_SERVER(data->args.inode); in nfs4_layoutcommit_done()
10187 if (!nfs41_sequence_done(task, &data->res.seq_res)) in nfs4_layoutcommit_done()
10190 switch (task->tk_status) { /* Just ignore these failures */ in nfs4_layoutcommit_done()
10191 case -NFS4ERR_DELEG_REVOKED: /* layout was recalled */ in nfs4_layoutcommit_done()
10192 case -NFS4ERR_BADIOMODE: /* no IOMODE_RW layout for range */ in nfs4_layoutcommit_done()
10193 case -NFS4ERR_BADLAYOUT: /* no layout */ in nfs4_layoutcommit_done()
10194 case -NFS4ERR_GRACE: /* loca_recalim always false */ in nfs4_layoutcommit_done()
10195 task->tk_status = 0; in nfs4_layoutcommit_done()
10200 if (nfs4_async_handle_error(task, server, NULL, NULL) == -EAGAIN) { in nfs4_layoutcommit_done()
10212 nfs_post_op_update_inode_force_wcc(data->args.inode, in nfs4_layoutcommit_release()
10213 data->res.fattr); in nfs4_layoutcommit_release()
10214 put_cred(data->cred); in nfs4_layoutcommit_release()
10215 nfs_iput_and_deactive(data->inode); in nfs4_layoutcommit_release()
10230 .rpc_argp = &data->args, in nfs4_proc_layoutcommit()
10231 .rpc_resp = &data->res, in nfs4_proc_layoutcommit()
10232 .rpc_cred = data->cred, in nfs4_proc_layoutcommit()
10235 .task = &data->task, in nfs4_proc_layoutcommit()
10236 .rpc_client = NFS_CLIENT(data->args.inode), in nfs4_proc_layoutcommit()
10247 data->args.lastbytewritten, in nfs4_proc_layoutcommit()
10248 data->args.inode->i_ino); in nfs4_proc_layoutcommit()
10251 data->inode = nfs_igrab_and_active(data->args.inode); in nfs4_proc_layoutcommit()
10252 if (data->inode == NULL) { in nfs4_proc_layoutcommit()
10254 return -EAGAIN; in nfs4_proc_layoutcommit()
10258 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); in nfs4_proc_layoutcommit()
10263 status = task->tk_status; in nfs4_proc_layoutcommit()
10264 trace_nfs4_layoutcommit(data->args.inode, &data->args.stateid, status); in nfs4_proc_layoutcommit()
10296 .rpc_client = server->client, in _nfs41_proc_secinfo_no_name()
10298 .callback_ops = server->nfs_client->cl_mvops->call_sync_ops, in _nfs41_proc_secinfo_no_name()
10306 task_setup.rpc_client = server->nfs_client->cl_rpcclient; in _nfs41_proc_secinfo_no_name()
10308 cred = nfs4_get_clid_cred(server->nfs_client); in _nfs41_proc_secinfo_no_name()
10314 dprintk("<-- %s status=%d\n", __func__, status); in _nfs41_proc_secinfo_no_name()
10331 err = -NFS4ERR_WRONGSEC; in nfs41_proc_secinfo_no_name()
10334 if (_nfs4_is_integrity_protected(server->nfs_client)) in nfs41_proc_secinfo_no_name()
10344 if (err == -NFS4ERR_WRONGSEC) in nfs41_proc_secinfo_no_name()
10350 case -NFS4ERR_WRONGSEC: in nfs41_proc_secinfo_no_name()
10351 case -ENOTSUPP: in nfs41_proc_secinfo_no_name()
10374 err = -ENOMEM; in nfs41_find_root_sec()
10385 if (err == -NFS4ERR_WRONGSEC || err == -ENOTSUPP) { in nfs41_find_root_sec()
10392 for (i = 0; i < flavors->num_flavors; i++) { in nfs41_find_root_sec()
10393 secinfo = &flavors->flavors[i]; in nfs41_find_root_sec()
10395 switch (secinfo->flavor) { in nfs41_find_root_sec()
10399 flavor = rpcauth_get_pseudoflavor(secinfo->flavor, in nfs41_find_root_sec()
10400 &secinfo->flavor_info); in nfs41_find_root_sec()
10407 if (!nfs_auth_info_match(&server->auth_info, flavor)) in nfs41_find_root_sec()
10419 err = -EPERM; in nfs41_find_root_sec()
10423 if (err == -EACCES) in nfs41_find_root_sec()
10424 return -EPERM; in nfs41_find_root_sec()
10444 struct rpc_clnt *rpc_client = server->client; in _nfs41_test_stateid()
10446 nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID, in _nfs41_test_stateid()
10457 dprintk("NFS reply test_stateid: succeeded, %d\n", -res.status); in _nfs41_test_stateid()
10458 return -res.status; in _nfs41_test_stateid()
10464 exception->retry = 0; in nfs4_handle_delay_or_session_error()
10466 case -NFS4ERR_DELAY: in nfs4_handle_delay_or_session_error()
10467 case -NFS4ERR_RETRY_UNCACHED_REP: in nfs4_handle_delay_or_session_error()
10470 case -NFS4ERR_BADSESSION: in nfs4_handle_delay_or_session_error()
10471 case -NFS4ERR_BADSLOT: in nfs4_handle_delay_or_session_error()
10472 case -NFS4ERR_BAD_HIGH_SLOT: in nfs4_handle_delay_or_session_error()
10473 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: in nfs4_handle_delay_or_session_error()
10474 case -NFS4ERR_DEADSESSION: in nfs4_handle_delay_or_session_error()
10480 * nfs41_test_stateid - perform a TEST_STATEID operation
10514 nfs4_setup_sequence(data->server->nfs_client, in nfs41_free_stateid_prepare()
10515 &data->args.seq_args, in nfs41_free_stateid_prepare()
10516 &data->res.seq_res, in nfs41_free_stateid_prepare()
10524 nfs41_sequence_done(task, &data->res.seq_res); in nfs41_free_stateid_done()
10526 switch (task->tk_status) { in nfs41_free_stateid_done()
10527 case -NFS4ERR_DELAY: in nfs41_free_stateid_done()
10528 if (nfs4_async_handle_error(task, data->server, NULL, NULL) == -EAGAIN) in nfs41_free_stateid_done()
10536 struct nfs_client *clp = data->server->nfs_client; in nfs41_free_stateid_release()
10549 * nfs41_free_stateid - perform a FREE_STATEID operation
10554 * @privileged: set to true if this call needs to be privileged
10568 .rpc_client = server->client, in nfs41_free_stateid()
10575 struct nfs_client *clp = server->nfs_client; in nfs41_free_stateid()
10577 if (!refcount_inc_not_zero(&clp->cl_count)) in nfs41_free_stateid()
10578 return -EIO; in nfs41_free_stateid()
10580 nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID, in nfs41_free_stateid()
10586 return -ENOMEM; in nfs41_free_stateid()
10587 data->server = server; in nfs41_free_stateid()
10588 nfs4_stateid_copy(&data->args.stateid, stateid); in nfs41_free_stateid()
10592 msg.rpc_argp = &data->args; in nfs41_free_stateid()
10593 msg.rpc_resp = &data->res; in nfs41_free_stateid()
10594 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, privileged); in nfs41_free_stateid()
10605 const struct cred *cred = lsp->ls_state->owner->so_cred; in nfs41_free_lock_state()
10607 nfs41_free_stateid(server, &lsp->ls_stateid, cred, false); in nfs41_free_lock_state()
10614 if (s1->type != s2->type) in nfs41_match_stateid()
10617 if (memcmp(s1->other, s2->other, sizeof(s1->other)) != 0) in nfs41_match_stateid()
10620 if (s1->seqid == s2->seqid) in nfs41_match_stateid()
10623 return s1->seqid == 0 || s2->seqid == 0; in nfs41_match_stateid()
10807 left -= error; in nfs4_listxattr()
10816 left -= error2; in nfs4_listxattr()
10825 return -ERANGE; in nfs4_listxattr()
10834 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; in nfs4_enable_swap()
10844 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; in nfs4_disable_swap()
10846 set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); in nfs4_disable_swap()
10847 clear_bit(NFS4CLNT_MANAGER_AVAILABLE, &clp->cl_state); in nfs4_disable_swap()
10848 wake_up_var(&clp->cl_state); in nfs4_disable_swap()
10937 .set = nfs4_xattr_set_nfs4_acl,
10945 .set = nfs4_xattr_set_nfs4_dacl,
10952 .set = nfs4_xattr_set_nfs4_sacl,
10960 .set = nfs4_xattr_set_nfs4_user,