From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751395AbdBXSPe (ORCPT ); Fri, 24 Feb 2017 13:15:34 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:42107 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbdBXSP2 (ORCPT ); Fri, 24 Feb 2017 13:15:28 -0500 Message-Id: <20170224162044.200355596@infradead.org> User-Agent: quilt/0.63-1 Date: Fri, 24 Feb 2017 16:43:34 +0100 From: Peter Zijlstra To: Al Viro , Linus Torvalds , Chris Mason Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Howells , elena.reshetova@intel.com, ishkamiel@gmail.com, dwindsor@gmail.com, gregkh@linuxfoundation.org, peterz@infradead.org Subject: [RFC][PATCH 05/10] fs: Remove iput_final() References: <20170224154329.478276481@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-fs-inode-3c.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fold iput_final() into iput, its only caller. This prepares things for future patches, also I feel iput_final() is a misnomer, since it can still be non-final and leave the inode hashed and ready. No functional change. Signed-off-by: Peter Zijlstra (Intel) --- fs/inode.c | 73 +++++++++++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 40 deletions(-) --- a/fs/inode.c +++ b/fs/inode.c @@ -1468,24 +1468,47 @@ int generic_delete_inode(struct inode *i } EXPORT_SYMBOL(generic_delete_inode); -/* - * Called when we're dropping the last reference - * to an inode. +/** + * iput - put an inode + * @inode: inode to put * - * Call the FS "drop_inode()" function, defaulting to - * the legacy UNIX filesystem behaviour. If it tells - * us to evict inode, do so. Otherwise, retain inode - * in cache if fs is alive, sync and evict if fs is - * shutting down. + * Puts an inode, dropping its usage count. If the inode use count hits + * zero, the inode is then freed and may also be destroyed. + * + * Consequently, iput() can sleep. */ -static void iput_final(struct inode *inode) +void iput(struct inode *inode) { struct super_block *sb = inode->i_sb; - const struct super_operations *op = inode->i_sb->s_op; + const struct super_operations *op = sb->s_op; int drop; + if (!inode) + return; + + BUG_ON(inode->i_state & I_CLEAR); +retry: + if (!atomic_dec_and_lock(&inode->i_count, &inode->i_lock)) + return; + + if (inode->i_nlink && (inode->i_state & I_DIRTY_TIME)) { + atomic_inc(&inode->i_count); + inode->i_state &= ~I_DIRTY_TIME; + spin_unlock(&inode->i_lock); + trace_writeback_lazytime_iput(inode); + mark_inode_dirty_sync(inode); + goto retry; + } + WARN_ON(inode->i_state & I_NEW); + /* + * Call the FS "drop_inode()" function, defaulting to + * the legacy UNIX filesystem behaviour. If it tells + * us to evict inode, do so. Otherwise, retain inode + * in cache if fs is alive, sync and evict if fs is + * shutting down. + */ if (op->drop_inode) drop = op->drop_inode(inode); else @@ -1514,36 +1537,6 @@ static void iput_final(struct inode *ino evict(inode); } - -/** - * iput - put an inode - * @inode: inode to put - * - * Puts an inode, dropping its usage count. If the inode use count hits - * zero, the inode is then freed and may also be destroyed. - * - * Consequently, iput() can sleep. - */ -void iput(struct inode *inode) -{ - if (!inode) - return; - - BUG_ON(inode->i_state & I_CLEAR); -retry: - if (!atomic_dec_and_lock(&inode->i_count, &inode->i_lock)) - return; - - if (inode->i_nlink && (inode->i_state & I_DIRTY_TIME)) { - atomic_inc(&inode->i_count); - inode->i_state &= ~I_DIRTY_TIME; - spin_unlock(&inode->i_lock); - trace_writeback_lazytime_iput(inode); - mark_inode_dirty_sync(inode); - goto retry; - } - iput_final(inode); -} EXPORT_SYMBOL(iput); /**