Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp59808lqc; Thu, 29 Feb 2024 10:14:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4ZU/LApgDa3PA6TpO+/2L8oizYk4JoLR0LqzMnkM+4CEaX435KSgyPnLu4pg2ByvwVVo3g1Hsnmbgvj7NAt3VtdGA1ijZYxTxq5afuQ== X-Google-Smtp-Source: AGHT+IGa47QV2F9+QkNUM/SCHXKrpL6AXGlmGK1Gado/XEg6sVWpbkj95Vu39ZwgrGWS4/tgnFPi X-Received: by 2002:a62:ce46:0:b0:6e5:309d:9fc7 with SMTP id y67-20020a62ce46000000b006e5309d9fc7mr3080773pfg.25.1709230441827; Thu, 29 Feb 2024 10:14:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709230441; cv=pass; d=google.com; s=arc-20160816; b=vkmln01Ne0yd3kE45BZSyVJtDWZ2SXFX/DYxPixVp0+4X+LtwRyh5kVO5BGxgv5Vr9 IU/Yms0v6EPUEVe0QJJtrb4g/wD2rIKs493jPDRroPxzp8gtk+ebSzms60Oc39S3DcL9 HmMh1JNBscWZrEHa43BfMe24nb+k+PU+83hpRFFb51F1LkYVW1Q4qcVVC/KbrIOYRIwT Jt7vuGTBIQYL4lZJH0R3VOOKsjw8tZ3gBWhOvA+bSVwMhR6DB/D8EYqxCuC/eqCQm56W LeRDD5AlKrgeAgf84Yt1K8GzSuEQoUwcLzieWQusVkI3IaNxs1+ZeH+4OAxDpTpa7X2/ FlIA== 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=rzIXC93M4QSZLUGOvxdd7AD7/8w/GqyAU4gK+DPYWBY=; fh=mwcpXTyoEFkNoOMMffgIkbSrkizo64QtncfgEH5Qgbs=; b=tPAajNRbFIDeYrSYnE0UgwNZ05IKk6yylOHdv9YHSSIuuxk11+ezZ8RpwKw14cP3m/ wKthemul5riP9y7Gl+TdBwwuz/qYRmc2e3JCqfdZZNxpjXuOzMO7kiVgeYUxrSNiS2kS 3tHL8NNGP2Li//FkIJ5xfnyDNe+iSc87E97xcO5AATyD2U2QTygRNvxflaOwFcEBFB9t mzGcyP9bUgwdlqdbGThUkb+G2qQpnrTJLHVYpNQrdeUHcyt/B/a1RbPmrh3FLah9l5t2 pkIl7UgkHyrd0AM0EvMeOgzSXmsQPSeBTFpZzXmBWhw6aWVlCNnq0xY0BmZZAIiofzko pN7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g6Qe5OyE; 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-87223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p1-20020aa79e81000000b006e4ee56c02esi1773375pfq.168.2024.02.29.10.14.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 10:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g6Qe5OyE; 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-87223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87223-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 730CDB25B64 for ; Thu, 29 Feb 2024 17:59:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EDA14AECA; Thu, 29 Feb 2024 17:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g6Qe5OyE" Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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 3A84B16063E for ; Thu, 29 Feb 2024 17:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709229536; cv=none; b=LxiJUpBamJ4txb0UoC5GmAfBNomUD03W0apgsvYBY6ymuFLylD5HTKFRWJ/1Wyyg90OYUHhRZ7u9ZRmi1ZzuwR3/SjAta1SO2cpDZX2r2QpQlKdIPxpCW+dkvtAnuCcpjLcClU58RM8sD++bZfcTMrMqzuotjUmARhrsI0KrjjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709229536; c=relaxed/simple; bh=dAkN5nx3ELejm9KAgl5dlkP/kYHieFw5OJ8MYAf+PBQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fxpWNzbZKKtQAbBpvjd4fxIu3+aIP2enYT5J7XhrExZ/GMigIaEmpgmaM+QHv/swBmT96m/ovkLPbZSKMnqjX/WVVTveW78I4rfYuSK+LMueQVTsulakK2BZJxa8L9+BNcUTdo/qybrKkxWPYFu/uQYHh+Z7n5Dah1veSynriUA= 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=g6Qe5OyE; arc=none smtp.client-ip=209.85.222.43 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-ua1-f43.google.com with SMTP id a1e0cc1a2514c-7dad8437347so492483241.3 for ; Thu, 29 Feb 2024 09:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709229534; x=1709834334; 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=rzIXC93M4QSZLUGOvxdd7AD7/8w/GqyAU4gK+DPYWBY=; b=g6Qe5OyEk7iXqLTl0Isx+uxjXW5KcEgJ3HyPpIyE/1ikc/8lB5N03vbbfiuLuduOWd UfNhOS49oK0/KlFyP35RmK3hsl+CEcL2I5bN6XPnp1sQDmJVId2LDVB9OoMtyEtl77K2 nTWPj1k5K4rQlXu62el0gh4cUp3LrKKm5aUaMoiVJq8C8lRtoHFc4SWjBnStHydp4OfS zbpPjH5ZuE7iwgRDAxGfHklCvSJ4zkefCQdS4ZEZQHMnejPjIvsH3ncgRRJCrSgqzm4i w//Hg0Ayh9AKLrTQlR/OVLJ/Ugkf7JUwZGvcmEqYCV8LBcWcFu7BQoX5ScThQY6MJF/u b5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709229534; x=1709834334; 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=rzIXC93M4QSZLUGOvxdd7AD7/8w/GqyAU4gK+DPYWBY=; b=GdfPREArrFcLzT5obh5/7kihSf0N+KQtdGqnGe1KxdRwupMeshnSoesBVuh8sZRJo9 S38TIl3N8lCq11N4Hgtvr3x+hNEbHCEAgFM8ovYU0MlfqqCKoadbYNFX1572CnlxKqjk 0rwNjb0JZk7RtEOdCagEkk72l1SaEiakXXV02589mCV/cRRGgFW3ZjjxcJNvSmH5YrcB sp4KIajEo4ReicffpLj4HVwImzjZcw9rdpnfsdEHLp2ucFuksz9M96RffNU3JzCdfvLH dhA8+xOmIjcudv/1H7JIGCT23ciGEXjGBW5+zONCo61jvxwDOOXpvE5JF8P1bsp/ZXu0 sTcQ== X-Forwarded-Encrypted: i=1; AJvYcCXwGQZ/6nAqpuanWt4IHqDlRwhRJbOwglzhjbXG1frPGtMXB2FuYrTK96kMCez5qeDpLNxsyAb4s3nexODKQT7IYm0uiuxxjsgYrn5d X-Gm-Message-State: AOJu0Ywun/lM8c1TTYJ2PlMn9DwIMdPeFhwKhVxV3GGNfm76izdW//oa 6W1lNurbUjxm87YGmOX6WqyYLeWrza+6I/qDTwT3loej3GvHJIYdR8Plk15OLrWoMQKksLwvxZK lNQ3pTYHMcDc9/L+D8qL5m9yeqJ8= X-Received: by 2002:a05:6102:3093:b0:472:6e7f:888b with SMTP id l19-20020a056102309300b004726e7f888bmr2722097vsb.32.1709229534095; Thu, 29 Feb 2024 09:58:54 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240226013208.2389246-1-chao@kernel.org> <20240226013208.2389246-3-chao@kernel.org> In-Reply-To: <20240226013208.2389246-3-chao@kernel.org> From: Daeho Jeong Date: Thu, 29 Feb 2024 09:58:43 -0800 Message-ID: Subject: Re: [f2fs-dev] [PATCH 3/4] f2fs: clean up new_curseg() To: Chao Yu Cc: jaegeuk@kernel.org, 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 Thanks, On Sun, Feb 25, 2024 at 5:33=E2=80=AFPM Chao Yu wrote: > > Move f2fs_valid_pinned_area() check logic from new_curseg() to > get_new_segment(), it can avoid calling __set_free() if it fails > to find free segment in conventional zone for pinned file. > > Signed-off-by: Chao Yu > --- > fs/f2fs/segment.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 847fe0b7f29f..c159b0985596 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -2715,12 +2715,19 @@ static int get_new_segment(struct f2fs_sb_info *s= bi, > got_it: > /* set it as dirty segment in free segmap */ > f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); > + > + /* no free section in conventional zone */ > + if (new_sec && pinning && > + !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) { > + ret =3D -EAGAIN; > + goto out_unlock; > + } > __set_inuse(sbi, segno); > *newseg =3D segno; > out_unlock: > spin_unlock(&free_i->segmap_lock); > > - if (ret) { > + if (ret =3D=3D -ENOSPC) { > f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMEN= T); > f2fs_bug_on(sbi, 1); > } > @@ -2796,19 +2803,17 @@ static int new_curseg(struct f2fs_sb_info *sbi, i= nt type, bool new_sec) > struct curseg_info *curseg =3D CURSEG_I(sbi, type); > unsigned int segno =3D curseg->segno; > bool pinning =3D type =3D=3D CURSEG_COLD_DATA_PINNED; > + int ret; > > if (curseg->inited) > write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, s= egno)); > > segno =3D __get_next_segno(sbi, type); > - if (get_new_segment(sbi, &segno, new_sec, pinning)) { > - curseg->segno =3D NULL_SEGNO; > - return -ENOSPC; > - } > - if (new_sec && pinning && > - !f2fs_valid_pinned_area(sbi, START_BLOCK(sbi, segno))) { > - __set_free(sbi, segno); > - return -EAGAIN; > + ret =3D get_new_segment(sbi, &segno, new_sec, pinning); > + if (ret) { > + if (ret =3D=3D -ENOSPC) > + curseg->segno =3D NULL_SEGNO; > + return ret; > } > > curseg->next_segno =3D segno; > -- > 2.40.1 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel