diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-01-31 10:39:30 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-02-06 18:47:58 -0500 |
commit | b01dd1d8fae6178cbec374b90da2e4a3b8dce9ba (patch) | |
tree | 64627fdd095c4659ebf02d4c9891fd172ecc5d04 | |
parent | 1cab0652ba985d11b67645bd344c39ebb6cd28a2 (diff) |
NFS: Call test_stateid() and free_stateid() with correct stateids
I noticed that test_stateid() was always using the same stateid for open
and lock recovery. After poking around a bit, I discovered that it was
always testing with a delegation stateid (even if there was no
delegation present). I figured this wasn't correct, so now delegation
and open stateids are tested during open_expired() and lock stateids are
tested during lock_expired().
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/nfs4proc.c | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8491d775e23c..aaaf98ba8956 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -1723,15 +1723,32 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *sta | |||
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | #if defined(CONFIG_NFS_V4_1) | 1725 | #if defined(CONFIG_NFS_V4_1) |
1726 | static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) | 1726 | static int nfs41_check_expired_stateid(struct nfs4_state *state, nfs4_stateid *stateid, unsigned int flags) |
1727 | { | 1727 | { |
1728 | int status; | 1728 | int status = NFS_OK; |
1729 | struct nfs_server *server = NFS_SERVER(state->inode); | 1729 | struct nfs_server *server = NFS_SERVER(state->inode); |
1730 | 1730 | ||
1731 | status = nfs41_test_stateid(server, &state->stateid); | 1731 | if (state->flags & flags) { |
1732 | if (status == NFS_OK) | 1732 | status = nfs41_test_stateid(server, stateid); |
1733 | return 0; | 1733 | if (status != NFS_OK) { |
1734 | nfs41_free_stateid(server, &state->stateid); | 1734 | nfs41_free_stateid(server, stateid); |
1735 | state->flags &= ~flags; | ||
1736 | } | ||
1737 | } | ||
1738 | return status; | ||
1739 | } | ||
1740 | |||
1741 | static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) | ||
1742 | { | ||
1743 | int deleg_status, open_status; | ||
1744 | int deleg_flags = 1 << NFS_DELEGATED_STATE; | ||
1745 | int open_flags = (1 << NFS_O_RDONLY_STATE) | (1 << NFS_O_WRONLY_STATE) | (1 << NFS_O_RDWR_STATE); | ||
1746 | |||
1747 | deleg_status = nfs41_check_expired_stateid(state, &state->stateid, deleg_flags); | ||
1748 | open_status = nfs41_check_expired_stateid(state, &state->open_stateid, open_flags); | ||
1749 | |||
1750 | if ((deleg_status == NFS_OK) && (open_status == NFS_OK)) | ||
1751 | return NFS_OK; | ||
1735 | return nfs4_open_expired(sp, state); | 1752 | return nfs4_open_expired(sp, state); |
1736 | } | 1753 | } |
1737 | #endif | 1754 | #endif |
@@ -4504,15 +4521,34 @@ out: | |||
4504 | } | 4521 | } |
4505 | 4522 | ||
4506 | #if defined(CONFIG_NFS_V4_1) | 4523 | #if defined(CONFIG_NFS_V4_1) |
4507 | static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) | 4524 | static int nfs41_check_expired_locks(struct nfs4_state *state) |
4508 | { | 4525 | { |
4509 | int status; | 4526 | int status, ret = NFS_OK; |
4527 | struct nfs4_lock_state *lsp; | ||
4510 | struct nfs_server *server = NFS_SERVER(state->inode); | 4528 | struct nfs_server *server = NFS_SERVER(state->inode); |
4511 | 4529 | ||
4512 | status = nfs41_test_stateid(server, &state->stateid); | 4530 | list_for_each_entry(lsp, &state->lock_states, ls_locks) { |
4531 | if (lsp->ls_flags & NFS_LOCK_INITIALIZED) { | ||
4532 | status = nfs41_test_stateid(server, &lsp->ls_stateid); | ||
4533 | if (status != NFS_OK) { | ||
4534 | nfs41_free_stateid(server, &lsp->ls_stateid); | ||
4535 | lsp->ls_flags &= ~NFS_LOCK_INITIALIZED; | ||
4536 | ret = status; | ||
4537 | } | ||
4538 | } | ||
4539 | }; | ||
4540 | |||
4541 | return ret; | ||
4542 | } | ||
4543 | |||
4544 | static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) | ||
4545 | { | ||
4546 | int status = NFS_OK; | ||
4547 | |||
4548 | if (test_bit(LK_STATE_IN_USE, &state->flags)) | ||
4549 | status = nfs41_check_expired_locks(state); | ||
4513 | if (status == NFS_OK) | 4550 | if (status == NFS_OK) |
4514 | return 0; | 4551 | return status; |
4515 | nfs41_free_stateid(server, &state->stateid); | ||
4516 | return nfs4_lock_expired(state, request); | 4552 | return nfs4_lock_expired(state, request); |
4517 | } | 4553 | } |
4518 | #endif | 4554 | #endif |