Skip to content

Commit 23ca067

Browse files
Sebastian Andrzej Siewiorjankara
authored andcommitted
mm: Fully initialize invalidate_lock, amend lock class later
The function __init_rwsem() is not part of the official API, it just a helper function used by init_rwsem(). Changing the lock's class and name should be done by using lockdep_set_class_and_name() after the has been fully initialized. The overhead of the additional class struct and setting it twice is negligible and it works across all locks. Fully initialize the lock with init_rwsem() and then set the custom class and name for the lock. Fixes: 730633f ("mm: Protect operations adding pages to page cache with invalidate_lock") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 6a4746b commit 23ca067

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/inode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
190190
mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE);
191191
mapping->private_data = NULL;
192192
mapping->writeback_index = 0;
193-
__init_rwsem(&mapping->invalidate_lock, "mapping.invalidate_lock",
194-
&sb->s_type->invalidate_lock_key);
193+
init_rwsem(&mapping->invalidate_lock);
194+
lockdep_set_class_and_name(&mapping->invalidate_lock,
195+
&sb->s_type->invalidate_lock_key,
196+
"mapping.invalidate_lock");
195197
inode->i_private = NULL;
196198
inode->i_mapping = mapping;
197199
INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */

0 commit comments

Comments
 (0)