• Ilya Dryomov's avatar
    Btrfs: rollback btrfs_device fields on umount · a1e8780a
    Ilya Dryomov authored
    It turns out we don't properly rollback in-core btrfs_device state on
    umount.  We zero out ->bdev, ->in_fs_metadata and that's about it.  In
    particular, we don't zero out ->generation, and this can lead to us
    refusing a mount -- a non-NULL fs_devices->latest_bdev is essential, but
    btrfs_close_extra_devices will happily assign NULL to ->latest_bdev if
    the first device on the dev_list happens to be missing and consequently
    has no bdev attached.  This happens because since commit a6b0d5c8
    btrfs_close_extra_devices adjusts ->latest_bdev, and in doing that,
    relies on the ->generation.  Fix this, and possibly other problems, by
    zeroing out everything except for what device_list_add sets, so that a
    mount right after insmod and 'btrfs dev scan' is no different from any
    later mount in this respect.
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
    Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
    a1e8780a
volumes.c 160 KB