Received: by 10.223.185.116 with SMTP id b49csp971053wrg; Wed, 21 Feb 2018 09:53:00 -0800 (PST) X-Google-Smtp-Source: AH8x224UnxhYRiDyxDtTJjfLHvz0m7TVCRkLCpv5XANNqyUbS0GsEiveNgxfZ3QOBXpJyzKe/tl8 X-Received: by 10.167.129.129 with SMTP id g1mr4057306pfi.224.1519235579926; Wed, 21 Feb 2018 09:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519235579; cv=none; d=google.com; s=arc-20160816; b=XxExZdqN0Th+SIhbA3/an5joOJZLKDfw6V/vak50qgHt3JOUuSw8hdMk8S035e4ijQ W/x5ceZWJq2wtx8Q1BpHSBMPoP1+fhLnD2QBDd8VhsaC08saSn6uMWbiAHnVASd0FPtM ZRiKRoJygudhiPoT9lvuftzAVJqTQXnmXLqTfZcU3rOeXiPGfXInricByMY6BWj89mY2 axJlsFYwg15d8LWLXvSp2aDZxwe5vRb/UQgaVYg19Iy2mlnzdOsyeLsfoTmU2Gti7HT1 0p5d5AXuGxS9l9Y0EaVwgO0cqm2CfkYrFvmPVyAcg8oHPNTJ8nze6uantMRAD4IotWVO OLDw== 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=Tf3u1JJEYNwvw9qOWo98z2MX5fMFwJVHJLbfiEENCpM=; b=aM4GVlUIZpYL/b5cyO2aC3MpVZzw1/TnyMG6piNQ/hxDBv4GfWxIBgXwywZib6Ya01 nd0PYQrRJ3nXAwEbjxFWJTXBZtI8iVW+8pgsE5iVgQ4vj89X/PiD9vksp/Rc4qcq7gV8 9bbQd4N39m2MleP4isTjOxYvxFSpdiDaeYPo10hC04AgDa//WPxpcT8ojdnw4usmUI+t +JNnL1TE8XPfGU42JiIOkF8R4GhQYcB2ayD1nV9Q58RPy5CxSHHXL2lmr+X7WSSuZR9i EIV/czdwa1WpizbyH8EBUuFSv1Q4bLAHBne26wd3t1Il+umSit2NfoZu4bUENFL8FIkL ZQyQ== 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 n11-v6si32813pls.347.2018.02.21.09.52.45; Wed, 21 Feb 2018 09:52:59 -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 S934160AbeBUMyz (ORCPT + 99 others); Wed, 21 Feb 2018 07:54:55 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34210 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934114AbeBUMyv (ORCPT ); Wed, 21 Feb 2018 07:54:51 -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 3B7D51110; Wed, 21 Feb 2018 12:54:50 +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.9 21/77] Btrfs: fix btrfs_evict_inode to handle abnormal inodes correctly Date: Wed, 21 Feb 2018 13:48:30 +0100 Message-Id: <20180221124433.073992378@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124432.172390020@linuxfoundation.org> References: <20180221124432.172390020@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.9-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 @@ -5229,7 +5229,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; }