@@ -222,7 +222,7 @@ static void nfs_end_page_writeback(struct page *page)
222222 clear_bdi_congested (& nfss -> backing_dev_info , BLK_RW_ASYNC );
223223}
224224
225- static struct nfs_page * nfs_find_and_lock_request (struct page * page )
225+ static struct nfs_page * nfs_find_and_lock_request (struct page * page , bool nonblock )
226226{
227227 struct inode * inode = page -> mapping -> host ;
228228 struct nfs_page * req ;
@@ -241,7 +241,10 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page)
241241 * request as dirty (in which case we don't care).
242242 */
243243 spin_unlock (& inode -> i_lock );
244- ret = nfs_wait_on_request (req );
244+ if (!nonblock )
245+ ret = nfs_wait_on_request (req );
246+ else
247+ ret = - EAGAIN ;
245248 nfs_release_request (req );
246249 if (ret != 0 )
247250 return ERR_PTR (ret );
@@ -256,12 +259,12 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page)
256259 * May return an error if the user signalled nfs_wait_on_request().
257260 */
258261static int nfs_page_async_flush (struct nfs_pageio_descriptor * pgio ,
259- struct page * page )
262+ struct page * page , bool nonblock )
260263{
261264 struct nfs_page * req ;
262265 int ret = 0 ;
263266
264- req = nfs_find_and_lock_request (page );
267+ req = nfs_find_and_lock_request (page , nonblock );
265268 if (!req )
266269 goto out ;
267270 ret = PTR_ERR (req );
@@ -283,12 +286,20 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
283286static int nfs_do_writepage (struct page * page , struct writeback_control * wbc , struct nfs_pageio_descriptor * pgio )
284287{
285288 struct inode * inode = page -> mapping -> host ;
289+ int ret ;
286290
287291 nfs_inc_stats (inode , NFSIOS_VFSWRITEPAGE );
288292 nfs_add_stats (inode , NFSIOS_WRITEPAGES , 1 );
289293
290294 nfs_pageio_cond_complete (pgio , page -> index );
291- return nfs_page_async_flush (pgio , page );
295+ ret = nfs_page_async_flush (pgio , page ,
296+ wbc -> sync_mode == WB_SYNC_NONE ||
297+ wbc -> nonblocking != 0 );
298+ if (ret == - EAGAIN ) {
299+ redirty_page_for_writepage (wbc , page );
300+ ret = 0 ;
301+ }
302+ return ret ;
292303}
293304
294305/*
@@ -1546,7 +1557,7 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage,
15461557
15471558 nfs_fscache_release_page (page , GFP_KERNEL );
15481559
1549- req = nfs_find_and_lock_request (page );
1560+ req = nfs_find_and_lock_request (page , false );
15501561 ret = PTR_ERR (req );
15511562 if (IS_ERR (req ))
15521563 goto out ;
0 commit comments