btrfs error(dev extent physical offset is beyond device boundary) when mount
Hi,
btrfs error(dev extent physical offset is beyond device boundary) happened on a brtfs file system with 3 disks when mount.
dmesg:
dev extent devid 3 physical offset 719991138680832 len 1073741824 is beyond device boundary 719992211374080
719991138680832+1073741824(1G)-719992211374080=1048576(1M) 719992211374080=670545 * 1024**3 = 670545 G
This is a hardware RAID device, so the size of this disk is just SZ_1G * 670545,
not like physical disk with the size of SZ_1G * N + some small value
and this btrfs are running on kernel version is 5.15.y and then 6.1.y.
Any advice about why this chunk was alloced beyond device boundary?
- Is it BTRFS_DEVICE_RANGE_RESERVED(1M) related?
- Is it multiple disks related?
Best Regards
Wang Yugui ([email protected])
2025/10/18
Hi,
Quoted 13 lines
Hi,
btrfs error(dev extent physical offset is beyond device boundary) happened on a brtfs file system with 3 disks when mount.
dmesg:
dev extent devid 3 physical offset 719991138680832 len 1073741824 is beyond device boundary 719992211374080719991138680832+1073741824(1G)-719992211374080=1048576(1M) 719992211374080=670545 * 1024**3 = 670545 G
This is a hardware RAID device, so the size of this disk is justSZ_1G* 670545,
not like physical disk with the size ofSZ_1G* N + some small value
Quoted 5 lines
and this btrfs are running on kernel version is 5.15.y and then 6.1.y.
Any advice about why this chunk was alloced beyond device boundary?
- Is itBTRFS_DEVICE_RANGE_RESERVED(1M)related?
- Is it multiple disks related?
although the following fix will make code more easy to read, but it is not a real BUG.
# no result change in 'rounddown(avail_space, BTRFS_STRIPE_LEN);'
fs/btrfs/super.c +3 -3
@@ -2273,6 +2273,8 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,break ; avail_space = device->total_bytes - device->bytes_used; +ASSERT (avail_space >=BTRFS_DEVICE_RANGE_RESERVED ); + avail_space -=BTRFS_DEVICE_RANGE_RESERVED ;/* align with stripe_len */ avail_space =rounddown (avail_space,BTRFS_STRIPE_LEN );
@@ -2281,11 +2283,9 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,* Ensure we have at least min_stripe_size on top of the * reserved space on the device. */ -if (avail_space <=BTRFS_DEVICE_RANGE_RESERVED + min_stripe_size) +if (avail_space <= min_stripe_size)continue ; - avail_space -=BTRFS_DEVICE_RANGE_RESERVED ; - devices_info[i].dev = device; devices_info[i].max_avail = avail_space;
Best Regards
Wang Yugui ([email protected])
2025/10/18
Hi,
Quoted 13 lines
Hi,
btrfs error(dev extent physical offset is beyond device boundary) happened on a brtfs file system with 3 disks when mount.
dmesg:
dev extent devid 3 physical offset 719991138680832 len 1073741824 is beyond device boundary 719992211374080719991138680832+1073741824(1G)-719992211374080=1048576(1M) 719992211374080=670545 * 1024**3 = 670545 G
This is a hardware RAID device, so the size of this disk is justSZ_1G* 670545,
not like physical disk with the size ofSZ_1G* N + some small value
Quoted 5 lines
and this btrfs are running on kernel version is 5.15.y and then 6.1.y.
Any advice about why this chunk was alloced beyond device boundary?
- Is itBTRFS_DEVICE_RANGE_RESERVED(1M)related?
- Is it multiple disks related?
this seems a realated bug-fix. but not sure whether it fix the root cause.
fs/btrfs/volumes.c +2 -2
@@ -5268,8 +5268,8 @@ static int gather_device_info(struct btrfs_fs_devices *fs_devices, test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) continue; -if (device->total_bytes > device->bytes_used) - total_avail = device->total_bytes - device->bytes_used; +if (device->total_bytes > device->bytes_used +BTRFS_DEVICE_RANGE_RESERVED ) + total_avail = device->total_bytes - device->bytes_used -BTRFS_DEVICE_RANGE_RESERVED ;else total_avail =0 ;
Best Regards
Wang Yugui ([email protected])
2025/10/19