]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ext2: s_next_generation locking
authorAndrew Morton <akpm@osdl.org>
Mon, 19 Jan 2004 13:07:14 +0000 (05:07 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 19 Jan 2004 13:07:14 +0000 (05:07 -0800)
There is no locking around the increment of this per-filesystem counter.
Create a new lock, just for this.

fs/ext2/ialloc.c
fs/ext2/super.c
include/linux/ext2_fs_sb.h

index 20d396902c250f900a228e05888013ba1bc33a59..95ad61fc80b79eb367dbec273a2653e391214784 100644 (file)
@@ -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)) {
index 410f95252bdbcbccf07667707f5a0f5e61e50eda..576951e2bbddf247f7bdc8312b5c39bdeea650bd 100644 (file)
@@ -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
         */
index 13178c16c7ea11a9146752eab736146d09bdc1f3..4eda0ed76a4898cfb46581b9bddbd710ca91303e 100644 (file)
@@ -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;