NFSv4: Print an error in the syslog when state is marked as irrecoverable
[linux-2.6-microblaze.git] / fs / nfs / nfs4state.c
index e2e3c4f..a71a61e 100644 (file)
@@ -87,6 +87,27 @@ const nfs4_stateid current_stateid = {
 
 static DEFINE_MUTEX(nfs_clid_init_mutex);
 
+static int nfs4_setup_state_renewal(struct nfs_client *clp)
+{
+       int status;
+       struct nfs_fsinfo fsinfo;
+       unsigned long now;
+
+       if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
+               nfs4_schedule_state_renewal(clp);
+               return 0;
+       }
+
+       now = jiffies;
+       status = nfs4_proc_get_lease_time(clp, &fsinfo);
+       if (status == 0) {
+               nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
+               nfs4_schedule_state_renewal(clp);
+       }
+
+       return status;
+}
+
 int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
 {
        struct nfs4_setclientid_res clid = {
@@ -114,7 +135,7 @@ do_confirm:
        if (status != 0)
                goto out;
        clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
-       nfs4_schedule_state_renewal(clp);
+       nfs4_setup_state_renewal(clp);
 out:
        return status;
 }
@@ -286,34 +307,13 @@ static int nfs4_begin_drain_session(struct nfs_client *clp)
 
 #if defined(CONFIG_NFS_V4_1)
 
-static int nfs41_setup_state_renewal(struct nfs_client *clp)
-{
-       int status;
-       struct nfs_fsinfo fsinfo;
-       unsigned long now;
-
-       if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
-               nfs4_schedule_state_renewal(clp);
-               return 0;
-       }
-
-       now = jiffies;
-       status = nfs4_proc_get_lease_time(clp, &fsinfo);
-       if (status == 0) {
-               nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now);
-               nfs4_schedule_state_renewal(clp);
-       }
-
-       return status;
-}
-
 static void nfs41_finish_session_reset(struct nfs_client *clp)
 {
        clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
        clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
        /* create_session negotiated new slot table */
        clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state);
-       nfs41_setup_state_renewal(clp);
+       nfs4_setup_state_renewal(clp);
 }
 
 int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred)
@@ -1064,8 +1064,7 @@ int nfs4_select_rw_stateid(struct nfs4_state *state,
                 * choose to use.
                 */
                goto out;
-       nfs4_copy_open_stateid(dst, state);
-       ret = 0;
+       ret = nfs4_copy_open_stateid(dst, state) ? 0 : -EAGAIN;
 out:
        if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41))
                dst->seqid = 0;
@@ -1464,7 +1463,7 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
                nfs4_schedule_state_manager(clp);
 }
 
-static void nfs4_state_mark_open_context_bad(struct nfs4_state *state)
+static void nfs4_state_mark_open_context_bad(struct nfs4_state *state, int err)
 {
        struct inode *inode = state->inode;
        struct nfs_inode *nfsi = NFS_I(inode);
@@ -1475,6 +1474,8 @@ static void nfs4_state_mark_open_context_bad(struct nfs4_state *state)
                if (ctx->state != state)
                        continue;
                set_bit(NFS_CONTEXT_BAD, &ctx->flags);
+               pr_warn("NFSv4: state recovery failed for open file %pd2, "
+                               "error = %d\n", ctx->dentry, err);
        }
        rcu_read_unlock();
 }
@@ -1482,7 +1483,7 @@ static void nfs4_state_mark_open_context_bad(struct nfs4_state *state)
 static void nfs4_state_mark_recovery_failed(struct nfs4_state *state, int error)
 {
        set_bit(NFS_STATE_RECOVERY_FAILED, &state->flags);
-       nfs4_state_mark_open_context_bad(state);
+       nfs4_state_mark_open_context_bad(state, error);
 }