@@ -3508,6 +3508,9 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
if (!dev->in_fs_metadata || !dev->writeable)
continue;
+ /* update device generation according to disk super */
+ dev->generation = sb->generation;
+
btrfs_set_stack_device_generation(dev_item, 0);
btrfs_set_stack_device_type(dev_item, dev->type);
btrfs_set_stack_device_id(dev_item, dev->devid);
@@ -525,10 +525,9 @@ static noinline int device_list_add(const char *path,
* tracking a problem where systems fail mount by subvolume id
* when we reject replacement on a mounted FS.
*/
- if (!fs_devices->opened && found_transid < device->generation) {
+ if (found_transid < device->generation) {
/*
- * That is if the FS is _not_ mounted and if you
- * are here, that means there is more than one
+ * If you are here, that means there is more than one
* disk with same uuid and devid.We keep the one
* with larger generation number or the last-in if
* generation are equal.