Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1253183pxb; Fri, 1 Apr 2022 08:27:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY7FTDv86BqXCjBEh91MepYHkF05I7cBWzxg9klHInlnzqtdk8rOIZ48IBNH8Q3l1sYleF X-Received: by 2002:a17:907:d2a:b0:6e0:963c:97d9 with SMTP id gn42-20020a1709070d2a00b006e0963c97d9mr302158ejc.736.1648826835859; Fri, 01 Apr 2022 08:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648826835; cv=none; d=google.com; s=arc-20160816; b=Mm9EXX6Q7K+telbWRPkX4X4ydXZDWcUiQ2P5J/q7LwNkgaGlzwPg/lF4XYdepLnDFp UV/2vCPcD69zcZQEMY4tiDOdgvN9Htdim7ihBGtA3I8qv91pmZnpCUdE0x4qVw7XIBZB tIqk3xwmp/Z9zQbF+at0RiBtURymuCqJFVxkIi9oMWXuXWwTTi6qmHfrloSS9yukVywY 3TlVdy3L1+ocaB/eVPuMl32rUmYd3OQrzqlxrPmT3hD934fnSwHhmAozGH2BgE5x/3nq d5Ae0x6gM/gbksIzXe1ECdOkR2VJNOhcDl7mcdS/MLaBtGKIr5mEAsdauGltt3Pc1ZPX +xew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zVX+ni+qIlknEI/UHZP1JghyHCXyos1MEYHumXUzMdo=; b=XoGVgksoW7tniP3qy5LpPhra9vXeLkPQCnqiY9rIPxhyJAtUEtwd5f4Oer2rH5U/lW ypkChpoyG5GCxJ1ASiaYAd/0O0UcKTz6Uv9s7UWZVQN3qDGlF5ks8rzZoE/lhrtboxzB BF7g+NMPHjVuOpXFR7GFtKai0Imd9ZpNDklHaRLiCNPlo9OdR5UmiAkhUXHydAiDzZyx y1pPV1XcH/MTqfSxJpWV4RMXAzFkLhXwUuR6KLXjevNcObt2yoHT6xxJx4g2cJPU4FYh GYbbhSYy50FG4GohAC7NoZvKOfTU3Qv7F7lHxlLrjUAl4jCGmI9xUWka/Rc3uHZg4gfv raSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S9D4MJkY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a17090631cb00b006df76385bbbsi1775703ejf.91.2022.04.01.08.26.48; Fri, 01 Apr 2022 08:27:15 -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=@gmail.com header.s=20210112 header.b=S9D4MJkY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242207AbiCaWEI (ORCPT + 99 others); Thu, 31 Mar 2022 18:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiCaWEH (ORCPT ); Thu, 31 Mar 2022 18:04:07 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88E431EE8E0 for ; Thu, 31 Mar 2022 15:02:19 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id z92so820752ede.13 for ; Thu, 31 Mar 2022 15:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zVX+ni+qIlknEI/UHZP1JghyHCXyos1MEYHumXUzMdo=; b=S9D4MJkYyQDK3oLILyCxZZyKRV6OVbtlSGbJuuU6xJtN1vOjdthqSlJTktw0BTDwbw uJw0uxWYmEzYnEnMUUejdmD7wM1QqfsiFffqIs/vGntK1gS7/C5+JqgMXfmrQNJ7XfS4 Zu1s9QUDg+NTrWCIiWdIhXOZJHOUmOaPs7WBgv0+/HOksljjt7N/D2t8W4YT6MPRMD0x 1tv6pAJSfnkl6Hk1cjgOopUnuKOIlP1JUXdGl7EWDMWpNA7Qg99fCUJpUhLunfSCqei4 pnmeeM10uh9B4xgX8UTYoCN6P/n9Aocr7nk/IK6U1z4czy8njWiaO7ZcmwViE0Ya3Xs7 m/1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zVX+ni+qIlknEI/UHZP1JghyHCXyos1MEYHumXUzMdo=; b=v6gI9Wdt1oJ1Y8Iimn5DQTPxIbsOKXIUCt/s9iC3Z9uGTMrF1fI3lAMCU7P3LZMoVu AZ5yJMN7Iw1sSKyWuWs3/HyhUt/cTAn6O2PYbDOXyy+8E19P1UekJjwwevZ1GE6m/d70 fL7ADKQ/5vZiYVKfXELvPyFL+mRNa/wO2FammfqRDv4ViviIp14qe39CXrBJLz9M8MR/ 7aAIB0XfD0xpEMzR1aDGkm2UHaEid/wxeKUIIQTKPnncO+ajiH1OUpeDs8ZRgdQ1uLSG S1q+ZQX4hBGe7O08q4pA0I4wSkNO6A2fEt66N6e7YOPEqxo3HhlkvR0KtUwmOZbb5oav 13iA== X-Gm-Message-State: AOAM533+14tLbkFredCBymL86/f2qzjs7+aar7h1MG9udRLNytBqg5Hj PyCs5GcJ/u8zqHAnGDSnztE= X-Received: by 2002:aa7:d445:0:b0:41b:5835:c6da with SMTP id q5-20020aa7d445000000b0041b5835c6damr15266061edr.309.1648764138136; Thu, 31 Mar 2022 15:02:18 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id n21-20020a170906725500b006e10a7d6d03sm238050ejk.219.2022.03.31.15.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 15:02:17 -0700 (PDT) From: Jakob Koschel To: Christine Caulfield Cc: David Teigland , cluster-devel@redhat.com, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH 1/2] dlm: remove usage of list iterator for list_add() after the loop body Date: Fri, 1 Apr 2022 00:00:12 +0200 Message-Id: <20220331220013.884633-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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]. Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the list_add() is performed within the loop and only done after the loop if it is done on the list head directly. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- fs/dlm/lock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index bdb51d209ba2..66e92617d7ea 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -1306,13 +1306,17 @@ static inline void unhold_lkb(struct dlm_lkb *lkb) static void lkb_add_ordered(struct list_head *new, struct list_head *head, int mode) { - struct dlm_lkb *lkb = NULL; + struct dlm_lkb *lkb = NULL, *iter; - list_for_each_entry(lkb, head, lkb_statequeue) - if (lkb->lkb_rqmode < mode) + list_for_each_entry(iter, head, lkb_statequeue) + if (iter->lkb_rqmode < mode) { + lkb = iter; + list_add_tail(new, &iter->lkb_statequeue); break; + } - __list_add(new, lkb->lkb_statequeue.prev, &lkb->lkb_statequeue); + if (!lkb) + list_add_tail(new, head); } /* add/remove lkb to rsb's grant/convert/wait queue */ base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275 -- 2.25.1