Lines Matching refs:inode
120 static int no_open(struct inode *inode, struct file *file) in no_open() argument
133 int inode_init_always(struct super_block *sb, struct inode *inode) in inode_init_always() argument
137 struct address_space *const mapping = &inode->i_data; in inode_init_always()
139 inode->i_sb = sb; in inode_init_always()
140 inode->i_blkbits = sb->s_blocksize_bits; in inode_init_always()
141 inode->i_flags = 0; in inode_init_always()
142 atomic64_set(&inode->i_sequence, 0); in inode_init_always()
143 atomic_set(&inode->i_count, 1); in inode_init_always()
144 inode->i_op = &empty_iops; in inode_init_always()
145 inode->i_fop = &no_open_fops; in inode_init_always()
146 inode->__i_nlink = 1; in inode_init_always()
147 inode->i_opflags = 0; in inode_init_always()
149 inode->i_opflags |= IOP_XATTR; in inode_init_always()
150 i_uid_write(inode, 0); in inode_init_always()
151 i_gid_write(inode, 0); in inode_init_always()
152 atomic_set(&inode->i_writecount, 0); in inode_init_always()
153 inode->i_size = 0; in inode_init_always()
154 inode->i_write_hint = WRITE_LIFE_NOT_SET; in inode_init_always()
155 inode->i_blocks = 0; in inode_init_always()
156 inode->i_bytes = 0; in inode_init_always()
157 inode->i_generation = 0; in inode_init_always()
158 inode->i_pipe = NULL; in inode_init_always()
159 inode->i_bdev = NULL; in inode_init_always()
160 inode->i_cdev = NULL; in inode_init_always()
161 inode->i_link = NULL; in inode_init_always()
162 inode->i_dir_seq = 0; in inode_init_always()
163 inode->i_rdev = 0; in inode_init_always()
164 inode->dirtied_when = 0; in inode_init_always()
167 inode->i_wb_frn_winner = 0; in inode_init_always()
168 inode->i_wb_frn_avg_time = 0; in inode_init_always()
169 inode->i_wb_frn_history = 0; in inode_init_always()
172 spin_lock_init(&inode->i_lock); in inode_init_always()
173 lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); in inode_init_always()
175 init_rwsem(&inode->i_rwsem); in inode_init_always()
176 lockdep_set_class(&inode->i_rwsem, &sb->s_type->i_mutex_key); in inode_init_always()
178 atomic_set(&inode->i_dio_count, 0); in inode_init_always()
181 mapping->host = inode; in inode_init_always()
193 inode->i_private = NULL; in inode_init_always()
194 inode->i_mapping = mapping; in inode_init_always()
195 INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */ in inode_init_always()
197 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; in inode_init_always()
201 inode->i_fsnotify_mask = 0; in inode_init_always()
203 inode->i_flctx = NULL; in inode_init_always()
205 if (unlikely(security_inode_alloc(inode))) in inode_init_always()
213 void free_inode_nonrcu(struct inode *inode) in free_inode_nonrcu() argument
215 kmem_cache_free(inode_cachep, inode); in free_inode_nonrcu()
221 struct inode *inode = container_of(head, struct inode, i_rcu); in i_callback() local
222 if (inode->free_inode) in i_callback()
223 inode->free_inode(inode); in i_callback()
225 free_inode_nonrcu(inode); in i_callback()
228 static struct inode *alloc_inode(struct super_block *sb) in alloc_inode()
231 struct inode *inode; in alloc_inode() local
234 inode = ops->alloc_inode(sb); in alloc_inode()
236 inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL); in alloc_inode()
238 if (!inode) in alloc_inode()
241 if (unlikely(inode_init_always(sb, inode))) { in alloc_inode()
243 ops->destroy_inode(inode); in alloc_inode()
247 inode->free_inode = ops->free_inode; in alloc_inode()
248 i_callback(&inode->i_rcu); in alloc_inode()
252 return inode; in alloc_inode()
255 void __destroy_inode(struct inode *inode) in __destroy_inode() argument
257 BUG_ON(inode_has_buffers(inode)); in __destroy_inode()
258 inode_detach_wb(inode); in __destroy_inode()
259 security_inode_free(inode); in __destroy_inode()
260 fsnotify_inode_delete(inode); in __destroy_inode()
261 locks_free_lock_context(inode); in __destroy_inode()
262 xpm_delete_cache_node_hook(inode); in __destroy_inode()
263 if (!inode->i_nlink) { in __destroy_inode()
264 WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0); in __destroy_inode()
265 atomic_long_dec(&inode->i_sb->s_remove_count); in __destroy_inode()
269 if (inode->i_acl && !is_uncached_acl(inode->i_acl)) in __destroy_inode()
270 posix_acl_release(inode->i_acl); in __destroy_inode()
271 if (inode->i_default_acl && !is_uncached_acl(inode->i_default_acl)) in __destroy_inode()
272 posix_acl_release(inode->i_default_acl); in __destroy_inode()
278 static void destroy_inode(struct inode *inode) in destroy_inode() argument
280 const struct super_operations *ops = inode->i_sb->s_op; in destroy_inode()
282 BUG_ON(!list_empty(&inode->i_lru)); in destroy_inode()
283 __destroy_inode(inode); in destroy_inode()
285 ops->destroy_inode(inode); in destroy_inode()
289 inode->free_inode = ops->free_inode; in destroy_inode()
290 call_rcu(&inode->i_rcu, i_callback); in destroy_inode()
304 void drop_nlink(struct inode *inode) in drop_nlink() argument
306 WARN_ON(inode->i_nlink == 0); in drop_nlink()
307 inode->__i_nlink--; in drop_nlink()
308 if (!inode->i_nlink) in drop_nlink()
309 atomic_long_inc(&inode->i_sb->s_remove_count); in drop_nlink()
321 void clear_nlink(struct inode *inode) in clear_nlink() argument
323 if (inode->i_nlink) { in clear_nlink()
324 inode->__i_nlink = 0; in clear_nlink()
325 atomic_long_inc(&inode->i_sb->s_remove_count); in clear_nlink()
338 void set_nlink(struct inode *inode, unsigned int nlink) in set_nlink() argument
341 clear_nlink(inode); in set_nlink()
344 if (inode->i_nlink == 0) in set_nlink()
345 atomic_long_dec(&inode->i_sb->s_remove_count); in set_nlink()
347 inode->__i_nlink = nlink; in set_nlink()
360 void inc_nlink(struct inode *inode) in inc_nlink() argument
362 if (unlikely(inode->i_nlink == 0)) { in inc_nlink()
363 WARN_ON(!(inode->i_state & I_LINKABLE)); in inc_nlink()
364 atomic_long_dec(&inode->i_sb->s_remove_count); in inc_nlink()
367 inode->__i_nlink++; in inc_nlink()
392 void inode_init_once(struct inode *inode) in inode_init_once() argument
394 memset(inode, 0, sizeof(*inode)); in inode_init_once()
395 INIT_HLIST_NODE(&inode->i_hash); in inode_init_once()
396 INIT_LIST_HEAD(&inode->i_devices); in inode_init_once()
397 INIT_LIST_HEAD(&inode->i_io_list); in inode_init_once()
398 INIT_LIST_HEAD(&inode->i_wb_list); in inode_init_once()
399 INIT_LIST_HEAD(&inode->i_lru); in inode_init_once()
400 __address_space_init_once(&inode->i_data); in inode_init_once()
401 i_size_ordered_init(inode); in inode_init_once()
407 struct inode *inode = (struct inode *) foo; in init_once() local
409 inode_init_once(inode); in init_once()
415 void __iget(struct inode *inode) in __iget() argument
417 atomic_inc(&inode->i_count); in __iget()
423 void ihold(struct inode *inode) in ihold() argument
425 WARN_ON(atomic_inc_return(&inode->i_count) < 2); in ihold()
429 static void inode_lru_list_add(struct inode *inode) in inode_lru_list_add() argument
431 if (list_lru_add(&inode->i_sb->s_inode_lru, &inode->i_lru)) in inode_lru_list_add()
434 inode->i_state |= I_REFERENCED; in inode_lru_list_add()
442 void inode_add_lru(struct inode *inode) in inode_add_lru() argument
444 if (!(inode->i_state & (I_DIRTY_ALL | I_SYNC | in inode_add_lru()
446 !atomic_read(&inode->i_count) && inode->i_sb->s_flags & SB_ACTIVE) in inode_add_lru()
447 inode_lru_list_add(inode); in inode_add_lru()
451 static void inode_lru_list_del(struct inode *inode) in inode_lru_list_del() argument
454 if (list_lru_del(&inode->i_sb->s_inode_lru, &inode->i_lru)) in inode_lru_list_del()
462 void inode_sb_list_add(struct inode *inode) in inode_sb_list_add() argument
464 spin_lock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_add()
465 list_add(&inode->i_sb_list, &inode->i_sb->s_inodes); in inode_sb_list_add()
466 spin_unlock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_add()
470 static inline void inode_sb_list_del(struct inode *inode) in inode_sb_list_del() argument
472 if (!list_empty(&inode->i_sb_list)) { in inode_sb_list_del()
473 spin_lock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_del()
474 list_del_init(&inode->i_sb_list); in inode_sb_list_del()
475 spin_unlock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_del()
497 void __insert_inode_hash(struct inode *inode, unsigned long hashval) in __insert_inode_hash() argument
499 struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval); in __insert_inode_hash()
502 spin_lock(&inode->i_lock); in __insert_inode_hash()
503 hlist_add_head_rcu(&inode->i_hash, b); in __insert_inode_hash()
504 spin_unlock(&inode->i_lock); in __insert_inode_hash()
515 void __remove_inode_hash(struct inode *inode) in __remove_inode_hash() argument
518 spin_lock(&inode->i_lock); in __remove_inode_hash()
519 hlist_del_init_rcu(&inode->i_hash); in __remove_inode_hash()
520 spin_unlock(&inode->i_lock); in __remove_inode_hash()
525 void clear_inode(struct inode *inode) in clear_inode() argument
532 xa_lock_irq(&inode->i_data.i_pages); in clear_inode()
533 BUG_ON(inode->i_data.nrpages); in clear_inode()
534 BUG_ON(inode->i_data.nrexceptional); in clear_inode()
535 xa_unlock_irq(&inode->i_data.i_pages); in clear_inode()
536 BUG_ON(!list_empty(&inode->i_data.private_list)); in clear_inode()
537 BUG_ON(!(inode->i_state & I_FREEING)); in clear_inode()
538 BUG_ON(inode->i_state & I_CLEAR); in clear_inode()
539 BUG_ON(!list_empty(&inode->i_wb_list)); in clear_inode()
541 inode->i_state = I_FREEING | I_CLEAR; in clear_inode()
558 static void evict(struct inode *inode) in evict() argument
560 const struct super_operations *op = inode->i_sb->s_op; in evict()
562 BUG_ON(!(inode->i_state & I_FREEING)); in evict()
563 BUG_ON(!list_empty(&inode->i_lru)); in evict()
565 if (!list_empty(&inode->i_io_list)) in evict()
566 inode_io_list_del(inode); in evict()
568 inode_sb_list_del(inode); in evict()
576 inode_wait_for_writeback(inode); in evict()
579 op->evict_inode(inode); in evict()
581 truncate_inode_pages_final(&inode->i_data); in evict()
582 clear_inode(inode); in evict()
584 if (S_ISBLK(inode->i_mode) && inode->i_bdev) in evict()
585 bd_forget(inode); in evict()
586 if (S_ISCHR(inode->i_mode) && inode->i_cdev) in evict()
587 cd_forget(inode); in evict()
589 remove_inode_hash(inode); in evict()
591 spin_lock(&inode->i_lock); in evict()
592 wake_up_bit(&inode->i_state, __I_NEW); in evict()
593 BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); in evict()
594 spin_unlock(&inode->i_lock); in evict()
596 destroy_inode(inode); in evict()
609 struct inode *inode; in dispose_list() local
611 inode = list_first_entry(head, struct inode, i_lru); in dispose_list()
612 list_del_init(&inode->i_lru); in dispose_list()
614 evict(inode); in dispose_list()
630 struct inode *inode, *next; in evict_inodes() local
635 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { in evict_inodes()
636 if (atomic_read(&inode->i_count)) in evict_inodes()
639 spin_lock(&inode->i_lock); in evict_inodes()
640 if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { in evict_inodes()
641 spin_unlock(&inode->i_lock); in evict_inodes()
645 inode->i_state |= I_FREEING; in evict_inodes()
646 inode_lru_list_del(inode); in evict_inodes()
647 spin_unlock(&inode->i_lock); in evict_inodes()
648 list_add(&inode->i_lru, &dispose); in evict_inodes()
681 struct inode *inode, *next; in invalidate_inodes() local
686 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { in invalidate_inodes()
687 spin_lock(&inode->i_lock); in invalidate_inodes()
688 if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { in invalidate_inodes()
689 spin_unlock(&inode->i_lock); in invalidate_inodes()
692 if (inode->i_state & I_DIRTY_ALL && !kill_dirty) { in invalidate_inodes()
693 spin_unlock(&inode->i_lock); in invalidate_inodes()
697 if (atomic_read(&inode->i_count)) { in invalidate_inodes()
698 spin_unlock(&inode->i_lock); in invalidate_inodes()
703 inode->i_state |= I_FREEING; in invalidate_inodes()
704 inode_lru_list_del(inode); in invalidate_inodes()
705 spin_unlock(&inode->i_lock); in invalidate_inodes()
706 list_add(&inode->i_lru, &dispose); in invalidate_inodes()
740 struct inode *inode = container_of(item, struct inode, i_lru); in inode_lru_isolate() local
746 if (!spin_trylock(&inode->i_lock)) in inode_lru_isolate()
753 if (atomic_read(&inode->i_count) || in inode_lru_isolate()
754 (inode->i_state & ~I_REFERENCED)) { in inode_lru_isolate()
755 list_lru_isolate(lru, &inode->i_lru); in inode_lru_isolate()
756 spin_unlock(&inode->i_lock); in inode_lru_isolate()
762 if (inode->i_state & I_REFERENCED) { in inode_lru_isolate()
763 inode->i_state &= ~I_REFERENCED; in inode_lru_isolate()
764 spin_unlock(&inode->i_lock); in inode_lru_isolate()
768 if (inode_has_buffers(inode) || inode->i_data.nrpages) { in inode_lru_isolate()
769 __iget(inode); in inode_lru_isolate()
770 spin_unlock(&inode->i_lock); in inode_lru_isolate()
772 if (remove_inode_buffers(inode)) { in inode_lru_isolate()
774 reap = invalidate_mapping_pages(&inode->i_data, 0, -1); in inode_lru_isolate()
782 iput(inode); in inode_lru_isolate()
787 WARN_ON(inode->i_state & I_NEW); in inode_lru_isolate()
788 inode->i_state |= I_FREEING; in inode_lru_isolate()
789 list_lru_isolate_move(lru, &inode->i_lru, freeable); in inode_lru_isolate()
790 spin_unlock(&inode->i_lock); in inode_lru_isolate()
813 static void __wait_on_freeing_inode(struct inode *inode);
817 static struct inode *find_inode(struct super_block *sb, in find_inode()
819 int (*test)(struct inode *, void *), in find_inode() argument
822 struct inode *inode = NULL; in find_inode() local
825 hlist_for_each_entry(inode, head, i_hash) { in find_inode()
826 if (inode->i_sb != sb) in find_inode()
828 if (!test(inode, data)) in find_inode()
830 spin_lock(&inode->i_lock); in find_inode()
831 if (inode->i_state & (I_FREEING|I_WILL_FREE)) { in find_inode()
832 __wait_on_freeing_inode(inode); in find_inode()
835 if (unlikely(inode->i_state & I_CREATING)) { in find_inode()
836 spin_unlock(&inode->i_lock); in find_inode()
839 __iget(inode); in find_inode()
840 spin_unlock(&inode->i_lock); in find_inode()
841 return inode; in find_inode()
850 static struct inode *find_inode_fast(struct super_block *sb, in find_inode_fast()
853 struct inode *inode = NULL; in find_inode_fast() local
856 hlist_for_each_entry(inode, head, i_hash) { in find_inode_fast()
857 if (inode->i_ino != ino) in find_inode_fast()
859 if (inode->i_sb != sb) in find_inode_fast()
861 spin_lock(&inode->i_lock); in find_inode_fast()
862 if (inode->i_state & (I_FREEING|I_WILL_FREE)) { in find_inode_fast()
863 __wait_on_freeing_inode(inode); in find_inode_fast()
866 if (unlikely(inode->i_state & I_CREATING)) { in find_inode_fast()
867 spin_unlock(&inode->i_lock); in find_inode_fast()
870 __iget(inode); in find_inode_fast()
871 spin_unlock(&inode->i_lock); in find_inode_fast()
872 return inode; in find_inode_fast()
929 struct inode *new_inode_pseudo(struct super_block *sb) in new_inode_pseudo()
931 struct inode *inode = alloc_inode(sb); in new_inode_pseudo() local
933 if (inode) { in new_inode_pseudo()
934 spin_lock(&inode->i_lock); in new_inode_pseudo()
935 inode->i_state = 0; in new_inode_pseudo()
936 spin_unlock(&inode->i_lock); in new_inode_pseudo()
937 INIT_LIST_HEAD(&inode->i_sb_list); in new_inode_pseudo()
939 return inode; in new_inode_pseudo()
954 struct inode *new_inode(struct super_block *sb) in new_inode()
956 struct inode *inode; in new_inode() local
960 inode = new_inode_pseudo(sb); in new_inode()
961 if (inode) in new_inode()
962 inode_sb_list_add(inode); in new_inode()
963 return inode; in new_inode()
968 void lockdep_annotate_inode_mutex_key(struct inode *inode) in lockdep_annotate_inode_mutex_key() argument
970 if (S_ISDIR(inode->i_mode)) { in lockdep_annotate_inode_mutex_key()
971 struct file_system_type *type = inode->i_sb->s_type; in lockdep_annotate_inode_mutex_key()
974 if (lockdep_match_class(&inode->i_rwsem, &type->i_mutex_key)) { in lockdep_annotate_inode_mutex_key()
979 init_rwsem(&inode->i_rwsem); in lockdep_annotate_inode_mutex_key()
980 lockdep_set_class(&inode->i_rwsem, in lockdep_annotate_inode_mutex_key()
995 void unlock_new_inode(struct inode *inode) in unlock_new_inode() argument
997 lockdep_annotate_inode_mutex_key(inode); in unlock_new_inode()
998 spin_lock(&inode->i_lock); in unlock_new_inode()
999 WARN_ON(!(inode->i_state & I_NEW)); in unlock_new_inode()
1000 inode->i_state &= ~I_NEW & ~I_CREATING; in unlock_new_inode()
1002 wake_up_bit(&inode->i_state, __I_NEW); in unlock_new_inode()
1003 spin_unlock(&inode->i_lock); in unlock_new_inode()
1007 void discard_new_inode(struct inode *inode) in discard_new_inode() argument
1009 lockdep_annotate_inode_mutex_key(inode); in discard_new_inode()
1010 spin_lock(&inode->i_lock); in discard_new_inode()
1011 WARN_ON(!(inode->i_state & I_NEW)); in discard_new_inode()
1012 inode->i_state &= ~I_NEW; in discard_new_inode()
1014 wake_up_bit(&inode->i_state, __I_NEW); in discard_new_inode()
1015 spin_unlock(&inode->i_lock); in discard_new_inode()
1016 iput(inode); in discard_new_inode()
1029 void lock_two_nondirectories(struct inode *inode1, struct inode *inode2) in lock_two_nondirectories()
1046 void unlock_two_nondirectories(struct inode *inode1, struct inode *inode2) in unlock_two_nondirectories()
1075 struct inode *inode_insert5(struct inode *inode, unsigned long hashval, in inode_insert5() argument
1076 int (*test)(struct inode *, void *), in inode_insert5() argument
1077 int (*set)(struct inode *, void *), void *data) in inode_insert5() argument
1079 struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); in inode_insert5()
1080 struct inode *old; in inode_insert5()
1081 bool creating = inode->i_state & I_CREATING; in inode_insert5()
1085 old = find_inode(inode->i_sb, head, test, data); in inode_insert5()
1102 if (set && unlikely(set(inode, data))) { in inode_insert5()
1103 inode = NULL; in inode_insert5()
1111 spin_lock(&inode->i_lock); in inode_insert5()
1112 inode->i_state |= I_NEW; in inode_insert5()
1113 hlist_add_head_rcu(&inode->i_hash, head); in inode_insert5()
1114 spin_unlock(&inode->i_lock); in inode_insert5()
1116 inode_sb_list_add(inode); in inode_insert5()
1120 return inode; in inode_insert5()
1144 struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, in iget5_locked()
1145 int (*test)(struct inode *, void *), in iget5_locked() argument
1146 int (*set)(struct inode *, void *), void *data) in iget5_locked() argument
1148 struct inode *inode = ilookup5(sb, hashval, test, data); in iget5_locked() local
1150 if (!inode) { in iget5_locked()
1151 struct inode *new = alloc_inode(sb); in iget5_locked()
1155 inode = inode_insert5(new, hashval, test, set, data); in iget5_locked()
1156 if (unlikely(inode != new)) in iget5_locked()
1160 return inode; in iget5_locked()
1177 struct inode *iget_locked(struct super_block *sb, unsigned long ino) in iget_locked()
1180 struct inode *inode; in iget_locked() local
1183 inode = find_inode_fast(sb, head, ino); in iget_locked()
1185 if (inode) { in iget_locked()
1186 if (IS_ERR(inode)) in iget_locked()
1188 wait_on_inode(inode); in iget_locked()
1189 if (unlikely(inode_unhashed(inode))) { in iget_locked()
1190 iput(inode); in iget_locked()
1193 return inode; in iget_locked()
1196 inode = alloc_inode(sb); in iget_locked()
1197 if (inode) { in iget_locked()
1198 struct inode *old; in iget_locked()
1204 inode->i_ino = ino; in iget_locked()
1205 spin_lock(&inode->i_lock); in iget_locked()
1206 inode->i_state = I_NEW; in iget_locked()
1207 hlist_add_head_rcu(&inode->i_hash, head); in iget_locked()
1208 spin_unlock(&inode->i_lock); in iget_locked()
1209 inode_sb_list_add(inode); in iget_locked()
1215 return inode; in iget_locked()
1224 destroy_inode(inode); in iget_locked()
1227 inode = old; in iget_locked()
1228 wait_on_inode(inode); in iget_locked()
1229 if (unlikely(inode_unhashed(inode))) { in iget_locked()
1230 iput(inode); in iget_locked()
1234 return inode; in iget_locked()
1248 struct inode *inode; in test_inode_iunique() local
1250 hlist_for_each_entry_rcu(inode, b, i_hash) { in test_inode_iunique()
1251 if (inode->i_ino == ino && inode->i_sb == sb) in test_inode_iunique()
1296 struct inode *igrab(struct inode *inode) in igrab() argument
1298 spin_lock(&inode->i_lock); in igrab()
1299 if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) { in igrab()
1300 __iget(inode); in igrab()
1301 spin_unlock(&inode->i_lock); in igrab()
1303 spin_unlock(&inode->i_lock); in igrab()
1309 inode = NULL; in igrab()
1311 return inode; in igrab()
1331 struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, in ilookup5_nowait()
1332 int (*test)(struct inode *, void *), void *data) in ilookup5_nowait() argument
1335 struct inode *inode; in ilookup5_nowait() local
1338 inode = find_inode(sb, head, test, data); in ilookup5_nowait()
1341 return IS_ERR(inode) ? NULL : inode; in ilookup5_nowait()
1362 struct inode *ilookup5(struct super_block *sb, unsigned long hashval, in ilookup5()
1363 int (*test)(struct inode *, void *), void *data) in ilookup5() argument
1365 struct inode *inode; in ilookup5() local
1367 inode = ilookup5_nowait(sb, hashval, test, data); in ilookup5()
1368 if (inode) { in ilookup5()
1369 wait_on_inode(inode); in ilookup5()
1370 if (unlikely(inode_unhashed(inode))) { in ilookup5()
1371 iput(inode); in ilookup5()
1375 return inode; in ilookup5()
1387 struct inode *ilookup(struct super_block *sb, unsigned long ino) in ilookup()
1390 struct inode *inode; in ilookup() local
1393 inode = find_inode_fast(sb, head, ino); in ilookup()
1396 if (inode) { in ilookup()
1397 if (IS_ERR(inode)) in ilookup()
1399 wait_on_inode(inode); in ilookup()
1400 if (unlikely(inode_unhashed(inode))) { in ilookup()
1401 iput(inode); in ilookup()
1405 return inode; in ilookup()
1432 struct inode *find_inode_nowait(struct super_block *sb, in find_inode_nowait()
1434 int (*match)(struct inode *, unsigned long, in find_inode_nowait() argument
1439 struct inode *inode, *ret_inode = NULL; in find_inode_nowait() local
1443 hlist_for_each_entry(inode, head, i_hash) { in find_inode_nowait()
1444 if (inode->i_sb != sb) in find_inode_nowait()
1446 mval = match(inode, hashval, data); in find_inode_nowait()
1450 ret_inode = inode; in find_inode_nowait()
1480 struct inode *find_inode_rcu(struct super_block *sb, unsigned long hashval, in find_inode_rcu()
1481 int (*test)(struct inode *, void *), void *data) in find_inode_rcu() argument
1484 struct inode *inode; in find_inode_rcu() local
1489 hlist_for_each_entry_rcu(inode, head, i_hash) { in find_inode_rcu()
1490 if (inode->i_sb == sb && in find_inode_rcu()
1491 !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)) && in find_inode_rcu()
1492 test(inode, data)) in find_inode_rcu()
1493 return inode; in find_inode_rcu()
1518 struct inode *find_inode_by_ino_rcu(struct super_block *sb, in find_inode_by_ino_rcu()
1522 struct inode *inode; in find_inode_by_ino_rcu() local
1527 hlist_for_each_entry_rcu(inode, head, i_hash) { in find_inode_by_ino_rcu()
1528 if (inode->i_ino == ino && in find_inode_by_ino_rcu()
1529 inode->i_sb == sb && in find_inode_by_ino_rcu()
1530 !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE))) in find_inode_by_ino_rcu()
1531 return inode; in find_inode_by_ino_rcu()
1537 int insert_inode_locked(struct inode *inode) in insert_inode_locked() argument
1539 struct super_block *sb = inode->i_sb; in insert_inode_locked()
1540 ino_t ino = inode->i_ino; in insert_inode_locked()
1544 struct inode *old = NULL; in insert_inode_locked()
1559 spin_lock(&inode->i_lock); in insert_inode_locked()
1560 inode->i_state |= I_NEW | I_CREATING; in insert_inode_locked()
1561 hlist_add_head_rcu(&inode->i_hash, head); in insert_inode_locked()
1562 spin_unlock(&inode->i_lock); in insert_inode_locked()
1584 int insert_inode_locked4(struct inode *inode, unsigned long hashval, in insert_inode_locked4() argument
1585 int (*test)(struct inode *, void *), void *data) in insert_inode_locked4() argument
1587 struct inode *old; in insert_inode_locked4()
1589 inode->i_state |= I_CREATING; in insert_inode_locked4()
1590 old = inode_insert5(inode, hashval, test, NULL, data); in insert_inode_locked4()
1592 if (old != inode) { in insert_inode_locked4()
1601 int generic_delete_inode(struct inode *inode) in generic_delete_inode() argument
1617 static void iput_final(struct inode *inode) in iput_final() argument
1619 struct super_block *sb = inode->i_sb; in iput_final()
1620 const struct super_operations *op = inode->i_sb->s_op; in iput_final()
1624 WARN_ON(inode->i_state & I_NEW); in iput_final()
1627 drop = op->drop_inode(inode); in iput_final()
1629 drop = generic_drop_inode(inode); in iput_final()
1632 !(inode->i_state & I_DONTCACHE) && in iput_final()
1634 inode_add_lru(inode); in iput_final()
1635 spin_unlock(&inode->i_lock); in iput_final()
1639 state = inode->i_state; in iput_final()
1641 WRITE_ONCE(inode->i_state, state | I_WILL_FREE); in iput_final()
1642 spin_unlock(&inode->i_lock); in iput_final()
1644 write_inode_now(inode, 1); in iput_final()
1646 spin_lock(&inode->i_lock); in iput_final()
1647 state = inode->i_state; in iput_final()
1652 WRITE_ONCE(inode->i_state, state | I_FREEING); in iput_final()
1653 if (!list_empty(&inode->i_lru)) in iput_final()
1654 inode_lru_list_del(inode); in iput_final()
1655 spin_unlock(&inode->i_lock); in iput_final()
1657 evict(inode); in iput_final()
1669 void iput(struct inode *inode) in iput() argument
1671 if (!inode) in iput()
1673 BUG_ON(inode->i_state & I_CLEAR); in iput()
1675 if (atomic_dec_and_lock(&inode->i_count, &inode->i_lock)) { in iput()
1676 if (inode->i_nlink && (inode->i_state & I_DIRTY_TIME)) { in iput()
1677 atomic_inc(&inode->i_count); in iput()
1678 spin_unlock(&inode->i_lock); in iput()
1679 trace_writeback_lazytime_iput(inode); in iput()
1680 mark_inode_dirty_sync(inode); in iput()
1683 iput_final(inode); in iput()
1703 int bmap(struct inode *inode, sector_t *block) in bmap() argument
1705 if (!inode->i_mapping->a_ops->bmap) in bmap()
1708 *block = inode->i_mapping->a_ops->bmap(inode->i_mapping, *block); in bmap()
1719 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, in relatime_need_update() argument
1728 if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0) in relatime_need_update()
1733 if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0) in relatime_need_update()
1740 if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60) in relatime_need_update()
1748 int generic_update_time(struct inode *inode, struct timespec64 *time, int flags) in generic_update_time() argument
1754 inode->i_atime = *time; in generic_update_time()
1756 dirty = inode_maybe_inc_iversion(inode, false); in generic_update_time()
1758 inode->i_ctime = *time; in generic_update_time()
1760 inode->i_mtime = *time; in generic_update_time()
1762 !(inode->i_sb->s_flags & SB_LAZYTIME)) in generic_update_time()
1767 __mark_inode_dirty(inode, iflags); in generic_update_time()
1776 int inode_update_time(struct inode *inode, struct timespec64 *time, int flags) in inode_update_time() argument
1778 if (inode->i_op->update_time) in inode_update_time()
1779 return inode->i_op->update_time(inode, time, flags); in inode_update_time()
1780 return generic_update_time(inode, time, flags); in inode_update_time()
1793 bool atime_needs_update(const struct path *path, struct inode *inode) in atime_needs_update() argument
1798 if (inode->i_flags & S_NOATIME) in atime_needs_update()
1804 if (HAS_UNMAPPED_ID(inode)) in atime_needs_update()
1807 if (IS_NOATIME(inode)) in atime_needs_update()
1809 if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode)) in atime_needs_update()
1814 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) in atime_needs_update()
1817 now = current_time(inode); in atime_needs_update()
1819 if (!relatime_need_update(mnt, inode, now)) in atime_needs_update()
1822 if (timespec64_equal(&inode->i_atime, &now)) in atime_needs_update()
1831 struct inode *inode = d_inode(path->dentry); in touch_atime() local
1834 if (!atime_needs_update(path, inode)) in touch_atime()
1837 if (!sb_start_write_trylock(inode->i_sb)) in touch_atime()
1851 now = current_time(inode); in touch_atime()
1852 inode_update_time(inode, &now, S_ATIME); in touch_atime()
1855 sb_end_write(inode->i_sb); in touch_atime()
1895 struct inode *inode = d_inode(dentry); in dentry_needs_remove_privs() local
1899 if (IS_NOSEC(inode)) in dentry_needs_remove_privs()
1930 struct inode *inode = file_inode(file); in file_remove_privs() local
1940 if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode)) in file_remove_privs()
1949 inode_has_no_xattr(inode); in file_remove_privs()
1970 struct inode *inode = file_inode(file); in file_update_time() local
1976 if (IS_NOCMTIME(inode)) in file_update_time()
1979 now = current_time(inode); in file_update_time()
1980 if (!timespec64_equal(&inode->i_mtime, &now)) in file_update_time()
1983 if (!timespec64_equal(&inode->i_ctime, &now)) in file_update_time()
1986 if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) in file_update_time()
1996 ret = inode_update_time(inode, &now, sync_it); in file_update_time()
2023 int inode_needs_sync(struct inode *inode) in inode_needs_sync() argument
2025 if (IS_SYNC(inode)) in inode_needs_sync()
2027 if (S_ISDIR(inode->i_mode) && IS_DIRSYNC(inode)) in inode_needs_sync()
2044 static void __wait_on_freeing_inode(struct inode *inode) in __wait_on_freeing_inode() argument
2047 DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW); in __wait_on_freeing_inode()
2048 wq = bit_waitqueue(&inode->i_state, __I_NEW); in __wait_on_freeing_inode()
2050 spin_unlock(&inode->i_lock); in __wait_on_freeing_inode()
2094 sizeof(struct inode), in inode_init()
2116 void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) in init_special_inode() argument
2118 inode->i_mode = mode; in init_special_inode()
2120 inode->i_fop = &def_chr_fops; in init_special_inode()
2121 inode->i_rdev = rdev; in init_special_inode()
2123 inode->i_fop = &def_blk_fops; in init_special_inode()
2124 inode->i_rdev = rdev; in init_special_inode()
2126 inode->i_fop = &pipefifo_fops; in init_special_inode()
2131 " inode %s:%lu\n", mode, inode->i_sb->s_id, in init_special_inode()
2132 inode->i_ino); in init_special_inode()
2142 void inode_init_owner(struct inode *inode, const struct inode *dir, in inode_init_owner() argument
2145 inode->i_uid = current_fsuid(); in inode_init_owner()
2147 inode->i_gid = dir->i_gid; in inode_init_owner()
2153 !in_group_p(inode->i_gid) && in inode_init_owner()
2157 inode->i_gid = current_fsgid(); in inode_init_owner()
2158 inode->i_mode = mode; in inode_init_owner()
2169 bool inode_owner_or_capable(const struct inode *inode) in inode_owner_or_capable() argument
2173 if (uid_eq(current_fsuid(), inode->i_uid)) in inode_owner_or_capable()
2177 if (kuid_has_mapping(ns, inode->i_uid) && ns_capable(ns, CAP_FOWNER)) in inode_owner_or_capable()
2186 static void __inode_dio_wait(struct inode *inode) in __inode_dio_wait() argument
2188 wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); in __inode_dio_wait()
2189 DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); in __inode_dio_wait()
2193 if (atomic_read(&inode->i_dio_count)) in __inode_dio_wait()
2195 } while (atomic_read(&inode->i_dio_count)); in __inode_dio_wait()
2209 void inode_dio_wait(struct inode *inode) in inode_dio_wait() argument
2211 if (atomic_read(&inode->i_dio_count)) in inode_dio_wait()
2212 __inode_dio_wait(inode); in inode_dio_wait()
2232 void inode_set_flags(struct inode *inode, unsigned int flags, in inode_set_flags() argument
2236 set_mask_bits(&inode->i_flags, mask, flags); in inode_set_flags()
2240 void inode_nohighmem(struct inode *inode) in inode_nohighmem() argument
2242 mapping_set_gfp_mask(inode->i_mapping, GFP_USER); in inode_nohighmem()
2255 struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) in timestamp_truncate() argument
2257 struct super_block *sb = inode->i_sb; in timestamp_truncate()
2287 struct timespec64 current_time(struct inode *inode) in current_time() argument
2293 if (unlikely(!inode->i_sb)) { in current_time()
2298 return timestamp_truncate(now, inode); in current_time()
2309 int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags, in vfs_ioc_setflags_prepare() argument
2322 return fscrypt_prepare_setflags(inode, oldflags, flags); in vfs_ioc_setflags_prepare()
2333 int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa, in vfs_ioc_fssetxattr_check() argument
2359 if ((fa->fsx_xflags & FS_XFLAG_EXTSIZE) && !S_ISREG(inode->i_mode)) in vfs_ioc_fssetxattr_check()
2363 !S_ISDIR(inode->i_mode)) in vfs_ioc_fssetxattr_check()
2367 !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) in vfs_ioc_fssetxattr_check()
2375 !(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) in vfs_ioc_fssetxattr_check()