NFS: Fix an infinite loop when layoutget fail with BAD_STATEID
[deliverable/linux.git] / fs / nfs / nfs4proc.c
index 3f73539579e54671602575f188091a96b5a7fbba..10ba6c1968e2110eba30488f7dc75230cf481ba8 100644 (file)
@@ -5014,11 +5014,10 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
        int result;
        size_t len;
        char *str;
-       bool retried = false;
 
        if (clp->cl_owner_id != NULL)
                return 0;
-retry:
+
        rcu_read_lock();
        len = 14 + strlen(clp->cl_ipaddr) + 1 +
                strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) +
@@ -5046,14 +5045,6 @@ retry:
                        rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO));
        rcu_read_unlock();
 
-       /* Did something change? */
-       if (result >= len) {
-               kfree(str);
-               if (retried)
-                       return -EINVAL;
-               retried = true;
-               goto retry;
-       }
        clp->cl_owner_id = str;
        return 0;
 }
@@ -5085,10 +5076,6 @@ nfs4_init_uniquifier_client_string(struct nfs_client *clp)
                        clp->rpc_ops->version, clp->cl_minorversion,
                        nfs4_client_id_uniquifier,
                        clp->cl_rpcclient->cl_nodename);
-       if (result >= len) {
-               kfree(str);
-               return -EINVAL;
-       }
        clp->cl_owner_id = str;
        return 0;
 }
@@ -5124,10 +5111,6 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
        result = scnprintf(str, len, "Linux NFSv%u.%u %s",
                        clp->rpc_ops->version, clp->cl_minorversion,
                        clp->cl_rpcclient->cl_nodename);
-       if (result >= len) {
-               kfree(str);
-               return -EINVAL;
-       }
        clp->cl_owner_id = str;
        return 0;
 }
@@ -7837,6 +7820,7 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)
                         * Mark the bad layout state as invalid, then retry
                         * with the current stateid.
                         */
+                       set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
                        pnfs_mark_matching_lsegs_invalid(lo, &head, NULL);
                        spin_unlock(&inode->i_lock);
                        pnfs_free_lseg_list(&head);
This page took 0.024919 seconds and 5 git commands to generate.