[PATCH] fs: unlock the superblock during iterate_supers_type

Darrick J. Wong posted 1 patch 4 months ago
fs/super.c |    4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] fs: unlock the superblock during iterate_supers_type
Posted by Darrick J. Wong 4 months ago
From: Darrick J. Wong <djwong@kernel.org>

This function takes super_lock in shared mode, so it should release the
same lock.

Cc: <stable@vger.kernel.org> # v6.16-rc1
Fixes: af7551cf13cf7f ("super: remove pointless s_root checks")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 fs/super.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index 21799e213fd747..80418ca8e215bb 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -964,8 +964,10 @@ void iterate_supers_type(struct file_system_type *type,
 		spin_unlock(&sb_lock);
 
 		locked = super_lock_shared(sb);
-		if (locked)
+		if (locked) {
 			f(sb, arg);
+			super_unlock_shared(sb);
+		}
 
 		spin_lock(&sb_lock);
 		if (p)
Re: [PATCH] fs: unlock the superblock during iterate_supers_type
Posted by Christian Brauner 4 months ago
On Wed, 11 Jun 2025 09:40:44 -0700, Darrick J. Wong wrote:
> This function takes super_lock in shared mode, so it should release the
> same lock.
> 
> 

https://youtu.be/m6uvv1aS5_I?si=8e0DYW802X30y2UM&t=224

---

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] fs: unlock the superblock during iterate_supers_type
      https://git.kernel.org/vfs/vfs/c/0b9d62a47149
Re: [PATCH] fs: unlock the superblock during iterate_supers_type
Posted by Jan Kara 4 months ago
On Wed 11-06-25 09:40:44, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> This function takes super_lock in shared mode, so it should release the
> same lock.
> 
> Cc: <stable@vger.kernel.org> # v6.16-rc1
> Fixes: af7551cf13cf7f ("super: remove pointless s_root checks")
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>

Indeed that was an oversight. Thanks for catching it! Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/super.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 21799e213fd747..80418ca8e215bb 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -964,8 +964,10 @@ void iterate_supers_type(struct file_system_type *type,
>  		spin_unlock(&sb_lock);
>  
>  		locked = super_lock_shared(sb);
> -		if (locked)
> +		if (locked) {
>  			f(sb, arg);
> +			super_unlock_shared(sb);
> +		}
>  
>  		spin_lock(&sb_lock);
>  		if (p)
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR