Merge tag 'nfs-for-4.21-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[sfrench/cifs-2.6.git] / fs / nfs / nfs4proc.c
index 867457d6dfbe54060ae6f152ca2a07dfa605ff71..557a5d63618394c2af4fdf7a7fb5b928ccbc2e47 100644 (file)
@@ -93,19 +93,19 @@ static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinf
 static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr);
 static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode);
 static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode);
-static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
+static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
                            struct nfs_fattr *fattr, struct iattr *sattr,
                            struct nfs_open_context *ctx, struct nfs4_label *ilabel,
                            struct nfs4_label *olabel);
 #ifdef CONFIG_NFS_V4_1
 static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
-               struct rpc_cred *cred,
+               const struct cred *cred,
                struct nfs4_slot *slot,
                bool is_privileged);
 static int nfs41_test_stateid(struct nfs_server *, nfs4_stateid *,
-               struct rpc_cred *);
+               const struct cred *);
 static int nfs41_free_stateid(struct nfs_server *, const nfs4_stateid *,
-               struct rpc_cred *, bool);
+               const struct cred *, bool);
 #endif
 
 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
@@ -361,7 +361,7 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent
 
 static void nfs4_test_and_free_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        const struct nfs4_minor_version_ops *ops = server->nfs_client->cl_mvops;
 
@@ -370,7 +370,7 @@ static void nfs4_test_and_free_stateid(struct nfs_server *server,
 
 static void __nfs4_free_revoked_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        stateid->type = NFS4_REVOKED_STATEID_TYPE;
        nfs4_test_and_free_stateid(server, stateid, cred);
@@ -378,7 +378,7 @@ static void __nfs4_free_revoked_stateid(struct nfs_server *server,
 
 static void nfs4_free_revoked_stateid(struct nfs_server *server,
                const nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        nfs4_stateid tmp;
 
@@ -908,7 +908,7 @@ static const struct rpc_call_ops nfs41_call_sync_ops = {
 
 static void
 nfs4_sequence_process_interrupted(struct nfs_client *client,
-               struct nfs4_slot *slot, struct rpc_cred *cred)
+               struct nfs4_slot *slot, const struct cred *cred)
 {
        struct rpc_task *task;
 
@@ -939,7 +939,7 @@ EXPORT_SYMBOL_GPL(nfs4_sequence_done);
 
 static void
 nfs4_sequence_process_interrupted(struct nfs_client *client,
-               struct nfs4_slot *slot, struct rpc_cred *cred)
+               struct nfs4_slot *slot, const struct cred *cred)
 {
        WARN_ON_ONCE(1);
        slot->interrupted = 0;
@@ -2484,7 +2484,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
  * Note that in the non-execute case, we want to turn off permission
  * checking if we just created a new file (POSIX open() semantics).
  */
-static int nfs4_opendata_access(struct rpc_cred *cred,
+static int nfs4_opendata_access(const struct cred *cred,
                                struct nfs4_opendata *opendata,
                                struct nfs4_state *state, fmode_t fmode,
                                int openflags)
@@ -2651,7 +2651,7 @@ static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
 
 static int nfs40_test_and_free_expired_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        return -NFS4ERR_BAD_STATEID;
 }
@@ -2659,7 +2659,7 @@ static int nfs40_test_and_free_expired_stateid(struct nfs_server *server,
 #if defined(CONFIG_NFS_V4_1)
 static int nfs41_test_and_free_expired_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        int status;
 
@@ -2693,7 +2693,7 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)
        struct nfs_server *server = NFS_SERVER(state->inode);
        nfs4_stateid stateid;
        struct nfs_delegation *delegation;
-       struct rpc_cred *cred;
+       const struct cred *cred = NULL;
        int status;
 
        /* Get the delegation credential for use by test/free_stateid */
@@ -2718,14 +2718,16 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)
                return;
        }
 
-       cred = get_rpccred(delegation->cred);
+       if (delegation->cred)
+               cred = get_cred(delegation->cred);
        rcu_read_unlock();
        status = nfs41_test_and_free_expired_stateid(server, &stateid, cred);
        trace_nfs4_test_delegation_stateid(state, NULL, status);
        if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID)
                nfs_finish_clear_delegation_stateid(state, &stateid);
 
-       put_rpccred(cred);
+       if (delegation->cred)
+               put_cred(cred);
 }
 
 /**
@@ -2748,7 +2750,7 @@ static int nfs41_check_expired_locks(struct nfs4_state *state)
        spin_lock(&state->state_lock);
        list_for_each_entry(lsp, &state->lock_states, ls_locks) {
                if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags)) {
-                       struct rpc_cred *cred = lsp->ls_state->owner->so_cred;
+                       const struct cred *cred = lsp->ls_state->owner->so_cred;
 
                        refcount_inc(&lsp->ls_count);
                        spin_unlock(&state->state_lock);
@@ -2792,7 +2794,7 @@ static int nfs41_check_open_stateid(struct nfs4_state *state)
 {
        struct nfs_server *server = NFS_SERVER(state->inode);
        nfs4_stateid *stateid = &state->open_stateid;
-       struct rpc_cred *cred = state->owner->so_cred;
+       const struct cred *cred = state->owner->so_cred;
        int status;
 
        if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) {
@@ -2950,7 +2952,7 @@ static int _nfs4_do_open(struct inode *dir,
        struct nfs_server       *server = NFS_SERVER(dir);
        struct nfs4_opendata *opendata;
        struct dentry *dentry = ctx->dentry;
-       struct rpc_cred *cred = ctx->cred;
+       const struct cred *cred = ctx->cred;
        struct nfs4_threshold **ctx_th = &ctx->mdsthreshold;
        fmode_t fmode = ctx->mode & (FMODE_READ|FMODE_WRITE|FMODE_EXEC);
        enum open_claim_type4 claim = NFS4_OPEN_CLAIM_NULL;
@@ -3120,7 +3122,7 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir,
 static int _nfs4_do_setattr(struct inode *inode,
                            struct nfs_setattrargs *arg,
                            struct nfs_setattrres *res,
-                           struct rpc_cred *cred,
+                           const struct cred *cred,
                            struct nfs_open_context *ctx)
 {
        struct nfs_server *server = NFS_SERVER(inode);
@@ -3130,7 +3132,7 @@ static int _nfs4_do_setattr(struct inode *inode,
                .rpc_resp       = res,
                .rpc_cred       = cred,
        };
-       struct rpc_cred *delegation_cred = NULL;
+       const struct cred *delegation_cred = NULL;
        unsigned long timestamp = jiffies;
        bool truncate;
        int status;
@@ -3165,14 +3167,14 @@ zero_stateid:
 
        status = nfs4_call_sync(server->client, server, &msg, &arg->seq_args, &res->seq_res, 1);
 
-       put_rpccred(delegation_cred);
+       put_cred(delegation_cred);
        if (status == 0 && ctx != NULL)
                renew_lease(server, timestamp);
        trace_nfs4_setattr(inode, &arg->stateid, status);
        return status;
 }
 
-static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
+static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
                           struct nfs_fattr *fattr, struct iattr *sattr,
                           struct nfs_open_context *ctx, struct nfs4_label *ilabel,
                           struct nfs4_label *olabel)
@@ -3973,7 +3975,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
                  struct iattr *sattr)
 {
        struct inode *inode = d_inode(dentry);
-       struct rpc_cred *cred = NULL;
+       const struct cred *cred = NULL;
        struct nfs_open_context *ctx = NULL;
        struct nfs4_label *label = NULL;
        int status;
@@ -4202,7 +4204,6 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
                        return -ENOMEM;
                args.bitmask = server->cache_consistency_bitmask;
        }
-
        status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0);
        if (!status) {
                nfs_access_set_mask(entry, res.access);
@@ -4691,7 +4692,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
        return err;
 }
 
-static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred,
                u64 cookie, struct page **pages, unsigned int count, bool plus)
 {
        struct inode            *dir = d_inode(dentry);
@@ -4729,7 +4730,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
        return status;
 }
 
-static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
+static int nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred,
                u64 cookie, struct page **pages, unsigned int count, bool plus)
 {
        struct nfs4_exception exception = { };
@@ -5257,7 +5258,7 @@ static const struct rpc_call_ops nfs4_renew_ops = {
        .rpc_release = nfs4_renew_release,
 };
 
-static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags)
+static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags)
 {
        struct rpc_message msg = {
                .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
@@ -5281,7 +5282,7 @@ static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred,
                        &nfs4_renew_ops, data);
 }
 
-static int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred)
+static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
 {
        struct rpc_message msg = {
                .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
@@ -5696,7 +5697,6 @@ nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen)
 {
        struct nfs4_label ilabel, *olabel = NULL;
        struct nfs_fattr fattr;
-       struct rpc_cred *cred;
        int status;
 
        if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL))
@@ -5709,10 +5709,6 @@ nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen)
        ilabel.label = (char *)buf;
        ilabel.len = buflen;
 
-       cred = rpc_lookup_cred();
-       if (IS_ERR(cred))
-               return PTR_ERR(cred);
-
        olabel = nfs4_label_alloc(NFS_SERVER(inode), GFP_KERNEL);
        if (IS_ERR(olabel)) {
                status = -PTR_ERR(olabel);
@@ -5725,7 +5721,6 @@ nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen)
 
        nfs4_label_free(olabel);
 out:
-       put_rpccred(cred);
        return status;
 }
 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
@@ -5894,13 +5889,13 @@ static const struct rpc_call_ops nfs4_setclientid_ops = {
  * @clp: state data structure
  * @program: RPC program for NFSv4 callback service
  * @port: IP port number for NFS4 callback service
- * @cred: RPC credential to use for this call
+ * @cred: credential to use for this call
  * @res: where to place the result
  *
  * Returns zero, a negative errno, or a negative NFS4ERR status code.
  */
 int nfs4_proc_setclientid(struct nfs_client *clp, u32 program,
-               unsigned short port, struct rpc_cred *cred,
+               unsigned short port, const struct cred *cred,
                struct nfs4_setclientid_res *res)
 {
        nfs4_verifier sc_verifier;
@@ -5969,13 +5964,13 @@ out:
  * nfs4_proc_setclientid_confirm - Confirm client ID
  * @clp: state data structure
  * @res: result of a previous SETCLIENTID
- * @cred: RPC credential to use for this call
+ * @cred: credential to use for this call
  *
  * Returns zero, a negative errno, or a negative NFS4ERR status code.
  */
 int nfs4_proc_setclientid_confirm(struct nfs_client *clp,
                struct nfs4_setclientid_res *arg,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct rpc_message msg = {
                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM],
@@ -6138,7 +6133,7 @@ static const struct rpc_call_ops nfs4_delegreturn_ops = {
        .rpc_release = nfs4_delegreturn_release,
 };
 
-static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync)
+static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync)
 {
        struct nfs4_delegreturndata *data;
        struct nfs_server *server = NFS_SERVER(inode);
@@ -6205,7 +6200,7 @@ out:
        return status;
 }
 
-int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync)
+int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs4_exception exception = { };
@@ -6311,7 +6306,8 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl,
        /* Ensure we don't close file until we're done freeing locks! */
        p->ctx = get_nfs_open_context(ctx);
        p->l_ctx = nfs_get_lock_context(ctx);
-       memcpy(&p->fl, fl, sizeof(p->fl));
+       locks_init_lock(&p->fl);
+       locks_copy_lock(&p->fl, fl);
        p->server = NFS_SERVER(inode);
        return p;
 }
@@ -6533,7 +6529,8 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
        p->server = server;
        refcount_inc(&lsp->ls_count);
        p->ctx = get_nfs_open_context(ctx);
-       memcpy(&p->fl, fl, sizeof(p->fl));
+       locks_init_lock(&p->fl);
+       locks_copy_lock(&p->fl, fl);
        return p;
 out_free_seqid:
        nfs_free_seqid(p->arg.open_seqid);
@@ -7266,7 +7263,7 @@ int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
  */
 static int _nfs40_proc_get_locations(struct inode *inode,
                                     struct nfs4_fs_locations *locations,
-                                    struct page *page, struct rpc_cred *cred)
+                                    struct page *page, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct rpc_clnt *clnt = server->client;
@@ -7323,7 +7320,7 @@ static int _nfs40_proc_get_locations(struct inode *inode,
  */
 static int _nfs41_proc_get_locations(struct inode *inode,
                                     struct nfs4_fs_locations *locations,
-                                    struct page *page, struct rpc_cred *cred)
+                                    struct page *page, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct rpc_clnt *clnt = server->client;
@@ -7382,7 +7379,7 @@ static int _nfs41_proc_get_locations(struct inode *inode,
  */
 int nfs4_proc_get_locations(struct inode *inode,
                            struct nfs4_fs_locations *locations,
-                           struct page *page, struct rpc_cred *cred)
+                           struct page *page, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs_client *clp = server->nfs_client;
@@ -7413,7 +7410,7 @@ int nfs4_proc_get_locations(struct inode *inode,
  * is appended to this compound to identify the client ID which is
  * performing recovery.
  */
-static int _nfs40_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
+static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
@@ -7459,7 +7456,7 @@ static int _nfs40_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
  * this operation is identified in the SEQUENCE operation in this
  * compound.
  */
-static int _nfs41_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
+static int _nfs41_proc_fsid_present(struct inode *inode, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct rpc_clnt *clnt = server->client;
@@ -7506,7 +7503,7 @@ static int _nfs41_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
  *  NFS4ERR code if some error occurred on the server, or a
  *  negative errno if a local failure occurred.
  */
-int nfs4_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
+int nfs4_proc_fsid_present(struct inode *inode, const struct cred *cred)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs_client *clp = server->nfs_client;
@@ -7553,7 +7550,7 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
                .rpc_resp = &res,
        };
        struct rpc_clnt *clnt = NFS_SERVER(dir)->client;
-       struct rpc_cred *cred = NULL;
+       const struct cred *cred = NULL;
 
        if (use_integrity) {
                clnt = NFS_SERVER(dir)->nfs_client->cl_rpcclient;
@@ -7570,8 +7567,7 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
                                &res.seq_res, 0);
        dprintk("NFS reply  secinfo: %d\n", status);
 
-       if (cred)
-               put_rpccred(cred);
+       put_cred(cred);
 
        return status;
 }
@@ -7652,7 +7648,7 @@ static
 int nfs4_proc_bind_one_conn_to_session(struct rpc_clnt *clnt,
                struct rpc_xprt *xprt,
                struct nfs_client *clp,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        int status;
        struct nfs41_bind_conn_to_session_args args = {
@@ -7714,7 +7710,7 @@ int nfs4_proc_bind_one_conn_to_session(struct rpc_clnt *clnt,
 
 struct rpc_bind_conn_calldata {
        struct nfs_client *clp;
-       struct rpc_cred *cred;
+       const struct cred *cred;
 };
 
 static int
@@ -7727,7 +7723,7 @@ nfs4_proc_bind_conn_to_session_callback(struct rpc_clnt *clnt,
        return nfs4_proc_bind_one_conn_to_session(clnt, xprt, p->clp, p->cred);
 }
 
-int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred)
+int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, const struct cred *cred)
 {
        struct rpc_bind_conn_calldata data = {
                .clp = clp,
@@ -7893,7 +7889,7 @@ static const struct rpc_call_ops nfs4_exchange_id_call_ops = {
  * Wrapper for EXCHANGE_ID operation.
  */
 static struct rpc_task *
-nfs4_run_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
+nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred,
                        u32 sp4_how, struct rpc_xprt *xprt)
 {
        struct rpc_message msg = {
@@ -7989,7 +7985,7 @@ out:
  *
  * Wrapper for EXCHANGE_ID operation.
  */
-static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
+static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred,
                        u32 sp4_how)
 {
        struct rpc_task *task;
@@ -8056,7 +8052,7 @@ out:
  *
  * Will attempt to negotiate SP4_MACH_CRED if krb5i / krb5p auth is used.
  */
-int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
+int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred)
 {
        rpc_authflavor_t authflavor = clp->cl_rpcclient->cl_auth->au_flavor;
        int status;
@@ -8088,7 +8084,7 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
  * @xprt: the rpc_xprt to test
  * @data: call data for _nfs4_proc_exchange_id.
  */
-int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
+void nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
                            void *data)
 {
        struct nfs4_add_xprt_data *adata = (struct nfs4_add_xprt_data *)data;
@@ -8105,20 +8101,22 @@ int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
        /* Test connection for session trunking. Async exchange_id call */
        task = nfs4_run_exchange_id(adata->clp, adata->cred, sp4_how, xprt);
        if (IS_ERR(task))
-               return PTR_ERR(task);
+               return;
 
        status = task->tk_status;
        if (status == 0)
                status = nfs4_detect_session_trunking(adata->clp,
                                task->tk_msg.rpc_resp, xprt);
 
+       if (status == 0)
+               rpc_clnt_xprt_switch_add_xprt(clnt, xprt);
+
        rpc_put_task(task);
-       return status;
 }
 EXPORT_SYMBOL_GPL(nfs4_test_session_trunk);
 
 static int _nfs4_proc_destroy_clientid(struct nfs_client *clp,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct rpc_message msg = {
                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_CLIENTID],
@@ -8136,7 +8134,7 @@ static int _nfs4_proc_destroy_clientid(struct nfs_client *clp,
 }
 
 static int nfs4_proc_destroy_clientid(struct nfs_client *clp,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        unsigned int loop;
        int ret;
@@ -8157,7 +8155,7 @@ static int nfs4_proc_destroy_clientid(struct nfs_client *clp,
 
 int nfs4_destroy_clientid(struct nfs_client *clp)
 {
-       struct rpc_cred *cred;
+       const struct cred *cred;
        int ret = 0;
 
        if (clp->cl_mvops->minor_version < 1)
@@ -8168,8 +8166,7 @@ int nfs4_destroy_clientid(struct nfs_client *clp)
                goto out;
        cred = nfs4_get_clid_cred(clp);
        ret = nfs4_proc_destroy_clientid(clp, cred);
-       if (cred)
-               put_rpccred(cred);
+       put_cred(cred);
        switch (ret) {
        case 0:
        case -NFS4ERR_STALE_CLIENTID:
@@ -8385,7 +8382,7 @@ static void nfs4_update_session(struct nfs4_session *session,
 }
 
 static int _nfs4_proc_create_session(struct nfs_client *clp,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct nfs4_session *session = clp->cl_session;
        struct nfs41_create_session_args args = {
@@ -8437,7 +8434,7 @@ out:
  * It is the responsibility of the caller to verify the session is
  * expired before calling this routine.
  */
-int nfs4_proc_create_session(struct nfs_client *clp, struct rpc_cred *cred)
+int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred)
 {
        int status;
        unsigned *ptr;
@@ -8468,7 +8465,7 @@ out:
  * The caller must serialize access to this routine.
  */
 int nfs4_proc_destroy_session(struct nfs4_session *session,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct rpc_message msg = {
                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION],
@@ -8570,7 +8567,7 @@ static const struct rpc_call_ops nfs41_sequence_ops = {
 };
 
 static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
-               struct rpc_cred *cred,
+               const struct cred *cred,
                struct nfs4_slot *slot,
                bool is_privileged)
 {
@@ -8613,7 +8610,7 @@ out_err:
        return ret;
 }
 
-static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags)
+static int nfs41_proc_async_sequence(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags)
 {
        struct rpc_task *task;
        int ret = 0;
@@ -8629,7 +8626,7 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cr
        return ret;
 }
 
-static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred)
+static int nfs4_proc_sequence(struct nfs_client *clp, const struct cred *cred)
 {
        struct rpc_task *task;
        int ret;
@@ -8725,7 +8722,7 @@ static const struct rpc_call_ops nfs4_reclaim_complete_call_ops = {
  * Issue a global reclaim complete.
  */
 static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct nfs4_reclaim_complete_data *calldata;
        struct rpc_task *task;
@@ -9078,7 +9075,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
 static int
 _nfs4_proc_getdeviceinfo(struct nfs_server *server,
                struct pnfs_device *pdev,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct nfs4_getdeviceinfo_args args = {
                .pdev = pdev,
@@ -9110,7 +9107,7 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server,
 
 int nfs4_proc_getdeviceinfo(struct nfs_server *server,
                struct pnfs_device *pdev,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct nfs4_exception exception = { };
        int err;
@@ -9167,7 +9164,7 @@ static void nfs4_layoutcommit_release(void *calldata)
        pnfs_cleanup_layoutcommit(data);
        nfs_post_op_update_inode_force_wcc(data->args.inode,
                                           data->res.fattr);
-       put_rpccred(data->cred);
+       put_cred(data->cred);
        nfs_iput_and_deactive(data->inode);
        kfree(data);
 }
@@ -9243,7 +9240,7 @@ _nfs41_proc_secinfo_no_name(struct nfs_server *server, struct nfs_fh *fhandle,
                .rpc_resp = &res,
        };
        struct rpc_clnt *clnt = server->client;
-       struct rpc_cred *cred = NULL;
+       const struct cred *cred = NULL;
        int status;
 
        if (use_integrity) {
@@ -9257,8 +9254,7 @@ _nfs41_proc_secinfo_no_name(struct nfs_server *server, struct nfs_fh *fhandle,
                                &res.seq_res, 0);
        dprintk("<-- %s status=%d\n", __func__, status);
 
-       if (cred)
-               put_rpccred(cred);
+       put_cred(cred);
 
        return status;
 }
@@ -9371,7 +9367,7 @@ out:
 
 static int _nfs41_test_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        int status;
        struct nfs41_test_stateid_args args = {
@@ -9432,7 +9428,7 @@ static void nfs4_handle_delay_or_session_error(struct nfs_server *server,
  */
 static int nfs41_test_stateid(struct nfs_server *server,
                nfs4_stateid *stateid,
-               struct rpc_cred *cred)
+               const struct cred *cred)
 {
        struct nfs4_exception exception = { };
        int err;
@@ -9494,7 +9490,7 @@ static const struct rpc_call_ops nfs41_free_stateid_ops = {
  */
 static int nfs41_free_stateid(struct nfs_server *server,
                const nfs4_stateid *stateid,
-               struct rpc_cred *cred,
+               const struct cred *cred,
                bool privileged)
 {
        struct rpc_message msg = {
@@ -9535,7 +9531,7 @@ static int nfs41_free_stateid(struct nfs_server *server,
 static void
 nfs41_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp)
 {
-       struct rpc_cred *cred = lsp->ls_state->owner->so_cred;
+       const struct cred *cred = lsp->ls_state->owner->so_cred;
 
        nfs41_free_stateid(server, &lsp->ls_stateid, cred, false);
        nfs4_free_lock_state(server, lsp);
@@ -9606,14 +9602,14 @@ static const struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = {
 
 static const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
        .sched_state_renewal = nfs4_proc_async_renew,
-       .get_state_renewal_cred_locked = nfs4_get_renew_cred_locked,
+       .get_state_renewal_cred = nfs4_get_renew_cred,
        .renew_lease = nfs4_proc_renew,
 };
 
 #if defined(CONFIG_NFS_V4_1)
 static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
        .sched_state_renewal = nfs41_proc_async_sequence,
-       .get_state_renewal_cred_locked = nfs4_get_machine_cred_locked,
+       .get_state_renewal_cred = nfs4_get_machine_cred,
        .renew_lease = nfs4_proc_sequence,
 };
 #endif