Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5875110imm; Wed, 12 Sep 2018 12:29:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbEzo8bj8rf9KvwTElyLpXeXKHIlmmPBw1uHQS0C4PWFnRSIbTNIF1H7IGGtBrskAzITjVJ X-Received: by 2002:a17:902:b902:: with SMTP id bf2-v6mr3920017plb.185.1536780573052; Wed, 12 Sep 2018 12:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536780573; cv=none; d=google.com; s=arc-20160816; b=TjLC/tyzokIL3OX6amcTwtoeCGIdeb1RYg5GqsSEheKzQYy2yYgwJg/BONJ58fVmm3 kIkgaXJJr2flb4HIHHguaPohY8SH0w+gT0nkkoeJSr0oNh9JR+vNlZVHn1FChc+AALIs GV2DwA1t7+fdWcCtUvqVzfVNTrh+5cd3pYj19+FrpXMgbYECFVOMXrpK+tuTnimgDjsm TKXff+QzDdFVrsg3Zxq97Le+JK69fLmONym9GCYhNQ32qpLev+C9kJOQWAKYiHjH4ozs IBSbvWvICWhEOcL95Cp5hqN+W/gHPGDxKgA8sVt0PIU45BEF2QYVg9Y0R40n1f/J89sF BSqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=n1N8yu1fUaagHuDnaUINdKbeyf3A85VQdjm4W8W7OVM=; b=n0HCZdLCezdILYhFlLabuvtX0Fqrc4QAE2XI7SyRJUiyykMxug4VrGGQ6N1g3s1kgF ByHkT4q6v/BlrLkmbQQRd8+aMNFliSHepxv9nOk81fBzBRJw74ddYPRhuknVEw/lT/H+ rm9aDXTlYg76r8pCWjcvo7Y/wLXgIyb5OLsQTBH4N0aNJ90ZDn+syHm1dB9zCWv02R/0 l6AZrOBTpBKDg57pCoUtZLp0x1cGs2XtzO4uZ9unx7Y5FMfE1PpTgfl666txoUuIxwoq h/T52kgLXgjhY2GRx6V1Rg5qPBIE43ztAAxS7Mvb0vohMVUL2XdRoe+59Bne9H/qn3zy Xxgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g20-v6si1840864pgb.239.2018.09.12.12.29.17; Wed, 12 Sep 2018 12:29:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728302AbeIMAfH (ORCPT + 99 others); Wed, 12 Sep 2018 20:35:07 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38362 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728222AbeIMAfG (ORCPT ); Wed, 12 Sep 2018 20:35:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2455040216F5; Wed, 12 Sep 2018 19:29:07 +0000 (UTC) Received: from llong.com (dhcp-17-55.bos.redhat.com [10.18.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEEBB10EE6D8; Wed, 12 Sep 2018 19:29:06 +0000 (UTC) From: Waiman Long To: Alexander Viro , Jan Kara , Jeff Layton , "J. Bruce Fields" , Tejun Heo , Christoph Lameter Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Andi Kleen , Dave Chinner , Boqun Feng , Davidlohr Bueso , Jan Kara , Waiman Long Subject: [PATCH v9 2/5] vfs: Remove unnecessary list_for_each_entry_safe() variants Date: Wed, 12 Sep 2018 15:28:49 -0400 Message-Id: <1536780532-4092-3-git-send-email-longman@redhat.com> In-Reply-To: <1536780532-4092-1-git-send-email-longman@redhat.com> References: <1536780532-4092-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 19:29:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 12 Sep 2018 19:29:07 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara evict_inodes() and invalidate_inodes() use list_for_each_entry_safe() to iterate sb->s_inodes list. However, since we use i_lru list entry for our local temporary list of inodes to destroy, the inode is guaranteed to stay in sb->s_inodes list while we hold sb->s_inode_list_lock. So there is no real need for safe iteration variant and we can use list_for_each_entry() just fine. Signed-off-by: Jan Kara Signed-off-by: Waiman Long --- fs/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 42f6d25..0b5381b 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -606,12 +606,12 @@ static void dispose_list(struct list_head *head) */ void evict_inodes(struct super_block *sb) { - struct inode *inode, *next; + struct inode *inode; LIST_HEAD(dispose); again: spin_lock(&sb->s_inode_list_lock); - list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { + list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { if (atomic_read(&inode->i_count)) continue; @@ -657,11 +657,11 @@ void evict_inodes(struct super_block *sb) int invalidate_inodes(struct super_block *sb, bool kill_dirty) { int busy = 0; - struct inode *inode, *next; + struct inode *inode; LIST_HEAD(dispose); spin_lock(&sb->s_inode_list_lock); - list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { + list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); -- 1.8.3.1