@@ -4940,31 +4940,6 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp,
49404940 return fl ;
49414941}
49424942
4943- static int nfsd4_check_conflicting_opens (struct nfs4_client * clp ,
4944- struct nfs4_file * fp )
4945- {
4946- struct nfs4_clnt_odstate * co ;
4947- struct file * f = fp -> fi_deleg_file -> nf_file ;
4948- struct inode * ino = locks_inode (f );
4949- int writes = atomic_read (& ino -> i_writecount );
4950-
4951- if (fp -> fi_fds [O_WRONLY ])
4952- writes -- ;
4953- if (fp -> fi_fds [O_RDWR ])
4954- writes -- ;
4955- if (writes > 0 )
4956- return - EAGAIN ;
4957- spin_lock (& fp -> fi_lock );
4958- list_for_each_entry (co , & fp -> fi_clnt_odstate , co_perfile ) {
4959- if (co -> co_client != clp ) {
4960- spin_unlock (& fp -> fi_lock );
4961- return - EAGAIN ;
4962- }
4963- }
4964- spin_unlock (& fp -> fi_lock );
4965- return 0 ;
4966- }
4967-
49684943static struct nfs4_delegation *
49694944nfs4_set_delegation (struct nfs4_client * clp , struct svc_fh * fh ,
49704945 struct nfs4_file * fp , struct nfs4_clnt_odstate * odstate )
@@ -4984,12 +4959,9 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
49844959
49854960 nf = find_readable_file (fp );
49864961 if (!nf ) {
4987- /*
4988- * We probably could attempt another open and get a read
4989- * delegation, but for now, don't bother until the
4990- * client actually sends us one.
4991- */
4992- return ERR_PTR (- EAGAIN );
4962+ /* We should always have a readable file here */
4963+ WARN_ON_ONCE (1 );
4964+ return ERR_PTR (- EBADF );
49934965 }
49944966 spin_lock (& state_lock );
49954967 spin_lock (& fp -> fi_lock );
@@ -5019,19 +4991,11 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
50194991 if (!fl )
50204992 goto out_clnt_odstate ;
50214993
5022- status = nfsd4_check_conflicting_opens (clp , fp );
5023- if (status ) {
5024- locks_free_lock (fl );
5025- goto out_clnt_odstate ;
5026- }
50274994 status = vfs_setlease (fp -> fi_deleg_file -> nf_file , fl -> fl_type , & fl , NULL );
50284995 if (fl )
50294996 locks_free_lock (fl );
50304997 if (status )
50314998 goto out_clnt_odstate ;
5032- status = nfsd4_check_conflicting_opens (clp , fp );
5033- if (status )
5034- goto out_clnt_odstate ;
50354999
50365000 spin_lock (& state_lock );
50375001 spin_lock (& fp -> fi_lock );
@@ -5113,6 +5077,17 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open,
51135077 goto out_no_deleg ;
51145078 if (!cb_up || !(oo -> oo_flags & NFS4_OO_CONFIRMED ))
51155079 goto out_no_deleg ;
5080+ /*
5081+ * Also, if the file was opened for write or
5082+ * create, there's a good chance the client's
5083+ * about to write to it, resulting in an
5084+ * immediate recall (since we don't support
5085+ * write delegations):
5086+ */
5087+ if (open -> op_share_access & NFS4_SHARE_ACCESS_WRITE )
5088+ goto out_no_deleg ;
5089+ if (open -> op_create == NFS4_OPEN_CREATE )
5090+ goto out_no_deleg ;
51165091 break ;
51175092 default :
51185093 goto out_no_deleg ;
@@ -5389,7 +5364,7 @@ nfs4_laundromat(struct nfsd_net *nn)
53895364 idr_for_each_entry (& nn -> s2s_cp_stateids , cps_t , i ) {
53905365 cps = container_of (cps_t , struct nfs4_cpntf_state , cp_stateid );
53915366 if (cps -> cp_stateid .sc_type == NFS4_COPYNOTIFY_STID &&
5392- cps -> cpntf_time > cutoff )
5367+ cps -> cpntf_time < cutoff )
53935368 _free_cpntf_state_locked (nn , cps );
53945369 }
53955370 spin_unlock (& nn -> s2s_cp_lock );
0 commit comments