From patchwork Fri Sep 2 17:01:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 1122682 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p82GwVYS030179 for ; Fri, 2 Sep 2011 16:58:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753492Ab1IBQ62 (ORCPT ); Fri, 2 Sep 2011 12:58:28 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:44576 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753476Ab1IBQ61 (ORCPT ); Fri, 2 Sep 2011 12:58:27 -0400 Received: from sf.home (unknown [178.125.30.200]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id E8B0B1B402D; Fri, 2 Sep 2011 16:58:26 +0000 (UTC) Received: by sf.home (Postfix, from userid 1000) id 7DC3A87FAE0; Fri, 2 Sep 2011 20:01:45 +0300 (EEST) From: slyich@gmail.com To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Josef Bacik , Sergei Trofimovich , Konstantin Khlebnikov Subject: [PATCH] btrfs: fix warning in iput for bad-inode Date: Fri, 2 Sep 2011 20:01:21 +0300 Message-Id: <1314982881-10754-1-git-send-email-slyich@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <20110831001724.1f6225c5@sf> References: <20110831001724.1f6225c5@sf> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 02 Sep 2011 16:58:32 +0000 (UTC) From: Sergei Trofimovich iput() shouldn't be called for inodes in I_NEW state. We need to mark inode as constructed first. WARNING: at fs/inode.c:1309 iput+0x20b/0x210() Call Trace: [] warn_slowpath_common+0x7a/0xb0 [] warn_slowpath_null+0x15/0x20 [] iput+0x20b/0x210 [] btrfs_iget+0x1eb/0x4a0 [] btrfs_run_defrag_inodes+0x136/0x210 [] cleaner_kthread+0x17f/0x1a0 [] ? sub_preempt_count+0x9d/0xd0 [] ? transaction_kthread+0x280/0x280 [] kthread+0x96/0xa0 [] kernel_thread_helper+0x4/0x10 [] ? kthread_worker_fn+0x190/0x190 [] ? gs_change+0xb/0xb Signed-off-by: Sergei Trofimovich CC: Konstantin Khlebnikov Tested-by: David Sterba --- Change since Konstantin's patch: - avoid using explicit destructor for inode, as it can(?) be shared among other threads. Use unlock_new_inode()/iput() instead. It fixes 100% CPU load after 'sync()' popped-up in Konstantin's patch fs/btrfs/inode.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0ccc743..ec4b550 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3952,7 +3952,6 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, struct btrfs_root *root, int *new) { struct inode *inode; - int bad_inode = 0; inode = btrfs_iget_locked(s, location->objectid, root); if (!inode) @@ -3968,15 +3967,12 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, if (new) *new = 1; } else { - bad_inode = 1; + unlock_new_inode(inode); + iput(inode); + inode = ERR_PTR(-ESTALE); } } - if (bad_inode) { - iput(inode); - inode = ERR_PTR(-ESTALE); - } - return inode; }