aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-05-11 09:45:14 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-05-31 20:29:48 -0400
commitce0fc43c5a09d50ff5ffe208cbb0d3a9c82f038a (patch)
treece9842a9df9b30da17e35df89c6be0fbba8fdd7e /fs/nfsd
parent82c5ff1b1409f43ccb282cbdfcb06991714e4c5f (diff)
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: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 83066abc66bb..c474161fd4b6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -492,6 +492,27 @@ test_access(u32 access, struct nfs4_ol_stateid *stp)
492 return test_bit(access, &stp->st_access_bmap); 492 return test_bit(access, &stp->st_access_bmap);
493} 493}
494 494
495/* set share deny for a given stateid */
496static inline void
497set_deny(u32 access, struct nfs4_ol_stateid *stp)
498{
499 __set_bit(access, &stp->st_deny_bmap);
500}
501
502/* clear share deny for a given stateid */
503static inline void
504clear_deny(u32 access, struct nfs4_ol_stateid *stp)
505{
506 __clear_bit(access, &stp->st_deny_bmap);
507}
508
509/* test whether a given stateid is denying specific access */
510static inline bool
511test_deny(u32 access, struct nfs4_ol_stateid *stp)
512{
513 return test_bit(access, &stp->st_deny_bmap);
514}
515
495static int nfs4_access_to_omode(u32 access) 516static int nfs4_access_to_omode(u32 access)
496{ 517{
497 switch (access & NFS4_SHARE_ACCESS_BOTH) { 518 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 stp->st_access_bmap = 0; 2483 stp->st_access_bmap = 0;
2463 stp->st_deny_bmap = 0; 2484 stp->st_deny_bmap = 0;
2464 set_access(open->op_share_access, stp); 2485 set_access(open->op_share_access, stp);
2465 __set_bit(open->op_share_deny, &stp->st_deny_bmap); 2486 set_deny(open->op_share_deny, stp);
2466 stp->st_openstp = NULL; 2487 stp->st_openstp = NULL;
2467} 2488}
2468 2489
@@ -2541,8 +2562,8 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
2541 ret = nfserr_locked; 2562 ret = nfserr_locked;
2542 /* Search for conflicting share reservations */ 2563 /* Search for conflicting share reservations */
2543 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) { 2564 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) {
2544 if (test_bit(deny_type, &stp->st_deny_bmap) || 2565 if (test_deny(deny_type, stp) ||
2545 test_bit(NFS4_SHARE_DENY_BOTH, &stp->st_deny_bmap)) 2566 test_deny(NFS4_SHARE_DENY_BOTH, stp))
2546 goto out; 2567 goto out;
2547 } 2568 }
2548 ret = nfs_ok; 2569 ret = nfs_ok;
@@ -2814,7 +2835,7 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *c
2814 } 2835 }
2815 /* remember the open */ 2836 /* remember the open */
2816 set_access(op_share_access, stp); 2837 set_access(op_share_access, stp);
2817 __set_bit(open->op_share_deny, &stp->st_deny_bmap); 2838 set_deny(open->op_share_deny, stp);
2818 2839
2819 return nfs_ok; 2840 return nfs_ok;
2820} 2841}
@@ -3687,12 +3708,12 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac
3687} 3708}
3688 3709
3689static void 3710static void
3690reset_union_bmap_deny(unsigned long deny, unsigned long *bmap) 3711reset_union_bmap_deny(unsigned long deny, struct nfs4_ol_stateid *stp)
3691{ 3712{
3692 int i; 3713 int i;
3693 for (i = 0; i < 4; i++) { 3714 for (i = 0; i < 4; i++) {
3694 if ((i & deny) != i) 3715 if ((i & deny) != i)
3695 __clear_bit(i, bmap); 3716 clear_deny(i, stp);
3696 } 3717 }
3697} 3718}
3698 3719
@@ -3724,14 +3745,14 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
3724 stp->st_access_bmap, od->od_share_access); 3745 stp->st_access_bmap, od->od_share_access);
3725 goto out; 3746 goto out;
3726 } 3747 }
3727 if (!test_bit(od->od_share_deny, &stp->st_deny_bmap)) { 3748 if (!test_deny(od->od_share_deny, stp)) {
3728 dprintk("NFSD:deny not a subset current bitmap: 0x%lx, input deny=%08x\n", 3749 dprintk("NFSD:deny not a subset current bitmap: 0x%lx, input deny=%08x\n",
3729 stp->st_deny_bmap, od->od_share_deny); 3750 stp->st_deny_bmap, od->od_share_deny);
3730 goto out; 3751 goto out;
3731 } 3752 }
3732 nfs4_stateid_downgrade(stp, od->od_share_access); 3753 nfs4_stateid_downgrade(stp, od->od_share_access);
3733 3754
3734 reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap); 3755 reset_union_bmap_deny(od->od_share_deny, stp);
3735 3756
3736 update_stateid(&stp->st_stid.sc_stateid); 3757 update_stateid(&stp->st_stid.sc_stateid);
3737 memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); 3758 memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));