mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	nfsd: Reduce the number of calls to nfsd_file_gc()
Don't call nfsd_file_gc() on every put of the reference in nfsd_file_put(). Instead, do it only when we're expecting the refcount to go to 1. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
		
							parent
							
								
									55f84cc47f
								
							
						
					
					
						commit
						b6669305d3
					
				
					 1 changed files with 12 additions and 7 deletions
				
			
		| 
						 | 
					@ -282,27 +282,32 @@ nfsd_file_unhash_and_release_locked(struct nfsd_file *nf, struct list_head *disp
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static void
 | 
				
			||||||
nfsd_file_put_noref(struct nfsd_file *nf)
 | 
					nfsd_file_put_noref(struct nfsd_file *nf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int count;
 | 
					 | 
				
			||||||
	trace_nfsd_file_put(nf);
 | 
						trace_nfsd_file_put(nf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	count = atomic_dec_return(&nf->nf_ref);
 | 
						if (atomic_dec_and_test(&nf->nf_ref)) {
 | 
				
			||||||
	if (!count) {
 | 
					 | 
				
			||||||
		WARN_ON(test_bit(NFSD_FILE_HASHED, &nf->nf_flags));
 | 
							WARN_ON(test_bit(NFSD_FILE_HASHED, &nf->nf_flags));
 | 
				
			||||||
		nfsd_file_free(nf);
 | 
							nfsd_file_free(nf);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return count;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
nfsd_file_put(struct nfsd_file *nf)
 | 
					nfsd_file_put(struct nfsd_file *nf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	bool is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
 | 
						bool is_hashed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
 | 
						set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
 | 
				
			||||||
	if (nfsd_file_put_noref(nf) == 1 && is_hashed)
 | 
						if (atomic_read(&nf->nf_ref) > 2 || !nf->nf_file) {
 | 
				
			||||||
 | 
							nfsd_file_put_noref(nf);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						filemap_flush(nf->nf_file->f_mapping);
 | 
				
			||||||
 | 
						is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
 | 
				
			||||||
 | 
						nfsd_file_put_noref(nf);
 | 
				
			||||||
 | 
						if (is_hashed)
 | 
				
			||||||
		nfsd_file_schedule_laundrette();
 | 
							nfsd_file_schedule_laundrette();
 | 
				
			||||||
	if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
 | 
						if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
 | 
				
			||||||
		nfsd_file_gc();
 | 
							nfsd_file_gc();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue