Commit b4272d4c810532e1a4dea111433a0af56d3bd2b7
1 parent
a4ffdde6e5
Exists in
master
and in
4 other branches
unify fs/inode.c callers of clear_inode()
For now, just a straightforward merge Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 17 additions and 19 deletions Side-by-side Diff
fs/inode.c
... | ... | @@ -321,6 +321,19 @@ |
321 | 321 | } |
322 | 322 | EXPORT_SYMBOL(clear_inode); |
323 | 323 | |
324 | +static void evict(struct inode *inode, int delete) | |
325 | +{ | |
326 | + const struct super_operations *op = inode->i_sb->s_op; | |
327 | + | |
328 | + if (delete && op->delete_inode) { | |
329 | + op->delete_inode(inode); | |
330 | + } else { | |
331 | + if (inode->i_data.nrpages) | |
332 | + truncate_inode_pages(&inode->i_data, 0); | |
333 | + clear_inode(inode); | |
334 | + } | |
335 | +} | |
336 | + | |
324 | 337 | /* |
325 | 338 | * dispose_list - dispose of the contents of a local list |
326 | 339 | * @head: the head of the list to free |
... | ... | @@ -338,9 +351,7 @@ |
338 | 351 | inode = list_first_entry(head, struct inode, i_list); |
339 | 352 | list_del(&inode->i_list); |
340 | 353 | |
341 | - if (inode->i_data.nrpages) | |
342 | - truncate_inode_pages(&inode->i_data, 0); | |
343 | - clear_inode(inode); | |
354 | + evict(inode, 0); | |
344 | 355 | |
345 | 356 | spin_lock(&inode_lock); |
346 | 357 | hlist_del_init(&inode->i_hash); |
... | ... | @@ -1194,8 +1205,6 @@ |
1194 | 1205 | */ |
1195 | 1206 | void generic_delete_inode(struct inode *inode) |
1196 | 1207 | { |
1197 | - const struct super_operations *op = inode->i_sb->s_op; | |
1198 | - | |
1199 | 1208 | list_del_init(&inode->i_list); |
1200 | 1209 | list_del_init(&inode->i_sb_list); |
1201 | 1210 | WARN_ON(inode->i_state & I_NEW); |
... | ... | @@ -1203,17 +1212,8 @@ |
1203 | 1212 | inodes_stat.nr_inodes--; |
1204 | 1213 | spin_unlock(&inode_lock); |
1205 | 1214 | |
1206 | - if (op->delete_inode) { | |
1207 | - void (*delete)(struct inode *) = op->delete_inode; | |
1208 | - /* Filesystems implementing their own | |
1209 | - * s_op->delete_inode are required to call | |
1210 | - * truncate_inode_pages and clear_inode() | |
1211 | - * internally */ | |
1212 | - delete(inode); | |
1213 | - } else { | |
1214 | - truncate_inode_pages(&inode->i_data, 0); | |
1215 | - clear_inode(inode); | |
1216 | - } | |
1215 | + evict(inode, 1); | |
1216 | + | |
1217 | 1217 | spin_lock(&inode_lock); |
1218 | 1218 | hlist_del_init(&inode->i_hash); |
1219 | 1219 | spin_unlock(&inode_lock); |
... | ... | @@ -1268,9 +1268,7 @@ |
1268 | 1268 | { |
1269 | 1269 | if (!generic_detach_inode(inode)) |
1270 | 1270 | return; |
1271 | - if (inode->i_data.nrpages) | |
1272 | - truncate_inode_pages(&inode->i_data, 0); | |
1273 | - clear_inode(inode); | |
1271 | + evict(inode, 0); | |
1274 | 1272 | wake_up_inode(inode); |
1275 | 1273 | destroy_inode(inode); |
1276 | 1274 | } |