Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1015778pxb; Fri, 3 Sep 2021 20:43:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1Uws5wlEXNij2H9hFI5QDwp7gxrQjRg+S4EzGmfBaGXtHtWcPL7QDGOtbDor+44Hyk06j X-Received: by 2002:a05:6402:14d3:: with SMTP id f19mr2312338edx.114.1630727021668; Fri, 03 Sep 2021 20:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630727021; cv=none; d=google.com; s=arc-20160816; b=UQnn189WRxjlNznrzqh8VZKvzfpX0tpLyv6Vl9uUGl31z/mwM0eGZoFl82lVZY129Z aaRSmRFd1xyZEFX/3ErkZMxiDlig0/dzCBpIdChyz58PixMMT8NYeXCLN0AcDxx+f7LH zu2oQ6qFQdBPrBAQmiTQ9QEdXSSy3Hz8lwm9yi2P41Uflc4ykcawWDTJjHT2orqJ39D+ RW/XOfGwCFtbKDgp/2BEJ2/E+lfVt9ggKaDxJ32XsuKuNXeSdhg2gT/0wx2JnrBLzM7g XNw75SYD7CvB3d23I6u3jDQjfPv+sew80m9TMtLazMxNM66b+iBbbBV1qw8g1K5dFgOc VpWA== 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=Cgttt+PmuLXEwn6spezJx6rx3osncPK4AC5hjcfB9MA=; b=FOEJx3VLZXqnxXRR+JTF1vFE5w4tyIquRgnz+he9NkmFJuwuV43sdojUjLGJf6P2Iw m2I4VBnAmhLRooBtRPfyODWeDt0gYGepWiq/jr/RiIm625cdBfSbRrPtOgOPMqtpptX7 5mpt2jeo03n1kWVs0pTtLGQX6ylnvYcnozxyP9hZYwymTVk4cdyBYIBxE7OJd3gYUSuE 4UzvfmgFPmTveqxjAZxl77zRm6qe5r867WjtlKIjHizdnVi49goDUw7wn7SDeAD4zW7+ fSFxsnEmwPj6y/DnBHgeaQIMKaDpD38ZMhMIlqBapLOzhrltwOGP7PwaJi0xl1Q53Rb1 iT4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iraM5xTi; 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 qb16si1248374ejc.558.2021.09.03.20.43.18; Fri, 03 Sep 2021 20:43:41 -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=iraM5xTi; 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 S229915AbhIDDeU (ORCPT + 99 others); Fri, 3 Sep 2021 23:34:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbhIDDeT (ORCPT ); Fri, 3 Sep 2021 23:34:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C813F6069E; Sat, 4 Sep 2021 03:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630726398; bh=vDInDMJ4sMJnmqblJcXU0QqfdBm47jpBvsDvYyfEXBk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=iraM5xTi9QjL341eo2RxFLV1aclSle5NhZTFsRGheHHVdZTduYXKuNdSs93EzOCVq 6o6+FQAhLcCmT3W0T8wEK22PEIG7H86pLQ40MeFVSBw9J4Z5FGZ4xhz1B96WQPzce3 5E2vDC0cVURUDAICMhdjbW0HBHLDiTu/f141xsy+q2kBL9cDHr+A8zZ64+gX1BYHye IMUPst2ejWYNR+S/B15UyKj/Qa8LhwCHXK9b9gsVfK6+ZpvqhSEMtHzxvusaldthus QsP7gybXytaFUFA7Yj42bC2O+uh1Ok9vWcctFh3+R+N2uc0t7i/iL8sfjaRdkPVBc2 z4ZPFGIU9cNCg== Subject: Re: [f2fs-dev] [PATCH v4] f2fs: introduce fragment allocation mode mount option To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong References: <20210902172404.3517626-1-daeho43@gmail.com> <9ab17089-accc-c3a3-a5dc-007fc4eeaa20@kernel.org> From: Chao Yu Message-ID: <8f8e4695-4062-60c4-0f91-2a1f6a5b0a11@kernel.org> Date: Sat, 4 Sep 2021 11:33:20 +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: 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/4 4:33, Daeho Jeong wrote: >> 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; >> } >> > > Do you need this in select_policy(), either? IMO, for this mode, I prefer to disable background GC and just use newly written userdata to fragment image, so I think it's fine to keep it as it is here. > Like, > if (f2fs_need_rand_seg(sbi)) > p->offset = prandom_u32() % (MAIN_SECS(sbi) * > sbi->segs_per_sec); > else if (f2fs_need_seq_seg(sbi)) > p->offset = 0; > >> 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. >> > > Sorry, I don't get it. You mean making fragment_remained_hole as a > global variable? As a per curseg field. > Maybe, we run into the same race condition issue you told before for > fragment_remained_chunk. > Could you clarify this more? e.g. F2FS_OPTION(sbi).fs_mode = FS_MODE_FRAGMENT_FIXED_BLK fragment_chunk_size = 384 fragment_hole_size = 384 When creating hole: - f2fs_allocate_data_block - __refresh_next_blkoff chunk locates in [0, 383] of current segment seg->next_blkoff = 384 sbi->fragment_remained_chunk = 0 then we will reset sbi->fragment_remained_chunk to 384 and move seg->next_blkoff forward to 768 (384 + 384) - __has_curseg_space() returns false - allocate_segment() allocates new current segment So, for such case that hole may cross two segments, hole size may be truncated to left size of previous segment. Thanks, > > Thanks, >