Commit 72edc4d0873ba5165c0759264298bf5f55351c7a

Authored by Al Viro
1 parent 3937871d91

merge ext2 delete_inode and clear_inode, switch to ->evict_inode()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 4 changed files with 36 additions and 37 deletions Side-by-side Diff

... ... @@ -119,7 +119,7 @@
119 119 /* inode.c */
120 120 extern struct inode *ext2_iget (struct super_block *, unsigned long);
121 121 extern int ext2_write_inode (struct inode *, struct writeback_control *);
122   -extern void ext2_delete_inode (struct inode *);
  122 +extern void ext2_evict_inode(struct inode *);
123 123 extern int ext2_sync_inode (struct inode *);
124 124 extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
125 125 extern int ext2_setattr (struct dentry *, struct iattr *);
... ... @@ -118,18 +118,13 @@
118 118 * Note: we must free any quota before locking the superblock,
119 119 * as writing the quota to disk may need the lock as well.
120 120 */
121   - if (!is_bad_inode(inode)) {
122   - /* Quota is already initialized in iput() */
123   - ext2_xattr_delete_inode(inode);
124   - dquot_free_inode(inode);
125   - dquot_drop(inode);
126   - }
  121 + /* Quota is already initialized in iput() */
  122 + ext2_xattr_delete_inode(inode);
  123 + dquot_free_inode(inode);
  124 + dquot_drop(inode);
127 125  
128 126 es = EXT2_SB(sb)->s_es;
129 127 is_directory = S_ISDIR(inode->i_mode);
130   -
131   - /* Do this BEFORE marking the inode not in use or returning an error */
132   - clear_inode (inode);
133 128  
134 129 if (ino < EXT2_FIRST_INO(sb) ||
135 130 ino > le32_to_cpu(es->s_inodes_count)) {
... ... @@ -69,26 +69,42 @@
69 69 /*
70 70 * Called at the last iput() if i_nlink is zero.
71 71 */
72   -void ext2_delete_inode (struct inode * inode)
  72 +void ext2_evict_inode(struct inode * inode)
73 73 {
74   - if (!is_bad_inode(inode))
  74 + struct ext2_block_alloc_info *rsv;
  75 + int want_delete = 0;
  76 +
  77 + if (!inode->i_nlink && !is_bad_inode(inode)) {
  78 + want_delete = 1;
75 79 dquot_initialize(inode);
  80 + } else {
  81 + dquot_drop(inode);
  82 + }
  83 +
76 84 truncate_inode_pages(&inode->i_data, 0);
77 85  
78   - if (is_bad_inode(inode))
79   - goto no_delete;
80   - EXT2_I(inode)->i_dtime = get_seconds();
81   - mark_inode_dirty(inode);
82   - __ext2_write_inode(inode, inode_needs_sync(inode));
  86 + if (want_delete) {
  87 + /* set dtime */
  88 + EXT2_I(inode)->i_dtime = get_seconds();
  89 + mark_inode_dirty(inode);
  90 + __ext2_write_inode(inode, inode_needs_sync(inode));
  91 + /* truncate to 0 */
  92 + inode->i_size = 0;
  93 + if (inode->i_blocks)
  94 + ext2_truncate_blocks(inode, 0);
  95 + }
83 96  
84   - inode->i_size = 0;
85   - if (inode->i_blocks)
86   - ext2_truncate_blocks(inode, 0);
87   - ext2_free_inode (inode);
  97 + invalidate_inode_buffers(inode);
  98 + end_writeback(inode);
88 99  
89   - return;
90   -no_delete:
91   - clear_inode(inode); /* We must guarantee clearing of inode... */
  100 + ext2_discard_reservation(inode);
  101 + rsv = EXT2_I(inode)->i_block_alloc_info;
  102 + EXT2_I(inode)->i_block_alloc_info = NULL;
  103 + if (unlikely(rsv))
  104 + kfree(rsv);
  105 +
  106 + if (want_delete)
  107 + ext2_free_inode(inode);
92 108 }
93 109  
94 110 typedef struct {
... ... @@ -195,17 +195,6 @@
195 195 kmem_cache_destroy(ext2_inode_cachep);
196 196 }
197 197  
198   -static void ext2_clear_inode(struct inode *inode)
199   -{
200   - struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
201   -
202   - dquot_drop(inode);
203   - ext2_discard_reservation(inode);
204   - EXT2_I(inode)->i_block_alloc_info = NULL;
205   - if (unlikely(rsv))
206   - kfree(rsv);
207   -}
208   -
209 198 static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
210 199 {
211 200 struct super_block *sb = vfs->mnt_sb;
212 201  
... ... @@ -299,13 +288,12 @@
299 288 .alloc_inode = ext2_alloc_inode,
300 289 .destroy_inode = ext2_destroy_inode,
301 290 .write_inode = ext2_write_inode,
302   - .delete_inode = ext2_delete_inode,
  291 + .evict_inode = ext2_evict_inode,
303 292 .put_super = ext2_put_super,
304 293 .write_super = ext2_write_super,
305 294 .sync_fs = ext2_sync_fs,
306 295 .statfs = ext2_statfs,
307 296 .remount_fs = ext2_remount,
308   - .clear_inode = ext2_clear_inode,
309 297 .show_options = ext2_show_options,
310 298 #ifdef CONFIG_QUOTA
311 299 .quota_read = ext2_quota_read,