From patchwork Wed Jun 15 20:35:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9179461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 28A1F6075D for ; Wed, 15 Jun 2016 20:35:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181CD2793B for ; Wed, 15 Jun 2016 20:35:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C58827F17; Wed, 15 Jun 2016 20:35:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F32292793B for ; Wed, 15 Jun 2016 20:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141AbcFOUfm (ORCPT ); Wed, 15 Jun 2016 16:35:42 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34048 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752631AbcFOUfk (ORCPT ); Wed, 15 Jun 2016 16:35:40 -0400 Received: by mail-pa0-f48.google.com with SMTP id bz2so10624035pad.1 for ; Wed, 15 Jun 2016 13:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BWmpvIWnzBVVlkcdzUwlI7v8GNRvtDh1TeHqCVBsvvw=; b=lV9XnlnH4O4Z/KHwX0J8FvBZnQDZeS7rQ+2hWg8ySomrrvtb6Cdgvh2NsDbc0Pj6TQ SaUP6/+tJLC0mE9/Gg+vhgP5U+kF6Bb/a6c06dCughblFLrQv0QZRQJRMktqgnNOAQaE ewpaI58fB3Qx2Oll1fzIQwC7ftKic5hOl0ivFhU8nyMElCPGXSKQAOWzSTdfoi03SJxJ 2hlgoIdMdNkRj1d22Hd2deNQ/jcAjEv4q7633mz5gYwwhf82ejXcNJyk04TYeQded35V rzSTTfNNaeMMtHegEGG6GCw5xKv0+pdPwyw8wPF1oVamu7/34VYbedV0yaICGATDowxk amsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BWmpvIWnzBVVlkcdzUwlI7v8GNRvtDh1TeHqCVBsvvw=; b=l9rLt6aLHWcfHe7mfBGr0oh80EVoVV/5CnsGiDQOzzddljrd1QZwqZojnA8omcjCUf vTpR9zwZo8XYcQpVUL6YcgO3rJUw8eEfwifrg5S306u7k6Bk5H4brGO76bPUA8a5esSw IgTZPOh2VOqa04HQpRTjkJTAVD1RD3h7RRvmOesiSNl8HdoVWVKHjtvH9yhBVjeJvKVO XPGLerkfKIml09MlJx01tGGoJtFNyLJSQMmJex8Reb/d+ObhvnI6B46TPLgGeKuJYSZl S75bvAtPm/qJDD+bBAdUszMhXVt/IdtqNKp5rgJSF2i8XUeZNwBFnroYY6rVradYCJNf 9oxw== X-Gm-Message-State: ALyK8tJLkAq5ASBpjA+UxQYAwFWR8EULcHVhZ94I35tvcZC8+0PPiw1NuWdd+STFIQ0lTepx X-Received: by 10.66.54.35 with SMTP id g3mr729381pap.30.1466022939375; Wed, 15 Jun 2016 13:35:39 -0700 (PDT) Received: from tahsin1.mtv.corp.google.com ([172.17.128.201]) by smtp.gmail.com with ESMTPSA id v62sm25354604pfv.50.2016.06.15.13.35.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jun 2016 13:35:38 -0700 (PDT) From: Tahsin Erdogan To: Jens Axboe , Tejun Heo , Alexander Viro , Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH v2] writeback: inode cgroup wb switch should not call ihold() Date: Wed, 15 Jun 2016 13:35:10 -0700 Message-Id: <1466022910-11243-1-git-send-email-tahsin@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Asynchronous wb switching of inodes takes an additional ref count on an inode to make sure inode remains valid until switchover is completed. However, anyone calling ihold() must already have a ref count on inode, but in this case inode->i_count may already be zero: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 917 at fs/inode.c:397 ihold+0x2b/0x30 CPU: 1 PID: 917 Comm: kworker/u4:5 Not tainted 4.7.0-rc2+ #49 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: writeback wb_workfn (flush-8:16) 0000000000000000 ffff88007ca0fb58 ffffffff805990af 0000000000000000 0000000000000000 ffff88007ca0fb98 ffffffff80268702 0000018d000004e2 ffff88007cef40e8 ffff88007c9b89a8 ffff880079e3a740 0000000000000003 Call Trace: [] dump_stack+0x4d/0x6e [] __warn+0xc2/0xe0 [] warn_slowpath_null+0x18/0x20 [] ihold+0x2b/0x30 [] inode_switch_wbs+0x11c/0x180 [] wbc_detach_inode+0x170/0x1a0 [] writeback_sb_inodes+0x21c/0x530 [] wb_writeback+0xee/0x1e0 [] wb_workfn+0xd7/0x280 [] ? try_to_wake_up+0x1b1/0x2b0 [] process_one_work+0x129/0x300 [] worker_thread+0x126/0x480 [] ? __schedule+0x1c7/0x561 [] ? process_one_work+0x300/0x300 [] kthread+0xc4/0xe0 [] ? kfree+0xc8/0x100 [] ret_from_fork+0x1f/0x40 [] ? __kthread_parkme+0x70/0x70 ---[ end trace aaefd2fd9f306bc4 ]--- Acked-by: Tejun Heo Signed-off-by: Tahsin Erdogan Reviewed-by: Jan Kara --- v2: removed inode->i_count == 0 check replaced ihold() with __iget() updated commit description fs/fs-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 989a2cef6b76..fe7e83a45eff 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -483,9 +483,9 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id) goto out_free; } inode->i_state |= I_WB_SWITCH; + __iget(inode); spin_unlock(&inode->i_lock); - ihold(inode); isw->inode = inode; atomic_inc(&isw_nr_in_flight);