aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-09-05 00:35:53 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:39 -0400
commit2879ed66e4c6da1dfc6bb0bd04566b61824f9256 (patch)
treef6d5b47abac374fb9ecd516eaea424d990821d83 /fs/nilfs2
parent090fd5b10165033d7c30afde0a7e59141d820602 (diff)
nilfs2: remove own inode allocator and destructor for metadata files
This finally removes own inode allocator and destructor functions for metadata files. Several routines, nilfs_mdt_new(), nilfs_mdt_new_common(), nilfs_mdt_clear(), nilfs_mdt_destroy(), and nilfs_alloc_inode_common() will be gone. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/mdt.c111
-rw-r--r--fs/nilfs2/mdt.h5
-rw-r--r--fs/nilfs2/nilfs.h1
-rw-r--r--fs/nilfs2/super.c9
4 files changed, 2 insertions, 124 deletions
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 0a2ccfc0d6f9..d60fdb097d52 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -36,7 +36,6 @@
36 36
37#define NILFS_MDT_MAX_RA_BLOCKS (16 - 1) 37#define NILFS_MDT_MAX_RA_BLOCKS (16 - 1)
38 38
39#define INIT_UNUSED_INODE_FIELDS
40 39
41static int 40static int
42nilfs_mdt_insert_new_block(struct inode *inode, unsigned long block, 41nilfs_mdt_insert_new_block(struct inode *inode, unsigned long block,
@@ -435,93 +434,6 @@ int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz)
435 return 0; 434 return 0;
436} 435}
437 436
438/*
439 * NILFS2 uses pseudo inodes for meta data files such as DAT, cpfile, sufile,
440 * ifile, or gcinodes. This allows the B-tree code and segment constructor
441 * to treat them like regular files, and this helps to simplify the
442 * implementation.
443 * On the other hand, some of the pseudo inodes have an irregular point:
444 * They don't have valid inode->i_sb pointer because their lifetimes are
445 * longer than those of the super block structs; they may continue for
446 * several consecutive mounts/umounts. This would need discussions.
447 */
448/**
449 * nilfs_mdt_new_common - allocate a pseudo inode for metadata file
450 * @nilfs: nilfs object
451 * @sb: super block instance the metadata file belongs to
452 * @ino: inode number
453 */
454struct inode *
455nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
456 ino_t ino)
457{
458 struct inode *inode = nilfs_alloc_inode_common(nilfs);
459
460 if (!inode)
461 return NULL;
462 else {
463 struct address_space * const mapping = &inode->i_data;
464
465 inode->i_sb = sb; /* sb may be NULL for some meta data files */
466 inode->i_blkbits = nilfs->ns_blocksize_bits;
467 inode->i_flags = 0;
468 atomic_set(&inode->i_count, 1);
469 inode->i_nlink = 1;
470 inode->i_ino = ino;
471
472#ifdef INIT_UNUSED_INODE_FIELDS
473 atomic_set(&inode->i_writecount, 0);
474 inode->i_size = 0;
475 inode->i_blocks = 0;
476 inode->i_bytes = 0;
477 inode->i_generation = 0;
478#ifdef CONFIG_QUOTA
479 memset(&inode->i_dquot, 0, sizeof(inode->i_dquot));
480#endif
481 inode->i_pipe = NULL;
482 inode->i_bdev = NULL;
483 inode->i_cdev = NULL;
484 inode->i_rdev = 0;
485#ifdef CONFIG_SECURITY
486 inode->i_security = NULL;
487#endif
488 inode->dirtied_when = 0;
489
490 INIT_LIST_HEAD(&inode->i_list);
491 INIT_LIST_HEAD(&inode->i_sb_list);
492 inode->i_state = 0;
493#endif
494
495 spin_lock_init(&inode->i_lock);
496 mutex_init(&inode->i_mutex);
497 init_rwsem(&inode->i_alloc_sem);
498
499 mapping->host = NULL; /* instead of inode */
500 mapping->flags = 0;
501 mapping->assoc_mapping = NULL;
502
503 inode->i_mapping = mapping;
504 }
505
506 return inode;
507}
508
509struct inode *nilfs_mdt_new(struct the_nilfs *nilfs, struct super_block *sb,
510 ino_t ino, size_t objsz)
511{
512 struct inode *inode;
513
514 inode = nilfs_mdt_new_common(nilfs, sb, ino);
515 if (!inode)
516 return NULL;
517
518 if (nilfs_mdt_init(inode, NILFS_MDT_GFP, objsz) < 0) {
519 nilfs_destroy_inode(inode);
520 return NULL;
521 }
522 return inode;
523}
524
525void nilfs_mdt_set_entry_size(struct inode *inode, unsigned entry_size, 437void nilfs_mdt_set_entry_size(struct inode *inode, unsigned entry_size,
526 unsigned header_size) 438 unsigned header_size)
527{ 439{
@@ -688,26 +600,3 @@ void nilfs_mdt_clear_shadow_map(struct inode *inode)
688 truncate_inode_pages(&shadow->frozen_btnodes, 0); 600 truncate_inode_pages(&shadow->frozen_btnodes, 0);
689 up_write(&mi->mi_sem); 601 up_write(&mi->mi_sem);
690} 602}
691
692static void nilfs_mdt_clear(struct inode *inode)
693{
694 struct nilfs_inode_info *ii = NILFS_I(inode);
695
696 invalidate_mapping_pages(inode->i_mapping, 0, -1);
697 truncate_inode_pages(inode->i_mapping, 0);
698
699 if (test_bit(NILFS_I_BMAP, &ii->i_state))
700 nilfs_bmap_clear(ii->i_bmap);
701 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
702}
703
704void nilfs_mdt_destroy(struct inode *inode)
705{
706 struct nilfs_mdt_info *mdi = NILFS_MDT(inode);
707
708 if (mdi->mi_palloc_cache)
709 nilfs_palloc_destroy_cache(inode);
710 nilfs_mdt_clear(inode);
711
712 nilfs_destroy_inode(inode);
713}
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h
index 76356d2899ed..b13734bf3521 100644
--- a/fs/nilfs2/mdt.h
+++ b/fs/nilfs2/mdt.h
@@ -82,11 +82,6 @@ int nilfs_mdt_mark_block_dirty(struct inode *, unsigned long);
82int nilfs_mdt_fetch_dirty(struct inode *); 82int nilfs_mdt_fetch_dirty(struct inode *);
83 83
84int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz); 84int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz);
85struct inode *nilfs_mdt_new(struct the_nilfs *, struct super_block *, ino_t,
86 size_t);
87struct inode *nilfs_mdt_new_common(struct the_nilfs *, struct super_block *,
88 ino_t);
89void nilfs_mdt_destroy(struct inode *);
90void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned); 85void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
91 86
92int nilfs_mdt_setup_shadow_map(struct inode *inode, 87int nilfs_mdt_setup_shadow_map(struct inode *inode,
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index f6e276eaaf6f..f7560da5a567 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -266,7 +266,6 @@ extern int nilfs_mark_inode_dirty(struct inode *);
266extern void nilfs_dirty_inode(struct inode *); 266extern void nilfs_dirty_inode(struct inode *);
267 267
268/* super.c */ 268/* super.c */
269extern struct inode *nilfs_alloc_inode_common(struct the_nilfs *);
270extern struct inode *nilfs_alloc_inode(struct super_block *); 269extern struct inode *nilfs_alloc_inode(struct super_block *);
271extern void nilfs_destroy_inode(struct inode *); 270extern void nilfs_destroy_inode(struct inode *);
272extern void nilfs_error(struct super_block *, const char *, const char *, ...) 271extern void nilfs_error(struct super_block *, const char *, const char *, ...)
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index ab96d26bf7e9..d92ebd5d60d9 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -146,7 +146,7 @@ void nilfs_warning(struct super_block *sb, const char *function,
146} 146}
147 147
148 148
149struct inode *nilfs_alloc_inode_common(struct the_nilfs *nilfs) 149struct inode *nilfs_alloc_inode(struct super_block *sb)
150{ 150{
151 struct nilfs_inode_info *ii; 151 struct nilfs_inode_info *ii;
152 152
@@ -157,15 +157,10 @@ struct inode *nilfs_alloc_inode_common(struct the_nilfs *nilfs)
157 ii->i_state = 0; 157 ii->i_state = 0;
158 ii->i_cno = 0; 158 ii->i_cno = 0;
159 ii->vfs_inode.i_version = 1; 159 ii->vfs_inode.i_version = 1;
160 nilfs_btnode_cache_init(&ii->i_btnode_cache, nilfs->ns_bdi); 160 nilfs_btnode_cache_init(&ii->i_btnode_cache, sb->s_bdi);
161 return &ii->vfs_inode; 161 return &ii->vfs_inode;
162} 162}
163 163
164struct inode *nilfs_alloc_inode(struct super_block *sb)
165{
166 return nilfs_alloc_inode_common(NILFS_SB(sb)->s_nilfs);
167}
168
169void nilfs_destroy_inode(struct inode *inode) 164void nilfs_destroy_inode(struct inode *inode)
170{ 165{
171 struct nilfs_mdt_info *mdi = NILFS_MDT(inode); 166 struct nilfs_mdt_info *mdi = NILFS_MDT(inode);