Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp639359rdh; Wed, 7 Feb 2024 15:51:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWnToTdphu9L6OvMzygUlvInkzcTA1A1leykCeiJnLC5Cxn4nOXZh12CnnijMp0xFeE9gkPDZn1mzM0fu/Ni+9aW7q63wu15f+pPyta+Q== X-Google-Smtp-Source: AGHT+IEPlEWby3Rg3QEa+MYkyARlRdYxQC90ArKy7v70+2yKPLBxUZPQ5m8lMCH9t0ejD1eTcOEw X-Received: by 2002:a05:622a:19a7:b0:42b:e19c:4091 with SMTP id u39-20020a05622a19a700b0042be19c4091mr9200107qtc.40.1707349893576; Wed, 07 Feb 2024 15:51:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707349893; cv=pass; d=google.com; s=arc-20160816; b=VlqcFrK/NfVo77/deSyDtrtqC46Ddg3tJWFFjUG/Sxc3hyzLPDdM/ux1lUBotH902u HRhvmM1d0kVCF+x0HJdwsPeFXQCLTKcq/vCQcZQ+DVXf1r6JR/+zW9KYjg15c5TgPOzo B1FPZpBSCgROGSE1Q8f38i8JyJ28F75odKpV21dDXrC5chR3MHz/KijY5JdA3fDM/B1L c+7zBlQ/vn+k+yq6BdlUOuUQtxwuC5pE0JMrbcpK2IcZ7t1zx5lLtPh3D/H0QUmx/C39 kF2AMkde8hbu/epTaIfaJjSmBuLxdnlawZAFADSZiE6JK9/CFbiuhVeRypajCUJlDgXm ywNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=QZjRuUJGY6Uf1zW/7hstp344HUm1MLKhCLcRGVyMops=; fh=Yq2hIbBnx4SLK33xUF+zaa2tc2lHUYSg5diUeFagUHs=; b=OC3xAhTwDIMhAAU1E3GCT+ENzfKffEbGHqayX0T6DW+Q1E8aWPP6LzdX54NYIVqHti knpNdXz0aG2n6sEqGwghvdqZutxwW+PZElpIXYjuSdCR//2fICHt3w2uJoM4/OcT2iEC m+lAmkNVBa/NluEAOfOaaDVPuY81d2A3Ax9TGVs/fJYHX0A8H/oXAC7r9zkX3puKU4qm 67PyYe47IP+O9DFBjfWTnGIVwVdf5YLzTCbHeADqotQobAoowmpN6F1IwiRwr67x/+Ka mt4xeDeYTbGc/X/jqCLxqFT/H5QLc8hG5JACE+YfsECWsVQztB39Xakh4HmeInP3zD8s RRcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gMJIVZs2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57303-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWrHYXIaJeJckwi5Dw3Nay1dkuotGTXZBBhnY1yVGtpTtjAXa7B+1BmvmeKfJ4aMwFa+BNLFx/h4xdV8jQWMGebZastknmm8gi2ggr88Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n17-20020ac85a11000000b0042c3a23144esi2225625qta.626.2024.02.07.15.51.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 15:51:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gMJIVZs2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-57303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57303-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 434E21C22B54 for ; Wed, 7 Feb 2024 23:51:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BAA2535C3; Wed, 7 Feb 2024 23:51:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gMJIVZs2" Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E099A535AB for ; Wed, 7 Feb 2024 23:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707349885; cv=none; b=MOcAqFQSc72fd5Rqih8uwtU6RG4acjGc1s65GbX+aKkMykXa1KgNZQvOgRn005DQQQsXbaZnSthRYekZnwd4qjxpwchwLtx4JFMao0CEkkWQAxNy7eA+vvkv/nvz4ymEmbL7gZrQto/0GgsAClecMXSzrnsQvDeqhVOFSVOmNnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707349885; c=relaxed/simple; bh=Eh7aI19yO2ZdB3KbGDY8Y2r/L8h0UfBdQ33zPfXGOXc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IFaI+TaGwtVpDo75aUjhn3FeV40e8GyiJu2noPla1s1kpFnKhfT+3KzewBrB24H6draTzJ1ednsSXmqanuWXhalkTfFZ4kOyd+ZZRpBqnWSznm1+24fDg2alI4huPBgql84VMS3DynnlmePggsob+LUlndY1XOqqF8QugezShfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gMJIVZs2; arc=none smtp.client-ip=209.85.221.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-4c0274ed2aaso441585e0c.2 for ; Wed, 07 Feb 2024 15:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707349882; x=1707954682; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QZjRuUJGY6Uf1zW/7hstp344HUm1MLKhCLcRGVyMops=; b=gMJIVZs2jP+CMPj/VNASzMBdDpVlAfJRPhb6AxBemEmDTZLXlgxi5DScJ/VFd+1v5q kuXNogkBpyfoTBEE31NKLRNt15XXbeD9lc/w3BfE78ln56uRqemHqwiTjZctPPCWfkPN ARSebZrSowAUHG84TWvq6MRfBtSQHZCfFZgOegR4A1+DNEtPXX+VtMFx244hdhIAWJLz x4G7eY+d4XzqTvXquWcnyegITjipC3cvDq21fIqv+hOg3J0QjJNGAGXpTOqQFxxfqV+Q 3N2TfC7DXfB3Kie6LysE3Chg3totLBbuJTP7b0LIV5RnPAc0cjpWiyW08CNaHVsUaqTH 0jUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707349882; x=1707954682; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QZjRuUJGY6Uf1zW/7hstp344HUm1MLKhCLcRGVyMops=; b=RaN8AaWGaNIrQvgWPgVXdEyMLTeXO5S7mru6yLgISyvsOh29TekEF7cNaKta14tOhy 6KOGsETNaKI8P2zgbUuiVNP/iLFX+zCiqOZ/tlrtwTgvLLo20/7GXpu3fdIynrLoqfoe M3cp4z4XAN62ITZ5aZRusDnDoxCXIjo841aF5eV5Eypf+rBJ2XnAc3Z+CwaqxXYd2c2i ppTRkvtIM9bZp1mK1zQzrfC5Sd+XT4WXmMDbPNbtJH5MpSBrTwmZ8CTpI2VZ+UkdBGlY LqfFRTHqsM4osq5KEofc+O9PuMe8vYZA1vjqPSl5BLbqAjhks0nQM0L1gRZgLJJUFgo2 qrbg== X-Gm-Message-State: AOJu0Yyqc7DnTbqD5pr+VuJIEk4jqn6axpToaNE7qWjxDsQYPnrjxfCZ 3MBYAhRn+kWTm5UHn9/LSBvcYbr5ESt3UOMBrUu0vKUTAx0o765iDXsN5zuOJAzKsbAjuA6VhP0 mXVRV/anFcIEeF3Z7fFoem6xGj7k= X-Received: by 2002:a05:6122:1807:b0:4c0:292d:193c with SMTP id ay7-20020a056122180700b004c0292d193cmr4332440vkb.12.1707349879913; Wed, 07 Feb 2024 15:51:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240207005105.3744811-1-jaegeuk@kernel.org> <20240207005105.3744811-3-jaegeuk@kernel.org> In-Reply-To: From: Daeho Jeong Date: Wed, 7 Feb 2024 15:51:08 -0800 Message-ID: Subject: Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: kill zone-capacity support To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Reviewed-by: Daeho Jeong On Wed, Feb 7, 2024 at 3:31=E2=80=AFPM Jaegeuk Kim wro= te: > > Since we don't see any user, let's kill. > > Signed-off-by: Jaegeuk Kim > --- > > from v1: > - keep setting the seq bit > > Documentation/ABI/testing/sysfs-fs-f2fs | 6 -- > fs/f2fs/debug.c | 7 +- > fs/f2fs/f2fs.h | 5 -- > fs/f2fs/file.c | 6 +- > fs/f2fs/gc.c | 33 +++------ > fs/f2fs/gc.h | 26 ------- > fs/f2fs/segment.c | 93 +++---------------------- > fs/f2fs/segment.h | 41 ++++------- > fs/f2fs/super.c | 16 ++--- > fs/f2fs/sysfs.c | 6 -- > 10 files changed, 44 insertions(+), 195 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/= testing/sysfs-fs-f2fs > index 48c135e24eb5..dff8c87d87dd 100644 > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > @@ -628,12 +628,6 @@ Contact: "Jaegeuk Kim" > Description: Controls max # of node block writes to be used for roll f= orward > recovery. This can limit the roll forward recovery time. > > -What: /sys/fs/f2fs//unusable_blocks_per_sec > -Date: June 2022 > -Contact: "Jaegeuk Kim" > -Description: Shows the number of unusable blocks in a section which wa= s defined by > - the zone capacity reported by underlying zoned device. > - > What: /sys/fs/f2fs//current_atomic_write > Date: July 2022 > Contact: "Daeho Jeong" > diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c > index 0d02224b99b7..6617195bd27e 100644 > --- a/fs/f2fs/debug.c > +++ b/fs/f2fs/debug.c > @@ -32,21 +32,20 @@ static struct dentry *f2fs_debugfs_root; > void f2fs_update_sit_info(struct f2fs_sb_info *sbi) > { > struct f2fs_stat_info *si =3D F2FS_STAT(sbi); > - unsigned long long blks_per_sec, hblks_per_sec, total_vblocks; > + unsigned long long hblks_per_sec, total_vblocks; > unsigned long long bimodal, dist; > unsigned int segno, vblocks; > int ndirty =3D 0; > > bimodal =3D 0; > total_vblocks =3D 0; > - blks_per_sec =3D CAP_BLKS_PER_SEC(sbi); > - hblks_per_sec =3D blks_per_sec / 2; > + hblks_per_sec =3D BLKS_PER_SEC(sbi) / 2; > for (segno =3D 0; segno < MAIN_SEGS(sbi); segno +=3D SEGS_PER_SEC= (sbi)) { > vblocks =3D get_valid_blocks(sbi, segno, true); > dist =3D abs(vblocks - hblks_per_sec); > bimodal +=3D dist * dist; > > - if (vblocks > 0 && vblocks < blks_per_sec) { > + if (vblocks > 0 && vblocks < BLKS_PER_SEC(sbi)) { > total_vblocks +=3D vblocks; > ndirty++; > } > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 9a9e858083af..34d718301392 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -1618,7 +1618,6 @@ struct f2fs_sb_info { > unsigned int meta_ino_num; /* meta inode number*/ > unsigned int log_blocks_per_seg; /* log2 blocks per segmen= t */ > unsigned int blocks_per_seg; /* blocks per segment */ > - unsigned int unusable_blocks_per_sec; /* unusable blocks per se= ction */ > unsigned int segs_per_sec; /* segments per section *= / > unsigned int secs_per_zone; /* sections per zone */ > unsigned int total_sections; /* total section count */ > @@ -3743,10 +3742,6 @@ void f2fs_destroy_segment_manager(struct f2fs_sb_i= nfo *sbi); > int __init f2fs_create_segment_manager_caches(void); > void f2fs_destroy_segment_manager_caches(void); > int f2fs_rw_hint_to_seg_type(enum rw_hint hint); > -unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, > - unsigned int segno); > -unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, > - unsigned int segno); > > #define DEF_FRAGMENT_SIZE 4 > #define MIN_FRAGMENT_SIZE 1 > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index b0be576b2090..2c13b340c8a0 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -1717,7 +1717,7 @@ static int f2fs_expand_inode_data(struct inode *ino= de, loff_t offset, > return 0; > > if (f2fs_is_pinned_file(inode)) { > - block_t sec_blks =3D CAP_BLKS_PER_SEC(sbi); > + block_t sec_blks =3D BLKS_PER_SEC(sbi); > block_t sec_len =3D roundup(map.m_len, sec_blks); > > map.m_len =3D sec_blks; > @@ -2525,7 +2525,7 @@ static int __f2fs_ioc_gc_range(struct file *filp, s= truct f2fs_gc_range *range) > ret =3D -EAGAIN; > goto out; > } > - range->start +=3D CAP_BLKS_PER_SEC(sbi); > + range->start +=3D BLKS_PER_SEC(sbi); > if (range->start <=3D end) > goto do_more; > out: > @@ -2654,7 +2654,7 @@ static int f2fs_defragment_range(struct f2fs_sb_inf= o *sbi, > goto out; > } > > - sec_num =3D DIV_ROUND_UP(total, CAP_BLKS_PER_SEC(sbi)); > + sec_num =3D DIV_ROUND_UP(total, BLKS_PER_SEC(sbi)); > > /* > * make sure there are enough free section for LFS allocation, th= is can > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index d61a60c1c844..0a1a50b68df8 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -340,14 +340,13 @@ static unsigned int get_cb_cost(struct f2fs_sb_info= *sbi, unsigned int segno) > unsigned char age =3D 0; > unsigned char u; > unsigned int i; > - unsigned int usable_segs_per_sec =3D f2fs_usable_segs_in_sec(sbi,= segno); > > - for (i =3D 0; i < usable_segs_per_sec; i++) > + for (i =3D 0; i < SEGS_PER_SEC(sbi); i++) > mtime +=3D get_seg_entry(sbi, start + i)->mtime; > vblocks =3D get_valid_blocks(sbi, segno, true); > > - mtime =3D div_u64(mtime, usable_segs_per_sec); > - vblocks =3D div_u64(vblocks, usable_segs_per_sec); > + mtime =3D div_u64(mtime, SEGS_PER_SEC(sbi)); > + vblocks =3D div_u64(vblocks, SEGS_PER_SEC(sbi)); > > u =3D (vblocks * 100) >> sbi->log_blocks_per_seg; > > @@ -530,7 +529,6 @@ static void atgc_lookup_victim(struct f2fs_sb_info *s= bi, > unsigned long long age, u, accu; > unsigned long long max_mtime =3D sit_i->dirty_max_mtime; > unsigned long long min_mtime =3D sit_i->dirty_min_mtime; > - unsigned int sec_blocks =3D CAP_BLKS_PER_SEC(sbi); > unsigned int vblocks; > unsigned int dirty_threshold =3D max(am->max_candidate_count, > am->candidate_ratio * > @@ -560,13 +558,13 @@ static void atgc_lookup_victim(struct f2fs_sb_info = *sbi, > > /* age =3D 10000 * x% * 60 */ > age =3D div64_u64(accu * (max_mtime - ve->mtime), total_time) * > - age_weigh= t; > + age_weight; > > vblocks =3D get_valid_blocks(sbi, ve->segno, true); > - f2fs_bug_on(sbi, !vblocks || vblocks =3D=3D sec_blocks); > + f2fs_bug_on(sbi, !vblocks || vblocks =3D=3D BLKS_PER_SEC(sbi)); > > /* u =3D 10000 * x% * 40 */ > - u =3D div64_u64(accu * (sec_blocks - vblocks), sec_blocks) * > + u =3D div64_u64(accu * (BLKS_PER_SEC(sbi) - vblocks), BLKS_PER_SE= C(sbi)) * > (100 - age_weight= ); > > f2fs_bug_on(sbi, age + u >=3D UINT_MAX); > @@ -1003,7 +1001,6 @@ static int gc_node_segment(struct f2fs_sb_info *sbi= , > int phase =3D 0; > bool fggc =3D (gc_type =3D=3D FG_GC); > int submitted =3D 0; > - unsigned int usable_blks_in_seg =3D f2fs_usable_blks_in_seg(sbi, = segno); > > start_addr =3D START_BLOCK(sbi, segno); > > @@ -1013,7 +1010,7 @@ static int gc_node_segment(struct f2fs_sb_info *sbi= , > if (fggc && phase =3D=3D 2) > atomic_inc(&sbi->wb_sync_req[NODE]); > > - for (off =3D 0; off < usable_blks_in_seg; off++, entry++) { > + for (off =3D 0; off < BLKS_PER_SEG(sbi); off++, entry++) { > nid_t nid =3D le32_to_cpu(entry->nid); > struct page *node_page; > struct node_info ni; > @@ -1498,14 +1495,13 @@ static int gc_data_segment(struct f2fs_sb_info *s= bi, struct f2fs_summary *sum, > int off; > int phase =3D 0; > int submitted =3D 0; > - unsigned int usable_blks_in_seg =3D f2fs_usable_blks_in_seg(sbi, = segno); > > start_addr =3D START_BLOCK(sbi, segno); > > next_step: > entry =3D sum; > > - for (off =3D 0; off < usable_blks_in_seg; off++, entry++) { > + for (off =3D 0; off < BLKS_PER_SEG(sbi); off++, entry++) { > struct page *data_page; > struct inode *inode; > struct node_info dni; /* dnode info for the data */ > @@ -1520,7 +1516,7 @@ static int gc_data_segment(struct f2fs_sb_info *sbi= , struct f2fs_summary *sum, > */ > if ((gc_type =3D=3D BG_GC && has_not_enough_free_secs(sbi= , 0, 0)) || > (!force_migrate && get_valid_blocks(sbi, segno, t= rue) =3D=3D > - CAP_BLKS_PER_SEC(= sbi))) > + BLKS_PER_SEC(sbi)= )) > return submitted; > > if (check_valid_map(sbi, segno, off) =3D=3D 0) > @@ -1680,15 +1676,6 @@ static int do_garbage_collect(struct f2fs_sb_info = *sbi, > if (__is_large_section(sbi)) > end_segno =3D rounddown(end_segno, SEGS_PER_SEC(sbi)); > > - /* > - * zone-capacity can be less than zone-size in zoned devices, > - * resulting in less than expected usable segments in the zone, > - * calculate the end segno in the zone which can be garbage colle= cted > - */ > - if (f2fs_sb_has_blkzoned(sbi)) > - end_segno -=3D SEGS_PER_SEC(sbi) - > - f2fs_usable_segs_in_sec(sbi, segn= o); > - > sanity_check_seg_type(sbi, get_seg_entry(sbi, segno)->type); > > /* readahead multi ssa blocks those have contiguous address */ > @@ -1862,7 +1849,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_g= c_control *gc_control) > > total_freed +=3D seg_freed; > > - if (seg_freed =3D=3D f2fs_usable_segs_in_sec(sbi, segno)) { > + if (seg_freed =3D=3D SEGS_PER_SEC(sbi)) { > sec_freed++; > total_sec_freed++; > } > diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h > index 28a00942802c..e4a75aa4160f 100644 > --- a/fs/f2fs/gc.h > +++ b/fs/f2fs/gc.h > @@ -68,34 +68,8 @@ struct victim_entry { > * inline functions > */ > > -/* > - * On a Zoned device zone-capacity can be less than zone-size and if > - * zone-capacity is not aligned to f2fs segment size(2MB), then the segm= ent > - * starting just before zone-capacity has some blocks spanning across th= e > - * zone-capacity, these blocks are not usable. > - * Such spanning segments can be in free list so calculate the sum of us= able > - * blocks in currently free segments including normal and spanning segme= nts. > - */ > -static inline block_t free_segs_blk_count_zoned(struct f2fs_sb_info *sbi= ) > -{ > - block_t free_seg_blks =3D 0; > - struct free_segmap_info *free_i =3D FREE_I(sbi); > - int j; > - > - spin_lock(&free_i->segmap_lock); > - for (j =3D 0; j < MAIN_SEGS(sbi); j++) > - if (!test_bit(j, free_i->free_segmap)) > - free_seg_blks +=3D f2fs_usable_blks_in_seg(sbi, j= ); > - spin_unlock(&free_i->segmap_lock); > - > - return free_seg_blks; > -} > - > static inline block_t free_segs_blk_count(struct f2fs_sb_info *sbi) > { > - if (f2fs_sb_has_blkzoned(sbi)) > - return free_segs_blk_count_zoned(sbi); > - > return free_segments(sbi) << sbi->log_blocks_per_seg; > } > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 8d330664b925..1013276ad12a 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -769,7 +769,7 @@ static void __locate_dirty_segment(struct f2fs_sb_inf= o *sbi, unsigned int segno, > get_valid_blocks(sbi, segno, true); > > f2fs_bug_on(sbi, unlikely(!valid_blocks || > - valid_blocks =3D=3D CAP_BLKS_PER_= SEC(sbi))); > + valid_blocks =3D=3D BLKS_PER_SEC(= sbi))); > > if (!IS_CURSEC(sbi, secno)) > set_bit(secno, dirty_i->dirty_secmap); > @@ -805,7 +805,7 @@ static void __remove_dirty_segment(struct f2fs_sb_inf= o *sbi, unsigned int segno, > unsigned int secno =3D GET_SEC_FROM_SEG(sbi, segn= o); > > if (!valid_blocks || > - valid_blocks =3D=3D CAP_BLKS_PER_= SEC(sbi)) { > + valid_blocks =3D=3D BLKS_PER_SEC(= sbi)) { > clear_bit(secno, dirty_i->dirty_secmap); > return; > } > @@ -825,22 +825,20 @@ static void locate_dirty_segment(struct f2fs_sb_inf= o *sbi, unsigned int segno) > { > struct dirty_seglist_info *dirty_i =3D DIRTY_I(sbi); > unsigned short valid_blocks, ckpt_valid_blocks; > - unsigned int usable_blocks; > > if (segno =3D=3D NULL_SEGNO || IS_CURSEG(sbi, segno)) > return; > > - usable_blocks =3D f2fs_usable_blks_in_seg(sbi, segno); > mutex_lock(&dirty_i->seglist_lock); > > valid_blocks =3D get_valid_blocks(sbi, segno, false); > ckpt_valid_blocks =3D get_ckpt_valid_blocks(sbi, segno, false); > > if (valid_blocks =3D=3D 0 && (!is_sbi_flag_set(sbi, SBI_CP_DISABL= ED) || > - ckpt_valid_blocks =3D=3D usable_blocks)) { > + ckpt_valid_blocks =3D=3D BLKS_PER_SEG(sbi))) { > __locate_dirty_segment(sbi, segno, PRE); > __remove_dirty_segment(sbi, segno, DIRTY); > - } else if (valid_blocks < usable_blocks) { > + } else if (valid_blocks < BLKS_PER_SEG(sbi)) { > __locate_dirty_segment(sbi, segno, DIRTY); > } else { > /* Recovery routine with SSR needs this */ > @@ -882,12 +880,7 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info= *sbi) > mutex_lock(&dirty_i->seglist_lock); > for_each_set_bit(segno, dirty_i->dirty_segmap[DIRTY], MAIN_SEGS(s= bi)) { > se =3D get_seg_entry(sbi, segno); > - if (IS_NODESEG(se->type)) > - holes[NODE] +=3D f2fs_usable_blks_in_seg(sbi, seg= no) - > - se->valid_blocks; > - else > - holes[DATA] +=3D f2fs_usable_blks_in_seg(sbi, seg= no) - > - se->valid_blocks; > + holes[SE_PAGETYPE(se)] +=3D BLKS_PER_SEG(sbi) - se->valid= _blocks; > } > mutex_unlock(&dirty_i->seglist_lock); > > @@ -2406,8 +2399,7 @@ static void update_sit_entry(struct f2fs_sb_info *s= bi, block_t blkaddr, int del) > new_vblocks =3D se->valid_blocks + del; > offset =3D GET_BLKOFF_FROM_SEG0(sbi, blkaddr); > > - f2fs_bug_on(sbi, (new_vblocks < 0 || > - (new_vblocks > f2fs_usable_blks_in_seg(sbi, segno= )))); > + f2fs_bug_on(sbi, new_vblocks < 0 || new_vblocks > BLKS_PER_SEG(sb= i)); > > se->valid_blocks =3D new_vblocks; > > @@ -3449,7 +3441,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *= sbi, struct page *page, > if (F2FS_OPTION(sbi).fs_mode =3D=3D FS_MODE_FRAGMENT_BLK) > f2fs_randomize_chunk(sbi, curseg); > } > - if (curseg->next_blkoff >=3D f2fs_usable_blks_in_seg(sbi, curseg-= >segno)) > + if (curseg->next_blkoff >=3D BLKS_PER_SEG(sbi)) > segment_full =3D true; > stat_inc_block_count(sbi, curseg); > > @@ -4687,8 +4679,6 @@ static void init_free_segmap(struct f2fs_sb_info *s= bi) > struct seg_entry *sentry; > > for (start =3D 0; start < MAIN_SEGS(sbi); start++) { > - if (f2fs_usable_blks_in_seg(sbi, start) =3D=3D 0) > - continue; > sentry =3D get_seg_entry(sbi, start); > if (!sentry->valid_blocks) > __set_free(sbi, start); > @@ -4710,7 +4700,7 @@ static void init_dirty_segmap(struct f2fs_sb_info *= sbi) > struct dirty_seglist_info *dirty_i =3D DIRTY_I(sbi); > struct free_segmap_info *free_i =3D FREE_I(sbi); > unsigned int segno =3D 0, offset =3D 0, secno; > - block_t valid_blocks, usable_blks_in_seg; > + block_t valid_blocks; > > while (1) { > /* find dirty segment based on free segmap */ > @@ -4719,10 +4709,9 @@ static void init_dirty_segmap(struct f2fs_sb_info = *sbi) > break; > offset =3D segno + 1; > valid_blocks =3D get_valid_blocks(sbi, segno, false); > - usable_blks_in_seg =3D f2fs_usable_blks_in_seg(sbi, segno= ); > - if (valid_blocks =3D=3D usable_blks_in_seg || !valid_bloc= ks) > + if (valid_blocks =3D=3D BLKS_PER_SEG(sbi) || !valid_block= s) > continue; > - if (valid_blocks > usable_blks_in_seg) { > + if (valid_blocks > BLKS_PER_SEG(sbi)) { > f2fs_bug_on(sbi, 1); > continue; > } > @@ -4739,7 +4728,7 @@ static void init_dirty_segmap(struct f2fs_sb_info *= sbi) > valid_blocks =3D get_valid_blocks(sbi, segno, true); > secno =3D GET_SEC_FROM_SEG(sbi, segno); > > - if (!valid_blocks || valid_blocks =3D=3D CAP_BLKS_PER_SEC= (sbi)) > + if (!valid_blocks || valid_blocks =3D=3D BLKS_PER_SEC(sbi= )) > continue; > if (IS_CURSEC(sbi, secno)) > continue; > @@ -5097,42 +5086,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *= sbi) > > return 0; > } > - > -/* > - * 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 > - * segments fully contained within a sequential zone capacity or a > - * conventional zone. For segments partially contained in a sequential > - * zone capacity, the number of usable blocks up to the zone capacity > - * is returned. 0 is returned in all other cases. > - */ > -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 secno; > - > - if (!sbi->unusable_blocks_per_sec) > - return BLKS_PER_SEG(sbi); > - > - secno =3D GET_SEC_FROM_SEG(sbi, segno); > - seg_start =3D START_BLOCK(sbi, segno); > - sec_start_blkaddr =3D START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secn= o)); > - sec_cap_blkaddr =3D sec_start_blkaddr + CAP_BLKS_PER_SEC(sbi); > - > - /* > - * If segment starts before zone capacity and spans beyond > - * zone capacity, then usable blocks are from seg start to > - * zone capacity. If the segment starts after the zone capacity, > - * then there are no usable blocks. > - */ > - if (seg_start >=3D sec_cap_blkaddr) > - return 0; > - if (seg_start + BLKS_PER_SEG(sbi) > sec_cap_blkaddr) > - return sec_cap_blkaddr - seg_start; > - > - return BLKS_PER_SEG(sbi); > -} > #else > int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi) > { > @@ -5143,31 +5096,7 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *= sbi) > { > return 0; > } > - > -static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_i= nfo *sbi, > - unsigned int segn= o) > -{ > - return 0; > -} > - > #endif > -unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, > - unsigned int segno) > -{ > - if (f2fs_sb_has_blkzoned(sbi)) > - return f2fs_usable_zone_blks_in_seg(sbi, segno); > - > - return BLKS_PER_SEG(sbi); > -} > - > -unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, > - unsigned int segno) > -{ > - if (f2fs_sb_has_blkzoned(sbi)) > - return CAP_SEGS_PER_SEC(sbi); > - > - return SEGS_PER_SEC(sbi); > -} > > /* > * Update min, max modified time for cost-benefit GC algorithm > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h > index 96cec83012f1..b725ae1a7043 100644 > --- a/fs/f2fs/segment.h > +++ b/fs/f2fs/segment.h > @@ -99,12 +99,6 @@ static inline void sanity_check_seg_type(struct f2fs_s= b_info *sbi, > ((!__is_valid_data_blkaddr(blk_addr)) ? \ > NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \ > GET_SEGNO_FROM_SEG0(sbi, blk_addr))) > -#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) =3D=3D -1) ? -1 : (segno) / (sbi)->segs_per_sec) > #define GET_SEG_FROM_SEC(sbi, secno) \ > @@ -440,7 +434,6 @@ static inline void __set_free(struct f2fs_sb_info *sb= i, unsigned int segno) > unsigned int secno =3D GET_SEC_FROM_SEG(sbi, segno); > unsigned int start_segno =3D GET_SEG_FROM_SEC(sbi, secno); > unsigned int next; > - unsigned int usable_segs =3D f2fs_usable_segs_in_sec(sbi, segno); > > spin_lock(&free_i->segmap_lock); > clear_bit(segno, free_i->free_segmap); > @@ -448,7 +441,7 @@ static inline void __set_free(struct f2fs_sb_info *sb= i, unsigned int segno) > > next =3D find_next_bit(free_i->free_segmap, > start_segno + SEGS_PER_SEC(sbi), start_segno); > - if (next >=3D start_segno + usable_segs) { > + if (next >=3D start_segno + SEGS_PER_SEC(sbi)) { > clear_bit(secno, free_i->free_secmap); > free_i->free_sections++; > } > @@ -474,7 +467,6 @@ static inline void __set_test_and_free(struct f2fs_sb= _info *sbi, > unsigned int secno =3D GET_SEC_FROM_SEG(sbi, segno); > unsigned int start_segno =3D GET_SEG_FROM_SEC(sbi, secno); > unsigned int next; > - unsigned int usable_segs =3D f2fs_usable_segs_in_sec(sbi, segno); > > spin_lock(&free_i->segmap_lock); > if (test_and_clear_bit(segno, free_i->free_segmap)) { > @@ -484,7 +476,7 @@ static inline void __set_test_and_free(struct f2fs_sb= _info *sbi, > goto skip_free; > next =3D find_next_bit(free_i->free_segmap, > start_segno + SEGS_PER_SEC(sbi), start_se= gno); > - if (next >=3D start_segno + usable_segs) { > + if (next >=3D start_segno + SEGS_PER_SEC(sbi)) { > if (test_and_clear_bit(secno, free_i->free_secmap= )) > free_i->free_sections++; > } > @@ -577,16 +569,15 @@ static inline bool has_curseg_enough_space(struct f= 2fs_sb_info *sbi, > /* check current node segment */ > for (i =3D CURSEG_HOT_NODE; i <=3D CURSEG_COLD_NODE; i++) { > segno =3D CURSEG_I(sbi, i)->segno; > - left_blocks =3D f2fs_usable_blks_in_seg(sbi, segno) - > + left_blocks =3D BLKS_PER_SEG(sbi) - > get_seg_entry(sbi, segno)->ckpt_valid_blo= cks; > - > if (node_blocks > left_blocks) > return false; > } > > /* check current data segment */ > segno =3D CURSEG_I(sbi, CURSEG_HOT_DATA)->segno; > - left_blocks =3D f2fs_usable_blks_in_seg(sbi, segno) - > + left_blocks =3D BLKS_PER_SEG(sbi) - > get_seg_entry(sbi, segno)->ckpt_valid_blocks; > if (dent_blocks > left_blocks) > return false; > @@ -604,10 +595,10 @@ static inline void __get_secs_required(struct f2fs_= sb_info *sbi, > get_pages(sbi, F2FS_DIRTY_DENTS) = + > get_pages(sbi, F2FS_DIRTY_IMETA); > unsigned int total_dent_blocks =3D get_pages(sbi, F2FS_DIRTY_DENT= S); > - unsigned int node_secs =3D total_node_blocks / CAP_BLKS_PER_SEC(s= bi); > - unsigned int dent_secs =3D total_dent_blocks / CAP_BLKS_PER_SEC(s= bi); > - unsigned int node_blocks =3D total_node_blocks % CAP_BLKS_PER_SEC= (sbi); > - unsigned int dent_blocks =3D total_dent_blocks % CAP_BLKS_PER_SEC= (sbi); > + unsigned int node_secs =3D total_node_blocks / BLKS_PER_SEC(sbi); > + unsigned int dent_secs =3D total_dent_blocks / BLKS_PER_SEC(sbi); > + unsigned int node_blocks =3D total_node_blocks % BLKS_PER_SEC(sbi= ); > + unsigned int dent_blocks =3D total_dent_blocks % BLKS_PER_SEC(sbi= ); > > if (lower_p) > *lower_p =3D node_secs + dent_secs; > @@ -766,22 +757,21 @@ static inline int check_block_count(struct f2fs_sb_= info *sbi, > bool is_valid =3D test_bit_le(0, raw_sit->valid_map) ? true : fa= lse; > int valid_blocks =3D 0; > int cur_pos =3D 0, next_pos; > - unsigned int usable_blks_per_seg =3D f2fs_usable_blks_in_seg(sbi,= segno); > > /* check bitmap with valid block count */ > do { > if (is_valid) { > next_pos =3D find_next_zero_bit_le(&raw_sit->vali= d_map, > - usable_blks_per_seg, > + BLKS_PER_SEG(sbi), > cur_pos); > valid_blocks +=3D next_pos - cur_pos; > } else > next_pos =3D find_next_bit_le(&raw_sit->valid_map= , > - usable_blks_per_seg, > + BLKS_PER_SEG(sbi), > cur_pos); > cur_pos =3D next_pos; > is_valid =3D !is_valid; > - } while (cur_pos < usable_blks_per_seg); > + } while (cur_pos < BLKS_PER_SEG(sbi)); > > if (unlikely(GET_SIT_VBLOCKS(raw_sit) !=3D valid_blocks)) { > f2fs_err(sbi, "Mismatch valid blocks %d vs. %d", > @@ -791,14 +781,9 @@ static inline int check_block_count(struct f2fs_sb_i= nfo *sbi, > return -EFSCORRUPTED; > } > > - if (usable_blks_per_seg < BLKS_PER_SEG(sbi)) > - f2fs_bug_on(sbi, find_next_bit_le(&raw_sit->valid_map, > - BLKS_PER_SEG(sbi), > - usable_blks_per_seg) !=3D BLKS_PER_SEG(sb= i)); > - > /* check segment usage, and check boundary of a given segment num= ber */ > - if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg > - || !valid_main_segno(sbi, segno))= ) { > + if (unlikely(GET_SIT_VBLOCKS(raw_sit) > BLKS_PER_SEG(sbi) || > + !valid_main_segno(sbi, segno))) { > f2fs_err(sbi, "Wrong valid blocks %d or segno %u", > GET_SIT_VBLOCKS(raw_sit), segno); > set_sbi_flag(sbi, SBI_NEED_FSCK); > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index c0688c124aa7..cd6a56020a5d 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -3837,21 +3837,13 @@ static int f2fs_report_zone_cb(struct blk_zone *z= one, unsigned int idx, > void *data) > { > struct f2fs_report_zones_args *rz_args =3D data; > - block_t unusable_blocks =3D (zone->len - zone->capacity) >> > - F2FS_LOG_SECTORS_PER_BLOCK; > > - if (zone->type =3D=3D BLK_ZONE_TYPE_CONVENTIONAL) > - return 0; > - > - set_bit(idx, rz_args->dev->blkz_seq); > - if (!rz_args->sbi->unusable_blocks_per_sec) { > - rz_args->sbi->unusable_blocks_per_sec =3D unusable_blocks= ; > - return 0; > - } > - if (rz_args->sbi->unusable_blocks_per_sec !=3D unusable_blocks) { > - f2fs_err(rz_args->sbi, "F2FS supports single zone capacit= y\n"); > + if (zone->len !=3D zone->capacity) { > + f2fs_err(rz_args->sbi, "F2FS does not support zone capaci= ty.\n"); > return -EINVAL; > } > + if (zone->type !=3D BLK_ZONE_TYPE_CONVENTIONAL) > + set_bit(idx, rz_args->dev->blkz_seq); > return 0; > } > > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > index 906d2af2d849..2689cc9c3bf8 100644 > --- a/fs/f2fs/sysfs.c > +++ b/fs/f2fs/sysfs.c > @@ -1018,9 +1018,6 @@ F2FS_SBI_GENERAL_RW_ATTR(revoked_atomic_block); > F2FS_SBI_GENERAL_RW_ATTR(hot_data_age_threshold); > F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold); > F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); > -#ifdef CONFIG_BLK_DEV_ZONED > -F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec); > -#endif > > /* STAT_INFO ATTR */ > #ifdef CONFIG_F2FS_STAT_FS > @@ -1172,9 +1169,6 @@ static struct attribute *f2fs_attrs[] =3D { > ATTR_LIST(moved_blocks_background), > ATTR_LIST(avg_vblocks), > #endif > -#ifdef CONFIG_BLK_DEV_ZONED > - ATTR_LIST(unusable_blocks_per_sec), > -#endif > #ifdef CONFIG_F2FS_FS_COMPRESSION > ATTR_LIST(compr_written_block), > ATTR_LIST(compr_saved_block), > -- > 2.43.0.594.gd9cf4e227d-goog > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel