From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796289299; b=GGFwt3fZiWMg3x/ju+QniryFmbG9xrJX/n21E2CrrqthOHN6mSPjRBkaj1PRGZWWhEBQ hFxKa2Z/gG73hluTFMOFQbE3EmW5OQ3RUwigfFKFuHeFxqwBhzWuw7htKQjSo/IzHRDv9 EsNzr/WdR1FfsqAIJxfzMzCCf2zHcN4i9fn3lwEFsUFis2qmOhYgwbuIVzDAVCvAlYRwR pqbGr22OBo2ySV2EL7jN3wHvrPKeaYD7jVCU6zbqkDmj5wwILJeRYV/RjDaiqAFGL09d0 t79kpP2NavbGm+oRICAz6T7zxb5/LYOSBdmCPo/3mSVcBGhoVqjyzTBW2p0CLgn/qQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289299; 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=zJTtf7f3oT9L8aJOH8eJIdIU3NQ4LxKj3oqYUgbo0pU=; b=EasOpLr3d276k41F3KqQJv3FfLNVJUVnxpRoAwEcATb91YYaR3VdBPHaTtybLHwtnzuh DErUZ2S5183iioSg2qrd7ifmb9H+KAZqqFRRC0w5ZmQq0yiGerjnGSR8PTsl5WV1pq1A5 TG9i8os+1Wg/WFnJideQQp0g1Rd0YPFZQs8pkzMl5GJj/v5asQlcceU3GWp/lw09/pUp7 XF7M/h57XUCi+YGCuj3SohE0heJx6MTJlMDShcw4ovjwHwmsvPF+YnbfHNEOU+6FymMWU QbKrHxRjCe06e+4W255mA4UyDxTdQiZMXLFxVsP+bGLqe/lkLd5Sj2FWa5sfyezt8kw== 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=cxVms1ju; arc=none smtp.remote-ip=209.85.215.173 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (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 EB258606A32C for ; Thu, 3 Dec 2026 09:14:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB258606A32C 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=cxVms1ju Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-cc758830601so10077022a12.2 for ; Thu, 03 Dec 2026 01:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796289298; x=1796894098; 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=zJTtf7f3oT9L8aJOH8eJIdIU3NQ4LxKj3oqYUgbo0pU=; b=cxVms1juFhGfZrqXTmHGRBnwYOqr3YNboYfBAZuYOWxqi9iuKFLpEFIaCo7RV7DTkB 74CgNRlgy8mM42vsdXy1gHvStsV9jX2W+VPd3ocl76z9KE9sQAJBLd0yPEDqVzDeQG9f KO5131IJ54CZdA/zg06f5d2V8ACXxS6V19bS/cA8fpgxSb6e49DMyWkWPvbqOQdL5bcd jAaykMyjkylg2tICcA+ThXOdZecuhgLSyowvXeC3dEb8ISeYQ6uUdrWY9K9DYDh+D/C1 4ZfcExw0KVlYS7PL5fkjQirWyBiMKTsXnAPPIWCdFqnnRZPu1+iMySHxNMEUyqYSXiGm vw6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796289298; x=1796894098; 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=zJTtf7f3oT9L8aJOH8eJIdIU3NQ4LxKj3oqYUgbo0pU=; b=DsQOTqEaH4ee9THhh6gqBZMbFnFWYUpo1C2qNLx85TIeW1P496CQLxAbyH+KGiAbXF HG9dWiD0oO52w4NBhfML5vc7wj6R70dekx4lpwjvhyPMBWU75/p7M76+kHOmm2k1ix11 4odKmC95eZG10VSWudqQpG9mfO57OeCSBNHXf7r5H3XtP5vhvh6hLcby4KHz4AYqDrs9 B+mrIAeLwm1RPQVf+rE/cJJKNqPGBByZolVaVUu4cH3EWpNLa5PzJfUQ1R171Sl7FJg4 R5cMM5TLKD/vl6juqanI2yB73DHXZk/GA1TMeAhfuTYPne1gFG06Iyd5PIoXovR145Fq QtSg== X-Forwarded-Encrypted: i=1; AL+hErEvUedbca0WExR1gnVG4kd3OOHZzdGeBrUcughA6E/n75D9U09ZUGsMCf0/V1uK2DiC85eJV0B5@vger.kernel.org X-Gm-Message-State: APuU4Z/LvnF4OtPvmalwuPB8hZOFW4gj8OrKVSH4i0gZ0xYfTfTnO8jn nyUmfYB0HyhghDYNUQ4o9KhItsL0zMraMcrej9tL7AMikxa4z3fr25y0 X-Gm-Gg: AZFdTZcmWJ2CJRzD0C002FivpXYmlBHqZSMTEaMDVsguR0Y3vNBvlgayXEFYdODtABx XMNapIlnBZSH21/thb3MV5Hh6IAaOArwv1gqvlq/QkAOFRYgawSe2L0c4yUD2vGYGnJVIV0aCz/ 5y/A469F+GdduNgfmJ9AOiqRaGOxECcQtu2eK0jCgPMqohAeZzgpVZKzWWw8qlYmxaXwSwfM0lF uWgGazZYSYZ4FFejldkwa/iLY15RKB2s8VPDLwqZWcW0akhAblDUdeC/9h+XHWo0YTitGDM4Olk OCrAPwpHiH5H9DPXQt/4A3QoEvRyKEFhpOUwI8sg5GlY2RBHpmMW6u3/opubdz6iRWtSv2xZCdT 69ru2fodfXJNjkkqI54WFu6fGEjk2eub2iSx/jgy64yNW1T4giyf5tShj0qFpfY3WLTVFd3HzIq eTuhQgnPLkMaqErYFCLxxLw0RtdhtbucQz1UCJqZNSmXrP4WF0gRZUYJj6sN5WBeqse4BlI10MZ BZED/OT/XTEIFg0F6DiNeAexKNWzOHIQb/hx4hUKMeJ5GsIhU+TXtAdfdj6yh+OZkuDqXJ3Sb0S rCoCsiNYV3DM1dbsrTN0C24JdoNSU6qw/Q8i1XjEqoZ6b9UGtkXyOaApckmx X-Received: by 2002:a05:6a20:a124:b0:3f9:ceaa:90e with SMTP id adf61e73a8af0-4014ca44dcfmr52347412637.23.1796289298111; Thu, 03 Dec 2026 01:14:58 -0800 (PST) Received: from localhost.localdomain ([64.118.140.61]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdebb45c972sm14827452a12.20.2026.12.03.01.14.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 01:14:57 -0800 (PST) From: Ding Feng To: Zorro Lang Cc: Ding Feng , fstests@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH] generic: punch a hole past EOF over preallocated blocks Date: Thu, 3 Dec 2026 17:14:52 +0800 Message-ID: <20261203091452.74081-1-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 X-Mailing-List: fstests@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 Blocks that fallocate(FALLOC_FL_KEEP_SIZE) allocates past EOF should be freed by a later FALLOC_FL_PUNCH_HOLE over them; fallocate(2) says whole blocks in the range are removed. XFS and tmpfs do so. ext4 returns early for a hole that starts at or past i_size and leaves them allocated. Write 4k, preallocate 1M with KEEP_SIZE, punch [4k, 1M), and check that at most the block holding EOF stays allocated, and that the size and the data below EOF are unchanged. On v7.4-rc5 this fails on ext4 (1048576 bytes stay allocated) and passes on XFS. It passes on ext4 with "ext4: punch hole beyond i_size", sent to linux-ext4. Signed-off-by: Ding Feng --- tests/generic/810 | 37 ++++++++++++++++++++++++++++++ tests/generic/810.out | 2 ++ 2 files changed, 39 insertions(+) create mode 100755 tests/generic/810 create mode 100644 tests/generic/810.out diff --git a/tests/generic/810 b/tests/generic/810 new file mode 100755 --- /dev/null +++ b/tests/generic/810 @@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Ding Feng. All Rights Reserved. +# +# FS QA Test No. 810 +# +# Punch a hole past EOF over blocks preallocated with FALLOC_FL_KEEP_SIZE +# and check that the blocks are freed while the size and the data below +# EOF stay unchanged. +# +. ./common/preamble +_begin_fstest auto quick punch prealloc + +_require_test +_require_xfs_io_command "falloc" "-k" +_require_xfs_io_command "fpunch" + +file=$TEST_DIR/$seq.file +rm -f $file + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 4k" -c "falloc -k 0 1m" -c fsync \ + $file >> $seqres.full +before=$(md5sum < $file) + +$XFS_IO_PROG -c "fpunch 4k 1020k" -c fsync $file >> $seqres.full + +bs=$(_get_file_block_size $TEST_DIR) +limit=$(( (4096 + bs - 1) / bs * bs )) +allocated=$(( $(stat -c %b $file) * 512 )) +[ $allocated -le $limit ] || \ + echo "$allocated bytes allocated after punching past EOF, expected at most $limit" +[ $(stat -c %s $file) -eq 4096 ] || echo "size changed to $(stat -c %s $file)" +[ "$(md5sum < $file)" = "$before" ] || echo "data below EOF changed" + +echo "Silence is golden" +status=0 +exit diff --git a/tests/generic/810.out b/tests/generic/810.out new file mode 100644 --- /dev/null +++ b/tests/generic/810.out @@ -0,0 +1,2 @@ +QA output created by 810 +Silence is golden