Lines Matching refs:inode
103 static void wake_up_inode(struct inode *inode) in wake_up_inode() argument
109 wake_up_bit(&inode->i_state, __I_LOCK); in wake_up_inode()
120 struct inode *inode_init_always(struct super_block *sb, struct inode *inode) in inode_init_always() argument
126 struct address_space * const mapping = &inode->i_data; in inode_init_always()
128 inode->i_sb = sb; in inode_init_always()
129 inode->i_blkbits = sb->s_blocksize_bits; in inode_init_always()
130 inode->i_flags = 0; in inode_init_always()
131 atomic_set(&inode->i_count, 1); in inode_init_always()
132 inode->i_op = &empty_iops; in inode_init_always()
133 inode->i_fop = &empty_fops; in inode_init_always()
134 inode->i_nlink = 1; in inode_init_always()
135 inode->i_uid = 0; in inode_init_always()
136 inode->i_gid = 0; in inode_init_always()
137 atomic_set(&inode->i_writecount, 0); in inode_init_always()
138 inode->i_size = 0; in inode_init_always()
139 inode->i_blocks = 0; in inode_init_always()
140 inode->i_bytes = 0; in inode_init_always()
141 inode->i_generation = 0; in inode_init_always()
143 memset(&inode->i_dquot, 0, sizeof(inode->i_dquot)); in inode_init_always()
145 inode->i_pipe = NULL; in inode_init_always()
146 inode->i_bdev = NULL; in inode_init_always()
147 inode->i_cdev = NULL; in inode_init_always()
148 inode->i_rdev = 0; in inode_init_always()
149 inode->dirtied_when = 0; in inode_init_always()
150 if (security_inode_alloc(inode)) { in inode_init_always()
151 if (inode->i_sb->s_op->destroy_inode) in inode_init_always()
152 inode->i_sb->s_op->destroy_inode(inode); in inode_init_always()
154 kmem_cache_free(inode_cachep, (inode)); in inode_init_always()
158 spin_lock_init(&inode->i_lock); in inode_init_always()
159 lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); in inode_init_always()
161 mutex_init(&inode->i_mutex); in inode_init_always()
162 lockdep_set_class(&inode->i_mutex, &sb->s_type->i_mutex_key); in inode_init_always()
164 init_rwsem(&inode->i_alloc_sem); in inode_init_always()
165 lockdep_set_class(&inode->i_alloc_sem, &sb->s_type->i_alloc_sem_key); in inode_init_always()
168 mapping->host = inode; in inode_init_always()
188 inode->i_private = NULL; in inode_init_always()
189 inode->i_mapping = mapping; in inode_init_always()
191 return inode; in inode_init_always()
195 static struct inode *alloc_inode(struct super_block *sb) in alloc_inode()
197 struct inode *inode; in alloc_inode() local
200 inode = sb->s_op->alloc_inode(sb); in alloc_inode()
202 inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL); in alloc_inode()
204 if (inode) in alloc_inode()
205 return inode_init_always(sb, inode); in alloc_inode()
209 void destroy_inode(struct inode *inode) in destroy_inode() argument
211 BUG_ON(inode_has_buffers(inode)); in destroy_inode()
212 security_inode_free(inode); in destroy_inode()
213 if (inode->i_sb->s_op->destroy_inode) in destroy_inode()
214 inode->i_sb->s_op->destroy_inode(inode); in destroy_inode()
216 kmem_cache_free(inode_cachep, (inode)); in destroy_inode()
226 void inode_init_once(struct inode *inode) in inode_init_once() argument
228 memset(inode, 0, sizeof(*inode)); in inode_init_once()
229 INIT_HLIST_NODE(&inode->i_hash); in inode_init_once()
230 INIT_LIST_HEAD(&inode->i_dentry); in inode_init_once()
231 INIT_LIST_HEAD(&inode->i_devices); in inode_init_once()
232 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); in inode_init_once()
233 spin_lock_init(&inode->i_data.tree_lock); in inode_init_once()
234 spin_lock_init(&inode->i_data.i_mmap_lock); in inode_init_once()
235 INIT_LIST_HEAD(&inode->i_data.private_list); in inode_init_once()
236 spin_lock_init(&inode->i_data.private_lock); in inode_init_once()
237 INIT_RAW_PRIO_TREE_ROOT(&inode->i_data.i_mmap); in inode_init_once()
238 INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear); in inode_init_once()
239 i_size_ordered_init(inode); in inode_init_once()
241 INIT_LIST_HEAD(&inode->inotify_watches); in inode_init_once()
242 mutex_init(&inode->inotify_mutex); in inode_init_once()
250 struct inode * inode = (struct inode *) foo; in init_once() local
252 inode_init_once(inode); in init_once()
258 void __iget(struct inode * inode) in __iget() argument
260 if (atomic_read(&inode->i_count)) { in __iget()
261 atomic_inc(&inode->i_count); in __iget()
264 atomic_inc(&inode->i_count); in __iget()
265 if (!(inode->i_state & (I_DIRTY|I_SYNC))) in __iget()
266 list_move(&inode->i_list, &inode_in_use); in __iget()
278 void clear_inode(struct inode *inode) in clear_inode() argument
281 invalidate_inode_buffers(inode); in clear_inode()
283 BUG_ON(inode->i_data.nrpages); in clear_inode()
284 BUG_ON(!(inode->i_state & I_FREEING)); in clear_inode()
285 BUG_ON(inode->i_state & I_CLEAR); in clear_inode()
286 inode_sync_wait(inode); in clear_inode()
287 DQUOT_DROP(inode); in clear_inode()
288 if (inode->i_sb->s_op->clear_inode) in clear_inode()
289 inode->i_sb->s_op->clear_inode(inode); in clear_inode()
290 if (S_ISBLK(inode->i_mode) && inode->i_bdev) in clear_inode()
291 bd_forget(inode); in clear_inode()
292 if (S_ISCHR(inode->i_mode) && inode->i_cdev) in clear_inode()
293 cd_forget(inode); in clear_inode()
294 inode->i_state = I_CLEAR; in clear_inode()
311 struct inode *inode; in dispose_list() local
313 inode = list_first_entry(head, struct inode, i_list); in dispose_list()
314 list_del(&inode->i_list); in dispose_list()
316 if (inode->i_data.nrpages) in dispose_list()
317 truncate_inode_pages(&inode->i_data, 0); in dispose_list()
318 clear_inode(inode); in dispose_list()
321 hlist_del_init(&inode->i_hash); in dispose_list()
322 list_del_init(&inode->i_sb_list); in dispose_list()
325 wake_up_inode(inode); in dispose_list()
326 destroy_inode(inode); in dispose_list()
345 struct inode * inode; in invalidate_list() local
358 inode = list_entry(tmp, struct inode, i_sb_list); in invalidate_list()
359 invalidate_inode_buffers(inode); in invalidate_list()
360 if (!atomic_read(&inode->i_count)) { in invalidate_list()
361 list_move(&inode->i_list, dispose); in invalidate_list()
362 WARN_ON(inode->i_state & I_NEW); in invalidate_list()
363 inode->i_state |= I_FREEING; in invalidate_list()
401 static int can_unuse(struct inode *inode) in can_unuse() argument
403 if (inode->i_state) in can_unuse()
405 if (inode_has_buffers(inode)) in can_unuse()
407 if (atomic_read(&inode->i_count)) in can_unuse()
409 if (inode->i_data.nrpages) in can_unuse()
437 struct inode *inode; in prune_icache() local
442 inode = list_entry(inode_unused.prev, struct inode, i_list); in prune_icache()
444 if (inode->i_state || atomic_read(&inode->i_count)) { in prune_icache()
445 list_move(&inode->i_list, &inode_unused); in prune_icache()
448 if (inode_has_buffers(inode) || inode->i_data.nrpages) { in prune_icache()
449 __iget(inode); in prune_icache()
451 if (remove_inode_buffers(inode)) in prune_icache()
452 reap += invalidate_mapping_pages(&inode->i_data, in prune_icache()
454 iput(inode); in prune_icache()
457 if (inode != list_entry(inode_unused.next, in prune_icache()
458 struct inode, i_list)) in prune_icache()
460 if (!can_unuse(inode)) in prune_icache()
463 list_move(&inode->i_list, &freeable); in prune_icache()
464 WARN_ON(inode->i_state & I_NEW); in prune_icache()
465 inode->i_state |= I_FREEING; in prune_icache()
508 static void __wait_on_freeing_inode(struct inode *inode);
515 static struct inode * find_inode(struct super_block * sb, struct hlist_head *head, int (*test)(stru… in find_inode() argument
518 struct inode * inode = NULL; in find_inode() local
521 hlist_for_each_entry(inode, node, head, i_hash) { in find_inode()
522 if (inode->i_sb != sb) in find_inode()
524 if (!test(inode, data)) in find_inode()
526 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { in find_inode()
527 __wait_on_freeing_inode(inode); in find_inode()
532 return node ? inode : NULL; in find_inode()
539 static struct inode * find_inode_fast(struct super_block * sb, struct hlist_head *head, unsigned lo… in find_inode_fast()
542 struct inode * inode = NULL; in find_inode_fast() local
545 hlist_for_each_entry(inode, node, head, i_hash) { in find_inode_fast()
546 if (inode->i_ino != ino) in find_inode_fast()
548 if (inode->i_sb != sb) in find_inode_fast()
550 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { in find_inode_fast()
551 __wait_on_freeing_inode(inode); in find_inode_fast()
556 return node ? inode : NULL; in find_inode_fast()
571 struct inode *inode) in __inode_add_to_lists() argument
574 list_add(&inode->i_list, &inode_in_use); in __inode_add_to_lists()
575 list_add(&inode->i_sb_list, &sb->s_inodes); in __inode_add_to_lists()
577 hlist_add_head(&inode->i_hash, head); in __inode_add_to_lists()
592 void inode_add_to_lists(struct super_block *sb, struct inode *inode) in inode_add_to_lists() argument
594 struct hlist_head *head = inode_hashtable + hash(sb, inode->i_ino); in inode_add_to_lists()
597 __inode_add_to_lists(sb, head, inode); in inode_add_to_lists()
614 struct inode *new_inode(struct super_block *sb) in new_inode()
622 struct inode * inode; in new_inode() local
626 inode = alloc_inode(sb); in new_inode()
627 if (inode) { in new_inode()
629 __inode_add_to_lists(sb, NULL, inode); in new_inode()
630 inode->i_ino = ++last_ino; in new_inode()
631 inode->i_state = 0; in new_inode()
634 return inode; in new_inode()
639 void unlock_new_inode(struct inode *inode) in unlock_new_inode() argument
642 if (inode->i_mode & S_IFDIR) { in unlock_new_inode()
643 struct file_system_type *type = inode->i_sb->s_type; in unlock_new_inode()
648 mutex_destroy(&inode->i_mutex); in unlock_new_inode()
649 mutex_init(&inode->i_mutex); in unlock_new_inode()
650 lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key); in unlock_new_inode()
661 WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW)); in unlock_new_inode()
662 inode->i_state &= ~(I_LOCK|I_NEW); in unlock_new_inode()
663 wake_up_inode(inode); in unlock_new_inode()
674 …tic struct inode * get_new_inode(struct super_block *sb, struct hlist_head *head, int (*test)(stru… in get_new_inode() argument
676 struct inode * inode; in get_new_inode() local
678 inode = alloc_inode(sb); in get_new_inode()
679 if (inode) { in get_new_inode()
680 struct inode * old; in get_new_inode()
686 if (set(inode, data)) in get_new_inode()
689 __inode_add_to_lists(sb, head, inode); in get_new_inode()
690 inode->i_state = I_LOCK|I_NEW; in get_new_inode()
696 return inode; in get_new_inode()
706 destroy_inode(inode); in get_new_inode()
707 inode = old; in get_new_inode()
708 wait_on_inode(inode); in get_new_inode()
710 return inode; in get_new_inode()
714 destroy_inode(inode); in get_new_inode()
722 static struct inode * get_new_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned … in get_new_inode_fast()
724 struct inode * inode; in get_new_inode_fast() local
726 inode = alloc_inode(sb); in get_new_inode_fast()
727 if (inode) { in get_new_inode_fast()
728 struct inode * old; in get_new_inode_fast()
734 inode->i_ino = ino; in get_new_inode_fast()
735 __inode_add_to_lists(sb, head, inode); in get_new_inode_fast()
736 inode->i_state = I_LOCK|I_NEW; in get_new_inode_fast()
742 return inode; in get_new_inode_fast()
752 destroy_inode(inode); in get_new_inode_fast()
753 inode = old; in get_new_inode_fast()
754 wait_on_inode(inode); in get_new_inode_fast()
756 return inode; in get_new_inode_fast()
781 struct inode *inode; in iunique() local
791 inode = find_inode_fast(sb, head, res); in iunique()
792 } while (inode != NULL); in iunique()
799 struct inode *igrab(struct inode *inode) in igrab() argument
802 if (!(inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))) in igrab()
803 __iget(inode); in igrab()
810 inode = NULL; in igrab()
812 return inode; in igrab()
836 static struct inode *ifind(struct super_block *sb, in ifind()
837 struct hlist_head *head, int (*test)(struct inode *, void *), in ifind() argument
840 struct inode *inode; in ifind() local
843 inode = find_inode(sb, head, test, data); in ifind()
844 if (inode) { in ifind()
845 __iget(inode); in ifind()
848 wait_on_inode(inode); in ifind()
849 return inode; in ifind()
870 static struct inode *ifind_fast(struct super_block *sb, in ifind_fast()
873 struct inode *inode; in ifind_fast() local
876 inode = find_inode_fast(sb, head, ino); in ifind_fast()
877 if (inode) { in ifind_fast()
878 __iget(inode); in ifind_fast()
880 wait_on_inode(inode); in ifind_fast()
881 return inode; in ifind_fast()
908 struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, in ilookup5_nowait()
909 int (*test)(struct inode *, void *), void *data) in ilookup5_nowait() argument
937 struct inode *ilookup5(struct super_block *sb, unsigned long hashval, in ilookup5()
938 int (*test)(struct inode *, void *), void *data) in ilookup5() argument
961 struct inode *ilookup(struct super_block *sb, unsigned long ino) in ilookup()
990 struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, in iget5_locked()
991 int (*test)(struct inode *, void *), in iget5_locked() argument
992 int (*set)(struct inode *, void *), void *data) in iget5_locked() argument
995 struct inode *inode; in iget5_locked() local
997 inode = ifind(sb, head, test, data, 1); in iget5_locked()
998 if (inode) in iget5_locked()
999 return inode; in iget5_locked()
1024 struct inode *iget_locked(struct super_block *sb, unsigned long ino) in iget_locked()
1027 struct inode *inode; in iget_locked() local
1029 inode = ifind_fast(sb, head, ino); in iget_locked()
1030 if (inode) in iget_locked()
1031 return inode; in iget_locked()
1041 int insert_inode_locked(struct inode *inode) in insert_inode_locked() argument
1043 struct super_block *sb = inode->i_sb; in insert_inode_locked()
1044 ino_t ino = inode->i_ino; in insert_inode_locked()
1046 struct inode *old; in insert_inode_locked()
1048 inode->i_state |= I_LOCK|I_NEW; in insert_inode_locked()
1053 hlist_add_head(&inode->i_hash, head); in insert_inode_locked()
1070 int insert_inode_locked4(struct inode *inode, unsigned long hashval, in insert_inode_locked4() argument
1071 int (*test)(struct inode *, void *), void *data) in insert_inode_locked4() argument
1073 struct super_block *sb = inode->i_sb; in insert_inode_locked4()
1075 struct inode *old; in insert_inode_locked4()
1077 inode->i_state |= I_LOCK|I_NEW; in insert_inode_locked4()
1083 hlist_add_head(&inode->i_hash, head); in insert_inode_locked4()
1108 void __insert_inode_hash(struct inode *inode, unsigned long hashval) in __insert_inode_hash() argument
1110 struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); in __insert_inode_hash()
1112 hlist_add_head(&inode->i_hash, head); in __insert_inode_hash()
1124 void remove_inode_hash(struct inode *inode) in remove_inode_hash() argument
1127 hlist_del_init(&inode->i_hash); in remove_inode_hash()
1145 void generic_delete_inode(struct inode *inode) in generic_delete_inode() argument
1147 const struct super_operations *op = inode->i_sb->s_op; in generic_delete_inode()
1149 list_del_init(&inode->i_list); in generic_delete_inode()
1150 list_del_init(&inode->i_sb_list); in generic_delete_inode()
1151 WARN_ON(inode->i_state & I_NEW); in generic_delete_inode()
1152 inode->i_state |= I_FREEING; in generic_delete_inode()
1156 security_inode_delete(inode); in generic_delete_inode()
1159 void (*delete)(struct inode *) = op->delete_inode; in generic_delete_inode()
1160 if (!is_bad_inode(inode)) in generic_delete_inode()
1161 DQUOT_INIT(inode); in generic_delete_inode()
1166 delete(inode); in generic_delete_inode()
1168 truncate_inode_pages(&inode->i_data, 0); in generic_delete_inode()
1169 clear_inode(inode); in generic_delete_inode()
1172 hlist_del_init(&inode->i_hash); in generic_delete_inode()
1174 wake_up_inode(inode); in generic_delete_inode()
1175 BUG_ON(inode->i_state != I_CLEAR); in generic_delete_inode()
1176 destroy_inode(inode); in generic_delete_inode()
1181 static void generic_forget_inode(struct inode *inode) in generic_forget_inode() argument
1183 struct super_block *sb = inode->i_sb; in generic_forget_inode()
1185 if (!hlist_unhashed(&inode->i_hash)) { in generic_forget_inode()
1186 if (!(inode->i_state & (I_DIRTY|I_SYNC))) in generic_forget_inode()
1187 list_move(&inode->i_list, &inode_unused); in generic_forget_inode()
1193 WARN_ON(inode->i_state & I_NEW); in generic_forget_inode()
1194 inode->i_state |= I_WILL_FREE; in generic_forget_inode()
1196 write_inode_now(inode, 1); in generic_forget_inode()
1198 WARN_ON(inode->i_state & I_NEW); in generic_forget_inode()
1199 inode->i_state &= ~I_WILL_FREE; in generic_forget_inode()
1201 hlist_del_init(&inode->i_hash); in generic_forget_inode()
1203 list_del_init(&inode->i_list); in generic_forget_inode()
1204 list_del_init(&inode->i_sb_list); in generic_forget_inode()
1205 WARN_ON(inode->i_state & I_NEW); in generic_forget_inode()
1206 inode->i_state |= I_FREEING; in generic_forget_inode()
1209 if (inode->i_data.nrpages) in generic_forget_inode()
1210 truncate_inode_pages(&inode->i_data, 0); in generic_forget_inode()
1211 clear_inode(inode); in generic_forget_inode()
1212 wake_up_inode(inode); in generic_forget_inode()
1213 destroy_inode(inode); in generic_forget_inode()
1221 void generic_drop_inode(struct inode *inode) in generic_drop_inode() argument
1223 if (!inode->i_nlink) in generic_drop_inode()
1224 generic_delete_inode(inode); in generic_drop_inode()
1226 generic_forget_inode(inode); in generic_drop_inode()
1242 static inline void iput_final(struct inode *inode) in iput_final() argument
1244 const struct super_operations *op = inode->i_sb->s_op; in iput_final()
1245 void (*drop)(struct inode *) = generic_drop_inode; in iput_final()
1249 drop(inode); in iput_final()
1261 void iput(struct inode *inode) in iput() argument
1263 if (inode) { in iput()
1264 BUG_ON(inode->i_state == I_CLEAR); in iput()
1266 if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) in iput()
1267 iput_final(inode); in iput()
1284 sector_t bmap(struct inode * inode, sector_t block) in bmap() argument
1287 if (inode->i_mapping->a_ops->bmap) in bmap()
1288 res = inode->i_mapping->a_ops->bmap(inode->i_mapping, block); in bmap()
1304 struct inode *inode = dentry->d_inode; in touch_atime() local
1309 if (inode->i_flags & S_NOATIME) in touch_atime()
1311 if (IS_NOATIME(inode)) in touch_atime()
1313 if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode)) in touch_atime()
1318 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) in touch_atime()
1325 if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && in touch_atime()
1326 timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) in touch_atime()
1330 now = current_fs_time(inode->i_sb); in touch_atime()
1331 if (timespec_equal(&inode->i_atime, &now)) in touch_atime()
1334 inode->i_atime = now; in touch_atime()
1335 mark_inode_dirty_sync(inode); in touch_atime()
1355 struct inode *inode = file->f_path.dentry->d_inode; in file_update_time() local
1360 if (IS_NOCMTIME(inode)) in file_update_time()
1367 now = current_fs_time(inode->i_sb); in file_update_time()
1368 if (!timespec_equal(&inode->i_mtime, &now)) { in file_update_time()
1369 inode->i_mtime = now; in file_update_time()
1373 if (!timespec_equal(&inode->i_ctime, &now)) { in file_update_time()
1374 inode->i_ctime = now; in file_update_time()
1378 if (IS_I_VERSION(inode)) { in file_update_time()
1379 inode_inc_iversion(inode); in file_update_time()
1384 mark_inode_dirty_sync(inode); in file_update_time()
1390 int inode_needs_sync(struct inode *inode) in inode_needs_sync() argument
1392 if (IS_SYNC(inode)) in inode_needs_sync()
1394 if (S_ISDIR(inode->i_mode) && IS_DIRSYNC(inode)) in inode_needs_sync()
1420 static void __wait_on_freeing_inode(struct inode *inode) in __wait_on_freeing_inode() argument
1423 DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK); in __wait_on_freeing_inode()
1424 wq = bit_waitqueue(&inode->i_state, __I_LOCK); in __wait_on_freeing_inode()
1438 void inode_double_lock(struct inode *inode1, struct inode *inode2) in inode_double_lock()
1458 void inode_double_unlock(struct inode *inode1, struct inode *inode2) in inode_double_unlock()
1511 sizeof(struct inode), in inode_init()
1536 void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) in init_special_inode() argument
1538 inode->i_mode = mode; in init_special_inode()
1540 inode->i_fop = &def_chr_fops; in init_special_inode()
1541 inode->i_rdev = rdev; in init_special_inode()
1543 inode->i_fop = &def_blk_fops; in init_special_inode()
1544 inode->i_rdev = rdev; in init_special_inode()
1546 inode->i_fop = &def_fifo_fops; in init_special_inode()
1548 inode->i_fop = &bad_sock_fops; in init_special_inode()