Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* btrfs error(dev extent physical offset is beyond device boundary) when mount
@ 2025-10-17 22:47 Wang Yugui
  2025-10-18 13:01 ` Wang Yugui
  2025-10-19 11:37 ` Wang Yugui
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Yugui @ 2025-10-17 22:47 UTC (permalink / raw)
  To: linux-btrfs

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 (wangyugui@e16-tech.com)
2025/10/18



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: btrfs error(dev extent physical offset is beyond device boundary) when mount
  2025-10-17 22:47 btrfs error(dev extent physical offset is beyond device boundary) when mount Wang Yugui
@ 2025-10-18 13:01 ` Wang Yugui
  2025-10-19 11:37 ` Wang Yugui
  1 sibling, 0 replies; 3+ messages in thread
From: Wang Yugui @ 2025-10-18 13:01 UTC (permalink / raw)
  To: linux-btrfs

Hi,

> 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?

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);'

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 91b19d6..c8c6a3d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -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 (wangyugui@e16-tech.com)
2025/10/18


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: btrfs error(dev extent physical offset is beyond device boundary) when mount
  2025-10-17 22:47 btrfs error(dev extent physical offset is beyond device boundary) when mount Wang Yugui
  2025-10-18 13:01 ` Wang Yugui
@ 2025-10-19 11:37 ` Wang Yugui
  1 sibling, 0 replies; 3+ messages in thread
From: Wang Yugui @ 2025-10-19 11:37 UTC (permalink / raw)
  To: linux-btrfs

Hi,


> 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?

this seems a realated bug-fix. but not sure whether it fix the root cause.

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 2bec544d8ba3..a8c2389012af 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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 (wangyugui@e16-tech.com)
2025/10/19



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-19 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 22:47 btrfs error(dev extent physical offset is beyond device boundary) when mount Wang Yugui
2025-10-18 13:01 ` Wang Yugui
2025-10-19 11:37 ` Wang Yugui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox