]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/nilfs2/the_nilfs.c
Merge tag 'v5.15-rc2' into spi-5.15
[mirror_ubuntu-jammy-kernel.git] / fs / nilfs2 / the_nilfs.c
index 8b7b01a380ceac262f3b73598e13deff235cc156..c8bfc01da5d71699739659e9a63d1761d719a21f 100644 (file)
@@ -792,14 +792,13 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)
 
 void nilfs_put_root(struct nilfs_root *root)
 {
-       if (refcount_dec_and_test(&root->count)) {
-               struct the_nilfs *nilfs = root->nilfs;
+       struct the_nilfs *nilfs = root->nilfs;
 
-               nilfs_sysfs_delete_snapshot_group(root);
-
-               spin_lock(&nilfs->ns_cptree_lock);
+       if (refcount_dec_and_lock(&root->count, &nilfs->ns_cptree_lock)) {
                rb_erase(&root->rb_node, &nilfs->ns_cptree);
                spin_unlock(&nilfs->ns_cptree_lock);
+
+               nilfs_sysfs_delete_snapshot_group(root);
                iput(root->ifile);
 
                kfree(root);