Commit 6283f86e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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.
parent 70d4c9f2
......@@ -599,7 +599,9 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
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)) {
......
......@@ -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
*/
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment