Btrfs - fix race between btrfs_get_sb() and umount

When mounting a btrfs file system btrfs_test_super() may attempt to
use sb->s_fs_info, the btrfs root, of a super block that is going away
and that has had the btrfs root set to NULL in its ->put_super(). But
if the super block is going away it cannot be an existing super block
so we can return false in this case.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

authored by Ian Kent and committed by Chris Mason 619c8c76 bc1cbf1f

+6
+6
fs/btrfs/super.c
··· 566 566 struct btrfs_fs_devices *test_fs_devices = data; 567 567 struct btrfs_root *root = btrfs_sb(s); 568 568 569 + /* 570 + * If this super block is going away, return false as it 571 + * can't match as an existing super block. 572 + */ 573 + if (!atomic_read(&s->s_active)) 574 + return 0; 569 575 return root->fs_info->fs_devices == test_fs_devices; 570 576 } 571 577