@@ -2951,6 +2951,21 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)
2951
2951
return 0 ;
2952
2952
}
2953
2953
2954
+ static char * nfs4_show_deleg_type (u32 dl_type )
2955
+ {
2956
+ switch (dl_type ) {
2957
+ case OPEN_DELEGATE_READ :
2958
+ return "r" ;
2959
+ case OPEN_DELEGATE_WRITE :
2960
+ return "w" ;
2961
+ case OPEN_DELEGATE_READ_ATTRS_DELEG :
2962
+ return "ra" ;
2963
+ case OPEN_DELEGATE_WRITE_ATTRS_DELEG :
2964
+ return "wa" ;
2965
+ }
2966
+ return "?" ;
2967
+ }
2968
+
2954
2969
static int nfs4_show_deleg (struct seq_file * s , struct nfs4_stid * st )
2955
2970
{
2956
2971
struct nfs4_delegation * ds ;
@@ -2964,8 +2979,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
2964
2979
nfs4_show_stateid (s , & st -> sc_stateid );
2965
2980
seq_puts (s , ": { type: deleg, " );
2966
2981
2967
- seq_printf (s , "access: %s" ,
2968
- ds -> dl_type == OPEN_DELEGATE_READ ? "r" : "w" );
2982
+ seq_printf (s , "access: %s" , nfs4_show_deleg_type (ds -> dl_type ));
2969
2983
2970
2984
/* XXX: lease time, whether it's being recalled. */
2971
2985
@@ -5581,7 +5595,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
5581
5595
static inline __be32
5582
5596
nfs4_check_delegmode (struct nfs4_delegation * dp , int flags )
5583
5597
{
5584
- if ((flags & WR_STATE ) && (dp -> dl_type == OPEN_DELEGATE_READ ))
5598
+ if ((flags & WR_STATE ) && deleg_is_read (dp -> dl_type ))
5585
5599
return nfserr_openmode ;
5586
5600
else
5587
5601
return nfs_ok ;
@@ -5813,8 +5827,7 @@ static bool nfsd4_cb_channel_good(struct nfs4_client *clp)
5813
5827
return clp -> cl_minorversion && clp -> cl_cb_state == NFSD4_CB_UNKNOWN ;
5814
5828
}
5815
5829
5816
- static struct file_lease * nfs4_alloc_init_lease (struct nfs4_delegation * dp ,
5817
- int flag )
5830
+ static struct file_lease * nfs4_alloc_init_lease (struct nfs4_delegation * dp )
5818
5831
{
5819
5832
struct file_lease * fl ;
5820
5833
@@ -5823,7 +5836,7 @@ static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp,
5823
5836
return NULL ;
5824
5837
fl -> fl_lmops = & nfsd_lease_mng_ops ;
5825
5838
fl -> c .flc_flags = FL_DELEG ;
5826
- fl -> c .flc_type = flag == OPEN_DELEGATE_READ ? F_RDLCK : F_WRLCK ;
5839
+ fl -> c .flc_type = deleg_is_read ( dp -> dl_type ) ? F_RDLCK : F_WRLCK ;
5827
5840
fl -> c .flc_owner = (fl_owner_t )dp ;
5828
5841
fl -> c .flc_pid = current -> tgid ;
5829
5842
fl -> c .flc_file = dp -> dl_stid .sc_file -> fi_deleg_file -> nf_file ;
@@ -6010,7 +6023,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
6010
6023
if (!dp )
6011
6024
goto out_delegees ;
6012
6025
6013
- fl = nfs4_alloc_init_lease (dp , dl_type );
6026
+ fl = nfs4_alloc_init_lease (dp );
6014
6027
if (!fl )
6015
6028
goto out_clnt_odstate ;
6016
6029
@@ -6210,14 +6223,14 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
6210
6223
static void nfsd4_deleg_xgrade_none_ext (struct nfsd4_open * open ,
6211
6224
struct nfs4_delegation * dp )
6212
6225
{
6213
- if (open -> op_deleg_want == OPEN4_SHARE_ACCESS_WANT_READ_DELEG &&
6214
- dp -> dl_type == OPEN_DELEGATE_WRITE ) {
6215
- open -> op_delegate_type = OPEN_DELEGATE_NONE_EXT ;
6216
- open -> op_why_no_deleg = WND4_NOT_SUPP_DOWNGRADE ;
6217
- } else if (open -> op_deleg_want == OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG &&
6218
- dp -> dl_type == OPEN_DELEGATE_WRITE ) {
6219
- open -> op_delegate_type = OPEN_DELEGATE_NONE_EXT ;
6220
- open -> op_why_no_deleg = WND4_NOT_SUPP_UPGRADE ;
6226
+ if (deleg_is_write ( dp -> dl_type )) {
6227
+ if ( open -> op_deleg_want == OPEN4_SHARE_ACCESS_WANT_READ_DELEG ) {
6228
+ open -> op_delegate_type = OPEN_DELEGATE_NONE_EXT ;
6229
+ open -> op_why_no_deleg = WND4_NOT_SUPP_DOWNGRADE ;
6230
+ } else if (open -> op_deleg_want == OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG ) {
6231
+ open -> op_delegate_type = OPEN_DELEGATE_NONE_EXT ;
6232
+ open -> op_why_no_deleg = WND4_NOT_SUPP_UPGRADE ;
6233
+ }
6221
6234
}
6222
6235
/* Otherwise the client must be confused wanting a delegation
6223
6236
* it already has, therefore we don't return
0 commit comments