Skip to content

Commit f5e5e97

Browse files
committed
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 <[email protected]>
1 parent c3a5e3e commit f5e5e97

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

fs/inode.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -898,18 +898,18 @@ long prune_icache_sb(struct super_block *sb, struct shrink_control *sc)
898898
return freed;
899899
}
900900

901-
static void __wait_on_freeing_inode(struct inode *inode, bool locked);
901+
static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_hash_locked);
902902
/*
903903
* Called with the inode lock held.
904904
*/
905905
static struct inode *find_inode(struct super_block *sb,
906906
struct hlist_head *head,
907907
int (*test)(struct inode *, void *),
908-
void *data, bool locked)
908+
void *data, bool is_inode_hash_locked)
909909
{
910910
struct inode *inode = NULL;
911911

912-
if (locked)
912+
if (is_inode_hash_locked)
913913
lockdep_assert_held(&inode_hash_lock);
914914
else
915915
lockdep_assert_not_held(&inode_hash_lock);
@@ -923,7 +923,7 @@ static struct inode *find_inode(struct super_block *sb,
923923
continue;
924924
spin_lock(&inode->i_lock);
925925
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
926-
__wait_on_freeing_inode(inode, locked);
926+
__wait_on_freeing_inode(inode, is_inode_hash_locked);
927927
goto repeat;
928928
}
929929
if (unlikely(inode->i_state & I_CREATING)) {
@@ -946,11 +946,11 @@ static struct inode *find_inode(struct super_block *sb,
946946
*/
947947
static struct inode *find_inode_fast(struct super_block *sb,
948948
struct hlist_head *head, unsigned long ino,
949-
bool locked)
949+
bool is_inode_hash_locked)
950950
{
951951
struct inode *inode = NULL;
952952

953-
if (locked)
953+
if (is_inode_hash_locked)
954954
lockdep_assert_held(&inode_hash_lock);
955955
else
956956
lockdep_assert_not_held(&inode_hash_lock);
@@ -964,7 +964,7 @@ static struct inode *find_inode_fast(struct super_block *sb,
964964
continue;
965965
spin_lock(&inode->i_lock);
966966
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
967-
__wait_on_freeing_inode(inode, locked);
967+
__wait_on_freeing_inode(inode, is_inode_hash_locked);
968968
goto repeat;
969969
}
970970
if (unlikely(inode->i_state & I_CREATING)) {
@@ -2297,7 +2297,7 @@ EXPORT_SYMBOL(inode_needs_sync);
22972297
* wake_up_bit(&inode->i_state, __I_NEW) after removing from the hash list
22982298
* will DTRT.
22992299
*/
2300-
static void __wait_on_freeing_inode(struct inode *inode, bool locked)
2300+
static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_hash_locked)
23012301
{
23022302
wait_queue_head_t *wq;
23032303
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
@@ -2306,7 +2306,7 @@ static void __wait_on_freeing_inode(struct inode *inode, bool locked)
23062306
* Handle racing against evict(), see that routine for more details.
23072307
*/
23082308
if (unlikely(inode_unhashed(inode))) {
2309-
WARN_ON(locked);
2309+
WARN_ON(is_inode_hash_locked);
23102310
spin_unlock(&inode->i_lock);
23112311
return;
23122312
}
@@ -2315,11 +2315,11 @@ static void __wait_on_freeing_inode(struct inode *inode, bool locked)
23152315
prepare_to_wait(wq, &wait.wq_entry, TASK_UNINTERRUPTIBLE);
23162316
spin_unlock(&inode->i_lock);
23172317
rcu_read_unlock();
2318-
if (locked)
2318+
if (is_inode_hash_locked)
23192319
spin_unlock(&inode_hash_lock);
23202320
schedule();
23212321
finish_wait(wq, &wait.wq_entry);
2322-
if (locked)
2322+
if (is_inode_hash_locked)
23232323
spin_lock(&inode_hash_lock);
23242324
rcu_read_lock();
23252325
}

0 commit comments

Comments
 (0)