From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F298F126BF7 for ; Mon, 22 Jun 2026 03:34:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782099264; cv=none; b=O93YuI+nv0nnnMBbwYKbFSwVr3kpFrTv6yGxLK+oqppxjiSLlP3A0IFj0Tr1pDeeSUKdknLw2ReVEuFnkekJK9e4L8X8BNFTJ9bE9om3bxR3zFHI073ojRI/NMINQHg1Z9n3LLpd3eZJL/rs+TRrxfpNIVWjuISrBH30x2qbbNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782099264; c=relaxed/simple; bh=i+23TubZpMztV+fx3d1ADEPG8wj8g2e4tm7tJqc7Xgg=; h=From:To:Cc:In-Reply-To:Subject:Date:Message-ID:MIME-Version: Content-Type:References; b=YJWpYs5zsHP+erlHrs4LOB+Lr7SeLSKmzHWjlepTAgKBFWNnJkrkdJRxT8S6ui3RlzgodFbERQSQJGo0e/4uPY6555LrJatRoRpSPc9MIpA3dzQpLB8pNtBmnzb1ZuzmFbB+GW4tpZhgX2vQPcBjuncX1Qf0Y1oCnKjq+82P8zc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=bnpv5MWB; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="bnpv5MWB" Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20260622033414epoutp035f91982d5318a609665d16d1eaf86cf9~7SdR0YjI73065130651epoutp03b for ; Mon, 22 Jun 2026 03:34:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20260622033414epoutp035f91982d5318a609665d16d1eaf86cf9~7SdR0YjI73065130651epoutp03b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1782099254; bh=IfgpQAD/vfdz21gCxgMtgiheUqVviDey2ND7ZWyteeM=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=bnpv5MWBozl9ow31u4TLR+Ab0rZlcTZd3P1Q8zyiHkmpIpzJEEWxADJq4SDmkzIxv PfmYRa5rqb752wyNrz4LCQJcbBPzye2vTz5y8xGsTZjk51a5+KC5oDTUBsmegvIAnR t/49ULof9YJUY/LzfkOsIHRrJa4C2bVLTh1ww9O8= Received: from epsnrtp02.localdomain (unknown [182.195.42.154]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPS id 20260622033413epcas1p16ac8053f02c6b2cdba979fa7832008d8~7SdRVWwYl2393023930epcas1p1R; Mon, 22 Jun 2026 03:34:13 +0000 (GMT) Received: from epcas1p2.samsung.com (unknown [182.195.38.190]) by epsnrtp02.localdomain (Postfix) with ESMTP id 4gkDMT4g16z2SSKY; Mon, 22 Jun 2026 03:34:13 +0000 (GMT) Received: from epsmtip2.samsung.com (unknown [182.195.34.31]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20260622033412epcas1p401bc4d22a9f3993d0fb9a333a6b0890f~7SdQUEhmV2631926319epcas1p4b; Mon, 22 Jun 2026 03:34:12 +0000 (GMT) Received: from sminjeong05 (unknown [10.253.99.183]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20260622033412epsmtip2628584a49fe0275e4b98e7dee5379549~7SdQNfLYZ1419614196epsmtip2b; Mon, 22 Jun 2026 03:34:12 +0000 (GMT) From: "Sunmin Jeong" To: "'Chao Yu'" , Cc: , , "'Yunji Kang'" , "'Yeongjin Gil'" , "'Sungjong Seo'" In-Reply-To: Subject: RE: [PATCH] f2fs: fix to round down start offset of fallocate for pin file Date: Mon, 22 Jun 2026 12:34:03 +0900 Message-ID: <00a001dd01f7$fe359fe0$faa0dfa0$@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: ko Thread-Index: AQGyqYFiX2zgyGFAKurllELkdaoPRAGJaRfHAuyyhIW2euuJsA== X-CMS-MailID: 20260622033412epcas1p401bc4d22a9f3993d0fb9a333a6b0890f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P cpgsPolicy: CPGSC10-711,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20260622023853epcas1p3d15698d1e456cc549da18ac2674e1f5f References: <20260622023805.3620189-1-s_min.jeong@samsung.com> >On 6/22/26 10:38, Sunmin Jeong wrote: >> Currently, the length of fallocate for pin file is section-aligned to >> keep allocated sections from being selected as victims of GC. However, >> for the case that the start offset of fallocate is not aligned in >> section, the allocated sections can't be fully utilized. It's because >> a new section is allocated by f2fs_allocate_pinning_section() after >> using blks_per_sec blocks regardless of the start offset. As a result, >> several unexpected dirty segments may be created, including blocks >> assigned to the pinned file. >> >> To address this issue, let's round down the start offset of fallocate >> to the length of section. > >It's good catch! > >> >> The reproducing scenario is as below >> >> chunk=$(((2<<20)+4096)) # 2MB + 4KB >> touch test >> f2fs_io pinfile set test >> f2fs_io fallocate 0 0 $chunk test >> f2fs_io fallocate 0 $chunk $chunk test f2fs_io fallocate 0 >> $((chunk*2)) $chunk test f2fs_io fiemap 0 $((chunk*3)) test >> >> Fiemap: offset = 0 len = 12288 >> logical addr. physical addr. length flags >> 0 0000000000000000 000000068c600000 0000000000400000 00001088 >> 1 0000000000400000 000000003d400000 0000000000001000 00001088 >> 2 0000000000401000 00000003eb200000 0000000000200000 00001088 >> 3 0000000000601000 00000005e4200000 0000000000001000 00001088 >> 4 0000000000602000 0000000605400000 0000000000200000 00001089 >> > >Fixes and Cc stable line. > >> Reviewed-by: Yunji Kang >> Reviewed-by: Yeongjin Gil >> Reviewed-by: Sungjong Seo >> Signed-off-by: Sunmin Jeong >> --- >> fs/f2fs/file.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index >> 2c4880f24b54..3954aea43bd9 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -1906,8 +1906,13 @@ static int f2fs_expand_inode_data(struct inode >> *inode, loff_t offset, >> >> if (f2fs_is_pinned_file(inode)) { >> block_t sec_blks = CAP_BLKS_PER_SEC(sbi); >> - block_t sec_len = roundup(map.m_len, sec_blks); >> + block_t sec_len; >> >> + if (map.m_lblk % sec_blks) { >> + map.m_lblk = rounddown(map.m_lblk, sec_blks); >> + map.m_len = pg_end - map.m_lblk; > >If pg_end is aligned to sec_blks, but off_end is non-zero, is there off-by- >one issue? > >Thanks, Thanks for your quick reply. I'll send a v2 patch. > >> + } >> + sec_len = roundup(map.m_len, sec_blks); >> map.m_len = sec_blks; >> next_alloc: >> f2fs_down_write(&sbi->pin_sem);