Skip to content

Commit e85b565

Browse files
Mark FashehLinus Torvalds
authored andcommitted
[PATCH] move truncate_inode_pages() into ->delete_inode()
Allow file systems supporting ->delete_inode() to call truncate_inode_pages() on their own. OCFS2 wants this so it can query the cluster before making a final decision on whether to wipe an inode from disk or not. In some corner cases an inode marked on the local node via voting may not actually get orphaned. A good example is node death before the transaction moving the inode to the orphan dir commits to the journal. Without this patch, the truncate_inode_pages() call in generic_delete_inode() would discard valid data for such inodes. During earlier discussion in the 2.6.13 merge plan thread, Christoph Hellwig indicated that other file systems might also find this useful. IMHO, the best solution would be to just allow ->drop_inode() to do the cluster query but it seems that would require a substantial reworking of that section of the code. Assuming it is safe to call write_inode_now() in ocfs2_delete_inode() for those inodes which won't actually get wiped, this solution should get us by for now. Trivial testing of this patch (and a related OCFS2 update) has shown this to avoid the corruption I'm seeing. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 7f6fd5d commit e85b565

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎fs/inode.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,19 +1034,21 @@ void generic_delete_inode(struct inode *inode)
10341034
inodes_stat.nr_inodes--;
10351035
spin_unlock(&inode_lock);
10361036

1037-
if (inode->i_data.nrpages)
1038-
truncate_inode_pages(&inode->i_data, 0);
1039-
10401037
security_inode_delete(inode);
10411038

10421039
if (op->delete_inode) {
10431040
void (*delete)(struct inode *) = op->delete_inode;
10441041
if (!is_bad_inode(inode))
10451042
DQUOT_INIT(inode);
1046-
/* s_op->delete_inode internally recalls clear_inode() */
1043+
/* Filesystems implementing their own
1044+
* s_op->delete_inode are required to call
1045+
* truncate_inode_pages and clear_inode()
1046+
* internally */
10471047
delete(inode);
1048-
} else
1048+
} else {
1049+
truncate_inode_pages(&inode->i_data, 0);
10491050
clear_inode(inode);
1051+
}
10501052
spin_lock(&inode_lock);
10511053
hlist_del_init(&inode->i_hash);
10521054
spin_unlock(&inode_lock);

0 commit comments

Comments
 (0)