Skip to contentSkip to conversation

dcache: unlock inode->i_lock before goto restart tag in, d_prune_aliases

PATCH In review Zhiqiang Liu 2 participants 3 messages Apr 15, 2020 – Apr 16, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dcache: unlock inode->i_lock before goto restart tag in, d_prune_aliases

From: Zhiqiang Liu <[email protected]>

coccicheck reports:
fs/dcache.c:1027:1-10: second lock on line 1027

In d_prune_aliases, before goto restart we should unlock inode->i_lock.

Fixes 29355c3904e ("d_prune_alias(): just lock the parent and call __dentry_kill()")
---
 fs/dcache.c | 1 +
 1 file changed, 1 insertion(+)
fs/dcache.c +1 -0
index b280e07e162b..1532ebe9d9ca 100644
@@ -1030,6 +1030,7 @@ void d_prune_aliases(struct inode *inode)
 		if (!dentry->d_lockref.count) {
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
+				spin_unlock(&inode->i_lock);
 				__dentry_kill(dentry);
 				dput(parent);
 				goto restart;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 21 lines · Zhiqiang Liu

From: Zhiqiang Liu <[email protected]>

coccicheck reports:
fs/dcache.c:1027:1-10: second lock on line 1027

In d_prune_aliases, before goto restart we should unlock inode->i_lock.

Fixes 29355c3904e ("d_prune_alias(): just lock the parent and call __dentry_kill()")
---
 fs/dcache.c | 1 +
 1 file changed, 1 insertion(+)
fs/dcache.c +0 -0
index b280e07e162b..1532ebe9d9ca 100644

fs/dcache.c void d_prune_aliases(struct inode *inode) · line 1036

Quoted 7 lines
fs/dcache.c +1 -0
@@ -1030,6 +1030,7 @@ void d_prune_aliases(struct inode *inode)
 		if (!dentry->d_lockref.count) {
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
+				spin_unlock(&inode->i_lock);
 				__dentry_kill(dentry);
 				dput(parent);
 				goto restart;

Doesn't __dentry_kill() already do the unlock, via dentry_unlink_inode()?

- Eric

#2 lore raw
Quoted 32 lines · Eric Biggers
Quoted 21 lines · Zhiqiang Liu

From: Zhiqiang Liu <[email protected]>

coccicheck reports:
fs/dcache.c:1027:1-10: second lock on line 1027

In d_prune_aliases, before goto restart we should unlock inode->i_lock.

Fixes 29355c3904e ("d_prune_alias(): just lock the parent and call __dentry_kill()")
---
 fs/dcache.c | 1 +
 1 file changed, 1 insertion(+)
fs/dcache.c +0 -0
index b280e07e162b..1532ebe9d9ca 100644

fs/dcache.c void d_prune_aliases(struct inode *inode) · line 1036

Quoted 7 lines
fs/dcache.c +1 -0
@@ -1030,6 +1030,7 @@ void d_prune_aliases(struct inode *inode)
 		if (!dentry->d_lockref.count) {
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
+				spin_unlock(&inode->i_lock);
 				__dentry_kill(dentry);
 				dput(parent);
 				goto restart;

Doesn't __dentry_kill() already do the unlock, via dentry_unlink_inode()?

Quoted 2 lines

- Eric

Yes, you are right. Sorry for that. Please ignore this patch.

Quoted 2 lines

.