All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dawei Li <set_pte_at@outlook.com>
To: xiang@kernel.org, chao@kernel.org
Cc: huyue2@coolpad.com, jefflexu@linux.alibaba.com,
	linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Dawei Li <set_pte_at@outlook.com>
Subject: [PATCH] erofs: protect s_inodes with s_inode_list_lock
Date: Sun, 16 Oct 2022 20:37:27 +0800	[thread overview]
Message-ID: <TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM> (raw)

s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.

base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1

Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
 fs/erofs/fscache.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 998cd26a1b3b..bbf5268440df 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -589,15 +589,18 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 	struct erofs_domain *domain = EROFS_SB(sb)->domain;
 	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
 
-	mutex_lock(&erofs_domain_cookies_lock);
+	spin_lock(&psb->s_inode_list_lock);
 	list_for_each_entry(inode, &psb->s_inodes, i_sb_list) {
 		ctx = inode->i_private;
 		if (!ctx || ctx->domain != domain || strcmp(ctx->name, name))
 			continue;
 		igrab(inode);
-		mutex_unlock(&erofs_domain_cookies_lock);
+		spin_unlock(&psb->s_inode_list_lock);
 		return ctx;
 	}
+	spin_unlock(&psb->s_inode_list_lock);
+
+	mutex_lock(&erofs_domain_cookies_lock);
 	ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode);
 	mutex_unlock(&erofs_domain_cookies_lock);
 	return ctx;
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Dawei Li <set_pte_at@outlook.com>
To: xiang@kernel.org, chao@kernel.org
Cc: Dawei Li <set_pte_at@outlook.com>,
	huyue2@coolpad.com, linux-erofs@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] erofs: protect s_inodes with s_inode_list_lock
Date: Sun, 16 Oct 2022 20:37:27 +0800	[thread overview]
Message-ID: <TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM> (raw)

s_inodes is superblock-specific resource, which should be
protected by sb's specific lock s_inode_list_lock.

base-commit: 8436c4a57bd147b0bd2943ab499bb8368981b9e1

Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
 fs/erofs/fscache.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 998cd26a1b3b..bbf5268440df 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -589,15 +589,18 @@ struct erofs_fscache *erofs_domain_register_cookie(struct super_block *sb,
 	struct erofs_domain *domain = EROFS_SB(sb)->domain;
 	struct super_block *psb = erofs_pseudo_mnt->mnt_sb;
 
-	mutex_lock(&erofs_domain_cookies_lock);
+	spin_lock(&psb->s_inode_list_lock);
 	list_for_each_entry(inode, &psb->s_inodes, i_sb_list) {
 		ctx = inode->i_private;
 		if (!ctx || ctx->domain != domain || strcmp(ctx->name, name))
 			continue;
 		igrab(inode);
-		mutex_unlock(&erofs_domain_cookies_lock);
+		spin_unlock(&psb->s_inode_list_lock);
 		return ctx;
 	}
+	spin_unlock(&psb->s_inode_list_lock);
+
+	mutex_lock(&erofs_domain_cookies_lock);
 	ctx = erofs_fscache_domain_init_cookie(sb, name, need_inode);
 	mutex_unlock(&erofs_domain_cookies_lock);
 	return ctx;
-- 
2.25.1


             reply	other threads:[~2022-10-16 12:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-16 12:37 Dawei Li [this message]
2022-10-16 12:37 ` [PATCH] erofs: protect s_inodes with s_inode_list_lock Dawei Li
2022-10-16 15:05 ` [External] " Jia Zhu
2022-10-16 15:05   ` Jia Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TYCP286MB23237A9993E0FFCFE5C2BDBECA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM \
    --to=set_pte_at@outlook.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.