NFS: Never use user credentials for lease renewal
[linux-2.6-block.git] / fs / nfs / nfs4state.c
index f27760b1b06fe22fabd9270d57282155d3c224a9..6818964bb7c0e8fe1432cfc8da286d0b88a01979 100644 (file)
@@ -352,62 +352,21 @@ int nfs41_discover_server_trunking(struct nfs_client *clp,
        return nfs41_walk_client_list(clp, result, cred);
 }
 
-struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp)
-{
-       struct rpc_cred *cred;
-
-       spin_lock(&clp->cl_lock);
-       cred = nfs4_get_machine_cred_locked(clp);
-       spin_unlock(&clp->cl_lock);
-       return cred;
-}
-
 #endif /* CONFIG_NFS_V4_1 */
 
-static struct rpc_cred *
-nfs4_get_setclientid_cred_server(struct nfs_server *server)
-{
-       struct nfs_client *clp = server->nfs_client;
-       struct rpc_cred *cred = NULL;
-       struct nfs4_state_owner *sp;
-       struct rb_node *pos;
-
-       spin_lock(&clp->cl_lock);
-       pos = rb_first(&server->state_owners);
-       if (pos != NULL) {
-               sp = rb_entry(pos, struct nfs4_state_owner, so_server_node);
-               cred = get_rpccred(sp->so_cred);
-       }
-       spin_unlock(&clp->cl_lock);
-       return cred;
-}
-
 /**
- * nfs4_get_setclientid_cred - Acquire credential for a setclientid operation
+ * nfs4_get_clid_cred - Acquire credential for a setclientid operation
  * @clp: client state handle
  *
  * Returns an rpc_cred with reference count bumped, or NULL.
  */
-struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
+struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp)
 {
-       struct nfs_server *server;
        struct rpc_cred *cred;
 
        spin_lock(&clp->cl_lock);
        cred = nfs4_get_machine_cred_locked(clp);
        spin_unlock(&clp->cl_lock);
-       if (cred != NULL)
-               goto out;
-
-       rcu_read_lock();
-       list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
-               cred = nfs4_get_setclientid_cred_server(server);
-               if (cred != NULL)
-                       break;
-       }
-       rcu_read_unlock();
-
-out:
        return cred;
 }
 
@@ -1631,7 +1590,7 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
        if (!nfs4_state_clear_reclaim_reboot(clp))
                return;
        ops = clp->cl_mvops->reboot_recovery_ops;
-       cred = ops->get_clid_cred(clp);
+       cred = nfs4_get_clid_cred(clp);
        nfs4_reclaim_complete(clp, ops, cred);
        put_rpccred(cred);
 }
@@ -1745,7 +1704,7 @@ static int nfs4_check_lease(struct nfs_client *clp)
        cred = ops->get_state_renewal_cred_locked(clp);
        spin_unlock(&clp->cl_lock);
        if (cred == NULL) {
-               cred = nfs4_get_setclientid_cred(clp);
+               cred = nfs4_get_clid_cred(clp);
                status = -ENOKEY;
                if (cred == NULL)
                        goto out;
@@ -1817,7 +1776,7 @@ static int nfs4_establish_lease(struct nfs_client *clp)
                clp->cl_mvops->reboot_recovery_ops;
        int status;
 
-       cred = ops->get_clid_cred(clp);
+       cred = nfs4_get_clid_cred(clp);
        if (cred == NULL)
                return -ENOENT;
        status = ops->establish_clid(clp, cred);
@@ -1891,7 +1850,7 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
        mutex_lock(&nfs_clid_init_mutex);
 again:
        status  = -ENOENT;
-       cred = ops->get_clid_cred(clp);
+       cred = nfs4_get_clid_cred(clp);
        if (cred == NULL)
                goto out_unlock;
 
@@ -2069,7 +2028,7 @@ static int nfs4_reset_session(struct nfs_client *clp)
        if (!nfs4_has_session(clp))
                return 0;
        nfs4_begin_drain_session(clp);
-       cred = nfs4_get_exchange_id_cred(clp);
+       cred = nfs4_get_clid_cred(clp);
        status = nfs4_proc_destroy_session(clp->cl_session, cred);
        switch (status) {
        case 0:
@@ -2112,7 +2071,7 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
        if (!nfs4_has_session(clp))
                return 0;
        nfs4_begin_drain_session(clp);
-       cred = nfs4_get_exchange_id_cred(clp);
+       cred = nfs4_get_clid_cred(clp);
        ret = nfs4_proc_bind_conn_to_session(clp, cred);
        if (cred)
                put_rpccred(cred);