Skip to contentSkip to conversation

btrfs: Fix missing close devices

PATCH NAK [email protected] 3 participants 3 messages Sep 21, 2020 – Sep 23, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Fix missing close devices

From: Zqiang <[email protected]>

When the btrfs fill super error, we should first close devices and then call deactivate_locked_super func to free fs_info.

---
 fs/btrfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/super.c +1 -0
index 8840a4fa81eb..3bfd54e8f388 100644
@@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
 		error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
 	security_free_mnt_opts(&new_sec_opts);
 	if (error) {
+		btrfs_close_devices(fs_devices);
 		deactivate_locked_super(s);
 		return ERR_PTR(error);
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · On 21/09/2020 13:00, [email protected] wrote:

From: Zqiang <[email protected]>

When the btrfs fill super error, we should first close devices and then call deactivate_locked_super func to free fs_info.

---
 fs/btrfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/super.c +0 -0
index 8840a4fa81eb..3bfd54e8f388 100644

fs/btrfs/super.c static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, · line 1681

Quoted 7 lines
fs/btrfs/super.c +1 -0
@@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
 		error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
 	security_free_mnt_opts(&new_sec_opts);
 	if (error) {
+		btrfs_close_devices(fs_devices);
 		deactivate_locked_super(s);
 		return ERR_PTR(error);
 	}

Hmm you didn't change anything, so my report in [1] still exists.

[1] https://lore.kernel.org/r/SN4PR0401MB359820738AC6479F9F47FEE59B3A0@SN4PR0401MB3598.namprd04.prod.outlook.com

#2 lore raw
In reply to [email protected]
Quoted 16 lines · On 21.09.20 г. 10:29 ч., [email protected] wrote:

From: Zqiang <[email protected]>

When the btrfs fill super error, we should first close devices and then call deactivate_locked_super func to free fs_info.

---
 fs/btrfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/super.c +0 -0
index 8840a4fa81eb..3bfd54e8f388 100644

fs/btrfs/super.c static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, · line 1681

Quoted 7 lines
fs/btrfs/super.c +1 -0
@@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
 		error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
 	security_free_mnt_opts(&new_sec_opts);
 	if (error) {
+		btrfs_close_devices(fs_devices);
 		deactivate_locked_super(s);
 		return ERR_PTR(error);
 	}

NAK,

Devices are properly closed via:

deactivate_locked_super
kill_sb (btrfs_kill_super)
kill_anon_super
generic_shutdown_super
put_super (btrfs_put_super)
close_ctree

It seems you haven't done deep enough analysis of the involved call chains.