Commit 546e1d8b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ext3: s_next_generation fixes

- Add missing locking around s_next_generation increment

- Correctly set the initial value of s_next_generation.
parent 6283f86e
......@@ -446,8 +446,8 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
return ERR_PTR(-ENOMEM);
ei = EXT3_I(inode);
es = EXT3_SB(sb)->s_es;
sbi = EXT3_SB(sb);
es = sbi->s_es;
if (S_ISDIR(mode)) {
if (test_opt (sb, OLDALLOC))
group = find_group_dir(sb, dir);
......@@ -591,7 +591,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
if (IS_DIRSYNC(inode))
handle->h_sync = 1;
insert_inode_hash(inode);
inode->i_generation = EXT3_SB(sb)->s_next_generation++;
spin_lock(&sbi->s_next_gen_lock);
inode->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock);
ei->i_state = EXT3_STATE_NEW;
......
......@@ -31,6 +31,7 @@
#include <linux/smp_lock.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include <linux/random.h>
#include <asm/uaccess.h>
#include "xattr.h"
#include "acl.h"
......@@ -1287,6 +1288,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
goto failed_mount2;
}
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
*/
......
......@@ -49,6 +49,7 @@ struct ext3_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;
u32 s_hash_seed[4];
int s_def_hash_version;
......
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