Received: by 10.223.164.202 with SMTP id h10csp138589wrb; Wed, 29 Nov 2017 18:44:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMYKJOwBoGNZQcTQ7eO5GvNgSQ6sJCMN9J8eMebsQ9ulKayXtInDXIz3ldeIGw8JpdBsSDFp X-Received: by 10.159.230.16 with SMTP id u16mr1006549plq.41.1512009841533; Wed, 29 Nov 2017 18:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512009841; cv=none; d=google.com; s=arc-20160816; b=qQ2H5OXdiQ94ZOzlI7joXFRJ4299dcwJD4x9y5Ze0H9aPrvqnlp+9hga6kbDTPEX4r E5aNySKXHtbhQCjwgYj/p74u3TedRnw4OlGYJc82E3x4zRjBsTAe7XG3J2z4lGf9fOzy eScVMGpplU7DO9rCy254+dwIUO+iXy42Jmrzipi7ELXRZmengf/tMv2aewqoEy4s3DNU qqAZ0tgzKRcsQHPxQk0ur9VKALTEYv6bohirK1MouWTGITQC4w4l/Se+8Lseiuemd851 aoEa55KSvv+URlXzuMH8pBdhpzaassRhHYI1R6Sy2jDX1YtFkb5MsabyFbTqZh4XGAsY TX/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=xzMlPdpmBnK2cIyuXVv2vz4+wFbx2eegM84nll9dhh0=; b=vF96aM1FK4A/EV8Iz0wdU5BT/Lyez7h0sqihOF6UmCbh4Z2IBHH+sVKgK9XQaqDadO xb7LI9+2WegxFipFs5Ni1yPjVDLDXcFcFLo+kuDrtkaGS6ZRs5yqm2/warEcWXdUO4nY AaqcUF2jAZYM2ehJfViqAbKz98fbirjBQao6Qfyc0kCsANI4yN3KVe2aqpOjGu41Mirg i8UvPd6MZOdB0SKOrx3kdodi+DOAGZ1QUMzd+BoPuwPJHXP8ks5sPIxk+UDklXKnuGKX UG5HfJrpXSSU7a2fpUb9vY227uyAVkh7wIJCcz5Zxi6Xt5b85lU/UU1SD0z2SRDxFmEw ksYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g71si2405147pfg.124.2017.11.29.18.43.47; Wed, 29 Nov 2017 18:44:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753113AbdK3Cng (ORCPT + 99 others); Wed, 29 Nov 2017 21:43:36 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2238 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752801AbdK3Cne (ORCPT ); Wed, 29 Nov 2017 21:43:34 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C7EE93355007F; Thu, 30 Nov 2017 10:43:28 +0800 (CST) Received: from [127.0.0.1] (10.111.220.140) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Thu, 30 Nov 2017 10:43:20 +0800 Subject: Re: [PATCH] f2fs: avoid false positive of free secs check To: Chao Yu , , , CC: , , , , References: <1511765699-47553-1-git-send-email-yunlong.song@huawei.com> From: Yunlong Song Message-ID: <277e385f-650f-fe29-ac41-ff847a1b7858@huawei.com> Date: Thu, 30 Nov 2017 10:42:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.111.220.140] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SSR can make hot/warm/cold nodes written together, so why should we account them different? On 2017/11/29 19:56, Chao Yu wrote: > On 2017/11/27 14:54, Yunlong Song wrote: >> Sometimes f2fs_gc is called with no target victim (e.g. xfstest >> generic/027, ndirty_node:545 ndiry_dent:1 ndirty_imeta:513 rsvd_segs:21 >> free_segs:27, has_not_enough_free_secs will return true). This patch >> first merges pages and then converts into sections. > I don't think this could be right, IMO, instead, it would be better to > account dirty hot/warm/cold nodes or imeta separately, as actually, they > will use different section, but currently, our calculation way is based > on that they could be written to same section. > > Thanks, > >> Signed-off-by: Yunlong Song >> --- >> fs/f2fs/f2fs.h | 9 --------- >> fs/f2fs/segment.c | 12 +++++++----- >> fs/f2fs/segment.h | 13 +++++++++---- >> 3 files changed, 16 insertions(+), 18 deletions(-) >> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >> index ca6b0c9..e89cff7 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -1675,15 +1675,6 @@ static inline int get_dirty_pages(struct inode *inode) >> return atomic_read(&F2FS_I(inode)->dirty_pages); >> } >> >> -static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) >> -{ >> - unsigned int pages_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg; >> - unsigned int segs = (get_pages(sbi, block_type) + pages_per_sec - 1) >> >> - sbi->log_blocks_per_seg; >> - >> - return segs / sbi->segs_per_sec; >> -} >> - >> static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) >> { >> return sbi->total_valid_block_count; >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index c117e09..603f805 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -171,17 +171,19 @@ static unsigned long __find_rev_next_zero_bit(const unsigned long *addr, >> >> bool need_SSR(struct f2fs_sb_info *sbi) >> { >> - int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES); >> - int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS); >> - int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA); >> + s64 node_pages = get_pages(sbi, F2FS_DIRTY_NODES); >> + s64 dent_pages = get_pages(sbi, F2FS_DIRTY_DENTS); >> + s64 imeta_pages = get_pages(sbi, F2FS_DIRTY_IMETA); >> >> if (test_opt(sbi, LFS)) >> return false; >> if (sbi->gc_thread && sbi->gc_thread->gc_urgent) >> return true; >> >> - return free_sections(sbi) <= (node_secs + 2 * dent_secs + imeta_secs + >> - SM_I(sbi)->min_ssr_sections + reserved_sections(sbi)); >> + return free_sections(sbi) <= >> + (PAGE2SEC(sbi, node_pages + imeta_pages) + >> + PAGE2SEC(sbi, 2 * dent_pages) + >> + SM_I(sbi)->min_ssr_sections + reserved_sections(sbi)); >> } >> >> void register_inmem_page(struct inode *inode, struct page *page) >> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h >> index d1d394c..723d79e 100644 >> --- a/fs/f2fs/segment.h >> +++ b/fs/f2fs/segment.h >> @@ -115,6 +115,10 @@ >> #define SECTOR_TO_BLOCK(sectors) \ >> ((sectors) >> F2FS_LOG_SECTORS_PER_BLOCK) >> >> +#define PAGE2SEC(sbi, pages) \ >> + ((((pages) + BLKS_PER_SEC(sbi) - 1) \ >> + >> sbi->log_blocks_per_seg) / sbi->segs_per_sec) >> + >> /* >> * indicate a block allocation direction: RIGHT and LEFT. >> * RIGHT means allocating new sections towards the end of volume. >> @@ -527,9 +531,9 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi) >> static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, >> int freed, int needed) >> { >> - int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES); >> - int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS); >> - int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA); >> + s64 node_pages = get_pages(sbi, F2FS_DIRTY_NODES); >> + s64 dent_pages = get_pages(sbi, F2FS_DIRTY_DENTS); >> + s64 imeta_pages = get_pages(sbi, F2FS_DIRTY_IMETA); >> >> if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) >> return false; >> @@ -538,7 +542,8 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, >> has_curseg_enough_space(sbi)) >> return false; >> return (free_sections(sbi) + freed) <= >> - (node_secs + 2 * dent_secs + imeta_secs + >> + (PAGE2SEC(sbi, node_pages + imeta_pages) + >> + PAGE2SEC(sbi, 2 * dent_pages) + >> reserved_sections(sbi) + needed); >> } >> >> > . > -- Thanks, Yunlong Song From 1585401557517702467@xxx Wed Nov 29 11:59:06 +0000 2017 X-GM-THRID: 1585201341637648616 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread