Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267180
b: refs/heads/master
c: 6409a5a
h: refs/heads/master
v: v3
  • Loading branch information
J. Bruce Fields committed Oct 10, 2011
1 parent 3d4d3e7 commit 33bcc46
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 71c3bcd71393a9e67d5b77597a612537f89c30ed
refs/heads/master: 6409a5a65d2b959c3f5e2b8adfa67c349e294652
31 changes: 22 additions & 9 deletions trunk/fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -3523,16 +3523,29 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
return status;
}

static inline void nfs4_file_downgrade(struct nfs4_ol_stateid *stp, unsigned int to_access)
static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access)
{
int i;
if (!test_bit(access, &stp->st_access_bmap))
return;
nfs4_file_put_access(stp->st_file, nfs4_access_to_omode(access));
__clear_bit(access, &stp->st_access_bmap);
}

for (i = 1; i < 4; i++) {
if (test_bit(i, &stp->st_access_bmap)
&& ((i & to_access) != i)) {
nfs4_file_put_access(stp->st_file, nfs4_access_to_omode(i));
__clear_bit(i, &stp->st_access_bmap);
}
static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access)
{
switch (to_access) {
case NFS4_SHARE_ACCESS_READ:
nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE);
nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
break;
case NFS4_SHARE_ACCESS_WRITE:
nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ);
nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
break;
case NFS4_SHARE_ACCESS_BOTH:
break;
default:
BUG();
}
}

Expand Down Expand Up @@ -3578,7 +3591,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
stp->st_deny_bmap, od->od_share_deny);
goto out;
}
nfs4_file_downgrade(stp, od->od_share_access);
nfs4_stateid_downgrade(stp, od->od_share_access);

reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap);

Expand Down
8 changes: 5 additions & 3 deletions trunk/fs/nfsd/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,11 @@ struct nfs4_file {
/* One each for O_RDONLY, O_WRONLY, O_RDWR: */
struct file * fi_fds[3];
/*
* Each open or lock stateid contributes 1 to either
* fi_access[O_RDONLY], fi_access[O_WRONLY], or both, depending
* on open or lock mode:
* Each open or lock stateid contributes 0-4 to the counts
* below depending on which bits are set in st_access_bitmap:
* 1 to fi_access[O_RDONLY] if NFS4_SHARE_ACCES_READ is set
* + 1 to fi_access[O_WRONLY] if NFS4_SHARE_ACCESS_WRITE is set
* + 1 to both of the above if NFS4_SHARE_ACCESS_BOTH is set.
*/
atomic_t fi_access[2];
struct file *fi_deleg_file;
Expand Down

0 comments on commit 33bcc46

Please sign in to comment.