aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nilfs2/inode.c28
-rw-r--r--fs/nilfs2/nilfs.h2
-rw-r--r--fs/nilfs2/super.c20
3 files changed, 26 insertions, 24 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 051d279abb37..eccb2f2e2315 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -27,6 +27,7 @@
27#include <linux/writeback.h> 27#include <linux/writeback.h>
28#include <linux/uio.h> 28#include <linux/uio.h>
29#include "nilfs.h" 29#include "nilfs.h"
30#include "btnode.h"
30#include "segment.h" 31#include "segment.h"
31#include "page.h" 32#include "page.h"
32#include "mdt.h" 33#include "mdt.h"
@@ -354,7 +355,6 @@ void nilfs_free_inode(struct inode *inode)
354 struct super_block *sb = inode->i_sb; 355 struct super_block *sb = inode->i_sb;
355 struct nilfs_sb_info *sbi = NILFS_SB(sb); 356 struct nilfs_sb_info *sbi = NILFS_SB(sb);
356 357
357 clear_inode(inode);
358 /* XXX: check error code? Is there any thing I can do? */ 358 /* XXX: check error code? Is there any thing I can do? */
359 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino); 359 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino);
360 atomic_dec(&sbi->s_inodes_count); 360 atomic_dec(&sbi->s_inodes_count);
@@ -614,16 +614,34 @@ void nilfs_truncate(struct inode *inode)
614 But truncate has no return value. */ 614 But truncate has no return value. */
615} 615}
616 616
617void nilfs_delete_inode(struct inode *inode) 617static void nilfs_clear_inode(struct inode *inode)
618{
619 struct nilfs_inode_info *ii = NILFS_I(inode);
620
621 /*
622 * Free resources allocated in nilfs_read_inode(), here.
623 */
624 BUG_ON(!list_empty(&ii->i_dirty));
625 brelse(ii->i_bh);
626 ii->i_bh = NULL;
627
628 if (test_bit(NILFS_I_BMAP, &ii->i_state))
629 nilfs_bmap_clear(ii->i_bmap);
630
631 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
632}
633
634void nilfs_evict_inode(struct inode *inode)
618{ 635{
619 struct nilfs_transaction_info ti; 636 struct nilfs_transaction_info ti;
620 struct super_block *sb = inode->i_sb; 637 struct super_block *sb = inode->i_sb;
621 struct nilfs_inode_info *ii = NILFS_I(inode); 638 struct nilfs_inode_info *ii = NILFS_I(inode);
622 639
623 if (unlikely(is_bad_inode(inode))) { 640 if (inode->i_nlink || unlikely(is_bad_inode(inode))) {
624 if (inode->i_data.nrpages) 641 if (inode->i_data.nrpages)
625 truncate_inode_pages(&inode->i_data, 0); 642 truncate_inode_pages(&inode->i_data, 0);
626 clear_inode(inode); 643 end_writeback(inode);
644 nilfs_clear_inode(inode);
627 return; 645 return;
628 } 646 }
629 nilfs_transaction_begin(sb, &ti, 0); /* never fails */ 647 nilfs_transaction_begin(sb, &ti, 0); /* never fails */
@@ -633,6 +651,8 @@ void nilfs_delete_inode(struct inode *inode)
633 651
634 nilfs_truncate_bmap(ii, 0); 652 nilfs_truncate_bmap(ii, 0);
635 nilfs_mark_inode_dirty(inode); 653 nilfs_mark_inode_dirty(inode);
654 end_writeback(inode);
655 nilfs_clear_inode(inode);
636 nilfs_free_inode(inode); 656 nilfs_free_inode(inode);
637 /* nilfs_free_inode() marks inode buffer dirty */ 657 /* nilfs_free_inode() marks inode buffer dirty */
638 if (IS_SYNC(inode)) 658 if (IS_SYNC(inode))
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 47d6d7928122..f03279748099 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -245,7 +245,7 @@ extern void nilfs_write_inode_common(struct inode *, struct nilfs_inode *, int);
245extern struct inode *nilfs_iget(struct super_block *, unsigned long); 245extern struct inode *nilfs_iget(struct super_block *, unsigned long);
246extern void nilfs_update_inode(struct inode *, struct buffer_head *); 246extern void nilfs_update_inode(struct inode *, struct buffer_head *);
247extern void nilfs_truncate(struct inode *); 247extern void nilfs_truncate(struct inode *);
248extern void nilfs_delete_inode(struct inode *); 248extern void nilfs_evict_inode(struct inode *);
249extern int nilfs_setattr(struct dentry *, struct iattr *); 249extern int nilfs_setattr(struct dentry *, struct iattr *);
250extern int nilfs_load_inode_block(struct nilfs_sb_info *, struct inode *, 250extern int nilfs_load_inode_block(struct nilfs_sb_info *, struct inode *,
251 struct buffer_head **); 251 struct buffer_head **);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 414ef68931cf..7c7572a4e138 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -159,23 +159,6 @@ void nilfs_destroy_inode(struct inode *inode)
159 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode)); 159 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode));
160} 160}
161 161
162static void nilfs_clear_inode(struct inode *inode)
163{
164 struct nilfs_inode_info *ii = NILFS_I(inode);
165
166 /*
167 * Free resources allocated in nilfs_read_inode(), here.
168 */
169 BUG_ON(!list_empty(&ii->i_dirty));
170 brelse(ii->i_bh);
171 ii->i_bh = NULL;
172
173 if (test_bit(NILFS_I_BMAP, &ii->i_state))
174 nilfs_bmap_clear(ii->i_bmap);
175
176 nilfs_btnode_cache_clear(&ii->i_btnode_cache);
177}
178
179static int nilfs_sync_super(struct nilfs_sb_info *sbi, int dupsb) 162static int nilfs_sync_super(struct nilfs_sb_info *sbi, int dupsb)
180{ 163{
181 struct the_nilfs *nilfs = sbi->s_nilfs; 164 struct the_nilfs *nilfs = sbi->s_nilfs;
@@ -467,7 +450,7 @@ static const struct super_operations nilfs_sops = {
467 /* .write_inode = nilfs_write_inode, */ 450 /* .write_inode = nilfs_write_inode, */
468 /* .put_inode = nilfs_put_inode, */ 451 /* .put_inode = nilfs_put_inode, */
469 /* .drop_inode = nilfs_drop_inode, */ 452 /* .drop_inode = nilfs_drop_inode, */
470 .delete_inode = nilfs_delete_inode, 453 .evict_inode = nilfs_evict_inode,
471 .put_super = nilfs_put_super, 454 .put_super = nilfs_put_super,
472 /* .write_super = nilfs_write_super, */ 455 /* .write_super = nilfs_write_super, */
473 .sync_fs = nilfs_sync_fs, 456 .sync_fs = nilfs_sync_fs,
@@ -475,7 +458,6 @@ static const struct super_operations nilfs_sops = {
475 /* .unlockfs */ 458 /* .unlockfs */
476 .statfs = nilfs_statfs, 459 .statfs = nilfs_statfs,
477 .remount_fs = nilfs_remount, 460 .remount_fs = nilfs_remount,
478 .clear_inode = nilfs_clear_inode,
479 /* .umount_begin */ 461 /* .umount_begin */
480 .show_options = nilfs_show_options 462 .show_options = nilfs_show_options
481}; 463};