From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0E9BC433E8 for ; Tue, 23 Mar 2021 18:33:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B929619BB for ; Tue, 23 Mar 2021 18:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232173AbhCWSdN (ORCPT ); Tue, 23 Mar 2021 14:33:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhCWSct (ORCPT ); Tue, 23 Mar 2021 14:32:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2AEB619BB; Tue, 23 Mar 2021 18:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616524369; bh=SrXcVBV4nIQgyIM/fSLSVHs7w6pMJ/2dsxCVsXvB8zY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rUjxWZ9gdwrdHn6tWK74f9t7uFHKIpK1FRY4C4+u0het+B+AG2OxVB/nx9jgS0UZ4 FeEa1ualNfMqtREFs8w3W4sm7yjOWOkDAfLCe7cmp1zF9fshivPKLAaE9ixmB0sYH2 h7pIoYN8jeDMLuja7RyiDJ4RaZ+rc4OzDcIN4OaocgEfAnB0tSypo3qDOidK6xAUW+ FKfU+nIIJu0GFVoBGQQTZtRqT9AEbm1ZuvpcGLhusOL7GeMzMmsE+of5ydaXRxPUMa GI4OJ/q8aY5AeSIiVeGwy513R4nCNr/TwchCu0ZLrTIawt7d1abEKHM01bgbrtP437 R3wvGVqQYIWwQ== Date: Tue, 23 Mar 2021 11:32:47 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: Re: [PATCH] f2fs: fix to align to section for fallocate() on pinned file Message-ID: References: <20210305095601.96591-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/23, Chao Yu wrote: > On 2021/3/5 17:56, Chao Yu wrote: > > Now, fallocate() on a pinned file only allocates blocks which aligns > > to segment rather than section, so GC may try to migrate pinned file's > > block, and after several times of failure, pinned file's block could > > be migrated to other place, however user won't be aware of such > > condition, and then old obsolete block address may be readed/written > > incorrectly. > > > > To avoid such condition, let's try to allocate pinned file's blocks > > with section alignment. > > > > Signed-off-by: Chao Yu > > Jaegeuk, > > Could you please check and apply below diff into original patch? > > --- > fs/f2fs/file.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 236f3f69681a..24fa68fdcaa0 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -1648,13 +1648,13 @@ static int expand_inode_data(struct inode *inode, loff_t offset, > return 0; > > if (f2fs_is_pinned_file(inode)) { > - block_t len = (map.m_len >> sbi->log_blocks_per_seg) << > - sbi->log_blocks_per_seg; > + block_t sec_blks = BLKS_PER_SEC(sbi); > + block_t len = rounddown(map.m_len, sec_blks); len is declared above, so let me rephrase this as well. > > - if (map.m_len % sbi->blocks_per_seg) > - len += sbi->blocks_per_seg; > + if (map.m_len % sec_blks) > + len += sec_blks; is this roundup()? Could you check this? https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=e1175f02291141bbd924fc578299305fcde35855 > > - map.m_len = sbi->blocks_per_seg; > + map.m_len = sec_blks; > next_alloc: > if (has_not_enough_free_secs(sbi, 0, > GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) { > -- > 2.22.1 >