mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	nfsd: Clean up nfsd_file_put()
Make it a little less racy, by removing the refcount_read() test. Then remove the redundant 'is_hashed' variable. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
		
							parent
							
								
									6b8a94332e
								
							
						
					
					
						commit
						999397926a
					
				
					 1 changed files with 3 additions and 10 deletions
				
			
		| 
						 | 
					@ -301,21 +301,14 @@ nfsd_file_put_noref(struct nfsd_file *nf)
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
nfsd_file_put(struct nfsd_file *nf)
 | 
					nfsd_file_put(struct nfsd_file *nf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	bool is_hashed;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
 | 
						set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
 | 
				
			||||||
	if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
 | 
						if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
 | 
				
			||||||
		nfsd_file_put_noref(nf);
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
 | 
					 | 
				
			||||||
	if (!is_hashed) {
 | 
					 | 
				
			||||||
		nfsd_file_flush(nf);
 | 
							nfsd_file_flush(nf);
 | 
				
			||||||
		nfsd_file_put_noref(nf);
 | 
							nfsd_file_put_noref(nf);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		nfsd_file_put_noref(nf);
 | 
							nfsd_file_put_noref(nf);
 | 
				
			||||||
		nfsd_file_schedule_laundrette();
 | 
							if (nf->nf_file)
 | 
				
			||||||
 | 
								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