From nobody Sat Feb 7 08:59:31 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C908C433F5 for ; Mon, 23 May 2022 17:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239975AbiEWROH (ORCPT ); Mon, 23 May 2022 13:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240080AbiEWRLi (ORCPT ); Mon, 23 May 2022 13:11:38 -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 617C7A464; Mon, 23 May 2022 10:11:02 -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 2F86EB81201; Mon, 23 May 2022 17:10:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74579C385A9; Mon, 23 May 2022 17:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325800; bh=lHiWW5REvsGzwImfar+7okrV0/z47MbErYMvXscxuWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SnELFX6JtHDzq74k8D+/Mbf9XRMt3ktluy46wIgwmzaQ/qzhMq09oI6l3eyZ4PD/7 FxV/jSI80CvWOuMA0b0mCpvuduk8z+tPXOMs9i9rjpVmle1JzdshIjVifBIzHYv3NM hG5C/czcwU+m/isB2SxktvbRFNwBOUZ8XoQp2uHo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakob Koschel , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 07/44] drbd: remove usage of list iterator variable after loop Date: Mon, 23 May 2022 19:04:51 +0200 Message-Id: <20220523165754.753884724@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165752.797318097@linuxfoundation.org> References: <20220523165752.797318097@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jakob Koschel [ Upstream commit 901aeda62efa21f2eae937bccb71b49ae531be06 ] In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or skip the iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Link: https://lore.kernel.org/r/20220331220349.885126-1-jakobkoschel@gmail.= com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/drbd/drbd_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 5e3885f5729b..c3e4f9d83b29 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -195,7 +195,7 @@ void tl_release(struct drbd_connection *connection, uns= igned int barrier_nr, unsigned int set_size) { struct drbd_request *r; - struct drbd_request *req =3D NULL; + struct drbd_request *req =3D NULL, *tmp =3D NULL; int expect_epoch =3D 0; int expect_size =3D 0; =20 @@ -249,8 +249,11 @@ void tl_release(struct drbd_connection *connection, un= signed int barrier_nr, * to catch requests being barrier-acked "unexpectedly". * It usually should find the same req again, or some READ preceding it. = */ list_for_each_entry(req, &connection->transfer_log, tl_requests) - if (req->epoch =3D=3D expect_epoch) + if (req->epoch =3D=3D expect_epoch) { + tmp =3D req; break; + } + req =3D list_prepare_entry(tmp, &connection->transfer_log, tl_requests); list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_reque= sts) { if (req->epoch !=3D expect_epoch) break; --=20 2.35.1