From: Peter Zijlstra <peterz@infradead.org>
To: Al Viro <viro@ZenIV.linux.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>,
Chris Mason <clm@fb.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
David Howells <dhowells@redhat.com>,
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()
Date: Fri, 24 Feb 2017 16:43:34 +0100 [thread overview]
Message-ID: <20170224162044.200355596@infradead.org> (raw)
In-Reply-To: <20170224154329.478276481@infradead.org>
[-- Attachment #1: peterz-fs-inode-3c.patch --]
[-- Type: text/plain, Size: 2905 bytes --]
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@infradead.org>
---
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);
/**
next prev parent reply other threads:[~2017-02-24 18:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 15:43 [RFC][PATCH 00/10] On inode::i_count and the usage vs reference count issue Peter Zijlstra
2017-02-24 15:43 ` [RFC][PATCH 01/10] fs: Use lockdep_assert_held() instead of comments Peter Zijlstra
2017-02-24 15:43 ` [RFC][PATCH 02/10] fs: Avoid looking at i_count without i_lock held Peter Zijlstra
[not found] ` <CA+55aFxLw8FXf61rsGYDjA1tS=joDeaF7OSgaepLWwcz4zt=dg@mail.gmail.com>
2017-02-24 17:06 ` Peter Zijlstra
2017-02-24 15:43 ` [RFC][PATCH 03/10] fs: Introduce i_count() Peter Zijlstra
2017-02-24 15:43 ` [RFC][PATCH 04/10] fs: Restructure iput() Peter Zijlstra
2017-02-24 15:43 ` Peter Zijlstra [this message]
2017-02-24 15:43 ` [RFC][PATCH 06/10] fs: Rework i_count Peter Zijlstra
2017-02-24 20:49 ` Al Viro
2017-02-24 15:43 ` [RFC][PATCH 07/10] orangefs: Use RCU for destroy_inode Peter Zijlstra
2017-02-24 20:52 ` Al Viro
2017-02-24 23:00 ` Mike Marshall
2017-02-25 20:31 ` Mike Marshall
2017-02-27 0:34 ` Mike Marshall
2017-02-27 1:20 ` Linus Torvalds
2017-02-27 8:44 ` David Howells
2017-02-27 14:44 ` Mike Marshall
2017-02-24 15:43 ` [RFC][PATCH 08/10] fs: Do RCU versions for find_inode() Peter Zijlstra
2017-02-24 15:43 ` [RFC][PATCH 09/10] locking/refcount: Provide refcount_dec_unless() Peter Zijlstra
2017-02-27 9:28 ` Reshetova, Elena
2017-02-24 15:43 ` [RFC][PATCH 10/10] fs: Convert i_count over to refcount_t Peter Zijlstra
2017-02-24 16:43 ` [RFC][PATCH 00/10] On inode::i_count and the usage vs reference count issue Christoph Hellwig
2017-02-24 17:07 ` Peter Zijlstra
2017-02-24 20:59 ` David Windsor
[not found] ` <CA+55aFy1bNbsX_3T-s_EUwTP-r_SmJJMvB3=-2nffehFVP=EdQ@mail.gmail.com>
[not found] ` <CA+55aFz0DbAGZ8gc+s35nm1N5frXjK_NOh7QzuSfZeJbjsT6Sg@mail.gmail.com>
[not found] ` <CA+55aFyR8wkHps5_AqUqzx8MDMNxRZZ7+MYH9g=ZCUi=4Oey8w@mail.gmail.com>
2017-02-24 19:24 ` Fwd: " Linus Torvalds
2017-02-24 20:42 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170224162044.200355596@infradead.org \
--to=peterz@infradead.org \
--cc=clm@fb.com \
--cc=dhowells@redhat.com \
--cc=dwindsor@gmail.com \
--cc=elena.reshetova@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ishkamiel@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome