mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 06:01:53 +02:00
inode: clarify what's locked
In __wait_on_freeing_inode() we warn in case the inode_hash_lock is held but the inode is unhashed. We then release the inode_lock. So using "locked" as parameter name is confusing. Use is_inode_hash_locked as parameter name instead. Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
c3a5e3e872
commit
f5e5e97c71
22
fs/inode.c
22
fs/inode.c
|
|
@ -898,18 +898,18 @@ long prune_icache_sb(struct super_block *sb, struct shrink_control *sc)
|
|||
return freed;
|
||||
}
|
||||
|
||||
static void __wait_on_freeing_inode(struct inode *inode, bool locked);
|
||||
static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_hash_locked);
|
||||
/*
|
||||
* Called with the inode lock held.
|
||||
*/
|
||||
static struct inode *find_inode(struct super_block *sb,
|
||||
struct hlist_head *head,
|
||||
int (*test)(struct inode *, void *),
|
||||
void *data, bool locked)
|
||||
void *data, bool is_inode_hash_locked)
|
||||
{
|
||||
struct inode *inode = NULL;
|
||||
|
||||
if (locked)
|
||||
if (is_inode_hash_locked)
|
||||
lockdep_assert_held(&inode_hash_lock);
|
||||
else
|
||||
lockdep_assert_not_held(&inode_hash_lock);
|
||||
|
|
@ -923,7 +923,7 @@ static struct inode *find_inode(struct super_block *sb,
|
|||
continue;
|
||||
spin_lock(&inode->i_lock);
|
||||
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
|
||||
__wait_on_freeing_inode(inode, locked);
|
||||
__wait_on_freeing_inode(inode, is_inode_hash_locked);
|
||||
goto repeat;
|
||||
}
|
||||
if (unlikely(inode->i_state & I_CREATING)) {
|
||||
|
|
@ -946,11 +946,11 @@ static struct inode *find_inode(struct super_block *sb,
|
|||
*/
|
||||
static struct inode *find_inode_fast(struct super_block *sb,
|
||||
struct hlist_head *head, unsigned long ino,
|
||||
bool locked)
|
||||
bool is_inode_hash_locked)
|
||||
{
|
||||
struct inode *inode = NULL;
|
||||
|
||||
if (locked)
|
||||
if (is_inode_hash_locked)
|
||||
lockdep_assert_held(&inode_hash_lock);
|
||||
else
|
||||
lockdep_assert_not_held(&inode_hash_lock);
|
||||
|
|
@ -964,7 +964,7 @@ static struct inode *find_inode_fast(struct super_block *sb,
|
|||
continue;
|
||||
spin_lock(&inode->i_lock);
|
||||
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
|
||||
__wait_on_freeing_inode(inode, locked);
|
||||
__wait_on_freeing_inode(inode, is_inode_hash_locked);
|
||||
goto repeat;
|
||||
}
|
||||
if (unlikely(inode->i_state & I_CREATING)) {
|
||||
|
|
@ -2297,7 +2297,7 @@ EXPORT_SYMBOL(inode_needs_sync);
|
|||
* wake_up_bit(&inode->i_state, __I_NEW) after removing from the hash list
|
||||
* will DTRT.
|
||||
*/
|
||||
static void __wait_on_freeing_inode(struct inode *inode, bool locked)
|
||||
static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_hash_locked)
|
||||
{
|
||||
wait_queue_head_t *wq;
|
||||
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
|
||||
|
|
@ -2306,7 +2306,7 @@ static void __wait_on_freeing_inode(struct inode *inode, bool locked)
|
|||
* Handle racing against evict(), see that routine for more details.
|
||||
*/
|
||||
if (unlikely(inode_unhashed(inode))) {
|
||||
WARN_ON(locked);
|
||||
WARN_ON(is_inode_hash_locked);
|
||||
spin_unlock(&inode->i_lock);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2315,11 +2315,11 @@ static void __wait_on_freeing_inode(struct inode *inode, bool locked)
|
|||
prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE);
|
||||
spin_unlock(&inode->i_lock);
|
||||
rcu_read_unlock();
|
||||
if (locked)
|
||||
if (is_inode_hash_locked)
|
||||
spin_unlock(&inode_hash_lock);
|
||||
schedule();
|
||||
finish_wait(wq, &wait.wq_entry);
|
||||
if (locked)
|
||||
if (is_inode_hash_locked)
|
||||
spin_lock(&inode_hash_lock);
|
||||
rcu_read_lock();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user