@@ -2307,30 +2307,39 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
2307
2307
2308
2308
root = btrfs_read_tree_root (tree_root , & location );
2309
2309
if (IS_ERR (root )) {
2310
- ret = PTR_ERR (root );
2311
- goto out ;
2310
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2311
+ ret = PTR_ERR (root );
2312
+ goto out ;
2313
+ }
2314
+ } else {
2315
+ set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2316
+ fs_info -> extent_root = root ;
2312
2317
}
2313
- set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2314
- fs_info -> extent_root = root ;
2315
2318
2316
2319
location .objectid = BTRFS_DEV_TREE_OBJECTID ;
2317
2320
root = btrfs_read_tree_root (tree_root , & location );
2318
2321
if (IS_ERR (root )) {
2319
- ret = PTR_ERR (root );
2320
- goto out ;
2322
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2323
+ ret = PTR_ERR (root );
2324
+ goto out ;
2325
+ }
2326
+ } else {
2327
+ set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2328
+ fs_info -> dev_root = root ;
2329
+ btrfs_init_devices_late (fs_info );
2321
2330
}
2322
- set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2323
- fs_info -> dev_root = root ;
2324
- btrfs_init_devices_late (fs_info );
2325
2331
2326
2332
location .objectid = BTRFS_CSUM_TREE_OBJECTID ;
2327
2333
root = btrfs_read_tree_root (tree_root , & location );
2328
2334
if (IS_ERR (root )) {
2329
- ret = PTR_ERR (root );
2330
- goto out ;
2335
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2336
+ ret = PTR_ERR (root );
2337
+ goto out ;
2338
+ }
2339
+ } else {
2340
+ set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2341
+ fs_info -> csum_root = root ;
2331
2342
}
2332
- set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2333
- fs_info -> csum_root = root ;
2334
2343
2335
2344
/*
2336
2345
* This tree can share blocks with some other fs tree during relocation
@@ -2339,11 +2348,14 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
2339
2348
root = btrfs_get_fs_root (tree_root -> fs_info ,
2340
2349
BTRFS_DATA_RELOC_TREE_OBJECTID , true);
2341
2350
if (IS_ERR (root )) {
2342
- ret = PTR_ERR (root );
2343
- goto out ;
2351
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2352
+ ret = PTR_ERR (root );
2353
+ goto out ;
2354
+ }
2355
+ } else {
2356
+ set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2357
+ fs_info -> data_reloc_root = root ;
2344
2358
}
2345
- set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2346
- fs_info -> data_reloc_root = root ;
2347
2359
2348
2360
location .objectid = BTRFS_QUOTA_TREE_OBJECTID ;
2349
2361
root = btrfs_read_tree_root (tree_root , & location );
@@ -2356,9 +2368,11 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
2356
2368
location .objectid = BTRFS_UUID_TREE_OBJECTID ;
2357
2369
root = btrfs_read_tree_root (tree_root , & location );
2358
2370
if (IS_ERR (root )) {
2359
- ret = PTR_ERR (root );
2360
- if (ret != - ENOENT )
2361
- goto out ;
2371
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2372
+ ret = PTR_ERR (root );
2373
+ if (ret != - ENOENT )
2374
+ goto out ;
2375
+ }
2362
2376
} else {
2363
2377
set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2364
2378
fs_info -> uuid_root = root ;
@@ -2368,11 +2382,14 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
2368
2382
location .objectid = BTRFS_FREE_SPACE_TREE_OBJECTID ;
2369
2383
root = btrfs_read_tree_root (tree_root , & location );
2370
2384
if (IS_ERR (root )) {
2371
- ret = PTR_ERR (root );
2372
- goto out ;
2385
+ if (!btrfs_test_opt (fs_info , IGNOREBADROOTS )) {
2386
+ ret = PTR_ERR (root );
2387
+ goto out ;
2388
+ }
2389
+ } else {
2390
+ set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2391
+ fs_info -> free_space_root = root ;
2373
2392
}
2374
- set_bit (BTRFS_ROOT_TRACK_DIRTY , & root -> state );
2375
- fs_info -> free_space_root = root ;
2376
2393
}
2377
2394
2378
2395
return 0 ;
0 commit comments