Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1572982rdb; Mon, 19 Feb 2024 23:31:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXCqut1MoyJlkT6ZbyN/ZxynLuZGSzQTEhpAU7TGhqD/3HNMiSEIMcXnIiOZhL+5gPUczX8+wfnhYVWv0ZqLYp4g//DBK1J5YzKtySSMg== X-Google-Smtp-Source: AGHT+IH/I1fJwvcOzbXKTZdVpO4f+MLn51OaTwSiALEaH81XzOinJiKoj57yCGfB92eExw0H2AkB X-Received: by 2002:a05:6402:12d3:b0:564:7d36:259d with SMTP id k19-20020a05640212d300b005647d36259dmr3123187edx.17.1708414280174; Mon, 19 Feb 2024 23:31:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708414280; cv=pass; d=google.com; s=arc-20160816; b=KAo3LfHYKtgxnE19hXtVWEtzoAHHeV3q12HKWomrswHwsZQ9Hhr+CCHHc9HORxJAmG 7uyYQ4wqFMpzabBDXOIBdfeE3PuQm0K73L7VpBWPVqVhDm0/adlN/B2rUauZS6yIImdD s/MlQirriFpZZd7BJxN14qXuXo2vlOaFJeof1Bm+IJNKh88z73HRuiEBlDMnArnPysDV cYYtheh7VUpA3+Oko0edIfYg/lf02B2jNhZvldSzkifiEFEPsDpHmRFKbU4kWj/th3Zk 3wssi1n1Kfr/GPxL7nR40ebCSWr04Cm3exAaCzJbch7G2VuI+hO892l+YtDcHaAwJb0b kpAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LXdZZWsekregI13VH2wKLdCjgx2gH/jIrNAs3e9XgQI=; fh=PHq4OuhOUUP7V1I+gDdMCZNzaT4vH9shSoLBu78e8bA=; b=xaUCauNBhFG/atWNEyuCpSLQTccOzAKBmDJFxgHdKNzDUeJrtHLEJc5lj+55UIkQr3 qyFah8a7B1zDpjblcvwPKk3obX6/fdyjiYeNrsHlyildu4aOldZ1yQ3dDB+mpKyyIWCJ 4l2EKxHy3SLPpY/wXI1LOdWM0x0PjtYUajVKqdc3lXs94tt/4Wc71uVC3D0oK5z4YsPN XRCGK0a/nNfZWXYYLb6IYxkSxyQa4dGbBGuZfkSY7ElCr/caTiTbtdLwrTH0MajKsX3j bKlETZL9FBZS/4h3gapuWKbP+nUiOpB9SRjRGnZXLiAdRyn/uxAt1CupCOTndLUK1W6I t/Gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fmVP63GF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t23-20020a05640203d700b00563f2aaedb0si3180499edw.291.2024.02.19.23.31.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 23:31:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fmVP63GF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E39701F24565 for ; Tue, 20 Feb 2024 07:31:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 865605B5B3; Tue, 20 Feb 2024 07:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fmVP63GF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9494A5B5BA for ; Tue, 20 Feb 2024 07:30:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708414250; cv=none; b=kS4jRJvD7ggwRULeJJCMFeydPCxOu9GhVoYp/PulNwAde30P5E611DbAIVYuV6BNmw1R4xaEJME5MhLDF36rMImAdLZnE7sUK1zI2GESyL/Stli6ItHBHf4CLWVndAm+8GFCReCjoybE4M+PyG1NEfQC100mkhyh5PN04gxjQfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708414250; c=relaxed/simple; bh=OXGYwlEcvKSUcy2Rn7wKI35ffz8WjMg3NS9M274cDBk=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=SI5/j5GTZCD4+18Pf6gvsWPIX7razdF3ILWmAb6GP1k9o5edz6WjjqQyuFlUhZJfXz5nHXP7OocCScHxb5jELgjsaxu4qE9W6OLUBdT2xsVP4LDXG1CId7vwBGjjVC36v8qpGNSRciZE+5sK11RV7ZsFqoHl7cQof/Bqy3xAh98= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fmVP63GF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 295DEC433F1; Tue, 20 Feb 2024 07:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708414250; bh=OXGYwlEcvKSUcy2Rn7wKI35ffz8WjMg3NS9M274cDBk=; h=Date:Subject:To:References:From:In-Reply-To:From; b=fmVP63GFYSZHSKWN5LDO/SlxUIB4eeyGvmf6n9OzQyvUKCrghxkUdaWEkcunV8FKU 3wme0jcNiIVelsPo8KPbDgquH4XtPw4e8W5AnHm7cTMtI+Szxf8be37I9t/x1hJUEl mfAIfnMEciWPIw9RBbTrH9UvTpJa++4aREfmPYYbNSfPrtbS8xfJCEHu6LJbpMvsPY u31AD3Harai+DtetK25epW78qBcxQij+oCoNqxhkYJFLaYxuStcC+TWoIhs6AKPq4+ GnjI1+V7pjqwjf2/Fk0Vj57b4aO3eTmBmd5H8tJzwrSATQaJb6Mez+iYCaYSk11wG5 nKYWa67hK9D1A== Message-ID: Date: Tue, 20 Feb 2024 15:30:46 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH 2/3 v2] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC Content-Language: en-US To: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20240207005105.3744811-1-jaegeuk@kernel.org> <20240207005105.3744811-2-jaegeuk@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/2/13 2:10, Jaegeuk Kim wrote: How do you think of appending below diff which cleans up missing parts? --- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 4 ++-- fs/f2fs/segment.c | 4 ++-- fs/f2fs/segment.h | 22 +++++++++++----------- fs/f2fs/super.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c4488e12c56e..fc9328655de8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3491,7 +3491,7 @@ static inline __le32 *get_dnode_addr(struct inode *inode, sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + (extra_isize))) \ -#define __is_large_section(sbi) ((sbi)->segs_per_sec > 1) +#define __is_large_section(sbi) (SEGS_PER_SEC(sbi) > 1) #define __is_meta_io(fio) (PAGE_TYPE_OF_BIO((fio)->type) == META) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 20a26bb5b889..ef43d33278ea 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2997,8 +2997,8 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg) if (!f2fs_is_multi_device(sbi) || sbi->s_ndevs - 1 <= range.dev_num || __is_large_section(sbi)) { - f2fs_warn(sbi, "Can't flush %u in %d for segs_per_sec %u != 1", - range.dev_num, sbi->s_ndevs, sbi->segs_per_sec); + f2fs_warn(sbi, "Can't flush %u in %d for SEGS_PER_SEC %u != 1", + range.dev_num, sbi->s_ndevs, SEGS_PER_SEC(sbi)); return -EINVAL; } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 97ac733ceffe..b59e29608ae7 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2750,7 +2750,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type) if (f2fs_need_rand_seg(sbi)) return get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); - /* if segs_per_sec is large than 1, we need to keep original policy. */ + /* if SEGS_PER_SEC() is large than 1, we need to keep original policy. */ if (__is_large_section(sbi)) return curseg->segno; @@ -3498,7 +3498,7 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, */ if (segment_full) { if (type == CURSEG_COLD_DATA_PINNED && - !((curseg->segno + 1) % sbi->segs_per_sec)) + !((curseg->segno + 1) % SEGS_PER_SEC(sbi))) goto skip_new_segment; if (from_gc) { diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index cb982af765c3..63f278210654 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -48,21 +48,21 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, #define IS_CURSEC(sbi, secno) \ (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \ - (sbi)->segs_per_sec) || \ + SEGS_PER_SEC(sbi)) || \ ((secno) == CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC)->segno / \ - (sbi)->segs_per_sec)) + SEGS_PER_SEC(sbi))) #define MAIN_BLKADDR(sbi) \ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \ @@ -93,7 +93,7 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, #define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \ (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> (sbi)->log_blocks_per_seg) #define GET_BLKOFF_FROM_SEG0(sbi, blk_addr) \ - (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & ((sbi)->blocks_per_seg - 1)) + (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & (BLKS_PER_SEG(sbi) - 1)) #define GET_SEGNO(sbi, blk_addr) \ ((!__is_valid_data_blkaddr(blk_addr) || \ @@ -101,9 +101,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \ GET_SEGNO_FROM_SEG0(sbi, blk_addr))) #define GET_SEC_FROM_SEG(sbi, segno) \ - (((segno) == -1) ? -1 : (segno) / (sbi)->segs_per_sec) + (((segno) == -1) ? -1 : (segno) / SEGS_PER_SEC(sbi)) #define GET_SEG_FROM_SEC(sbi, secno) \ - ((secno) * (sbi)->segs_per_sec) + ((secno) * SEGS_PER_SEC(sbi)) #define GET_ZONE_FROM_SEC(sbi, secno) \ (((secno) == -1) ? -1 : (secno) / (sbi)->secs_per_zone) #define GET_ZONE_FROM_SEG(sbi, segno) \ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 2a8b6cfaf683..9d2c680a61f5 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4723,7 +4723,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) .reason = CP_DISCARD, .trim_start = 0, .trim_end = MAIN_SEGS(sbi) - 1, - .trim_minlen = sbi->blocks_per_seg, + .trim_minlen = BLKS_PER_SEG(sbi), }; f2fs_write_checkpoint(sbi, &cpc); } -- 2.40.1