aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/fs/inode.c b/fs/inode.c
index a48fa5355fb4..d0c72ff6b30e 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -361,9 +361,11 @@ EXPORT_SYMBOL_GPL(inode_sb_list_add);
361 361
362static inline void inode_sb_list_del(struct inode *inode) 362static inline void inode_sb_list_del(struct inode *inode)
363{ 363{
364 spin_lock(&inode_sb_list_lock); 364 if (!list_empty(&inode->i_sb_list)) {
365 list_del_init(&inode->i_sb_list); 365 spin_lock(&inode_sb_list_lock);
366 spin_unlock(&inode_sb_list_lock); 366 list_del_init(&inode->i_sb_list);
367 spin_unlock(&inode_sb_list_lock);
368 }
367} 369}
368 370
369static unsigned long hash(struct super_block *sb, unsigned long hashval) 371static unsigned long hash(struct super_block *sb, unsigned long hashval)
@@ -796,6 +798,29 @@ unsigned int get_next_ino(void)
796EXPORT_SYMBOL(get_next_ino); 798EXPORT_SYMBOL(get_next_ino);
797 799
798/** 800/**
801 * new_inode_pseudo - obtain an inode
802 * @sb: superblock
803 *
804 * Allocates a new inode for given superblock.
805 * Inode wont be chained in superblock s_inodes list
806 * This means :
807 * - fs can't be unmount
808 * - quotas, fsnotify, writeback can't work
809 */
810struct inode *new_inode_pseudo(struct super_block *sb)
811{
812 struct inode *inode = alloc_inode(sb);
813
814 if (inode) {
815 spin_lock(&inode->i_lock);
816 inode->i_state = 0;
817 spin_unlock(&inode->i_lock);
818 INIT_LIST_HEAD(&inode->i_sb_list);
819 }
820 return inode;
821}
822
823/**
799 * new_inode - obtain an inode 824 * new_inode - obtain an inode
800 * @sb: superblock 825 * @sb: superblock
801 * 826 *
@@ -813,13 +838,9 @@ struct inode *new_inode(struct super_block *sb)
813 838
814 spin_lock_prefetch(&inode_sb_list_lock); 839 spin_lock_prefetch(&inode_sb_list_lock);
815 840
816 inode = alloc_inode(sb); 841 inode = new_inode_pseudo(sb);
817 if (inode) { 842 if (inode)
818 spin_lock(&inode->i_lock);
819 inode->i_state = 0;
820 spin_unlock(&inode->i_lock);
821 inode_sb_list_add(inode); 843 inode_sb_list_add(inode);
822 }
823 return inode; 844 return inode;
824} 845}
825EXPORT_SYMBOL(new_inode); 846EXPORT_SYMBOL(new_inode);