Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp106154pxf; Tue, 23 Mar 2021 23:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb2OU2/NfP82yS9DdSfbuIE+ZK67sbio64z/ALu5MUc2eT0kUeSpFfU6Lh6OQV91zjRAUP X-Received: by 2002:a17:906:c0c8:: with SMTP id bn8mr1988463ejb.445.1616568706073; Tue, 23 Mar 2021 23:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616568706; cv=none; d=google.com; s=arc-20160816; b=bsKe4tVteEipNSH8ANEKce+Pm4TV0iW+UoHnViZnWyQScUaUknM7mAIos7NJiczkAU XzRE8yEpYh6uW6aKnYMaIBp4RLg07wXKd3MHtTN6Zqxx72W1eJH8gXRgXRiuKyFNaqTQ 4NFNqaKnjekBM5zlXtunZi6LTqrelGZc6h2+l//smKmJbTENjmcqLd+0Ta7sRAreydeF 4IEk5N2ZeH96s3g8Z0fXemSJ6wbZpFHb7kslxVizKFYcaEabU60/8z+zEcuNjXex8Ftn TfDp7GsuB8GFvTve5N9DHaiQJJUeDRPKiJKDC1n8xN/1PCFUIU1wj/3jVYBcFB9Ynrot s7EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4ACpTaTaccGZz22NVLefFKJA0kreKzoZN1bibjo5Od0=; b=XqiBNxQW0Fu+MTjQSviklO5Ps7k3Oj6Eow0sREcMolG8IlpODiNjC4n6uMqSnc74F9 LvwD5/DbzAJFMoBt4Z7BtF0VqoCYXh2zllLDotK7dmASU2z3cGBzKGNW5UOjhl+hzohx FqQ+srnI90viDhPVgfeeYlds/XoYxqQ1lldAWKx7O80iu/xzM2nrHzzq0B2V56CFg78z hLJk672i8U1CKmX8qzhfnivICuZqxKOL0mVw6dnr21VTyMdyCUBACGEuTwyCWYo7XGHq aJgTMs2F5h7ztyyhpF0jgEVzhH9myNZy1e4W7l5o1GHtaeHHH2U3iLBqDqaofy+gAifc l5zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rUjxWZ9g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si1037370edb.55.2021.03.23.23.51.23; Tue, 23 Mar 2021 23:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rUjxWZ9g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232147AbhCWSdL (ORCPT + 99 others); Tue, 23 Mar 2021 14:33:11 -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 >