Commit 6c26d08f authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Linus Torvalds

[PATCH] nfsd4: fix open_downgrade

Bad bookkeeping of the share reservations when handling open upgrades was
causing open downgrade to fail.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fb553c0f
...@@ -1609,26 +1609,26 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta ...@@ -1609,26 +1609,26 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta
{ {
struct file *filp = stp->st_vfs_file; struct file *filp = stp->st_vfs_file;
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
unsigned int share_access; unsigned int share_access, new_writer;
int status; int status;
set_access(&share_access, stp->st_access_bmap); set_access(&share_access, stp->st_access_bmap);
share_access = ~share_access; new_writer = (~share_access) & open->op_share_access
share_access &= open->op_share_access; & NFS4_SHARE_ACCESS_WRITE;
if (!(share_access & NFS4_SHARE_ACCESS_WRITE))
return nfsd4_truncate(rqstp, cur_fh, open);
status = get_write_access(inode); if (new_writer) {
if (status) status = get_write_access(inode);
return nfserrno(status); if (status)
return nfserrno(status);
}
status = nfsd4_truncate(rqstp, cur_fh, open); status = nfsd4_truncate(rqstp, cur_fh, open);
if (status) { if (status) {
put_write_access(inode); if (new_writer)
put_write_access(inode);
return status; return status;
} }
/* remember the open */ /* remember the open */
filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ; filp->f_mode |= open->op_share_access;
set_bit(open->op_share_access, &stp->st_access_bmap); set_bit(open->op_share_access, &stp->st_access_bmap);
set_bit(open->op_share_deny, &stp->st_deny_bmap); set_bit(open->op_share_deny, &stp->st_deny_bmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment