aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-09-18 16:05:44 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-09-24 07:47:25 -0400
commit22fe404218156328a27e66349b1175cd0baa4990 (patch)
treef03f8eb0b346a6950815212a5fa86c6b7e65bd16 /fs/inode.c
parentaf0d9ae811d11de8a01d6bc922c5e062be01bd7f (diff)
vfs: split generic_forget_inode() so that hugetlbfs does not have to copy it
Hugetlbfs needs to do special things instead of truncate_inode_pages(). Currently, it copied generic_forget_inode() except for truncate_inode_pages() call which is asking for trouble (the code there isn't trivial). So create a separate function generic_detach_inode() which does all the list magic done in generic_forget_inode() and call it from hugetlbfs_forget_inode(). Signed-off-by: Jan Kara <jack@suse.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 07d775ea6161..fa506d539653 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1241,7 +1241,16 @@ void generic_delete_inode(struct inode *inode)
1241} 1241}
1242EXPORT_SYMBOL(generic_delete_inode); 1242EXPORT_SYMBOL(generic_delete_inode);
1243 1243
1244static void generic_forget_inode(struct inode *inode) 1244/**
1245 * generic_detach_inode - remove inode from inode lists
1246 * @inode: inode to remove
1247 *
1248 * Remove inode from inode lists, write it if it's dirty. This is just an
1249 * internal VFS helper exported for hugetlbfs. Do not use!
1250 *
1251 * Returns 1 if inode should be completely destroyed.
1252 */
1253int generic_detach_inode(struct inode *inode)
1245{ 1254{
1246 struct super_block *sb = inode->i_sb; 1255 struct super_block *sb = inode->i_sb;
1247 1256
@@ -1251,7 +1260,7 @@ static void generic_forget_inode(struct inode *inode)
1251 inodes_stat.nr_unused++; 1260 inodes_stat.nr_unused++;
1252 if (sb->s_flags & MS_ACTIVE) { 1261 if (sb->s_flags & MS_ACTIVE) {
1253 spin_unlock(&inode_lock); 1262 spin_unlock(&inode_lock);
1254 return; 1263 return 0;
1255 } 1264 }
1256 WARN_ON(inode->i_state & I_NEW); 1265 WARN_ON(inode->i_state & I_NEW);
1257 inode->i_state |= I_WILL_FREE; 1266 inode->i_state |= I_WILL_FREE;
@@ -1269,6 +1278,14 @@ static void generic_forget_inode(struct inode *inode)
1269 inode->i_state |= I_FREEING; 1278 inode->i_state |= I_FREEING;
1270 inodes_stat.nr_inodes--; 1279 inodes_stat.nr_inodes--;
1271 spin_unlock(&inode_lock); 1280 spin_unlock(&inode_lock);
1281 return 1;
1282}
1283EXPORT_SYMBOL_GPL(generic_detach_inode);
1284
1285static void generic_forget_inode(struct inode *inode)
1286{
1287 if (!generic_detach_inode(inode))
1288 return;
1272 if (inode->i_data.nrpages) 1289 if (inode->i_data.nrpages)
1273 truncate_inode_pages(&inode->i_data, 0); 1290 truncate_inode_pages(&inode->i_data, 0);
1274 clear_inode(inode); 1291 clear_inode(inode);