]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/nfs4state.c
NFSv4: Add recovery for individual stateids
[linux-2.6-omap-h63xx.git] / fs / nfs / nfs4state.c
index beade5570b5690403fc8b8ccef84135a76abd014..3d78706b3efb55575a6f1957846087a1e73f532e 100644 (file)
@@ -305,10 +305,6 @@ nfs4_drop_state_owner(struct nfs4_state_owner *sp)
        }
 }
 
-/*
- * Note: must be called with clp->cl_sem held in order to prevent races
- *       with reboot recovery!
- */
 struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct rpc_cred *cred)
 {
        struct nfs_client *clp = server->nfs_client;
@@ -337,10 +333,6 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct
        return sp;
 }
 
-/*
- * Must be called with clp->cl_sem held in order to avoid races
- * with state recovery...
- */
 void nfs4_put_state_owner(struct nfs4_state_owner *sp)
 {
        struct nfs_client *clp = sp->so_client;
@@ -442,10 +434,6 @@ out:
        return state;
 }
 
-/*
- * Beware! Caller must be holding exactly one
- * reference to clp->cl_sem!
- */
 void nfs4_put_open_state(struct nfs4_state *state)
 {
        struct inode *inode = state->inode;
@@ -578,7 +566,6 @@ static void nfs4_free_lock_state(struct nfs4_lock_state *lsp)
  * Return a compatible lock_state. If no initialized lock_state structure
  * exists, return an uninitialized one.
  *
- * The caller must be holding clp->cl_sem
  */
 static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner)
 {
@@ -837,7 +824,7 @@ static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_st
        return 1;
 }
 
-static int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state)
+int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state)
 {
        set_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags);
        clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
@@ -849,9 +836,11 @@ static int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_s
 static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
 {
        struct inode *inode = state->inode;
+       struct nfs_inode *nfsi = NFS_I(inode);
        struct file_lock *fl;
        int status = 0;
 
+       down_write(&nfsi->rwsem);
        for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
                if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
                        continue;
@@ -874,8 +863,10 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
                                goto out_err;
                }
        }
+       up_write(&nfsi->rwsem);
        return 0;
 out_err:
+       up_write(&nfsi->rwsem);
        return status;
 }
 
@@ -1123,7 +1114,6 @@ static int reclaimer(void *ptr)
        allow_signal(SIGKILL);
 
        /* Ensure exclusive access to NFSv4 state */
-       down_write(&clp->cl_sem);
        while (!list_empty(&clp->cl_superblocks)) {
                if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
                        /* We're going to have to re-establish a clientid */
@@ -1145,7 +1135,6 @@ static int reclaimer(void *ptr)
 
                /* First recover reboot state... */
                if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) {
-                       /* Note: list is protected by exclusive lock on cl->cl_sem */
                        status = nfs4_do_reclaim(clp, &nfs4_reboot_recovery_ops);
                        if (status == -NFS4ERR_STALE_CLIENTID)
                                continue;
@@ -1155,7 +1144,6 @@ static int reclaimer(void *ptr)
 
                /* Now recover expired state... */
                if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
-                       /* Note: list is protected by exclusive lock on cl->cl_sem */
                        status = nfs4_do_reclaim(clp, &nfs4_nograce_recovery_ops);
                        if (status < 0) {
                                set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state);
@@ -1171,7 +1159,6 @@ static int reclaimer(void *ptr)
                break;
        }
 out:
-       up_write(&clp->cl_sem);
        if (test_and_clear_bit(NFS4CLNT_CB_PATH_DOWN, &clp->cl_state))
                nfs_handle_cb_pathdown(clp);
        nfs4_clear_recover_bit(clp);