[RFC][PATCH 05/10] fs: Remove iput_final()

From: Peter Zijlstra
Date: Fri Feb 24 2017 - 13:15:43 EST


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) <peterz@xxxxxxxxxxxxx>
---
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);

/**