mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
ext2: mark s_next_generation as guarded by s_next_gen_lock
s_next_generation is only ever modified while holding s_next_gen_lock (in ext2_new_inode()), so annotate it with __guarded_by() for Clang's context analysis. The only other write is the initialisation in ext2_fill_super(), which runs before the superblock is live. No concurrent access should be possible. Convert the spinlock initialization to use scoped_guard(spinlock_init, ...) and place the write under the guard to prevent a warning. Signed-off-by: Timothy Day <timday@thelustrecollective.com> Acked-by: Marco Elver <elver@google.com> Link: https://patch.msgid.link/20260811160336.782342-2-timday@thelustrecollective.com Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
127b0d8764
commit
e76ed86ee8
|
|
@ -93,7 +93,7 @@ struct ext2_sb_info {
|
|||
int s_inode_size;
|
||||
int s_first_ino;
|
||||
spinlock_t s_next_gen_lock;
|
||||
u32 s_next_generation;
|
||||
u32 s_next_generation __guarded_by(&s_next_gen_lock);
|
||||
unsigned long s_dir_count;
|
||||
u8 *s_debts;
|
||||
struct percpu_counter s_freeblocks_counter;
|
||||
|
|
|
|||
|
|
@ -1126,8 +1126,9 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
|
|||
goto failed_mount2;
|
||||
}
|
||||
sbi->s_gdb_count = db_count;
|
||||
sbi->s_next_generation = get_random_u32();
|
||||
spin_lock_init(&sbi->s_next_gen_lock);
|
||||
scoped_guard(spinlock, &sbi->s_next_gen_lock)
|
||||
sbi->s_next_generation = get_random_u32();
|
||||
|
||||
/* per filesystem reservation list head & lock */
|
||||
spin_lock_init(&sbi->s_rsv_window_lock);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user