From nobody Sun Jun 14 12:45:21 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 032C64315A for ; Fri, 3 Apr 2026 03:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775187258; cv=none; b=q1FH8rCCid7L+h4PalcRqXcS0CLxUXcWiGnl+jO4OP46Gp2xsAbJewNS99pn4mz43nb9LWc1dPNvDsyJZgfe/LqqqvAuaGJBDR8tLPbnpkpBl9pwrGBvj/05x4a8Dp86x9euNMdxEvf6716Wf9GQ14ybypUlSuyCWlJEkBNCO+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775187258; c=relaxed/simple; bh=rHj3+jTHvBKjwk5TUzM/qwtrzUgCZk+JAWfEnm7jvFk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OoHl5/kVkbbx0Lzq5LrWVRYo8I6tCkiJSmsXbrt9rGa3fgbBJkhM5Rr9R36g8/KBqnKom1OC+uhDYHokJJK3jNLXauWIxbcKpGA0+zR/cG2eVyZvlpX133Yubc9zZHGSuBGvuM0M8/F1Ov9B0Uh/MtVZ5dxBdQ69nPtoaLRcH4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b1pb/QlD; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b1pb/QlD" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-35da9692ec3so1433008a91.1 for ; Thu, 02 Apr 2026 20:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775187256; x=1775792056; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MLJOW2uio0l4V1rabuDMkmWkdxrZh2Qy/LsLVe1bvVs=; b=b1pb/QlD/Q/Z6UQCQPE1k/tEEI2/Fu4fvP0AwcHbUuVo1INgwgJK16crwoc3cxCrPj wDHZqVHG+KptIfmEfj8qcAFXRtox01N2env+GrZsq3GP/o2LEzjjPcdV3apWCg1/UZY4 PzZ6o9EL03BEJIXT0vQK5ReLZn8eyMgCt4uAvmDEkQFzRGpOkEr4cal2IdYzSc7UXVTT 3Z7Kro3e0xCKQBdk0kd9ZdjxJiK+O1Moo9oXtCEigxLfKbmhi2d8YNOzj9W1LFVxxz04 aXd7r4z2eQ0pbVoUNpJAX8/uBr4UB8/Lvhv2L98MpozUoQKJrJUgMSvhLHsYNnpBDWqT 1xkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775187256; x=1775792056; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MLJOW2uio0l4V1rabuDMkmWkdxrZh2Qy/LsLVe1bvVs=; b=GVkKRxdNPsG/ba0FgMZ45nqhzNtqgGhdmzgEmL2p88sKmIS9pWTqxEkP0LneRgupdc OTxKTJkQSd98zswrGza2GWEtWScuFiqnR22ZBYSFjcKWCIh9+/iFhk5Tn3bnbz2q4SBQ zDDh3I+2DEmseY6rmOUygMPsDh5VJ7ESZOt1OHA2tCFIFU+1ef1D05CRHXFfBTBTHRhd 2LSD8UXltCW/6WGYnplIW1A/VeX4xzp+aaFhPlYIN+uChUcykJq+kEyCoLwqtzp61Yjb RUATdI+oMPiySV5dgsQIX7URsJ+Rol7mVP7PHCKmUsJHfZfjF/n2nz85b3VrUno4RIBy z2qA== X-Forwarded-Encrypted: i=1; AJvYcCVTzrdlRjep5kOXTpHWyBRgcHiO2uLrPhC91gNJzHK1jPTx63DJbS6uO9CUAAuaV2DsUS2ma1xZcCYCzD8=@vger.kernel.org X-Gm-Message-State: AOJu0YzWvqlfuRSPDRRV4e5nYF3Jclno/zfL1dMLcfCsIzoz0NLhzDIL 0w/quLKMNPkFacV22ZLQTmNNq30QH9NWPeYV5qCb1XqHAbFL2TG3HPB1Y+MK2Q== X-Gm-Gg: AeBDiev45V202nk6miW8H/fvyb7fFlEeoxANRXcw5/eYb3v+5uO/3FaA4j7gd3vT9cb sG2NPolxvGnpSBKN2XIZzAXrJx9YzJJR1JFUu3RYtXGBaLYXDvyfXPJ1SIMznKISAkM3CdE7+DD MNxELVOSwPNvDLWxtxpYFgkESHjG7guWavDQqqdgBLXio4BDAeNNX7QMaUjCXe5IaDnZSTSu7rO 7sxYYeziCX7fBUKcOHo5l6r+UFCj8E0b32FZX6fyww385qeJqpbjAg/7JpC93xvZpWvDcx0Ew9k yJ8+iMahronEyTosMwD6+lTctwq43jTM3UBVtylCp16IVS5/DHrdlKXkjKFbw93osUMSl9k/WbW /WtwdkWNoBbTPJtgcB+DZxLu2CbZOIQ21CiX0+xm6noKAFFJxMnoE6pPmp10821RDTKqX+o2gq8 qQ2ItwPR2oMtBTcSixsScC5RvIjDTZAoJHGiGEAWkDbI0zlWQ= X-Received: by 2002:a17:90b:5104:b0:35d:9efd:7956 with SMTP id 98e67ed59e1d1-35de6844943mr1470065a91.11.1775187256260; Thu, 02 Apr 2026 20:34:16 -0700 (PDT) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.237]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35dbe95abc3sm10230843a91.15.2026.04.02.20.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2026 20:34:15 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Gao Xiang Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH] erofs: handle 48-bit blocks/uniaddr for extra devices Date: Fri, 3 Apr 2026 11:34:09 +0800 Message-ID: <20260403033409.70704-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" erofs_init_device() only reads blocks_lo and uniaddr_lo from the on-disk device slot, ignoring blocks_hi and uniaddr_hi that were introduced alongside the 48-bit block addressing feature. For the primary device (dif0), erofs_read_superblock() already handles this correctly by combining blocks_lo with blocks_hi when 48-bit layout is enabled. But the same logic was not applied to extra devices. With a 48-bit EROFS image using extra devices whose uniaddr or blocks exceed 32-bit range, the truncated values cause erofs_map_dev() to compute wrong physical addresses, leading to silent data corruption. Fix this by reading blocks_hi and uniaddr_hi in erofs_init_device() when 48-bit layout is enabled, consistent with the primary device handling. Fixes: 61ba89b57905 ("erofs: add 48-bit block addressing on-disk support") Signed-off-by: Zhan Xusheng --- Note: erofs-utils also needs corresponding fixes for the write path (erofs_mkfs_format_devices) and a swapped hi/lo read in erofs_read_superblock, which will be sent separately. --- fs/erofs/super.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 972a0c82198d..a04e70ef4fcc 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -177,6 +177,10 @@ static int erofs_init_device(struct erofs_buf *buf, st= ruct super_block *sb, =20 dif->blocks =3D le32_to_cpu(dis->blocks_lo); dif->uniaddr =3D le32_to_cpu(dis->uniaddr_lo); + if (erofs_sb_has_48bit(sbi)) { + dif->blocks |=3D (u64)le32_to_cpu(dis->blocks_hi) << 32; + dif->uniaddr |=3D (u64)le16_to_cpu(dis->uniaddr_hi) << 32; + } sbi->total_blocks +=3D dif->blocks; *pos +=3D EROFS_DEVT_SLOT_SIZE; return 0; --=20 2.43.0