From nobody Sun Jun 14 12:45:22 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 0AEF22DAFDF for ; Fri, 3 Apr 2026 06:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775198227; cv=none; b=fa5dAiZ5rWxsR7XQQSnIkeNDUx/FngSuvmgXqfQZBhJVBGzGNRwjVudoM81u8UBdVYWR6FL7fwGDOWzgxdmID8kJJc5BiaxHbDOKMI2S04SPrHR5vm3OlsmKuZRsED0W0UGOOntEoRHuKaG5mLyeZGjTNVkPG1qgFh7chIk+YVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775198227; c=relaxed/simple; bh=MW+nOpe7n2UKOoL0mkrWaSFsQj7dl0ruGzpez/jkj18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QI3lfMYB/7S6mUneK9TndAJutSXRBVGLNsHcs2S85ThlFofxcEa9aRLSZX6fU3KG0mgDVfUnDbagBm/HUBBNizttksrfnh7POtAZfwUp3prMpPG8b7VAPjExZDApzWE862oOj4L2XgdDV/u2oWivv6RgxHacWa6jfg2gq7dGUpo= 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=DoBz54bH; arc=none smtp.client-ip=209.85.210.176 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="DoBz54bH" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-82ce09b61beso760345b3a.0 for ; Thu, 02 Apr 2026 23:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775198225; x=1775803025; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WznkZC1iLDwREmUmFRaqxDds7AGj7ZhSYjV7CeXw+YQ=; b=DoBz54bHEgjU68yDFmjw7tXEwvfKj+5ISpysJlEnqiVU4cA5spk3qW44JVc3vDaNZh aM9OgAuCUr4Z/6bdLLs6PPgUtqL8LHIODSmktC2vI5oGwAGO00dFZ0tLUnJ/JCMLVWUN 5grDSgRZ9YMMhHf2iCOOf4pOCvc4GHXivwrXsxB6ai9lisT/IlE3xSlPVFtvWpsZsF5S SrYx+JTjvWAfArUnC9p+JK+tM0kS0R3k51c9Fs30rKoDHqShIqMwRbmT+YRaCGbAdSL+ rEpM7m79HqJPlYa3q699QRdpTdfk8kR+lxiS9X6vTsotnADeca+K/JXu1EHSX3RcQuv2 oJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775198225; x=1775803025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WznkZC1iLDwREmUmFRaqxDds7AGj7ZhSYjV7CeXw+YQ=; b=lNTR/eDOSp4VqvPgurS0zswlpbciu0iVu7vWTY0Wyo1PZuX11KkU5fy20E3Y4my4b+ 9HHH7ZFxQcYPy7IWzuOT/K6BUP3n7Tt/sQWtNYAxEZXL7it+mLNfxgXZK2QOluU2I5L+ ITI2CLm9rBanz3PMvo72yekhUp+Eo0mn1d7ALufx5PCbtVV1dozKXU0XwnsbV6mkn9Pv ltu1V5s8FHr+1mpZZWGPSkXPHLbL2rsEZMO4lYrr/5fwcKH+NDzfeSM4ISsfhPmTpN76 vwdrZRjylAtLbl4tIecbjgROtLdTeDGA6UPN6eBUHW3WaL1yeji+Yh9lV4gv6HlSsVR9 gF1Q== X-Forwarded-Encrypted: i=1; AJvYcCWwL3DxvLUnPFAcfmbaLeM0gmVb58ovtvSZ40OTKZCnvp8nhmS3uJGkHiHqyLryCZhcuFkxjgk2nvTHHm8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz42wN2grdhXAmbrEh4CLnoUjAvGNMWfydRKl96e47zxAf3R875 HvI9BaPZmXNufZ93fLY0E/1JUv+1qQU6gc1ehH2z1xHMTLs8QoMtiU9bLYiFHQ== X-Gm-Gg: AeBDievjnPG5YFG6jO6tjH+QvuknOyOWIbBeu2FyL7w2sD1wWZiixMBTTOsJSUaU51/ um4ZlFRTbK9hHJuYzLMPqQE8CqxerD2qQRkNNFSK2udQAi23/GwM/40KuhBewtsa6uv4aaJ07vE Y5e12mxYc1PrkzLVNOxj7qjnH6as+NWbBIlMDa5+rx5s71pzCje/J4RlhV98TFGnvCo74gHbLrz EZM4ZP1oMloMi1KuLpkCvGSA1gdnCuzLFLH7z/j+ET8Xwqtuj+u56qXb3FvFR5NaRb2KPXyqQKy gTUfhuy0p7nHANEhqkpCkrYliEFOy6Pmz132t9+nPY1ovov4bsVURcoP88vC1bcq5oP1gU2r7Q8 lNM9Q02P0DOwK5KcXByWI6bv0junYQL3dRy4x4W9L+Y55GJg8EmwbiREX+y2HcsHXeS3KUoEz3v QXCqUDqHkGIFLO1OfuEAP+WABM2iloUkFZFzyU4msevPFNNpo= X-Received: by 2002:a05:6a00:234a:b0:82a:6167:b1ae with SMTP id d2e1a72fcca58-82d0da8f2b9mr1989714b3a.24.1775198225286; Thu, 02 Apr 2026 23:37:05 -0700 (PDT) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.237]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b5fb22sm6418466b3a.26.2026.04.02.23.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2026 23:37:04 -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 , Gao Xiang Subject: [PATCH v2] erofs: handle 48-bit blocks/uniaddr for extra devices Date: Fri, 3 Apr 2026 14:36:58 +0800 Message-ID: <20260403063658.72140-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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. Also fix the erofs_deviceslot on-disk definition where blocks_hi was incorrectly declared as __le32 instead of __le16. Fixes: 61ba89b57905 ("erofs: add 48-bit block addressing on-disk support") Suggested-by: Gao Xiang Signed-off-by: Zhan Xusheng Reviewed-by: Gao Xiang --- fs/erofs/erofs_fs.h | 4 ++-- fs/erofs/super.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h index b80c6bb33a58..7871b16c1d33 100644 --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h @@ -44,9 +44,9 @@ struct erofs_deviceslot { u8 tag[64]; /* digest(sha256), etc. */ __le32 blocks_lo; /* total blocks count of this device */ __le32 uniaddr_lo; /* unified starting block of this device */ - __le32 blocks_hi; /* total blocks count MSB */ + __le16 blocks_hi; /* total blocks count MSB */ __le16 uniaddr_hi; /* unified starting block MSB */ - u8 reserved[50]; + u8 reserved[52]; }; #define EROFS_DEVT_SLOT_SIZE sizeof(struct erofs_deviceslot) =20 diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 972a0c82198d..802add6652fd 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -129,6 +129,7 @@ static int erofs_init_device(struct erofs_buf *buf, str= uct super_block *sb, struct erofs_fscache *fscache; struct erofs_deviceslot *dis; struct file *file; + bool _48bit; =20 dis =3D erofs_read_metabuf(buf, sb, *pos, false); if (IS_ERR(dis)) @@ -175,8 +176,11 @@ static int erofs_init_device(struct erofs_buf *buf, st= ruct super_block *sb, dif->file =3D file; } =20 - dif->blocks =3D le32_to_cpu(dis->blocks_lo); - dif->uniaddr =3D le32_to_cpu(dis->uniaddr_lo); + _48bit =3D erofs_sb_has_48bit(sbi); + dif->blocks =3D le32_to_cpu(dis->blocks_lo) | + (_48bit ? (u64)le16_to_cpu(dis->blocks_hi) << 32 : 0); + dif->uniaddr =3D le32_to_cpu(dis->uniaddr_lo) | + (_48bit ? (u64)le16_to_cpu(dis->uniaddr_hi) << 32 : 0); sbi->total_blocks +=3D dif->blocks; *pos +=3D EROFS_DEVT_SLOT_SIZE; return 0; --=20 2.43.0