Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp94706pxb; Thu, 2 Sep 2021 20:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyChdjs59mY1qeFGIqdWJVykGAdGkfUUQ+kny/T/OtWyW5xhJcVyE5PZwJnA3BSZsOzhhUa X-Received: by 2002:a05:6e02:f08:: with SMTP id x8mr971207ilj.92.1630639509259; Thu, 02 Sep 2021 20:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630639509; cv=none; d=google.com; s=arc-20160816; b=J5neyJ27ipUW+QIslYbjjS1nWcsoabOMPZid97rcJXCwrMuOykKfBh9jHU5FvLFiDV N20/XoYkdCRD9Yxq5rbhVsgrlqI43QJi5afrQWaKcIoOZQnuR5YbQceBG1Fkh7ZuGMzg Qo6QbpwMqBrsr5D4BS/N7bWJ+T2aiDP7opoC0OfkDkHHGBlcl0r1YlL4PEnVl8cXZ5P3 U2zfuYJSSC5aLIZMzQpLzuBOp1Ejx+3fPKv0vAFP35lR8mKMIfv4yMGXpsWzKWFmS00C ulI105ApyQllXUvZ1hZPRn3puu3wLr40eoJ2He2/1ZCZCf4MkzBMYxNIrRKSiCGbXyHk ymew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=0b4HhATCZi6jAYbELw7XRSYG/ZtkgDvtGKHPcR98B8I=; b=SqI8LNKkUp5h+QJjUGV7gT63UGfjyrvC4d5kgb/hVPhHMOOspcdl4omgtfNSAdCp3v nLFTzc5wQsgDlaoTaKqBFp/Q49w17uaH+2lObmilssl8OT+H/MJcybib21/EJlIi3jti Tmog07ICko+1yFHPMYZkcmD0eK3+NqAmEoZBYZGPiphZsCZ/e2kJ+cPG3pUo/KAqsqdn MW3UIPkDURiHGRls0STkzMmjGVoy3GmImTyhYcOQN2mcTLRzNsc1uNiUUFOqvhkG193U wC27G4qTffgS7VO+YfBCeuWkikccb3/6IlBmrIFCw79DMe6/iwVqOZj17vmiGPl0F7Gf k7kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eqU0fedD; 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 s4si1362686jaa.5.2021.09.02.20.24.57; Thu, 02 Sep 2021 20:25:09 -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=eqU0fedD; 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 S244445AbhIBX6j (ORCPT + 99 others); Thu, 2 Sep 2021 19:58:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:32904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243538AbhIBX6i (ORCPT ); Thu, 2 Sep 2021 19:58:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EAC9861053; Thu, 2 Sep 2021 23:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630627059; bh=99fHBy+T4K/mLQGDUtNtGh+nM1zfP3QWsKjosICZFrE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=eqU0fedD54QHOyuaINSODjXbVG0NaNgqeOg3QZxtWr6oqLPlevyqizlfn0GJg4GoU O0E2kRc8DEvnzwUM+x8sq+KMY2XNMmLmyNJS0B45Hm/6IZ05QU7ijl+NqPeZY2JrSu fidkF6W1XwEJfO8wJ5s2P8KvKFaeY6/lhgPdEFHagSatrY1RLsfezF/MIUTFGRTEJv ZDk658AZDCqNCLgfM3bysTBBjF3VcTZ0XLGg1ZIcouWlS2sPh67pVCfdpgiMZdyxMs B1Z8WGprIt4gD9Wy06heBB9e4MXM+qSerl/HRySDst+99dsPgpQqlQdZPD10V/+Z6v Lip+UhPCQtD/g== Subject: Re: [f2fs-dev] [PATCH v4] f2fs: introduce fragment allocation mode mount option To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong References: <20210902172404.3517626-1-daeho43@gmail.com> From: Chao Yu Message-ID: <9ab17089-accc-c3a3-a5dc-007fc4eeaa20@kernel.org> Date: Fri, 3 Sep 2021 07:57:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210902172404.3517626-1-daeho43@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/3 1:24, Daeho Jeong wrote: > @@ -2630,6 +2631,8 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type) > unsigned short seg_type = curseg->seg_type; > > sanity_check_seg_type(sbi, seg_type); > + if (f2fs_need_rand_seg(sbi)) > + return prandom_u32() % (MAIN_SECS(sbi) * sbi->segs_per_sec); if (f2fs_need_seq_seg(sbi)) return 0; static inline bool f2fs_need_seq_seg(struct f2fs_sb_info *sbi) { return F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_FIXED_BLK; } > @@ -2707,12 +2715,29 @@ static int __next_free_blkoff(struct f2fs_sb_info *sbi, > static void __refresh_next_blkoff(struct f2fs_sb_info *sbi, > struct curseg_info *seg) > { > - if (seg->alloc_type == SSR) > + if (seg->alloc_type == SSR) { > seg->next_blkoff = > __next_free_blkoff(sbi, seg->segno, > seg->next_blkoff + 1); > - else > + } else { > seg->next_blkoff++; > + if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_FIXED_BLK) { > + if (--seg->fragment_remained_chunk <= 0) { > + seg->fragment_remained_chunk = > + sbi->fragment_chunk_size; > + seg->next_blkoff += > + sbi->fragment_hole_size; One more concern... we'd better to save fragment_remained_hole as well as fragment_remained_chunk, otherwise, if fragment_chunk_size + fragment_hole_size > 512, fragment hole will be truncated to 512 - fragment_chunk_size due to we won't create hole with enough size as seg->next_blkoff has crossed end of current segment. Thanks,