From patchwork Thu Feb 9 12:44:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9564457 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 DC1436020C for ; Thu, 9 Feb 2017 12:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4099284D1 for ; Thu, 9 Feb 2017 12:45:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6CBF28499; Thu, 9 Feb 2017 12:45:52 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4A2BE28499 for ; Thu, 9 Feb 2017 12:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbdBIMpv (ORCPT ); Thu, 9 Feb 2017 07:45:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:34594 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751217AbdBIMpu (ORCPT ); Thu, 9 Feb 2017 07:45:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3056BAD09; Thu, 9 Feb 2017 12:44:44 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 28C701E1116; Thu, 9 Feb 2017 13:44:43 +0100 (CET) From: Jan Kara To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Tejun Heo , Dan Williams , Thiago Jung Bauermann , NeilBrown , Jan Kara Subject: [PATCH 05/10] writeback: Generalize and standardize I_SYNC waiting function Date: Thu, 9 Feb 2017 13:44:28 +0100 Message-Id: <20170209124433.2626-6-jack@suse.cz> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170209124433.2626-1-jack@suse.cz> References: <20170209124433.2626-1-jack@suse.cz> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP __inode_wait_for_writeback() waits for I_SYNC on inode to get cleared. There's nothing specific regarting I_SYNC for that function. Generalize it so that we can use it also for I_WB_SWITCH bit. Also the function uses __wait_on_bit() unnecessarily. Switch it to wait_on_bit() to remove some code. Signed-off-by: Jan Kara Acked-by: Tejun Heo --- fs/fs-writeback.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index ef600591d96f..c9770de11650 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1170,21 +1170,16 @@ static int write_inode(struct inode *inode, struct writeback_control *wbc) } /* - * Wait for writeback on an inode to complete. Called with i_lock held. + * Wait for bit in inode->i_state to clear. Called with i_lock held. * Caller must make sure inode cannot go away when we drop i_lock. */ -static void __inode_wait_for_writeback(struct inode *inode) +static void __inode_wait_for_state_bit(struct inode *inode, int bit_nr) __releases(inode->i_lock) __acquires(inode->i_lock) { - DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); - wait_queue_head_t *wqh; - - wqh = bit_waitqueue(&inode->i_state, __I_SYNC); - while (inode->i_state & I_SYNC) { + while (inode->i_state & (1 << bit_nr)) { spin_unlock(&inode->i_lock); - __wait_on_bit(wqh, &wq, bit_wait, - TASK_UNINTERRUPTIBLE); + wait_on_bit(&inode->i_state, bit_nr, TASK_UNINTERRUPTIBLE); spin_lock(&inode->i_lock); } } @@ -1195,7 +1190,7 @@ static void __inode_wait_for_writeback(struct inode *inode) void inode_wait_for_writeback(struct inode *inode) { spin_lock(&inode->i_lock); - __inode_wait_for_writeback(inode); + __inode_wait_for_state_bit(inode, __I_SYNC); spin_unlock(&inode->i_lock); } @@ -1397,7 +1392,7 @@ static int writeback_single_inode(struct inode *inode, * inode reference or inode has I_WILL_FREE set, it cannot go * away under us. */ - __inode_wait_for_writeback(inode); + __inode_wait_for_state_bit(inode, __I_SYNC); } WARN_ON(inode->i_state & I_SYNC); /*