diff options
author | Neil Brown <neilb@cse.unsw.edu.au> | 2005-03-30 16:59:29 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-03-30 16:59:29 -0800 |
commit | 9e06799ec1c744c19f423496ec5afb8ad15968d0 (patch) | |
tree | 58600a5a2584dbdf7df81b842480b951ff378eab | |
parent | 3a090f986f1e998a3645dd7f5fd9b7371e439888 (diff) | |
download | history-9e06799ec1c744c19f423496ec5afb8ad15968d0.tar.gz |
[PATCH] nfsd4: fix failure to truncate on some opens
An OPEN upgrade on a file already open for WRITE will not upgrade the OPEN,
but can still truncate the file.
Signed-off-by: Andy Adamson <andros@citi.umich.edu>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/nfsd/nfs4state.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index ce424c54ddb65a..6d2923b8126e74 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1602,21 +1602,22 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta share_access = ~share_access; share_access &= open->op_share_access; - /* update the struct file */ - if (share_access & NFS4_SHARE_ACCESS_WRITE) { - status = get_write_access(inode); - if (status) - return nfserrno(status); - status = nfsd4_truncate(rqstp, cur_fh, open); - if (status) { - put_write_access(inode); - return status; - } - /* remember the open */ - filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ; - set_bit(open->op_share_access, &stp->st_access_bmap); - set_bit(open->op_share_deny, &stp->st_deny_bmap); + if (!(share_access & NFS4_SHARE_ACCESS_WRITE)) + return nfsd4_truncate(rqstp, cur_fh, open); + + status = get_write_access(inode); + if (status) + return nfserrno(status); + status = nfsd4_truncate(rqstp, cur_fh, open); + if (status) { + put_write_access(inode); + return status; } + /* remember the open */ + filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ; + set_bit(open->op_share_access, &stp->st_access_bmap); + set_bit(open->op_share_deny, &stp->st_deny_bmap); + return nfs_ok; } |