@@ -1642,7 +1642,7 @@ static int nfs4_handle_reclaim_lease_error(struct nfs_client *clp, int status)
16421642 return 0 ;
16431643}
16441644
1645- static int nfs4_reclaim_lease (struct nfs_client * clp )
1645+ static int nfs4_establish_lease (struct nfs_client * clp )
16461646{
16471647 struct rpc_cred * cred ;
16481648 const struct nfs4_state_recovery_ops * ops =
@@ -1655,7 +1655,37 @@ static int nfs4_reclaim_lease(struct nfs_client *clp)
16551655 status = ops -> establish_clid (clp , cred );
16561656 put_rpccred (cred );
16571657 if (status != 0 )
1658+ return status ;
1659+ pnfs_destroy_all_layouts (clp );
1660+ return 0 ;
1661+ }
1662+
1663+ static int nfs4_reclaim_lease (struct nfs_client * clp )
1664+ {
1665+ int status ;
1666+
1667+ status = nfs4_establish_lease (clp );
1668+ if (status < 0 )
1669+ return nfs4_handle_reclaim_lease_error (clp , status );
1670+ if (test_and_clear_bit (NFS4CLNT_SERVER_SCOPE_MISMATCH , & clp -> cl_state ))
1671+ nfs4_state_start_reclaim_nograce (clp );
1672+ if (!test_bit (NFS4CLNT_RECLAIM_NOGRACE , & clp -> cl_state ))
1673+ set_bit (NFS4CLNT_RECLAIM_REBOOT , & clp -> cl_state );
1674+ clear_bit (NFS4CLNT_CHECK_LEASE , & clp -> cl_state );
1675+ clear_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state );
1676+ return 0 ;
1677+ }
1678+
1679+ static int nfs4_purge_lease (struct nfs_client * clp )
1680+ {
1681+ int status ;
1682+
1683+ status = nfs4_establish_lease (clp );
1684+ if (status < 0 )
16581685 return nfs4_handle_reclaim_lease_error (clp , status );
1686+ clear_bit (NFS4CLNT_PURGE_STATE , & clp -> cl_state );
1687+ set_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state );
1688+ nfs4_state_start_reclaim_nograce (clp );
16591689 return 0 ;
16601690}
16611691
@@ -1868,31 +1898,19 @@ static void nfs4_state_manager(struct nfs_client *clp)
18681898 do {
18691899 if (test_bit (NFS4CLNT_PURGE_STATE , & clp -> cl_state )) {
18701900 section = "purge state" ;
1871- status = nfs4_reclaim_lease (clp );
1901+ status = nfs4_purge_lease (clp );
18721902 if (status < 0 )
18731903 goto out_error ;
1874- clear_bit (NFS4CLNT_PURGE_STATE , & clp -> cl_state );
1875- set_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state );
1904+ continue ;
18761905 }
18771906
1878- if (test_and_clear_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state )) {
1907+ if (test_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state )) {
18791908 section = "lease expired" ;
18801909 /* We're going to have to re-establish a clientid */
18811910 status = nfs4_reclaim_lease (clp );
18821911 if (status < 0 )
18831912 goto out_error ;
1884- if (test_bit (NFS4CLNT_LEASE_EXPIRED , & clp -> cl_state ))
1885- continue ;
1886- clear_bit (NFS4CLNT_CHECK_LEASE , & clp -> cl_state );
1887-
1888- if (test_and_clear_bit (NFS4CLNT_SERVER_SCOPE_MISMATCH ,
1889- & clp -> cl_state ))
1890- nfs4_state_start_reclaim_nograce (clp );
1891- else
1892- set_bit (NFS4CLNT_RECLAIM_REBOOT ,
1893- & clp -> cl_state );
1894-
1895- pnfs_destroy_all_layouts (clp );
1913+ continue ;
18961914 }
18971915
18981916 if (test_and_clear_bit (NFS4CLNT_CHECK_LEASE , & clp -> cl_state )) {
0 commit comments