@@ -2951,6 +2951,21 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)
29512951 return 0 ;
29522952}
29532953
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+
29542969static int nfs4_show_deleg (struct seq_file * s , struct nfs4_stid * st )
29552970{
29562971 struct nfs4_delegation * ds ;
@@ -2964,8 +2979,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)
29642979 nfs4_show_stateid (s , & st -> sc_stateid );
29652980 seq_puts (s , ": { type: deleg, " );
29662981
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 ));
29692983
29702984 /* XXX: lease time, whether it's being recalled. */
29712985
@@ -5581,7 +5595,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
55815595static inline __be32
55825596nfs4_check_delegmode (struct nfs4_delegation * dp , int flags )
55835597{
5584- if ((flags & WR_STATE ) && (dp -> dl_type == OPEN_DELEGATE_READ ))
5598+ if ((flags & WR_STATE ) && deleg_is_read (dp -> dl_type ))
55855599 return nfserr_openmode ;
55865600 else
55875601 return nfs_ok ;
@@ -5813,8 +5827,7 @@ static bool nfsd4_cb_channel_good(struct nfs4_client *clp)
58135827 return clp -> cl_minorversion && clp -> cl_cb_state == NFSD4_CB_UNKNOWN ;
58145828}
58155829
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 )
58185831{
58195832 struct file_lease * fl ;
58205833
@@ -5823,7 +5836,7 @@ static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp,
58235836 return NULL ;
58245837 fl -> fl_lmops = & nfsd_lease_mng_ops ;
58255838 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 ;
58275840 fl -> c .flc_owner = (fl_owner_t )dp ;
58285841 fl -> c .flc_pid = current -> tgid ;
58295842 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,
60106023 if (!dp )
60116024 goto out_delegees ;
60126025
6013- fl = nfs4_alloc_init_lease (dp , dl_type );
6026+ fl = nfs4_alloc_init_lease (dp );
60146027 if (!fl )
60156028 goto out_clnt_odstate ;
60166029
@@ -6210,14 +6223,14 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
62106223static void nfsd4_deleg_xgrade_none_ext (struct nfsd4_open * open ,
62116224 struct nfs4_delegation * dp )
62126225{
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+ }
62216234 }
62226235 /* Otherwise the client must be confused wanting a delegation
62236236 * it already has, therefore we don't return
0 commit comments