From nobody Sat Jun 13 09:19:21 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 DC6B93CCA1E for ; Fri, 8 May 2026 09:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778233974; cv=none; b=EjYSkb5/lEoOl5Fq+oyVs+OdJd+7mXgz9nIsuM+GNTaMKMq2kG3dvycikKWPg6VxqSLJPOPdzzTCmaTJ234mqt+dRgm5lNxaSfgRwWcJCajFts24ishLFMB/MIijub8dwW3s7KbjpO4FmPuWqb7lEi8D6qnW77HPSKormkyOiDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778233974; c=relaxed/simple; bh=bids4gV80ewu5muoOn/XudEANMsNY9yAl2etnxektHQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PcSyw3rUqYBw5wY3A6jcMGcs4wBxwK3dubFO7VkVPyeqxPY6ABFE4Aee8wqjyiOQrZuv6dP6RvmY8/SFNvwRKaOQGZzZzGKCuByJqu8NjbixGpwmg8flb8WyFcjeC00RUV9LhqvxPXLwssHd1jSCRvjf2QDGPQ8PJ6Mx7UVLACI= 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=htgRpWgr; arc=none smtp.client-ip=209.85.210.177 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="htgRpWgr" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-83945063f70so1319085b3a.0 for ; Fri, 08 May 2026 02:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778233971; x=1778838771; 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=7Vk+/FfSN7bI/zuuvZaTjfE0BzpCHebHCaKRSWm4BhE=; b=htgRpWgrO2qvxC+mh0ATwgEwU7t/rMaJf0fi/ld8AOW4ilZhO/Z0Auc2A/iWjLz1VU 7RXDHPEK9inFHZjVptFWOcj7nEpStbva7B2nQRb9V7RaCzmZQrU5EzV7w/dtg+s1D7TT LzvM5yCH09dYXkdqrPohbWhVa5qPlzzgoiY2eMgZZnPcmuCMl93c4fVljIvOIDT4Vuqq 5UCxiSCUgRLialNM4jg24FqZpju3LcBgQR30pikmh3QCkv2sZR7OrQbbHKxueE2Ns15p dz0P/LL5oiaw8R1oMClyYvECeThmnq5gwkvfVzs8Az9zemjzNpIatrZu7G4+kQi16R3f qDbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778233971; x=1778838771; 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=7Vk+/FfSN7bI/zuuvZaTjfE0BzpCHebHCaKRSWm4BhE=; b=kMbQXhEvt5JAjureV0xdU2oShsx2x4pBmuEvq5Fui2HdRzQnbMyu6yHOCc87/+CRjZ cQtwYXorspZmWMg2U9zU+tGIVaOwTF2LH7CgIQpWqEIaprUKD3ycx1vedNHCNeXBtyc8 YJqMIAUtvQAMUrpzHxZJXl0EklIMnOc90ke3Y2MdGWBDvNanXuvuSWx6d2OQOQ0iLqLh 48XAshqFiX1gSLl2uspzDEvDTVreywL60renmTteBxhgfw2At07MTqhGLFyGXhd/qSNY pRSXmpnVrtVYl6TgC9/da7uESt8GiHIWr8P9MJIvR9VqSX380wzQ5IQkoiiIAIiqxHFS 1fvA== X-Gm-Message-State: AOJu0Yzxy62hrPtuFQ5d2veawdnmvhHRrbJMwifVDGtZ8Gs55Q2PuWbd Gb8AMko/BDYOCnEynSoBmxbLbRb+mwTKhnkyoLGirejN813PyRbVZtkZ X-Gm-Gg: Acq92OFAV2KzwQGOiaY/q1fIjJa0RQpKz2R2SYirx4+HhqIuhNHRPEwlfOEe5izrfug GXbzXeReqH8gWhhhk1uUsL13dIhfX+qRd/iB5rKeEKdmn70Iu7e08nii3QBQs1vKONhcwRkqzXS RWpB25978oVmUyDem1FEkXfE5Kb1yZrDVgMSjIf3WTquUhEP+xVLAkDb4JE1YmwSODlGrHotwXi hRscwJUlP7Y6SAIAz2feSkUVJXfny46e7m3UV5y0sCwg3r85n0+4s37+9Jj1BcnLoTL6T/ZqGh8 K+pK7mT8JAQTu67dY1nFIgecUjdWezFYOJD6yPTnTPmnLM4rmSg3CCak9+m1SJTVYbHBfGQ48u+ s5Zh36KnuO8aKY+DN9r8k7CyykNnJhQ4oGMo4LsWx3q2tf0rQ4Z8nNQZid5FAlHg6md2Azdm8T5 jl/SnllGWsJJ/FPxwZtgTyEnPWKqP0V7ca2EjceeVNjPfWrI7byH8s3tQFTQ== X-Received: by 2002:a05:6a00:4213:b0:82f:456c:29f1 with SMTP id d2e1a72fcca58-83bb6cd6beemr5463709b3a.12.1778233970491; Fri, 08 May 2026 02:52:50 -0700 (PDT) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.246]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83967dbf0cesm14871946b3a.46.2026.05.08.02.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 02:52:50 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Konstantin Komarov Cc: linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH] fs/ntfs3: fix wrong LCN in run_remove_range() when splitting a run Date: Fri, 8 May 2026 17:52:45 +0800 Message-ID: <20260508095245.78254-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" When run_remove_range() removes a middle portion of a non-sparse run, it splits the run into head and tail parts. The tail is inserted via run_add_entry() but uses the original r->lcn as its starting LCN instead of advancing it by the split offset. For example, removing VCN range [10, 20) from a run {vcn=3D0, lcn=3D100, len=3D30} should produce: {vcn=3D0, lcn=3D100, len=3D10} (head) {vcn=3D20, lcn=3D120, len=3D10} (tail, lcn advanced by 20) But the current code produces: {vcn=3D0, lcn=3D100, len=3D10} {vcn=3D20, lcn=3D100, len=3D10} (wrong: points to same physical cluster= s) This creates overlapping physical mappings in the in-memory run tree, which can corrupt cluster allocation decisions and lead to data corruption. The correct pattern is already used in run_insert_range(): CLST lcn2 =3D r->lcn =3D=3D SPARSE_LCN ? SPARSE_LCN : (r->lcn + len1); Apply the same logic in run_remove_range(). Fixes: 10d7c95af043 ("fs/ntfs3: add delayed-allocation (delalloc) support") Signed-off-by: Zhan Xusheng --- fs/ntfs3/run.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c index 1ce7d92fb274..cca6bdf2e7aa 100644 --- a/fs/ntfs3/run.c +++ b/fs/ntfs3/run.c @@ -1292,9 +1292,12 @@ bool run_remove_range(struct runs_tree *run, CLST vc= n, CLST len, CLST *done) =20 if (r_end > end) { /* Remove a middle part, split. */ + CLST tail_lcn =3D r->lcn =3D=3D SPARSE_LCN ? + SPARSE_LCN : (r->lcn + (end - r->vcn)); + *done +=3D len; r->len =3D d; - return run_add_entry(run, end, r->lcn, r_end - end, + return run_add_entry(run, end, tail_lcn, r_end - end, false); } /* Remove tail of run .*/ --=20 2.43.0