@@ -153,20 +153,10 @@ nfs_page_set_inode_ref(struct nfs_page *req, struct inode *inode)
153153 }
154154}
155155
156- static int
157- nfs_cancel_remove_inode (struct nfs_page * req , struct inode * inode )
156+ static void nfs_cancel_remove_inode (struct nfs_page * req , struct inode * inode )
158157{
159- int ret ;
160-
161- if (!test_bit (PG_REMOVE , & req -> wb_flags ))
162- return 0 ;
163- ret = nfs_page_group_lock (req );
164- if (ret )
165- return ret ;
166158 if (test_and_clear_bit (PG_REMOVE , & req -> wb_flags ))
167159 nfs_page_set_inode_ref (req , inode );
168- nfs_page_group_unlock (req );
169- return 0 ;
170160}
171161
172162/**
@@ -585,19 +575,18 @@ static struct nfs_page *nfs_lock_and_join_requests(struct folio *folio)
585575 }
586576 }
587577
578+ ret = nfs_page_group_lock (head );
579+ if (ret < 0 )
580+ goto out_unlock ;
581+
588582 /* Ensure that nobody removed the request before we locked it */
589583 if (head != folio -> private ) {
584+ nfs_page_group_unlock (head );
590585 nfs_unlock_and_release_request (head );
591586 goto retry ;
592587 }
593588
594- ret = nfs_cancel_remove_inode (head , inode );
595- if (ret < 0 )
596- goto out_unlock ;
597-
598- ret = nfs_page_group_lock (head );
599- if (ret < 0 )
600- goto out_unlock ;
589+ nfs_cancel_remove_inode (head , inode );
601590
602591 /* lock each request in the page group */
603592 for (subreq = head -> wb_this_page ;
@@ -786,7 +775,8 @@ static void nfs_inode_remove_request(struct nfs_page *req)
786775{
787776 struct nfs_inode * nfsi = NFS_I (nfs_page_to_inode (req ));
788777
789- if (nfs_page_group_sync_on_bit (req , PG_REMOVE )) {
778+ nfs_page_group_lock (req );
779+ if (nfs_page_group_sync_on_bit_locked (req , PG_REMOVE )) {
790780 struct folio * folio = nfs_page_to_folio (req -> wb_head );
791781 struct address_space * mapping = folio -> mapping ;
792782
@@ -798,6 +788,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
798788 }
799789 spin_unlock (& mapping -> i_private_lock );
800790 }
791+ nfs_page_group_unlock (req );
801792
802793 if (test_and_clear_bit (PG_INODE_REF , & req -> wb_flags )) {
803794 atomic_long_dec (& nfsi -> nrequests );
0 commit comments