From 6283f86ec40c482d69acb720451cf69098009b9d Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 19 Jan 2004 05:07:14 -0800 Subject: [PATCH] [PATCH] ext2: s_next_generation locking There is no locking around the increment of this per-filesystem counter. Create a new lock, just for this. --- fs/ext2/ialloc.c | 2 ++ fs/ext2/super.c | 1 + include/linux/ext2_fs_sb.h | 1 + 3 files changed, 4 insertions(+) diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 20d396902c250..95ad61fc80b79 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -599,7 +599,9 @@ got: ei->i_dir_start_lookup = 0; ei->i_state = EXT2_STATE_NEW; ext2_set_inode_flags(inode); + spin_lock(&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++; + spin_unlock(&sbi->s_next_gen_lock); insert_inode_hash(inode); if (DQUOT_ALLOC_INODE(inode)) { diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 410f95252bdbc..576951e2bbddf 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -809,6 +809,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) } sbi->s_gdb_count = db_count; get_random_bytes(&sbi->s_next_generation, sizeof(u32)); + spin_lock_init(&sbi->s_next_gen_lock); /* * set up enough so that it can read an inode */ diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h index 13178c16c7ea1..4eda0ed76a489 100644 --- a/include/linux/ext2_fs_sb.h +++ b/include/linux/ext2_fs_sb.h @@ -45,6 +45,7 @@ struct ext2_sb_info { int s_desc_per_block_bits; int s_inode_size; int s_first_ino; + spinlock_t s_next_gen_lock; u32 s_next_generation; unsigned long s_dir_count; u8 *s_debts; -- 2.53.0