NFS: Add a count of the number of unstable writes carried by an inode
In order to know when we should do opportunistic commits of the unstable writes, when the VM is doing a background flush, we add a field to count the number of unstable writes. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
		
					parent
					
						
							
								8fc795f703
							
						
					
				
			
			
				commit
				
					
						ff778d02bf
					
				
			
		
					 3 changed files with 12 additions and 4 deletions
				
			
		| 
						 | 
					@ -1404,6 +1404,7 @@ static void init_once(void *foo)
 | 
				
			||||||
	INIT_LIST_HEAD(&nfsi->access_cache_inode_lru);
 | 
						INIT_LIST_HEAD(&nfsi->access_cache_inode_lru);
 | 
				
			||||||
	INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC);
 | 
						INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC);
 | 
				
			||||||
	nfsi->npages = 0;
 | 
						nfsi->npages = 0;
 | 
				
			||||||
 | 
						nfsi->ncommit = 0;
 | 
				
			||||||
	atomic_set(&nfsi->silly_count, 1);
 | 
						atomic_set(&nfsi->silly_count, 1);
 | 
				
			||||||
	INIT_HLIST_HEAD(&nfsi->silly_list);
 | 
						INIT_HLIST_HEAD(&nfsi->silly_list);
 | 
				
			||||||
	init_waitqueue_head(&nfsi->waitqueue);
 | 
						init_waitqueue_head(&nfsi->waitqueue);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -438,6 +438,7 @@ nfs_mark_request_commit(struct nfs_page *req)
 | 
				
			||||||
	radix_tree_tag_set(&nfsi->nfs_page_tree,
 | 
						radix_tree_tag_set(&nfsi->nfs_page_tree,
 | 
				
			||||||
			req->wb_index,
 | 
								req->wb_index,
 | 
				
			||||||
			NFS_PAGE_TAG_COMMIT);
 | 
								NFS_PAGE_TAG_COMMIT);
 | 
				
			||||||
 | 
						nfsi->ncommit++;
 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
						spin_unlock(&inode->i_lock);
 | 
				
			||||||
	inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
 | 
						inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
 | 
				
			||||||
	inc_bdi_stat(req->wb_page->mapping->backing_dev_info, BDI_RECLAIMABLE);
 | 
						inc_bdi_stat(req->wb_page->mapping->backing_dev_info, BDI_RECLAIMABLE);
 | 
				
			||||||
| 
						 | 
					@ -573,11 +574,15 @@ static int
 | 
				
			||||||
nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
 | 
					nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct nfs_inode *nfsi = NFS_I(inode);
 | 
						struct nfs_inode *nfsi = NFS_I(inode);
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!nfs_need_commit(nfsi))
 | 
						if (!nfs_need_commit(nfsi))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nfs_scan_list(nfsi, dst, idx_start, npages, NFS_PAGE_TAG_COMMIT);
 | 
						ret = nfs_scan_list(nfsi, dst, idx_start, npages, NFS_PAGE_TAG_COMMIT);
 | 
				
			||||||
 | 
						if (ret > 0)
 | 
				
			||||||
 | 
							nfsi->ncommit -= ret;
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline int nfs_need_commit(struct nfs_inode *nfsi)
 | 
					static inline int nfs_need_commit(struct nfs_inode *nfsi)
 | 
				
			||||||
| 
						 | 
					@ -642,9 +647,10 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
 | 
				
			||||||
		spin_lock(&inode->i_lock);
 | 
							spin_lock(&inode->i_lock);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (nfs_clear_request_commit(req))
 | 
						if (nfs_clear_request_commit(req) &&
 | 
				
			||||||
			radix_tree_tag_clear(&NFS_I(inode)->nfs_page_tree,
 | 
								radix_tree_tag_clear(&NFS_I(inode)->nfs_page_tree,
 | 
				
			||||||
				req->wb_index, NFS_PAGE_TAG_COMMIT);
 | 
									req->wb_index, NFS_PAGE_TAG_COMMIT) != NULL)
 | 
				
			||||||
 | 
							NFS_I(inode)->ncommit--;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Okay, the request matches. Update the region */
 | 
						/* Okay, the request matches. Update the region */
 | 
				
			||||||
	if (offset < req->wb_offset) {
 | 
						if (offset < req->wb_offset) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -166,6 +166,7 @@ struct nfs_inode {
 | 
				
			||||||
	struct radix_tree_root	nfs_page_tree;
 | 
						struct radix_tree_root	nfs_page_tree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	unsigned long		npages;
 | 
						unsigned long		npages;
 | 
				
			||||||
 | 
						unsigned long		ncommit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Open contexts for shared mmap writes */
 | 
						/* Open contexts for shared mmap writes */
 | 
				
			||||||
	struct list_head	open_files;
 | 
						struct list_head	open_files;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue