Received: by 10.223.185.116 with SMTP id b49csp697841wrg; Wed, 21 Feb 2018 05:35:06 -0800 (PST) X-Google-Smtp-Source: AH8x224/asvV0tlCTANnBEu7j7I+t/LIaen3ZWvzLqrQ0u1iD8CWwD/UelewHmCy+FcVK31gpKAu X-Received: by 2002:a17:902:b413:: with SMTP id x19-v6mr3174947plr.420.1519220106802; Wed, 21 Feb 2018 05:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519220106; cv=none; d=google.com; s=arc-20160816; b=k6EDDZhFZeNHphv+3ea+k5gNkeHRNvshwEyvQeL19R93BFFG2gcTnDy5kNoN+njZPe A9+3c0VK4XuuV5aCffM5PA9fnj94jdpfmHassy1Fw9qAiDaCDU5erD+3QOCNVOULtacQ TEEIe+6PM6VUsYGa3wafl24YEhsBFcphZ40jPT3w5EOhL9JHrlcIEjW+me2+5zh6rL8o iM4ow3KBxcD72UI+0ZtLaqzjX65zxSJrwzsLEt543l6a8wegBt7+DnQy336tjuYUz2jD 0rNhzPRFg7Yhk8GN+WbXecAhjM774QqE2zic+7DEU9cTqFcj6YbSYZzkT2XpdZJ7ycSY +Fhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vN90t4oNKSlNbU95QRVX9BU+fIvzfvSbrLvgCAWfjxg=; b=IzDR8UimgeJGy/nrsEI6Hf5e6bAiCf607ZIHx2XkB6nAkidvrORP5TrPRB6VVMQNpt Kq798xbaM9VW5yRRdsZRdvofSm01S4ZZ4EQDlHNupSFHC/8eN5a6Acr/cDMa76x6Imsr y7cyEMk1oX509X7fCqlVgFcmEPT+GdgzL7oPNQnx6WXWOSC4Rpq8gdIPUSGwFH7SYpuU 9HnoQiU5l0Z3WOasdriL46Xs+4HFPrDmcGQuSdVaO31nguPc+ZWfJL5nHRBKUCtgkXjY f29awBHWM65h6/5gUXjeKx+lqxpzcIsXDU3Xe1LH+MTDzOrQardTSaUL/unja7d9qJMZ BDBw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73-v6si531462ple.195.2018.02.21.05.34.52; Wed, 21 Feb 2018 05:35:06 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936478AbeBUNNa (ORCPT + 99 others); Wed, 21 Feb 2018 08:13:30 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46060 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754572AbeBUNN1 (ORCPT ); Wed, 21 Feb 2018 08:13:27 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CAF6810EA; Wed, 21 Feb 2018 13:13:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Bo , Nikolay Borisov , Josef Bacik , David Sterba Subject: [PATCH 4.15 138/163] Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly Date: Wed, 21 Feb 2018 13:49:27 +0100 Message-Id: <20180221124537.793312598@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liu Bo commit e8f1bc1493855e32b7a2a019decc3c353d94daf6 upstream. This regression is introduced in commit 3d48d9810de4 ("btrfs: Handle uninitialised inode eviction"). There are two problems, a) it is ->destroy_inode() that does the final free on inode, not ->evict_inode(), b) clear_inode() must be called before ->evict_inode() returns. This could end up hitting BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); in evict() because I_CLEAR is set in clear_inode(). Fixes: commit 3d48d9810de4 ("btrfs: Handle uninitialised inode eviction") Cc: # v4.7-rc6+ Signed-off-by: Liu Bo Reviewed-by: Nikolay Borisov Reviewed-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5266,7 +5266,7 @@ void btrfs_evict_inode(struct inode *ino trace_btrfs_inode_evict(inode); if (!root) { - kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); + clear_inode(inode); return; }