Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9091108pxu; Mon, 28 Dec 2020 06:25:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTkesCUpG6FuRb8gvRkwDqIi/VW9PM+e1ruUzGU77t7oJiHZ8kb2e+wp2rQp2JQc10kB0r X-Received: by 2002:a17:906:31d2:: with SMTP id f18mr41557567ejf.407.1609165515732; Mon, 28 Dec 2020 06:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165515; cv=none; d=google.com; s=arc-20160816; b=Xoqnr30/zOGXkLY0FwrQtZMKSLURmSoX4YSrWLuEAX4sSCoWfuWJuAD7XpWfbdcXhP VrpBnOt6TOA27Q3b0QxI6+QOqeKufuhLIDZqei4oF+MpsGcSMLlF1ylN6+jJFeDkoLDo 5C/EwVspzMvrTwID9MaACJnVyMPm2YRlw0XrmG6mNeLRTxoVD/Ciisu0SzX8l7NeVpOy 3kETfzJxcZzQinBNHCBhzWbObRmMsPAgb7uf5wSun68t2/t6aTjOdXhxcioXBaafzLtl /0bKZ44l5Tp74uXaO7/AFxmIJ4I1jKRHSDHu36BMwtuj7ksCt/qp88WaJo1VqAf9eh4T M69w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QqtTG/fWq8a+JMt803xpfkOtxg5LS6/xes3vIE7le9M=; b=FlJ1kMjA33S4yd83SpxmxcGUmNJCkC4EmDosR8jnbuRW5+D+aNa7Dn/70Y+6XUf8fU 9v0+LSnswrHF5mHq45A8XCIoMN1yhgZaBd1Y8gdkkKIdtCHgFWmQhJhzmM6bvS7dwBbX DZzPyOfEaf6RuZHNkb8XFRv3rF3ucIEMOTuyHSFLR+KzSJG9O+UemwOvmDurNV8y4f95 imL8A0hKJFFhfqAVbW79U0gnLAm/qf7sXZRftK8n36duV04yCHYyrZs5M0SEyGiMK0BL uDFOmkm9PuMsL75FkSgTBrN046P87pNeNaezIDgqAKsB7O+fkIsfzpHDJ5dMp8q7+vxN Gdiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yHipJ8NL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si18265301ejg.407.2020.12.28.06.24.52; Mon, 28 Dec 2020 06:25:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yHipJ8NL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437708AbgL1OUM (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:54352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436591AbgL1OUH (ORCPT ); Mon, 28 Dec 2020 09:20:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B129521D94; Mon, 28 Dec 2020 14:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165186; bh=eGQQCOXn+RhnImPbPiE5mK0SYXfOqSninblDmJdNxJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yHipJ8NLczWhTNvW2ZEtZwgjWI96L3zWvFCqhRmoCzt0gF1u2gz11BHbCsx2T+Z1D F5ZB5Zb7HuHYGivW7N82792TIdmZSm9iJREmzIwXkYMXhV/7iIMWObtM7RsbumxyaJ Ppqfl2IRJMF8Srl0ysN0ATTLe3bLevl6yUhb/oUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Li , Dave Chinner , Ira Weiny , Al Viro , Sasha Levin Subject: [PATCH 5.10 412/717] fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode() Date: Mon, 28 Dec 2020 13:46:50 +0100 Message-Id: <20201228125040.709020346@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hao Li [ Upstream commit 88149082bb8ef31b289673669e080ec6a00c2e59 ] If generic_drop_inode() returns true, it means iput_final() can evict this inode regardless of whether it is dirty or not. If we check I_DONTCACHE in generic_drop_inode(), any inode with this bit set will be evicted unconditionally. This is not the desired behavior because I_DONTCACHE only means the inode shouldn't be cached on the LRU list. As for whether we need to evict this inode, this is what generic_drop_inode() should do. This patch corrects the usage of I_DONTCACHE. This patch was proposed in [1]. [1]: https://lore.kernel.org/linux-fsdevel/20200831003407.GE12096@dread.disaster.area/ Fixes: dae2f8ed7992 ("fs: Lift XFS_IDONTCACHE to the VFS layer") Signed-off-by: Hao Li Reviewed-by: Dave Chinner Reviewed-by: Ira Weiny Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/inode.c | 4 +++- include/linux/fs.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 9d78c37b00b81..5eea9912a0b9d 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1627,7 +1627,9 @@ static void iput_final(struct inode *inode) else drop = generic_drop_inode(inode); - if (!drop && (sb->s_flags & SB_ACTIVE)) { + if (!drop && + !(inode->i_state & I_DONTCACHE) && + (sb->s_flags & SB_ACTIVE)) { inode_add_lru(inode); spin_unlock(&inode->i_lock); return; diff --git a/include/linux/fs.h b/include/linux/fs.h index 8667d0cdc71e7..8bde32cf97115 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2878,8 +2878,7 @@ extern int inode_needs_sync(struct inode *inode); extern int generic_delete_inode(struct inode *inode); static inline int generic_drop_inode(struct inode *inode) { - return !inode->i_nlink || inode_unhashed(inode) || - (inode->i_state & I_DONTCACHE); + return !inode->i_nlink || inode_unhashed(inode); } extern void d_mark_dontcache(struct inode *inode); -- 2.27.0