Skip to contentSkip to conversation

fs/dcache: prevent repeated locking

PATCH In review [email protected] 3 participants 4 messages Dec 7, 2021 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/dcache: prevent repeated locking

From: Lv Ruyi <[email protected]>

Move the spin_lock above the restart to prevent to lock twice when the code goto restart.

---
 fs/dcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dcache.c +1 -1
index c84269c6e8bf..8580d51b397a 100644
@@ -1102,8 +1102,8 @@ struct dentry *d_find_alias_rcu(struct inode *inode)
 void d_prune_aliases(struct inode *inode)
 {
 	struct dentry *dentry;
-restart:
 	spin_lock(&inode->i_lock);
+restart:
 	hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
 		spin_lock(&dentry->d_lock);
 		if (!dentry->d_lockref.count) {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · On Tue, Dec 07, 2021 at 10:16:46AM +0000, [email protected] wrote:

From: Lv Ruyi <[email protected]>

Move the spin_lock above the restart to prevent to lock twice when the code goto restart.

This is madness.

void d_prune_aliases(struct inode *inode)

        spin_lock(&inode->i_lock);
                        if (likely(!dentry->d_lockref.count)) {
                                __dentry_kill(dentry);
                                goto restart;
...
static void __dentry_kill(struct dentry *dentry)
        if (dentry->d_inode)
                dentry_unlink_inode(dentry);
...
static void dentry_unlink_inode(struct dentry * dentry)
        spin_unlock(&inode->i_lock);

Did you even test this patch?

#2 lore raw
Quoted 21 lines · Matthew Wilcox
Quoted 4 lines · On Tue, Dec 07, 2021 at 10:16:46AM +0000, [email protected] wrote:

From: Lv Ruyi <[email protected]>

Move the spin_lock above the restart to prevent to lock twice when the code goto restart.

This is madness.

void d_prune_aliases(struct inode *inode)

        spin_lock(&inode->i_lock);
                        if (likely(!dentry->d_lockref.count)) {
                                __dentry_kill(dentry);
                                goto restart;
...
static void __dentry_kill(struct dentry *dentry)
        if (dentry->d_inode)
                dentry_unlink_inode(dentry);
...
static void dentry_unlink_inode(struct dentry * dentry)
        spin_unlock(&inode->i_lock);
Quoted 1 line

Did you even test this patch?

This same wrong patch has been sent several times before. I think it's fair to say that this code could use a comment, e.g.:

	/* i_lock was dropped */
	goto restart;

- Eric

#3 lore raw
Quoted 22 lines · Eric Biggers
Quoted 21 lines · Matthew Wilcox
Quoted 4 lines · On Tue, Dec 07, 2021 at 10:16:46AM +0000, [email protected] wrote:

From: Lv Ruyi <[email protected]>

Move the spin_lock above the restart to prevent to lock twice when the code goto restart.

This is madness.

void d_prune_aliases(struct inode *inode)

        spin_lock(&inode->i_lock);
                        if (likely(!dentry->d_lockref.count)) {
                                __dentry_kill(dentry);
                                goto restart;
...
static void __dentry_kill(struct dentry *dentry)
        if (dentry->d_inode)
                dentry_unlink_inode(dentry);
...
static void dentry_unlink_inode(struct dentry * dentry)
        spin_unlock(&inode->i_lock);
Quoted 7 lines
Quoted 1 line

Did you even test this patch?

This same wrong patch has been sent several times before. I think it's fair to say that this code could use a comment, e.g.:

	/* i_lock was dropped */
	goto restart;

Not sure that'll do much good. It seems to be fools running some script that they haven't the wit to understand.