From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307349; b=drTGTTofxzzOiXU2GeOxgcKh7XbcDAXFtO6W739jmHwMFxTUG9DZvjfNZbjldulg33+o vgcns6ZsuUXR/eYljk7CRoJ5QUKXCIuOAdmMrVYrel1Z8h1k8r2pfEfK08KwL5G1tUZQe d50+6ScULBTWDqVORre+kv5ODBlJthd9neG6R9RLbj5XgZ/RrLcy+1L7Tg8UtX742ItQA yx7jjVeADigEeOWlmODtLKXLAMZGcLotIdiYRsfApXlHLbXvednCejOegb1BqnJoFzeSD No8v9IeurGE6powIqvVa4KnUgVIawrxQEOP1j/8jIRi+YQF/gXxf6Oa7Z7Cae5z2UOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307349; 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:MIME-Version: Content-Transfer-Encoding; bh=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=DAb43fmGTZgBiQzeBhgjW6XMnM4EJJvZAQFRXQnqeszigQjaCBjltt9iJ31E4Is4R7BV h0HmthrNpDDZL+LGepBtgNwRSSqGOwqkojbPnXe0M10R+f+KrcfWlwflOQsGejMyVdDS+ 92WKYdkOtm1NqRj+sQh85WBC65iWqjbBXFTL69XieZaNCyeeZjefvD4ebG8sghR0qzMeJ P71QuwB2A/4oOG55vNLIzzIJnCALgSmAcvIR9/Vzy+k4ZnMKQxqLxomoztFGbJCkrH0rE B6mFR3aVXPrhjz1iSI6St1aaMlVeGt9GXWm5Egi6YQZjAEDx12nXgDSVW1VN6adoyvw== 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=kvbyEE8B; arc=none smtp.remote-ip=209.85.215.172 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 58B06606A32D for ; Thu, 3 Dec 2026 14:15:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 58B06606A32D 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=kvbyEE8B Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-ce1186c9e40so313180a12.0 for ; Thu, 03 Dec 2026 06:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796307348; x=1796912148; 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:content-type; bh=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=kvbyEE8Bzrp4NiVilhpHepx7x+qy69DDGB1vv3UGZHFkWLdahGKXxh+szI4mLSrJAL K+lyZZQB7N6nZhIa+1RE7KthBMg6hghr5ZK23AUwfPEmi0iDmk4ZpYtrroJWXR71XdTZ sY9Emgne8KfO1+uvGvJLDTeR1j7ofYwAtNysdpkIXoY6UKPH/AOKQoi4TlxXTxL1R5+L TPohzZ6uFaTfG5jUE60yllDMpmR1IAeeBVXzlrephLWy6XU51Q7QRFcCwzrqWV+WqCYK GPabw1SZkBeZdAISmHcolcKuORDiqGYKOwOdP7xEKHO1LHSr6GcpClnH1KoiTRshM0l7 jcEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796307348; x=1796912148; 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:content-type; bh=ix5RjfvCQDa2D180z7yTQDxPH5erfyMFjVQKBMifXb0=; b=I0jVBayppvGUyeaKWGsIsojmb11mxJXkXB8XFTZgknOSArvBxh1yWq1NHiGH5HoS2n A8kagikC+quA4P4uaAf8tta/FOZaDBhGdLMcTQXUElc5Pt02UU8gP7QEjhafQhJ1Lyga VJDC3RYEAwtdI88JtXpDH3XBlb3sGGgrJGA9Alzy97oKbSaqr0PUfXwDf+cn6iYxG6Df zD2gdqc7wbqm2kQtL3ZaSv6FhTIUHrvl0xMqxfKkMWyhnKPYe6GBFAFgV2xIUj1rk2So P46mfvzayrQL/M8Wuv2iYA1rXirPOgmQ+LaE3Q2BqQATqOVdU/aYikkd6Fd3ax8NdmQ1 wsiw== X-Forwarded-Encrypted: i=1; AL+hErG8zL+0NrVwKRvEo1jBiZRvG78kdz/APIjFkON/4ltA+z86MsqWpjK3EX/kyVg/91vHAxgeM2PrIFYvFFI=@vger.kernel.org X-Gm-Message-State: APuU4Z/MxV/o2pxAH20tKcNvmalReL9WqwtrkHU3A2fYPUst+g7dJmBo YevUSM/fjcfHhv5b9xNHVDZegUwAejQHKmmz1UExTe449C6Lgx8j5kWl X-Gm-Gg: AZFdTZdrVMiqD5R2vpuCcjpxCCkZxxnZFVCkPR8jtDQp3eC/FuTe2HkiaTS3/xbSc7r JucgGWRiPrRa5eqgMJ202PqLvXowwOd9MxzYA8M0vE4xA/AJllkNm8UJ7kVhptAhROoWaqvgA3i qiKpyNvHaln7ZHYMp0Fp5tuUNjE+wcfZokAupJsADgb/ITP7b3YdzXqOzm4Va9Bp1p37UP4sDj2 624bgjXXTinsxTS8zTUvYNn+lIt0QUHsa8ddhMSjI/MAlvWBZvesAY5GapfancJd0wYRGmwEJlB 987MsXykNssJK3gpwKthgckmpFCuAwJCJoBmcqezqPWuD0aaIFD32SUhZb6m1S6y7DaKFKKAIdx 9WeTNNij5p5mFAwbqyklOFXF6JVKPUc9QLGtjduJg7nkFRA5Z16wCZfprFbkRbD3LvoI7pDt6Hz NfSSfA+H+psr9s2klTzgQf4OXJu8tMH5Yu7EoITJNG5CMgTeZx/EtSfx9+1KNF3R0IGZauBZt8g PkiBmbMrL9bijKqD0I7bcxnA4C8hjjLfSVDbrJyFyAgZxI6lrHndXV/EiziyWEBDu9GIN74ub6z PYOLm1yskgUyuxVWTW3RcZCwT2YTMupZ1jsRMAoPAKCadcU6h+M2ajCPFfqM X-Received: by 2002:a05:6a21:3a41:b0:3fa:caf6:a7 with SMTP id adf61e73a8af0-4014e74d619mr45248290637.67.1796307348396; Thu, 03 Dec 2026 06:15:48 -0800 (PST) Received: from localhost.localdomain ([64.118.140.61]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d03adafsm24544845a12.23.2026.12.03.06.15.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 06:15:48 -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 v4 0/2] ext4: punch hole beyond i_size Date: Thu, 3 Dec 2026 22:15:34 +0800 Message-ID: <20261203141536.52700-1-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 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 cannot punch out blocks that FALLOC_FL_KEEP_SIZE allocated past EOF: ext4_punch_hole() returns early for a hole that starts at or past i_size, and ends any other hole at the block that holds i_size. Patch 2 lifts that limit. Patch 1 fixes the range the punch records for fast commit, which wraps to 0 once a hole can run to s_maxbytes. Changes since v3 [1]: - Patch 2: call ext4_update_disksize_before_punch() only for a hole that starts below i_size (Sashiko [2]). Since v1, a punch at i_size moved i_disksize up to i_size ahead of writeback: after a buffered 1 MiB append, a punch at 1 MiB and a journal-only shutdown, v3 brought the file back as 1 MiB of zeros; v4, like v7.4-rc5, brings it back empty. - Patch 1: leave ext4_fc_track_inode() where it was. v2 and v3 moved it out of "if (end_lblk > start_lblk)" so that a hole within one block would still queue the inode, but ext4_mark_inode_dirty() queues it on every path, so the move changed nothing. - Patch 2: the changelog and a comment said that nothing past EOF is written and that the EOF block is freed. A hole that starts inside the EOF block zeroes it to its end and keeps it, as before; both now say so. The KUnit case "Punch past i_size is a no-op" is reworded to what it checks. Changes since v2 [3]: patch 2 keeps rounding a hole that reaches i_size up to the end of the EOF block, so the EOF block is still freed. Changes since v1 [4]: patch 1 is new; with v1 on a fast_commit filesystem, punching [0, s_maxbytes), fsync and a shutdown brought the punched data back after replay. Patch 2 zeroes nothing for a hole that starts past i_size and cites Fixes: 2be4751b21ae. Tested on v7.4-rc5, x86_64 under QEMU: - fstests -g punch on ext4 with 4k and 1k blocks: generic/042 fails with and without the series, nothing else fails. On ext4 without extents the 8 punch tests that run without falloc pass. - generic/811, "generic: punch a hole past EOF over preallocated blocks" [5], fails without the series and passes with it, on ext4 4k and 1k; it passes on XFS. - ext4 KUnit: 538 pass. W=1 adds no warnings. - The i_disksize and fast commit crash checks above, a 5000-byte file punched over [0, 5000) and [0, 6000) at 4k and 1k blocks (the EOF block is freed), and punches past EOF on indirect-block files (e2fsck clean). - Not tested: bigalloc, block sizes above 4k, DAX. [1] https://lore.kernel.org/all/20261203130608.64892-1-dingf3ng@gmail.com/ [2] https://lore.kernel.org/all/sashiko-outbox-247862@kernel.org/ [3] https://lore.kernel.org/all/20261203115201.48810-1-dingf3ng@gmail.com/ [4] https://lore.kernel.org/all/20261203091435.73786-1-dingf3ng@gmail.com/ [5] https://lore.kernel.org/all/20261203115229.50163-1-dingf3ng@gmail.com/ Ding Feng (2): ext4: fix the fast commit range of a punched hole ext4: punch hole beyond i_size fs/ext4/inode-test.c | 2 +- fs/ext4/inode.c | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) -- 2.39.5