From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303186; b=FCbfWAwT+gQPBTXXFimeGmjEauXoKa0dBVLdIyIqxCsfQ3Hj66kxIHvJNDvwZcxa31+5 VfZ6jyP4aXwGLmNrA6R+TlQiCD6ldGbof9kUNRQhYMAu51+Lesqua5xxLKqYOMYFvj6VI RBbKkwHPwksyjEaIhPYpU0kpB6zsihHq5fqSHpFcfzxLiFvOj62MR0T8OvPLDy+tjJctW OTiDvF0hlcOGAekba4HVrTKwoKJpFhVZFmaPUPQ5Z6NpTWPKZD28p8GE0ffrNbWIl+sy1 kibKKApy7njItYen5pqS3uYAhWOnnm6Qo1YOSW5nMGU6c3+FIBtCzuKY5r8SyNTQudg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303186; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=jfBX3rYlZ1IPDXtJ1NB70Zb00ZVrDsV4r12sY6UKNeo=; b=0vOntqsAtaIDaCA699Ui1A1aPCmtcbMuCjorblCM593jxEafLJom4SFhnJgVo+LktPgg phlsyZtUHYiRlkmh/DKnubB/J3QrElSrn47G+5v8O4rfo4P2heN2kCxrNTtVL8lMt4mmz PgqwbmNvv6ORfcHIeLiGJO612tBsIX+pDqI8btzv56lqbDT8RPAwpjw+RDcyRJUr43Ls2 QtQDkoaEA7Kx0gUQMRjup69G2I3pTIRuzVc7dLd9Zz3aCW33HESNjdHiE75Ir0p0fKtYg pCefUqLKz6VlVebiZb9R2BTrPaHggTegULQ5Pyhik9B20cSyM0J3rwUiCY1eWOYdmBA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Q7OWpD63; arc=none smtp.remote-ip=209.85.214.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 131F1606A330 for ; Thu, 3 Dec 2026 13:06:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 131F1606A330 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.a=rsa-sha256 header.s=20260707 header.b=Q7OWpD63 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f06ff94acfso72010665ad.0 for ; Thu, 03 Dec 2026 05:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796303185; x=1796907985; 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:content-type; bh=jfBX3rYlZ1IPDXtJ1NB70Zb00ZVrDsV4r12sY6UKNeo=; b=Q7OWpD634FCTmf+Mnkj0pxSLnVmzMSBiIFnSxYyWjX9nFZd2bsZSQ++CYEd9gs5FBr 9n/LU57JfxWZ1nsLp5Jb6fSZjcHGDbXJEXvPT87TOg13xVKvDQH7wedJd+94whH46UTI tDWWZ9R1BM73i32d3a9YF2Mum+a5S9/DrG9+AarrX/Yth2x13kktUUVkRu+g73k1/cPm vmxJEeEu7DSt0rHWpxqKdy1lFeCzd44rp3bQsrZSJE7cus21Sj2ygx0RzYxwDK5aBZxX vTOUcZZV2qW3bqkE2Wzk6GaUQmS7MIUtn9KltYa+vBVMI+lBz8+sQY6F58p0vWnsgWbZ l8WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796303185; x=1796907985; 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:content-type; bh=jfBX3rYlZ1IPDXtJ1NB70Zb00ZVrDsV4r12sY6UKNeo=; b=fOqTyhsYIm43XLjlW+/9znzjOIMHksn9bL5iVFClL1WvZ444b2iagD7iDEVZP4Cvg1 MJTac45uWS3e339ZAOpkuC+0bRNiKm/Y5Uw46h5lxpj+6q6uVOZtNdBB2Sk/NL/+ZDyV YKZqtPxIeSsR1ngKsrccGiIipkolj+htt0lT35hEHITz6Xsm9nP4J4MnQcKfqrQu6Gl/ M7uk0gaL3MtwZgC5UQhuoGWafcqoUr6o2JIhfsCpSAoBYUGUwAtanu4l0x9T381ss/eb B5+/PuRioLb0rUMvQ/6Fym3K3fSuOYe1zuAccyg8631y2DlLZx0DKavKePQ0NZRZUmOr Z0XQ== X-Forwarded-Encrypted: i=1; AL+hErGllPViTSG6PPqeWosq731neHBES5auYDH2MwmsFPgI908LloIj15CvA0YRMNB1OBPOASxVCDhYrqDRNzU=@vger.kernel.org X-Gm-Message-State: APuU4Z9VwEDVw4o/QL35pH127phxk/IIujXcRYofeSXQRyl8lUS6XAtN jRRMLpTng+5xfbknovQq1sPe1bj4FWaFf0wYYGBktLPqO/aZkH5mMRQ5 X-Gm-Gg: AZFdTZf3icvdl+uuxPQYC5siiQ6iGtMIDpiPN5RnjIh2iGYc3nGGlLGNUjHq1Wn/gC2 lZ3+9E+28w8MiEMd9ITQbrst0v8BWHqwhLHUriCNP6RVGvKNJdmUlI9W6MJ9cI6+TVV6U9PZVs6 GA2FoCSsm2u/lBbBOE3nzJ85fSZDUU9y9uup2n2mCHUl7pK4+s9+Z2z2MdhO4wBqqEazFE8ztC2 zKQJN3Dy3ba8RsMSa9UA2dgMnj1OQTpP8nQVMxDgDv8EJ1lRYywMl9AHU+yy1JVuNjlL9RZ6r7i uLqqto4h4RtWe7BtgOLXIR3wO2XZieuxTzP4d9Uy/ssccdo5MwQdYvkAoEfn5JPVJ9q9m5+9Qsa Q9jc+uPFcKk30jJBRwuE4UlPcyGVJDx0NHu4tAO4tVO1LTclYuJpePIK5AUBbeREoorJaxGnNfk n4/a8BDCU4BmKmf0cm+KZO0CsUsqKNk4Wtcf7Yf8y/fQ65fczRZw2IyRIzAGZdI+epqaL+a9VlF YOcTyn6WaVi0hg1uu/CVNRU6GF1a3v10WhRd1t4jjHC+t8Cxc3LPpEymU3TBlnwzR3AfUpkCLNO qZUB6scuabCbZE4qipeE53nIPg== X-Received: by 2002:a17:902:dacc:b0:2ea:19bc:2fe2 with SMTP id d9443c01a7336-2f03ef59bf0mr448851755ad.10.1796303185076; Thu, 03 Dec 2026 05:06:25 -0800 (PST) Received: from localhost.localdomain ([2404:c140:2100:6::1b:9648]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d028a54sm22209945a12.18.2026.12.03.05.06.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 05:06:24 -0800 (PST) From: Ding Feng To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: jack@suse.cz, libaokun@linux.alibaba.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, yi.zhang@huawei.com, hughd@google.com, david@fromorbit.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] ext4: fix the fast commit range of a punched hole Date: Thu, 3 Dec 2026 21:06:07 +0800 Message-ID: <20261203130608.64892-2-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261203130608.64892-1-dingf3ng@gmail.com> References: <20261203130608.64892-1-dingf3ng@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ext4_fc_track_range() takes an inclusive end block: __track_range() records end - start + 1 blocks. ext4_punch_hole() passes end_lblk, the first block after the hole, so fast commit tracks one block more than the punch removed, and it is called even when the hole covers no whole block. The extra block also wraps the length: with huge_file, s_maxbytes is 0xffffffff blocks, so a hole from block 0 to s_maxbytes records a length of 0, which ext4_fc_snapshot_inode_data() reads as no change to the file's blocks. Today the hole stops at the block that holds i_size, so only a file that large gets there; the next patch lets the hole run to s_maxbytes on any file. Track [start_lblk, end_lblk - 1], and only when blocks were removed. Keep queueing the inode for every punch, which the call at the end did for a hole within one block, by tracking the inode before the removal. Fixes: aa75f4d3daae ("ext4: main fast-commit commit path") Signed-off-by: Ding Feng --- fs/ext4/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 07a62d856..26cf00ff8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5426,10 +5426,10 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) start_lblk = EXT4_B_TO_LBLK(inode, offset); end_lblk = end >> inode->i_blkbits; + ext4_fc_track_inode(handle, inode); if (end_lblk > start_lblk) { ext4_lblk_t hole_len = end_lblk - start_lblk; - ext4_fc_track_inode(handle, inode); ext4_check_map_extents_env(inode); down_write(&EXT4_I(inode)->i_data_sem); ext4_discard_preallocations(inode); @@ -5450,8 +5450,8 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) ext4_es_insert_extent(inode, start_lblk, hole_len, ~0, EXTENT_STATUS_HOLE, 0); up_write(&EXT4_I(inode)->i_data_sem); + ext4_fc_track_range(handle, inode, start_lblk, end_lblk - 1); } - ext4_fc_track_range(handle, inode, start_lblk, end_lblk); ret = ext4_mark_inode_dirty(handle, inode); if (unlikely(ret)) -- 2.39.5