mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	d_delete(): get rid of trylock loop
just grab ->i_lock first; we have a positive dentry, nothing's going to happen to inode Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									c1d0c1a2b5
								
							
						
					
					
						commit
						c19457f0ae
					
				
					 1 changed files with 9 additions and 19 deletions
				
			
		
							
								
								
									
										28
									
								
								fs/dcache.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								fs/dcache.c
									
									
									
									
									
								
							| 
						 | 
					@ -2377,32 +2377,22 @@ EXPORT_SYMBOL(d_hash_and_lookup);
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
void d_delete(struct dentry * dentry)
 | 
					void d_delete(struct dentry * dentry)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct inode *inode;
 | 
						struct inode *inode = dentry->d_inode;
 | 
				
			||||||
	int isdir = 0;
 | 
						int isdir = d_is_dir(dentry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock(&inode->i_lock);
 | 
				
			||||||
 | 
						spin_lock(&dentry->d_lock);
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Are we the only user?
 | 
						 * Are we the only user?
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
again:
 | 
					 | 
				
			||||||
	spin_lock(&dentry->d_lock);
 | 
					 | 
				
			||||||
	inode = dentry->d_inode;
 | 
					 | 
				
			||||||
	isdir = S_ISDIR(inode->i_mode);
 | 
					 | 
				
			||||||
	if (dentry->d_lockref.count == 1) {
 | 
						if (dentry->d_lockref.count == 1) {
 | 
				
			||||||
		if (!spin_trylock(&inode->i_lock)) {
 | 
					 | 
				
			||||||
			spin_unlock(&dentry->d_lock);
 | 
					 | 
				
			||||||
			cpu_relax();
 | 
					 | 
				
			||||||
			goto again;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		dentry->d_flags &= ~DCACHE_CANT_MOUNT;
 | 
							dentry->d_flags &= ~DCACHE_CANT_MOUNT;
 | 
				
			||||||
		dentry_unlink_inode(dentry);
 | 
							dentry_unlink_inode(dentry);
 | 
				
			||||||
		fsnotify_nameremove(dentry, isdir);
 | 
						} else {
 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!d_unhashed(dentry))
 | 
					 | 
				
			||||||
		__d_drop(dentry);
 | 
							__d_drop(dentry);
 | 
				
			||||||
 | 
							spin_unlock(&dentry->d_lock);
 | 
				
			||||||
	spin_unlock(&dentry->d_lock);
 | 
							spin_unlock(&inode->i_lock);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	fsnotify_nameremove(dentry, isdir);
 | 
						fsnotify_nameremove(dentry, isdir);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(d_delete);
 | 
					EXPORT_SYMBOL(d_delete);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue