@@ -46,6 +46,7 @@ static void nfs_redirty_request(struct nfs_page *req);
4646static const struct rpc_call_ops nfs_write_common_ops ;
4747static const struct rpc_call_ops nfs_commit_ops ;
4848static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops ;
49+ static const struct nfs_commit_completion_ops nfs_commit_completion_ops ;
4950
5051static struct kmem_cache * nfs_wdata_cachep ;
5152static mempool_t * nfs_wdata_mempool ;
@@ -505,6 +506,7 @@ static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
505506 cinfo -> lock = & inode -> i_lock ;
506507 cinfo -> mds = & NFS_I (inode )-> commit_info ;
507508 cinfo -> ds = pnfs_get_ds_info (inode );
509+ cinfo -> completion_ops = & nfs_commit_completion_ops ;
508510}
509511
510512void nfs_init_cinfo (struct nfs_commit_info * cinfo ,
@@ -1358,13 +1360,12 @@ static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait)
13581360 return (ret < 0 ) ? ret : 1 ;
13591361}
13601362
1361- void nfs_commit_clear_lock (struct nfs_inode * nfsi )
1363+ static void nfs_commit_clear_lock (struct nfs_inode * nfsi )
13621364{
13631365 clear_bit (NFS_INO_COMMIT , & nfsi -> flags );
13641366 smp_mb__after_clear_bit ();
13651367 wake_up_bit (& nfsi -> flags , NFS_INO_COMMIT );
13661368}
1367- EXPORT_SYMBOL_GPL (nfs_commit_clear_lock );
13681369
13691370void nfs_commitdata_release (struct nfs_commit_data * data )
13701371{
@@ -1413,8 +1414,9 @@ EXPORT_SYMBOL_GPL(nfs_initiate_commit);
14131414 * Set up the argument/result storage required for the RPC call.
14141415 */
14151416void nfs_init_commit (struct nfs_commit_data * data ,
1416- struct list_head * head ,
1417- struct pnfs_layout_segment * lseg )
1417+ struct list_head * head ,
1418+ struct pnfs_layout_segment * lseg ,
1419+ struct nfs_commit_info * cinfo )
14181420{
14191421 struct nfs_page * first = nfs_list_entry (head -> next );
14201422 struct inode * inode = first -> wb_context -> dentry -> d_inode ;
@@ -1428,6 +1430,7 @@ void nfs_init_commit(struct nfs_commit_data *data,
14281430 data -> cred = first -> wb_context -> cred ;
14291431 data -> lseg = lseg ; /* reference transferred */
14301432 data -> mds_ops = & nfs_commit_ops ;
1433+ data -> completion_ops = cinfo -> completion_ops ;
14311434
14321435 data -> args .fh = NFS_FH (data -> inode );
14331436 /* Note: we always request a commit of the entire inode */
@@ -1473,11 +1476,12 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
14731476 goto out_bad ;
14741477
14751478 /* Set up the argument struct */
1476- nfs_init_commit (data , head , NULL );
1479+ nfs_init_commit (data , head , NULL , cinfo );
1480+ atomic_inc (& cinfo -> mds -> rpcs_out );
14771481 return nfs_initiate_commit (NFS_CLIENT (inode ), data , data -> mds_ops , how );
14781482 out_bad :
14791483 nfs_retry_commit (head , NULL , cinfo );
1480- nfs_commit_clear_lock (NFS_I (inode ));
1484+ cinfo -> completion_ops -> error_cleanup (NFS_I (inode ));
14811485 return - ENOMEM ;
14821486}
14831487
@@ -1495,10 +1499,11 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
14951499 NFS_PROTO (data -> inode )-> commit_done (task , data );
14961500}
14971501
1498- void nfs_commit_release_pages (struct nfs_commit_data * data )
1502+ static void nfs_commit_release_pages (struct nfs_commit_data * data )
14991503{
15001504 struct nfs_page * req ;
15011505 int status = data -> task .tk_status ;
1506+ struct nfs_commit_info cinfo ;
15021507
15031508 while (!list_empty (& data -> pages )) {
15041509 req = nfs_list_entry (data -> pages .next );
@@ -1531,15 +1536,16 @@ void nfs_commit_release_pages(struct nfs_commit_data *data)
15311536 next :
15321537 nfs_unlock_request (req );
15331538 }
1539+ nfs_init_cinfo (& cinfo , data -> inode , data -> dreq );
1540+ if (atomic_dec_and_test (& cinfo .mds -> rpcs_out ))
1541+ nfs_commit_clear_lock (NFS_I (data -> inode ));
15341542}
1535- EXPORT_SYMBOL_GPL (nfs_commit_release_pages );
15361543
15371544static void nfs_commit_release (void * calldata )
15381545{
15391546 struct nfs_commit_data * data = calldata ;
15401547
1541- nfs_commit_release_pages (data );
1542- nfs_commit_clear_lock (NFS_I (data -> inode ));
1548+ data -> completion_ops -> completion (data );
15431549 nfs_commitdata_release (calldata );
15441550}
15451551
@@ -1549,6 +1555,11 @@ static const struct rpc_call_ops nfs_commit_ops = {
15491555 .rpc_release = nfs_commit_release ,
15501556};
15511557
1558+ static const struct nfs_commit_completion_ops nfs_commit_completion_ops = {
1559+ .completion = nfs_commit_release_pages ,
1560+ .error_cleanup = nfs_commit_clear_lock ,
1561+ };
1562+
15521563static int nfs_generic_commit_list (struct inode * inode , struct list_head * head ,
15531564 int how , struct nfs_commit_info * cinfo )
15541565{
0 commit comments