From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB833C433F5 for ; Tue, 12 Apr 2022 11:02:35 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1neEI6-0004bZ-1H; Tue, 12 Apr 2022 11:02:33 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1neEI3-0004at-6E for linux-f2fs-devel@lists.sourceforge.net; Tue, 12 Apr 2022 11:02:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=To:References:Message-Id:Content-Transfer-Encoding: Cc:Date:In-Reply-To:From:Subject:Mime-Version:Content-Type:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VYlSwRs2xXTAAyUlwb+gbXuW16FUgB8AcvnUgAkw87M=; b=F5MunA0rmuCNIlk0nwFbWEjUJY FYpbv3XzDgNN63EAgM8+1Fu0JaKUqNkzQ3Ax4u8FiyWf3jDhPOEFJ65yLmojtvlor5AmnvplZq19S RPA1z4jv88tx0IdfQPZl3nVPptC24kmzqjCpR4bxGi85OoHmuKVYfpB9mxPrLdKnYLjg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=To:References:Message-Id:Content-Transfer-Encoding:Cc:Date:In-Reply-To: From:Subject:Mime-Version:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VYlSwRs2xXTAAyUlwb+gbXuW16FUgB8AcvnUgAkw87M=; b=aKhmNqUUUxi42IUvOM0599JNP7 1wWt5ShhGZQKHoQYzhRAbXxqZKPLKOHvtN3ktFeaYQfyQYHmalpg6vxzhHw6TYAia0K0SBopnZsoT eP56wntxX6NoDkJVNaKrC8Bzcv3WVmvg4MstfTJa0VJEqunwC5Af4bXYhMvIv6+8lnVE=; Received: from mail-ej1-f48.google.com ([209.85.218.48]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94.2) id 1neEHx-0006ct-4E for linux-f2fs-devel@lists.sourceforge.net; Tue, 12 Apr 2022 11:02:30 +0000 Received: by mail-ej1-f48.google.com with SMTP id bv19so13546329ejb.6 for ; Tue, 12 Apr 2022 04:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VYlSwRs2xXTAAyUlwb+gbXuW16FUgB8AcvnUgAkw87M=; b=eSbceTFB98b3Z4e++6Y2eKyh0djI4T4ned0/KGkHF4WkQ2ae1MrCfN/x1DtyjdQ9EK I6uRjCoOv2AxG0UVJB0EOUOEcKG1gRlCsYmqXVCMaB1783YxmdMMk9Er1euKcvHliDpE tRH2iCH/Aaoe6tasaDrdqEiifWeCJ3oo0c8Gps11Zz8r3CFiu+WckRFSke/7vQpAhA39 SdyWjtnFobiiFiq0baedSX18wfT0ay8xSeoyNDUUujyaFI7DfjEyqROymvDx4JAbt5cB Q9dW0CrEFyWsiFUbVC+RGVEBAtPjMno47ARxUA30DU7nZ+ZhEguqThGbutt1Rd0YYr/W YCig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VYlSwRs2xXTAAyUlwb+gbXuW16FUgB8AcvnUgAkw87M=; b=h2PL9YfQFEZ4T/oPsFpSEEsumNI3osUr8/RbS9b7eMdZDJ9jynd7TkOfA3+YcGj2oi bTH1bta98d5okJd7vXcvIXNylUogGbxEORrFIkE/XDhcXwOMbrm8j2xFxsOCzzmemTxR XPJ2ok8Xg6gDjRMwIYtG3ufj7BusijrkkgbGDSmr1AY3r5jgeIKZUtC4xx/6INgsoeyL GX44f3n6Ml420fozLj4shR7nc7i9Z62YNDNFX0B6vdy/9z7i3X7Ce0t+L+gmpn5Qp7s8 +1TiFnwEbpQop8HOqOeWxHVi6xI2TgpoGxipkaB5UFvGycAa8yw2re55gSJIPaUnVBoH FBQA== X-Gm-Message-State: AOAM531DKYwOFsHCJqnsrhlTzZrjAXJhJEWZxGXx1mdTzIfk1D7RHVxr FUwNYADAhmF0dkG9h/Uww4ue5Z9/P0AJGg== X-Google-Smtp-Source: ABdhPJwPcRInSEEVAplx2Q7xSQldnlj/l6p5lEplZaCg8iRKCy5wsP3rhJrj4lvajacO3js5nLJNfQ== X-Received: by 2002:a17:907:d04:b0:6e8:8cbc:e86a with SMTP id gn4-20020a1709070d0400b006e88cbce86amr9739701ejc.194.1649761338744; Tue, 12 Apr 2022 04:02:18 -0700 (PDT) Received: from smtpclient.apple (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.gmail.com with ESMTPSA id f1-20020a056402194100b00416b174987asm16990227edz.35.2022.04.12.04.02.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Apr 2022 04:02:18 -0700 (PDT) Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) From: Jakob Koschel In-Reply-To: <4d54f494-b143-8885-a31e-924a83409e2d@kernel.org> Date: Tue, 12 Apr 2022 13:02:17 +0200 Message-Id: <632AA316-A1B4-4E2C-B5FD-204FD3BE8633@gmail.com> References: <20220331221650.891790-1-jakobkoschel@gmail.com> <4d54f494-b143-8885-a31e-924a83409e2d@kernel.org> To: Chao Yu X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Headers-End: 1neEHx-0006ct-4E Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: use separate list iterator variable to call list_move_tail() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LKML , "Bos, H.J." , Brian Johannesmeyer , Cristiano Giuffrida , Jaegeuk Kim , Linux F2FS Dev Mailing List , Mike Rapoport Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net > On 12. Apr 2022, at 11:40, Chao Yu wrote: > > On 2022/4/1 6:16, Jakob Koschel wrote: >> In preparation to limit the scope of a list iterator to the list >> traversal loop, use a dedicated pointer to point to the found element >> [1]. >> If no break is hit or the list is empty, 'next' will be NULL and >> list_move_tail() should be called explicitly on the head directly. >> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ >> Signed-off-by: Jakob Koschel >> --- >> fs/f2fs/segment.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index 22dfeb991529..81ef2c3d08e5 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -4175,16 +4175,20 @@ static void release_sit_entry_set(struct sit_entry_set *ses) >> static void adjust_sit_entry_set(struct sit_entry_set *ses, >> struct list_head *head) >> { >> - struct sit_entry_set *next = ses; >> + struct sit_entry_set *next = NULL, *iter = ses; >> if (list_is_last(&ses->set_list, head)) >> return; >> - list_for_each_entry_continue(next, head, set_list) >> - if (ses->entry_cnt <= next->entry_cnt) >> + list_for_each_entry_continue(iter, head, set_list) >> + if (ses->entry_cnt <= iter->entry_cnt) { >> + next = iter; >> + list_move_tail(&ses->set_list, &iter->set_list); >> break; > > return; > >> + } >> - list_move_tail(&ses->set_list, &next->set_list); >> + if (!next) >> + list_move_tail(&ses->set_list, head); > > list_move_tail(&ses->set_list, head); > > Then we don't need @next variable, right? Of course yes, good spot! I'll fix and resend a v2 in the next days. Thanks for the input. > > Thanks, > >> } >> static void add_sit_entry(unsigned int segno, struct list_head *head) >> base-commit: d888c83fcec75194a8a48ccd283953bdba7b2550 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel