From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796437287; b=u/XUL3s2yeRyFTP0TGuljSKPJ/853s0h4A/niShWKnq3MpB+P9ExbwUK5Jq2eiWHwNNl bqbR/URwvEyJgpmYn3DpXaRI9DjdWWL2HtMd3WPID840fTATK/H0rTKFUflHgJfyskHXv uCr1yDgrwVDSi1YCEp97ar66aGENVxlOjz1Xqu1DI1rI5AMEe3F1ot+rAvTsVGfk25Mud A/MNVps+JIQi75dLmFXgAF4diA1YYAFYSRFAki2GX7t2caKM0XlhqJuygct38FGvB7Em5 7acmywe2/punx2sRWXXugy92GHzPq05zihgS9Oq3ddZWnOehBRIVb/APaQNAmb1pqiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796437287; 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=O8PanRVa+W4hTsW12bp7apow1znJK2Kspn8vouCieDI=; b=DS1Bj3K/CRbRVTSxdQBU7Tb4m+KstKTTfszPf3TOovI6247P2OcrGI1HvUrRRMAQfRGt W3B8VYzwysS6RBZZXeBuKxwoQwedQ+bCDYtSmsN55MifuD334OCbWwTUxDHxfUBr4XxlH is+p4d0m7+BF0kLrR+zswetJSO3w1j7rpypN93eZlty9o1mzLuW6efSFrTVhVSgvFIE2e sy4PYDzGtWC2mjl0ycEgbUDwmccL/aU7YJFnip+IrP4dSbWgFGIwURHqPea2HjQFATbRS KmGxMteND9vH6Z8JZwuvZrffjZyvbXliqwEI+H8iSNGyE7kvGvHJ7+i1sid5c9AJb/Q== 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="nxXkh/Ut"; arc=none smtp.remote-ip=74.125.229.2 Received: from mail-dy2-f2.google.com (mail-dy2-f2.google.com [74.125.229.2]) (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 BF667606A330 for ; Sat, 5 Dec 2026 02:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF667606A330 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=nxXkh/Ut Received: by mail-dy2-f2.google.com with SMTP id 5a478bee46e88-327b1d5824fso1943879eec.1 for ; Fri, 04 Dec 2026 18:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796437286; x=1797042086; 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=O8PanRVa+W4hTsW12bp7apow1znJK2Kspn8vouCieDI=; b=nxXkh/Ut/532KvwcY9W2Nl+/TksIsYIX3QfFGYSRVOpQ/sLoksyL6QPGT121MziF9i mPb6LbLQ8bB2BYlUjpKP0+W2A0J9wtDreGhIgxkem9EF6orXOkJ0gnIZPCU0jteLBb6V BPg9iNY9eViaw7UraP1SPW5/wvljM9SW9RLHmgNppXSIqM0YKWun6Za/fHJQDNzOzdsS ulcfKIpzpr9DURfXO++i7s4jfTGBXt/w4gcn3M5MjIjDLcXP0ufkwOplv3ocQjCbyMNZ odgCPleehZxOjZ/0S5fD2oiHNAIDmHj1V3grnrq3WQefhHGaID3axB2hVUB/n8O5oJvL 0sTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796437286; x=1797042086; 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=O8PanRVa+W4hTsW12bp7apow1znJK2Kspn8vouCieDI=; b=vyQMwaFEutEf5bIivcdNCG7sfx6Jct5NARhw8f1b6X7S4mfeuyvzTPK9ESgS9Awq/8 /QMedhsPmoAOnAfio17NR78Y8y1ufr3nd0QTdsSegUSmldfX/HIhbb3nkr2FZFBsU3UW crpOzaeHl4JQVoemPunx3aGfXRac22v4EpYG7EdKVfXlFGm6YbK88tqirD3NMYg5RiZY HHKqvl2t3Msu7yRe8W+mUZnGyM9uKJ7oU4uuGDaiELf7+uyEtDOj5tYTPMlMMFGRU5Sk otxT726pW/Fn1/CRqblztBwcOaO/Jbj1YoesIz17mr1OZXu6qBm4ahhJv7oc6itpDBNU uJpg== X-Forwarded-Encrypted: i=1; AL+hErGDzlI71ka8Ih3Z+b7xUhwC8Uzsd1ETBFPzeKd7c6NrRyR16k8zngr/tM7pOULHtelGn22LUFuai1EfR7Q=@vger.kernel.org X-Gm-Message-State: AB4q+uGAcZe+wpVJc+cYlcJvfjH/7rda1v33k9DJB0cModWZywMedr1L 6v8NkvKWskOFjUznBqBrvQ8Aj7GD4VZlWZkNlU1sN72Xsb2r1P1bH/nV X-Gm-Gg: AZFdTZc2Cyw3EJ4nbFfUuC3mKdpVT6X4r8cTfXywWn054p/PQuXJbkvGNB+iISEdr9q FuT4oKNYMREWP6O5vOI7iCJCXDoxXMKh5zkhZeR2xaIt4Ii07wkDZWpxgmbwphUbcKC1a8Iasxx OYMKhXQqihvEwGjDRS2YDl+juJgTcjltJiccZZQWLGv7+O9yMSwpAw64LvtIB58UDJvm66cY18u 2SciSKL5tMSL/nFL71u410WqiKc5WbEsXPyabKLnOJC5J38urpcKlSNKgnPmRBIejjSLDtdaLgL TrSYYu/qybHht4d/Kaf/OwD9bknkxBIAXitte7MQAiCy+jHk6f897qTxou1uVoHGYhYeRm8abAw yjbGNlB4nAYT9oUpMWlmIN4hiy5tHC191VKQbyJ1IYtsrlHCelahal2w5pHNqPLWq4PNY903OAj q2Sy9ZUnOVAAJEDaUXdHN82RHFp22eqZYD6q/oHChXQVV2zSLkwieJguFuSJ29Vr5rP0pvkLRW9 FIVHmcDrMQ0YKyNR1ODXFr6+ao0xY2Dkg+Wv/baQkDxKXLKWlQ1Aaxb7cO1GJBGzX9vW9fjqDq9 kcQF45UB08JG5RXNf75dPBJs01zlTQOZ9ePsPLqzWIWwCfN9WMvDdyoBGT7BSp3g8n4RaSUWW5H 9Icd0JHctt+DL62QxE/cf60oT03OvWUXhg5PcP7vVzw== X-Received: by 2002:a05:7301:10c7:b0:380:9c6f:ad0a with SMTP id 5a478bee46e88-387521691dcmr5114283eec.10.1796437285664; Fri, 04 Dec 2026 18:21:25 -0800 (PST) Received: from localhost.localdomain ([76.33.234.50]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521c17a3sm15373886eec.11.2026.12.04.18.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 18:21:25 -0800 (PST) From: Hungyu Lin To: jaegeuk@kernel.org, chao@kernel.org Cc: lizhijun3@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, dennylin0707@gmail.com Subject: [PATCH v2 1/2] f2fs: fix to avoid pinfile fragment on checkpoint=disable mode Date: Sat, 5 Dec 2026 02:21:10 +0000 Message-ID: <20261205022111.49900-2-dennylin0707@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261205022111.49900-1-dennylin0707@gmail.com> References: <20261205022111.49900-1-dennylin0707@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 fallocate() on pinfile allocates a whole section at a time, so on a large section device the pinned log moves to the next segment in the middle of the allocation. If checkpoint is disabled, need_new_seg() picks an SSR segment at that point instead of the next segment of the section, so that the rest of the blocks come from dirty segments. It results in fragment blocks in pinfile, which violates the semantics of pinfile introduced in commit f5a53edcf01e ("f2fs: support aligned pinned file"), and fallocate() may also fail with -ENOSPC, as the pinned log is closed once an SSR segment at the end of a section is used up. mkfs.f2fs -f -s 4 /dev/vda mount /dev/vda /mnt/f2fs for ((i=0;i<32;i++)) do dd if=/dev/zero of=/mnt/f2fs/$i bs=1M count=1 done sync for ((i=0;i<32;i+=2)) do { rm /mnt/f2fs/$i; } done sync mount -o remount,checkpoint=disable:10% /mnt/f2fs touch /mnt/f2fs/pinfile f2fs_io pinfile set /mnt/f2fs/pinfile f2fs_io fallocate 0 0 $((1024*1024*16)) /mnt/f2fs/pinfile filefrag -v /mnt/f2fs/pinfile Before, fallocate() fails with -ENOSPC after 2816 blocks and filefrag shows 9 extents: the first segment of each new section and 256-block pieces of dirty segments. After, it succeeds and the file is one extent of 4096 blocks. Let's always allocate a new segment in LFS manner for pinfile. Fixes: e1175f022911 ("f2fs: fix to align to section for fallocate() on pinned file") Cc: stable@vger.kernel.org Signed-off-by: Hungyu Lin --- fs/f2fs/segment.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 84fa9b95de82..61be4dbf76db 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3445,6 +3445,8 @@ static bool need_new_seg(struct f2fs_sb_info *sbi, int type) { struct curseg_info *curseg = CURSEG_I(sbi, type); + if (type == CURSEG_COLD_DATA_PINNED) + return true; if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) && curseg->seg_type == CURSEG_WARM_NODE) return true; -- 2.43.0