Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2942713pxb; Mon, 19 Apr 2021 18:54:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy8ZFFvtes1JWlyCtt/65Tm0y7ip9q/w+r+EHPiuw86a7xp+bkUm9FeUpNgQZ9XJGhOxG3 X-Received: by 2002:a17:907:3f8e:: with SMTP id hr14mr24815816ejc.258.1618883646007; Mon, 19 Apr 2021 18:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618883646; cv=none; d=google.com; s=arc-20160816; b=rZpxFMN/oq9bcunaoY0CGuojrwBFp7uX0bisfd738rddOu+c8rUDAB7aVm4H7Oucvf TexJ2Uvxq9IAr8Yl4JAuQghmF00gua6ciJAVnzptjHRvLJ+60gUviS3ISIjsSu7tfKDD CadshtbX71SFseyN9kre+chn8eMcVaDWO5bojzD2k0hJphZQXkSJ46owklzIUcIrCP2f FspcTFVrH2jtAy/khgwm4wmlmgPrwW+MUjU/VnS7oavnP2zNvCdw6Id3t3v5tf5AW0Gb kF6NVda4hCd9KgqO9Bjy2z3FsyT9X1BcjJpD9GLJXl3vx7wJCIWcSJvSW4KPKT5u65La CBHA== 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; bh=G9KuMT/EmgzVxuxVeZ+kzqUmsWTov+sdO2J/W/Ujme4=; b=OAU+eGghSWeZmlVWpmPAki2rJwhkzcRUtyTZ81BFQkexz0PMinziYW2nXyrRfZ7+L3 h1plINDCgB9q24dGHAJMiAjePZ/AnDLDmI4oeGpCBMFbl/D3sDyoa7hMtPH8oO6YZ4fA AUjI4052pWSZgRvwQJlV4nkPWNtE1GkYQSwugYLMhuxYEoCDABOtj3xW1aytC528DOx8 u/a+EjNLTJKrUtdjalqwfS61zG+V9JL3U9cPEbFl51JD40Slk77iffk92Fj2tgPMXEaW 669bI6KA/JCRVcJqz3k1bYuOGweIxIHMkdPcaI1kFGw0ZgjfbGKb6QffqzpIPw4qzsX7 41vQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si13321242edd.211.2021.04.19.18.53.42; Mon, 19 Apr 2021 18:54:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229575AbhDTBxZ (ORCPT + 99 others); Mon, 19 Apr 2021 21:53:25 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16139 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbhDTBxZ (ORCPT ); Mon, 19 Apr 2021 21:53:25 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FPRSy1sJnzmdWg; Tue, 20 Apr 2021 09:49:54 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 20 Apr 2021 09:52:48 +0800 Subject: Re: [PATCH] f2fs: fix to cover allocate_segment() with lock To: Jaegeuk Kim CC: , , References: <20210414012134.128066-1-yuchao0@huawei.com> From: Chao Yu Message-ID: <03dc1c69-9215-1b5f-b1cc-c38454f3b90a@huawei.com> Date: Tue, 20 Apr 2021 09:52:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/20 0:57, Jaegeuk Kim wrote: > On 04/14, Chao Yu wrote: >> As we did for other cases, in fix_curseg_write_pointer(), let's >> change as below: >> - use callback function s_ops->allocate_segment() instead of >> raw function allocate_segment_by_default(); >> - cover allocate_segment() with curseg_lock and sentry_lock. >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/segment.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index b2ee6b7791b0..daf9531ec58f 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type) >> >> f2fs_notice(sbi, "Assign new section to curseg[%d]: " >> "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff); >> - allocate_segment_by_default(sbi, type, true); >> + >> + down_read(&SM_I(sbi)->curseg_lock); >> + down_write(&SIT_I(sbi)->sentry_lock); >> + SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true); >> + up_write(&SIT_I(sbi)->sentry_lock); >> + up_read(&SM_I(sbi)->curseg_lock); > > Seems f2fs_allocate_new_section()? f2fs_allocate_new_section() will allocate new section only when current section has been initialized and has valid block/ckpt_block. It looks fix_curseg_write_pointer() wants to force migrating current segment to new section whenever write pointer and curseg->next_blkoff is inconsistent. So how about adding a parameter to force f2fs_allocate_new_section() to allocate new section? Thanks, > >> >> /* check consistency of the zone curseg pointed to */ >> if (check_zone_write_pointer(sbi, zbd, &zone)) >> -- >> 2.29.2 > . >