diff options
-rw-r--r-- | fs/nfsd/nfs4state.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3791c9d84dad..8ac0c9abe941 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1547,22 +1547,28 @@ find_delegation_file(struct nfs4_file *fp, stateid_t *stid) | |||
1547 | return NULL; | 1547 | return NULL; |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | static void | 1550 | static int |
1551 | nfs4_check_deleg(struct nfs4_file *fp, struct nfsd4_open *open, | 1551 | nfs4_check_deleg(struct nfs4_file *fp, struct nfsd4_open *open, |
1552 | struct nfs4_delegation **dp) | 1552 | struct nfs4_delegation **dp) |
1553 | { | 1553 | { |
1554 | int flags; | 1554 | int flags; |
1555 | int status; | 1555 | int status = nfserr_bad_stateid; |
1556 | 1556 | ||
1557 | *dp = find_delegation_file(fp, &open->op_delegate_stateid); | 1557 | *dp = find_delegation_file(fp, &open->op_delegate_stateid); |
1558 | if (*dp == NULL) | 1558 | if (*dp == NULL) |
1559 | return; | 1559 | goto out; |
1560 | flags = open->op_share_access == NFS4_SHARE_ACCESS_READ ? | 1560 | flags = open->op_share_access == NFS4_SHARE_ACCESS_READ ? |
1561 | RD_STATE : WR_STATE; | 1561 | RD_STATE : WR_STATE; |
1562 | status = nfs4_check_delegmode(*dp, flags); | 1562 | status = nfs4_check_delegmode(*dp, flags); |
1563 | if (status) | 1563 | if (status) |
1564 | *dp = NULL; | 1564 | *dp = NULL; |
1565 | return; | 1565 | out: |
1566 | if (open->op_claim_type != NFS4_OPEN_CLAIM_DELEGATE_CUR) | ||
1567 | return nfs_ok; | ||
1568 | if (status) | ||
1569 | return status; | ||
1570 | open->op_stateowner->so_confirmed = 1; | ||
1571 | return nfs_ok; | ||
1566 | } | 1572 | } |
1567 | 1573 | ||
1568 | static int | 1574 | static int |
@@ -1760,8 +1766,13 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
1760 | if (fp) { | 1766 | if (fp) { |
1761 | if ((status = nfs4_check_open(fp, open, &stp))) | 1767 | if ((status = nfs4_check_open(fp, open, &stp))) |
1762 | goto out; | 1768 | goto out; |
1763 | nfs4_check_deleg(fp, open, &dp); | 1769 | status = nfs4_check_deleg(fp, open, &dp); |
1770 | if (status) | ||
1771 | goto out; | ||
1764 | } else { | 1772 | } else { |
1773 | status = nfserr_bad_stateid; | ||
1774 | if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) | ||
1775 | goto out; | ||
1765 | status = nfserr_resource; | 1776 | status = nfserr_resource; |
1766 | fp = alloc_init_file(ino); | 1777 | fp = alloc_init_file(ino); |
1767 | if (fp == NULL) | 1778 | if (fp == NULL) |