Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5284044rwl; Tue, 21 Mar 2023 16:40:53 -0700 (PDT) X-Google-Smtp-Source: AK7set/7ikxo72AQipTE08C3cwCQQb66kJLyQUO4Rmb+srmEkuafHX4hl2m6rebgE11tdsMgYId1 X-Received: by 2002:a05:6a00:180c:b0:5e2:3086:f977 with SMTP id y12-20020a056a00180c00b005e23086f977mr4262803pfa.2.1679442053248; Tue, 21 Mar 2023 16:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679442053; cv=none; d=google.com; s=arc-20160816; b=rCKg4fwYCHOCb6kbmPftletFavafsN3xiWpbeAJn4QqRFcyGG1mfH0R9b4aHqhusaD GRwTXxvoYhN6KLnzH55n8PVVb9nCkk2iNCHACDfJEFRV78MqcyB7hFLGg52rb7NEHTBx Z61z5wZU/2fQur27ahkhIAenn0RrWWWCImj52vKM6Q1LYO8EljyYHSrW9Cxs2KhFrwvd 8YikP3Ecy14WxSWpbQMf3v1JenKLIL99Ah0FvRTz/Xv2tq/gXuwE46BIjZh5JxPhTsWq VL1IuPIFSpFilKuewBXHiq1+M+cv139q0sZc6Fw2H6uBBcLMFsZ6wNjIvOIv2kHsnbsI gtvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=ynivmx/GgkxArgX3uTv3e65nr0x7QXVcmR26SXepKHI=; b=U/c+02iB37Dy8Ca8abZCIsYeDlOtAq7QQHJ6Chph2y+KUTbF4TQc2T7jcAqVe1dr/Q HCKqwZ65HLNdxZONTN12IIwIMLg86ZI15BqVLlRbjWbyd4EGhWIz0ylkAWOGVSMqvVHl uNcQ8VegGlxNiM3MRB8Bcb36zYleA7+PjI6XS+LP2Kq6J8jcpYY+M2fQ2YTesu3zmtO8 c/QhU2l83X8Gmslo8YM90R7Eoza8LsO4+7P4CuCA/RNR1h0ilCgBOOqppOXpEREcG0vI 26rEs48+s0DWS6aF2gpoIPKwgIw3Tt0WPbhJgYI+TTzYTMw8pBZu7FgSWn99Errhyy0H unFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kqmpPWIl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a056a00244a00b006260e021ddesi15041950pfj.175.2023.03.21.16.40.41; Tue, 21 Mar 2023 16:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kqmpPWIl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230178AbjCUXfi (ORCPT + 99 others); Tue, 21 Mar 2023 19:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjCUXff (ORCPT ); Tue, 21 Mar 2023 19:35:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9537B55061 for ; Tue, 21 Mar 2023 16:35:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2D617B81ABD for ; Tue, 21 Mar 2023 23:35:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9138C433EF; Tue, 21 Mar 2023 23:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679441730; bh=PZ2yEhhSeCeCeKzYLqPfWKOUkMktx89UXXqJ0+k+Nl8=; h=Date:From:To:Subject:References:In-Reply-To:From; b=kqmpPWIlRBwlB2oQhWYTuKkB5oCnkhNijseuOiiXF7lMPi2PE2ZEODaZieqfO4ZPE YYWSUYOAjBFHfwDN9E4e7Ml52vcpzXUIwivTkqm8xxjcRmp7iRQBuyC5bx/Gpd3M7V DSLtyDSfb4xZ8GySWTvCapDYV8PnNGZOMox70BurBnIq9tVgo9hFvW91WiwFRgtPhk MIWmeTfh6mxR1fwNN+P4+gBxTekqwAQGr4U6x75p/gRl+aBHiRz/OePakluX9NB/BH HC04Rg8lh0TnjmHEMxhUST4xCfGurwbCwkKKtJ9Osu1s+Krz5hraQPmoLEMTmat4Bj zVHQgzz4QHk5A== Date: Tue, 21 Mar 2023 16:35:29 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH] f2fs: apply zone capacity to all zone type Message-ID: References: <20230321231157.963598-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230321231157.963598-1-jaegeuk@kernel.org> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/21, Jaegeuk Kim wrote: > If we manage the zone capacity per zone type, it'll break the GC assumption. > And, the current logic complains valid block count mismatch. > Let's apply zone capacity to all zone type, if specified. > Added: Fixes: de881df97768 ("f2fs: support zone capacity less than zone size") > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/segment.c | 65 +++-------------------------------------------- > fs/f2fs/segment.h | 3 +++ > 2 files changed, 7 insertions(+), 61 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 055e70e77aa2..6c11789da884 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -4999,48 +4999,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi) > return 0; > } > > -static bool is_conv_zone(struct f2fs_sb_info *sbi, unsigned int zone_idx, > - unsigned int dev_idx) > -{ > - if (!bdev_is_zoned(FDEV(dev_idx).bdev)) > - return true; > - return !test_bit(zone_idx, FDEV(dev_idx).blkz_seq); > -} > - > -/* Return the zone index in the given device */ > -static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno, > - int dev_idx) > -{ > - block_t sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno)); > - > - return (sec_start_blkaddr - FDEV(dev_idx).start_blk) >> > - sbi->log_blocks_per_blkz; > -} > - > -/* > - * Return the usable segments in a section based on the zone's > - * corresponding zone capacity. Zone is equal to a section. > - */ > -static inline unsigned int f2fs_usable_zone_segs_in_sec( > - struct f2fs_sb_info *sbi, unsigned int segno) > -{ > - unsigned int dev_idx, zone_idx; > - > - dev_idx = f2fs_target_device_index(sbi, START_BLOCK(sbi, segno)); > - zone_idx = get_zone_idx(sbi, GET_SEC_FROM_SEG(sbi, segno), dev_idx); > - > - /* Conventional zone's capacity is always equal to zone size */ > - if (is_conv_zone(sbi, zone_idx, dev_idx)) > - return sbi->segs_per_sec; > - > - if (!sbi->unusable_blocks_per_sec) > - return sbi->segs_per_sec; > - > - /* Get the segment count beyond zone capacity block */ > - return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >> > - sbi->log_blocks_per_seg); > -} > - > /* > * Return the number of usable blocks in a segment. The number of blocks > * returned is always equal to the number of blocks in a segment for > @@ -5053,23 +5011,13 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg( > struct f2fs_sb_info *sbi, unsigned int segno) > { > block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr; > - unsigned int zone_idx, dev_idx, secno; > - > - secno = GET_SEC_FROM_SEG(sbi, segno); > - seg_start = START_BLOCK(sbi, segno); > - dev_idx = f2fs_target_device_index(sbi, seg_start); > - zone_idx = get_zone_idx(sbi, secno, dev_idx); > - > - /* > - * Conventional zone's capacity is always equal to zone size, > - * so, blocks per segment is unchanged. > - */ > - if (is_conv_zone(sbi, zone_idx, dev_idx)) > - return sbi->blocks_per_seg; > + unsigned int secno; > > if (!sbi->unusable_blocks_per_sec) > return sbi->blocks_per_seg; > > + secno = GET_SEC_FROM_SEG(sbi, segno); > + seg_start = START_BLOCK(sbi, segno); > sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno)); > sec_cap_blkaddr = sec_start_blkaddr + CAP_BLKS_PER_SEC(sbi); > > @@ -5103,11 +5051,6 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi > return 0; > } > > -static inline unsigned int f2fs_usable_zone_segs_in_sec(struct f2fs_sb_info *sbi, > - unsigned int segno) > -{ > - return 0; > -} > #endif > unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, > unsigned int segno) > @@ -5122,7 +5065,7 @@ unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, > unsigned int segno) > { > if (f2fs_sb_has_blkzoned(sbi)) > - return f2fs_usable_zone_segs_in_sec(sbi, segno); > + return CAP_SEGS_PER_SEC(sbi); > > return sbi->segs_per_sec; > } > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h > index efdb7fc3b797..babb29a1c034 100644 > --- a/fs/f2fs/segment.h > +++ b/fs/f2fs/segment.h > @@ -104,6 +104,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, > #define CAP_BLKS_PER_SEC(sbi) \ > ((sbi)->segs_per_sec * (sbi)->blocks_per_seg - \ > (sbi)->unusable_blocks_per_sec) > +#define CAP_SEGS_PER_SEC(sbi) \ > + ((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\ > + (sbi)->log_blocks_per_seg)) > #define GET_SEC_FROM_SEG(sbi, segno) \ > (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec) > #define GET_SEG_FROM_SEC(sbi, secno) \ > -- > 2.40.0.rc1.284.g88254d51c5-goog