Commit ce0fc43c authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd: wrap all accesses to st_deny_bmap

Handle the st_deny_bmap in a similar fashion to the st_access_bmap. Add
accessor functions and use those instead of bare bitops.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 82c5ff1b
...@@ -492,6 +492,27 @@ test_access(u32 access, struct nfs4_ol_stateid *stp) ...@@ -492,6 +492,27 @@ test_access(u32 access, struct nfs4_ol_stateid *stp)
return test_bit(access, &stp->st_access_bmap); return test_bit(access, &stp->st_access_bmap);
} }
/* set share deny for a given stateid */
static inline void
set_deny(u32 access, struct nfs4_ol_stateid *stp)
{
__set_bit(access, &stp->st_deny_bmap);
}
/* clear share deny for a given stateid */
static inline void
clear_deny(u32 access, struct nfs4_ol_stateid *stp)
{
__clear_bit(access, &stp->st_deny_bmap);
}
/* test whether a given stateid is denying specific access */
static inline bool
test_deny(u32 access, struct nfs4_ol_stateid *stp)
{
return test_bit(access, &stp->st_deny_bmap);
}
static int nfs4_access_to_omode(u32 access) static int nfs4_access_to_omode(u32 access)
{ {
switch (access & NFS4_SHARE_ACCESS_BOTH) { switch (access & NFS4_SHARE_ACCESS_BOTH) {
...@@ -2462,7 +2483,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, ...@@ -2462,7 +2483,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
stp->st_access_bmap = 0; stp->st_access_bmap = 0;
stp->st_deny_bmap = 0; stp->st_deny_bmap = 0;
set_access(open->op_share_access, stp); set_access(open->op_share_access, stp);
__set_bit(open->op_share_deny, &stp->st_deny_bmap); set_deny(open->op_share_deny, stp);
stp->st_openstp = NULL; stp->st_openstp = NULL;
} }
...@@ -2541,8 +2562,8 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type) ...@@ -2541,8 +2562,8 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
ret = nfserr_locked; ret = nfserr_locked;
/* Search for conflicting share reservations */ /* Search for conflicting share reservations */
list_for_each_entry(stp, &fp->fi_stateids, st_perfile) { list_for_each_entry(stp, &fp->fi_stateids, st_perfile) {
if (test_bit(deny_type, &stp->st_deny_bmap) || if (test_deny(deny_type, stp) ||
test_bit(NFS4_SHARE_DENY_BOTH, &stp->st_deny_bmap)) test_deny(NFS4_SHARE_DENY_BOTH, stp))
goto out; goto out;
} }
ret = nfs_ok; ret = nfs_ok;
...@@ -2814,7 +2835,7 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *c ...@@ -2814,7 +2835,7 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *c
} }
/* remember the open */ /* remember the open */
set_access(op_share_access, stp); set_access(op_share_access, stp);
__set_bit(open->op_share_deny, &stp->st_deny_bmap); set_deny(open->op_share_deny, stp);
return nfs_ok; return nfs_ok;
} }
...@@ -3687,12 +3708,12 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac ...@@ -3687,12 +3708,12 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac
} }
static void static void
reset_union_bmap_deny(unsigned long deny, unsigned long *bmap) reset_union_bmap_deny(unsigned long deny, struct nfs4_ol_stateid *stp)
{ {
int i; int i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if ((i & deny) != i) if ((i & deny) != i)
__clear_bit(i, bmap); clear_deny(i, stp);
} }
} }
...@@ -3724,14 +3745,14 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, ...@@ -3724,14 +3745,14 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
stp->st_access_bmap, od->od_share_access); stp->st_access_bmap, od->od_share_access);
goto out; goto out;
} }
if (!test_bit(od->od_share_deny, &stp->st_deny_bmap)) { if (!test_deny(od->od_share_deny, stp)) {
dprintk("NFSD:deny not a subset current bitmap: 0x%lx, input deny=%08x\n", dprintk("NFSD:deny not a subset current bitmap: 0x%lx, input deny=%08x\n",
stp->st_deny_bmap, od->od_share_deny); stp->st_deny_bmap, od->od_share_deny);
goto out; goto out;
} }
nfs4_stateid_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); reset_union_bmap_deny(od->od_share_deny, stp);
update_stateid(&stp->st_stid.sc_stateid); update_stateid(&stp->st_stid.sc_stateid);
memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
......
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