Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: btrfs error(dev extent physical offset is beyond device boundary) when mount
Date: Sat, 18 Oct 2025 21:01:58 +0800	[thread overview]
Message-ID: <20251018210157.268D.409509F4@e16-tech.com> (raw)
In-Reply-To: <20251018064727.9E9B.409509F4@e16-tech.com>

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


  reply	other threads:[~2025-10-18 13:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-10-19 11:37 ` Wang Yugui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251018210157.268D.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox