diff options
| -rw-r--r-- | fs/nilfs2/inode.c | 8 | ||||
| -rw-r--r-- | fs/nilfs2/sb.h | 4 | ||||
| -rw-r--r-- | fs/nilfs2/super.c | 11 | ||||
| -rw-r--r-- | fs/nilfs2/the_nilfs.c | 5 | ||||
| -rw-r--r-- | fs/nilfs2/the_nilfs.h | 6 |
5 files changed, 15 insertions, 19 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index dd5d6d633ea1..7a3dbe4f229c 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
| @@ -295,7 +295,7 @@ const struct address_space_operations nilfs_aops = { | |||
| 295 | struct inode *nilfs_new_inode(struct inode *dir, int mode) | 295 | struct inode *nilfs_new_inode(struct inode *dir, int mode) |
| 296 | { | 296 | { |
| 297 | struct super_block *sb = dir->i_sb; | 297 | struct super_block *sb = dir->i_sb; |
| 298 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 298 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
| 299 | struct inode *inode; | 299 | struct inode *inode; |
| 300 | struct nilfs_inode_info *ii; | 300 | struct nilfs_inode_info *ii; |
| 301 | struct nilfs_root *root; | 301 | struct nilfs_root *root; |
| @@ -340,9 +340,9 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode) | |||
| 340 | /* ii->i_dir_acl = 0; */ | 340 | /* ii->i_dir_acl = 0; */ |
| 341 | ii->i_dir_start_lookup = 0; | 341 | ii->i_dir_start_lookup = 0; |
| 342 | nilfs_set_inode_flags(inode); | 342 | nilfs_set_inode_flags(inode); |
| 343 | spin_lock(&sbi->s_next_gen_lock); | 343 | spin_lock(&nilfs->ns_next_gen_lock); |
| 344 | inode->i_generation = sbi->s_next_generation++; | 344 | inode->i_generation = nilfs->ns_next_generation++; |
| 345 | spin_unlock(&sbi->s_next_gen_lock); | 345 | spin_unlock(&nilfs->ns_next_gen_lock); |
| 346 | insert_inode_hash(inode); | 346 | insert_inode_hash(inode); |
| 347 | 347 | ||
| 348 | err = nilfs_init_acl(inode, dir); | 348 | err = nilfs_init_acl(inode, dir); |
diff --git a/fs/nilfs2/sb.h b/fs/nilfs2/sb.h index 3232e75fab75..6f190dfdc649 100644 --- a/fs/nilfs2/sb.h +++ b/fs/nilfs2/sb.h | |||
| @@ -40,10 +40,6 @@ struct nilfs_sb_info { | |||
| 40 | 40 | ||
| 41 | /* Segment constructor */ | 41 | /* Segment constructor */ |
| 42 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ | 42 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ |
| 43 | |||
| 44 | /* Inode allocator */ | ||
| 45 | spinlock_t s_next_gen_lock; | ||
| 46 | u32 s_next_generation; | ||
| 47 | }; | 43 | }; |
| 48 | 44 | ||
| 49 | static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) | 45 | static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 6dc8b3cad127..1368c4293c7f 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
| @@ -43,7 +43,6 @@ | |||
| 43 | #include <linux/init.h> | 43 | #include <linux/init.h> |
| 44 | #include <linux/blkdev.h> | 44 | #include <linux/blkdev.h> |
| 45 | #include <linux/parser.h> | 45 | #include <linux/parser.h> |
| 46 | #include <linux/random.h> | ||
| 47 | #include <linux/crc32.h> | 46 | #include <linux/crc32.h> |
| 48 | #include <linux/vfs.h> | 47 | #include <linux/vfs.h> |
| 49 | #include <linux/writeback.h> | 48 | #include <linux/writeback.h> |
| @@ -943,16 +942,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 943 | if (err) | 942 | if (err) |
| 944 | goto failed_nilfs; | 943 | goto failed_nilfs; |
| 945 | 944 | ||
| 946 | /* | ||
| 947 | * Following initialization is overlapped because | ||
| 948 | * nilfs_sb_info structure has been cleared at the beginning. | ||
| 949 | * But we reserve them to keep our interest and make ready | ||
| 950 | * for the future change. | ||
| 951 | */ | ||
| 952 | get_random_bytes(&sbi->s_next_generation, | ||
| 953 | sizeof(sbi->s_next_generation)); | ||
| 954 | spin_lock_init(&sbi->s_next_gen_lock); | ||
| 955 | |||
| 956 | sb->s_op = &nilfs_sops; | 945 | sb->s_op = &nilfs_sops; |
| 957 | sb->s_export_op = &nilfs_export_ops; | 946 | sb->s_export_op = &nilfs_export_ops; |
| 958 | sb->s_root = NULL; | 947 | sb->s_root = NULL; |
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 40239a932dec..1bf695e887a7 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
| 27 | #include <linux/backing-dev.h> | 27 | #include <linux/backing-dev.h> |
| 28 | #include <linux/random.h> | ||
| 28 | #include <linux/crc32.h> | 29 | #include <linux/crc32.h> |
| 29 | #include "nilfs.h" | 30 | #include "nilfs.h" |
| 30 | #include "segment.h" | 31 | #include "segment.h" |
| @@ -78,6 +79,7 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) | |||
| 78 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); | 79 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); |
| 79 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); | 80 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); |
| 80 | spin_lock_init(&nilfs->ns_inode_lock); | 81 | spin_lock_init(&nilfs->ns_inode_lock); |
| 82 | spin_lock_init(&nilfs->ns_next_gen_lock); | ||
| 81 | spin_lock_init(&nilfs->ns_last_segment_lock); | 83 | spin_lock_init(&nilfs->ns_last_segment_lock); |
| 82 | nilfs->ns_cptree = RB_ROOT; | 84 | nilfs->ns_cptree = RB_ROOT; |
| 83 | spin_lock_init(&nilfs->ns_cptree_lock); | 85 | spin_lock_init(&nilfs->ns_cptree_lock); |
| @@ -593,6 +595,9 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | |||
| 593 | nilfs->ns_blocksize_bits = sb->s_blocksize_bits; | 595 | nilfs->ns_blocksize_bits = sb->s_blocksize_bits; |
| 594 | nilfs->ns_blocksize = blocksize; | 596 | nilfs->ns_blocksize = blocksize; |
| 595 | 597 | ||
| 598 | get_random_bytes(&nilfs->ns_next_generation, | ||
| 599 | sizeof(nilfs->ns_next_generation)); | ||
| 600 | |||
| 596 | err = nilfs_store_disk_layout(nilfs, sbp); | 601 | err = nilfs_store_disk_layout(nilfs, sbp); |
| 597 | if (err) | 602 | if (err) |
| 598 | goto failed_sbh; | 603 | goto failed_sbh; |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 6106ec5ad89a..3ecc968f2123 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
| @@ -74,6 +74,8 @@ enum { | |||
| 74 | * @ns_dirty_files: list of dirty files | 74 | * @ns_dirty_files: list of dirty files |
| 75 | * @ns_inode_lock: lock protecting @ns_dirty_files | 75 | * @ns_inode_lock: lock protecting @ns_dirty_files |
| 76 | * @ns_gc_inodes: dummy inodes to keep live blocks | 76 | * @ns_gc_inodes: dummy inodes to keep live blocks |
| 77 | * @ns_next_generation: next generation number for inodes | ||
| 78 | * @ns_next_gen_lock: lock protecting @ns_next_generation | ||
| 77 | * @ns_mount_opt: mount options | 79 | * @ns_mount_opt: mount options |
| 78 | * @ns_resuid: uid for reserved blocks | 80 | * @ns_resuid: uid for reserved blocks |
| 79 | * @ns_resgid: gid for reserved blocks | 81 | * @ns_resgid: gid for reserved blocks |
| @@ -159,6 +161,10 @@ struct the_nilfs { | |||
| 159 | /* GC inode list */ | 161 | /* GC inode list */ |
| 160 | struct list_head ns_gc_inodes; | 162 | struct list_head ns_gc_inodes; |
| 161 | 163 | ||
| 164 | /* Inode allocator */ | ||
| 165 | u32 ns_next_generation; | ||
| 166 | spinlock_t ns_next_gen_lock; | ||
| 167 | |||
| 162 | /* Mount options */ | 168 | /* Mount options */ |
| 163 | unsigned long ns_mount_opt; | 169 | unsigned long ns_mount_opt; |
| 164 | 170 | ||
