@@ -1277,7 +1277,7 @@ struct zone_info {
1277
1277
1278
1278
static int btrfs_load_zone_info (struct btrfs_fs_info * fs_info , int zone_idx ,
1279
1279
struct zone_info * info , unsigned long * active ,
1280
- struct btrfs_chunk_map * map )
1280
+ struct btrfs_chunk_map * map , bool new )
1281
1281
{
1282
1282
struct btrfs_dev_replace * dev_replace = & fs_info -> dev_replace ;
1283
1283
struct btrfs_device * device ;
@@ -1307,6 +1307,8 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
1307
1307
return 0 ;
1308
1308
}
1309
1309
1310
+ ASSERT (!new || btrfs_dev_is_empty_zone (device , info -> physical ));
1311
+
1310
1312
/* This zone will be used for allocation, so mark this zone non-empty. */
1311
1313
btrfs_dev_clear_zone_empty (device , info -> physical );
1312
1314
@@ -1319,6 +1321,18 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
1319
1321
* to determine the allocation offset within the zone.
1320
1322
*/
1321
1323
WARN_ON (!IS_ALIGNED (info -> physical , fs_info -> zone_size ));
1324
+
1325
+ if (new ) {
1326
+ sector_t capacity ;
1327
+
1328
+ capacity = bdev_zone_capacity (device -> bdev , info -> physical >> SECTOR_SHIFT );
1329
+ up_read (& dev_replace -> rwsem );
1330
+ info -> alloc_offset = 0 ;
1331
+ info -> capacity = capacity << SECTOR_SHIFT ;
1332
+
1333
+ return 0 ;
1334
+ }
1335
+
1322
1336
nofs_flag = memalloc_nofs_save ();
1323
1337
ret = btrfs_get_dev_zone (device , info -> physical , & zone );
1324
1338
memalloc_nofs_restore (nofs_flag );
@@ -1588,7 +1602,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
1588
1602
}
1589
1603
1590
1604
for (i = 0 ; i < map -> num_stripes ; i ++ ) {
1591
- ret = btrfs_load_zone_info (fs_info , i , & zone_info [i ], active , map );
1605
+ ret = btrfs_load_zone_info (fs_info , i , & zone_info [i ], active , map , new );
1592
1606
if (ret )
1593
1607
goto out ;
1594
1608
0 commit comments