Lines Matching refs:inode
144 static int no_open(struct inode *inode, struct file *file) in no_open() argument
157 int inode_init_always(struct super_block *sb, struct inode *inode) in inode_init_always() argument
161 struct address_space *const mapping = &inode->i_data; in inode_init_always()
163 inode->i_sb = sb; in inode_init_always()
164 inode->i_blkbits = sb->s_blocksize_bits; in inode_init_always()
165 inode->i_flags = 0; in inode_init_always()
166 atomic64_set(&inode->i_sequence, 0); in inode_init_always()
167 atomic_set(&inode->i_count, 1); in inode_init_always()
168 inode->i_op = &empty_iops; in inode_init_always()
169 inode->i_fop = &no_open_fops; in inode_init_always()
170 inode->i_ino = 0; in inode_init_always()
171 inode->__i_nlink = 1; in inode_init_always()
172 inode->i_opflags = 0; in inode_init_always()
174 inode->i_opflags |= IOP_XATTR; in inode_init_always()
175 i_uid_write(inode, 0); in inode_init_always()
176 i_gid_write(inode, 0); in inode_init_always()
177 atomic_set(&inode->i_writecount, 0); in inode_init_always()
178 inode->i_size = 0; in inode_init_always()
179 inode->i_write_hint = WRITE_LIFE_NOT_SET; in inode_init_always()
180 inode->i_blocks = 0; in inode_init_always()
181 inode->i_bytes = 0; in inode_init_always()
182 inode->i_generation = 0; in inode_init_always()
183 inode->i_pipe = NULL; in inode_init_always()
184 inode->i_cdev = NULL; in inode_init_always()
185 inode->i_link = NULL; in inode_init_always()
186 inode->i_dir_seq = 0; in inode_init_always()
187 inode->i_rdev = 0; in inode_init_always()
188 inode->dirtied_when = 0; in inode_init_always()
191 inode->i_wb_frn_winner = 0; in inode_init_always()
192 inode->i_wb_frn_avg_time = 0; in inode_init_always()
193 inode->i_wb_frn_history = 0; in inode_init_always()
196 spin_lock_init(&inode->i_lock); in inode_init_always()
197 lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); in inode_init_always()
199 init_rwsem(&inode->i_rwsem); in inode_init_always()
200 lockdep_set_class(&inode->i_rwsem, &sb->s_type->i_mutex_key); in inode_init_always()
202 atomic_set(&inode->i_dio_count, 0); in inode_init_always()
205 mapping->host = inode; in inode_init_always()
219 inode->i_private = NULL; in inode_init_always()
220 inode->i_mapping = mapping; in inode_init_always()
221 INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */ in inode_init_always()
223 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; in inode_init_always()
227 inode->i_fsnotify_mask = 0; in inode_init_always()
229 inode->i_flctx = NULL; in inode_init_always()
231 if (unlikely(security_inode_alloc(inode))) in inode_init_always()
239 void free_inode_nonrcu(struct inode *inode) in free_inode_nonrcu() argument
241 kmem_cache_free(inode_cachep, inode); in free_inode_nonrcu()
247 struct inode *inode = container_of(head, struct inode, i_rcu); in i_callback() local
248 if (inode->free_inode) in i_callback()
249 inode->free_inode(inode); in i_callback()
251 free_inode_nonrcu(inode); in i_callback()
254 static struct inode *alloc_inode(struct super_block *sb) in alloc_inode()
257 struct inode *inode; in alloc_inode() local
260 inode = ops->alloc_inode(sb); in alloc_inode()
262 inode = alloc_inode_sb(sb, inode_cachep, GFP_KERNEL); in alloc_inode()
264 if (!inode) in alloc_inode()
267 if (unlikely(inode_init_always(sb, inode))) { in alloc_inode()
269 ops->destroy_inode(inode); in alloc_inode()
273 inode->free_inode = ops->free_inode; in alloc_inode()
274 i_callback(&inode->i_rcu); in alloc_inode()
278 return inode; in alloc_inode()
281 void __destroy_inode(struct inode *inode) in __destroy_inode() argument
283 BUG_ON(inode_has_buffers(inode)); in __destroy_inode()
284 inode_detach_wb(inode); in __destroy_inode()
285 security_inode_free(inode); in __destroy_inode()
286 fsnotify_inode_delete(inode); in __destroy_inode()
287 locks_free_lock_context(inode); in __destroy_inode()
288 if (!inode->i_nlink) { in __destroy_inode()
289 WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0); in __destroy_inode()
290 atomic_long_dec(&inode->i_sb->s_remove_count); in __destroy_inode()
294 if (inode->i_acl && !is_uncached_acl(inode->i_acl)) in __destroy_inode()
295 posix_acl_release(inode->i_acl); in __destroy_inode()
296 if (inode->i_default_acl && !is_uncached_acl(inode->i_default_acl)) in __destroy_inode()
297 posix_acl_release(inode->i_default_acl); in __destroy_inode()
303 static void destroy_inode(struct inode *inode) in destroy_inode() argument
305 const struct super_operations *ops = inode->i_sb->s_op; in destroy_inode()
307 BUG_ON(!list_empty(&inode->i_lru)); in destroy_inode()
308 __destroy_inode(inode); in destroy_inode()
310 ops->destroy_inode(inode); in destroy_inode()
314 inode->free_inode = ops->free_inode; in destroy_inode()
315 call_rcu(&inode->i_rcu, i_callback); in destroy_inode()
329 void drop_nlink(struct inode *inode) in drop_nlink() argument
331 WARN_ON(inode->i_nlink == 0); in drop_nlink()
332 inode->__i_nlink--; in drop_nlink()
333 if (!inode->i_nlink) in drop_nlink()
334 atomic_long_inc(&inode->i_sb->s_remove_count); in drop_nlink()
346 void clear_nlink(struct inode *inode) in clear_nlink() argument
348 if (inode->i_nlink) { in clear_nlink()
349 inode->__i_nlink = 0; in clear_nlink()
350 atomic_long_inc(&inode->i_sb->s_remove_count); in clear_nlink()
363 void set_nlink(struct inode *inode, unsigned int nlink) in set_nlink() argument
366 clear_nlink(inode); in set_nlink()
369 if (inode->i_nlink == 0) in set_nlink()
370 atomic_long_dec(&inode->i_sb->s_remove_count); in set_nlink()
372 inode->__i_nlink = nlink; in set_nlink()
385 void inc_nlink(struct inode *inode) in inc_nlink() argument
387 if (unlikely(inode->i_nlink == 0)) { in inc_nlink()
388 WARN_ON(!(inode->i_state & I_LINKABLE)); in inc_nlink()
389 atomic_long_dec(&inode->i_sb->s_remove_count); in inc_nlink()
392 inode->__i_nlink++; in inc_nlink()
417 void inode_init_once(struct inode *inode) in inode_init_once() argument
419 memset(inode, 0, sizeof(*inode)); in inode_init_once()
420 INIT_HLIST_NODE(&inode->i_hash); in inode_init_once()
421 INIT_LIST_HEAD(&inode->i_devices); in inode_init_once()
422 INIT_LIST_HEAD(&inode->i_io_list); in inode_init_once()
423 INIT_LIST_HEAD(&inode->i_wb_list); in inode_init_once()
424 INIT_LIST_HEAD(&inode->i_lru); in inode_init_once()
425 INIT_LIST_HEAD(&inode->i_sb_list); in inode_init_once()
426 __address_space_init_once(&inode->i_data); in inode_init_once()
427 i_size_ordered_init(inode); in inode_init_once()
433 struct inode *inode = (struct inode *) foo; in init_once() local
435 inode_init_once(inode); in init_once()
441 void __iget(struct inode *inode) in __iget() argument
443 atomic_inc(&inode->i_count); in __iget()
449 void ihold(struct inode *inode) in ihold() argument
451 WARN_ON(atomic_inc_return(&inode->i_count) < 2); in ihold()
455 static void __inode_add_lru(struct inode *inode, bool rotate) in __inode_add_lru() argument
457 if (inode->i_state & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE)) in __inode_add_lru()
459 if (atomic_read(&inode->i_count)) in __inode_add_lru()
461 if (!(inode->i_sb->s_flags & SB_ACTIVE)) in __inode_add_lru()
463 if (!mapping_shrinkable(&inode->i_data)) in __inode_add_lru()
466 if (list_lru_add(&inode->i_sb->s_inode_lru, &inode->i_lru)) in __inode_add_lru()
469 inode->i_state |= I_REFERENCED; in __inode_add_lru()
477 void inode_add_lru(struct inode *inode) in inode_add_lru() argument
479 __inode_add_lru(inode, false); in inode_add_lru()
482 static void inode_lru_list_del(struct inode *inode) in inode_lru_list_del() argument
484 if (list_lru_del(&inode->i_sb->s_inode_lru, &inode->i_lru)) in inode_lru_list_del()
492 void inode_sb_list_add(struct inode *inode) in inode_sb_list_add() argument
494 spin_lock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_add()
495 list_add(&inode->i_sb_list, &inode->i_sb->s_inodes); in inode_sb_list_add()
496 spin_unlock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_add()
500 static inline void inode_sb_list_del(struct inode *inode) in inode_sb_list_del() argument
502 if (!list_empty(&inode->i_sb_list)) { in inode_sb_list_del()
503 spin_lock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_del()
504 list_del_init(&inode->i_sb_list); in inode_sb_list_del()
505 spin_unlock(&inode->i_sb->s_inode_list_lock); in inode_sb_list_del()
527 void __insert_inode_hash(struct inode *inode, unsigned long hashval) in __insert_inode_hash() argument
529 struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval); in __insert_inode_hash()
532 spin_lock(&inode->i_lock); in __insert_inode_hash()
533 hlist_add_head_rcu(&inode->i_hash, b); in __insert_inode_hash()
534 spin_unlock(&inode->i_lock); in __insert_inode_hash()
545 void __remove_inode_hash(struct inode *inode) in __remove_inode_hash() argument
548 spin_lock(&inode->i_lock); in __remove_inode_hash()
549 hlist_del_init_rcu(&inode->i_hash); in __remove_inode_hash()
550 spin_unlock(&inode->i_lock); in __remove_inode_hash()
557 struct inode *host; in dump_mapping()
604 void clear_inode(struct inode *inode) in clear_inode() argument
611 xa_lock_irq(&inode->i_data.i_pages); in clear_inode()
612 BUG_ON(inode->i_data.nrpages); in clear_inode()
621 xa_unlock_irq(&inode->i_data.i_pages); in clear_inode()
622 BUG_ON(!list_empty(&inode->i_data.private_list)); in clear_inode()
623 BUG_ON(!(inode->i_state & I_FREEING)); in clear_inode()
624 BUG_ON(inode->i_state & I_CLEAR); in clear_inode()
625 BUG_ON(!list_empty(&inode->i_wb_list)); in clear_inode()
627 inode->i_state = I_FREEING | I_CLEAR; in clear_inode()
644 static void evict(struct inode *inode) in evict() argument
646 const struct super_operations *op = inode->i_sb->s_op; in evict()
648 BUG_ON(!(inode->i_state & I_FREEING)); in evict()
649 BUG_ON(!list_empty(&inode->i_lru)); in evict()
651 if (!list_empty(&inode->i_io_list)) in evict()
652 inode_io_list_del(inode); in evict()
654 inode_sb_list_del(inode); in evict()
662 inode_wait_for_writeback(inode); in evict()
665 op->evict_inode(inode); in evict()
667 truncate_inode_pages_final(&inode->i_data); in evict()
668 clear_inode(inode); in evict()
670 if (S_ISCHR(inode->i_mode) && inode->i_cdev) in evict()
671 cd_forget(inode); in evict()
673 remove_inode_hash(inode); in evict()
675 spin_lock(&inode->i_lock); in evict()
676 wake_up_bit(&inode->i_state, __I_NEW); in evict()
677 BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); in evict()
678 spin_unlock(&inode->i_lock); in evict()
680 destroy_inode(inode); in evict()
693 struct inode *inode; in dispose_list() local
695 inode = list_first_entry(head, struct inode, i_lru); in dispose_list()
696 list_del_init(&inode->i_lru); in dispose_list()
698 evict(inode); in dispose_list()
714 struct inode *inode, *next; in evict_inodes() local
719 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { in evict_inodes()
720 if (atomic_read(&inode->i_count)) in evict_inodes()
723 spin_lock(&inode->i_lock); in evict_inodes()
724 if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { in evict_inodes()
725 spin_unlock(&inode->i_lock); in evict_inodes()
729 inode->i_state |= I_FREEING; in evict_inodes()
730 inode_lru_list_del(inode); in evict_inodes()
731 spin_unlock(&inode->i_lock); in evict_inodes()
732 list_add(&inode->i_lru, &dispose); in evict_inodes()
765 struct inode *inode, *next; in invalidate_inodes() local
770 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { in invalidate_inodes()
771 spin_lock(&inode->i_lock); in invalidate_inodes()
772 if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { in invalidate_inodes()
773 spin_unlock(&inode->i_lock); in invalidate_inodes()
776 if (inode->i_state & I_DIRTY_ALL && !kill_dirty) { in invalidate_inodes()
777 spin_unlock(&inode->i_lock); in invalidate_inodes()
781 if (atomic_read(&inode->i_count)) { in invalidate_inodes()
782 spin_unlock(&inode->i_lock); in invalidate_inodes()
787 inode->i_state |= I_FREEING; in invalidate_inodes()
788 inode_lru_list_del(inode); in invalidate_inodes()
789 spin_unlock(&inode->i_lock); in invalidate_inodes()
790 list_add(&inode->i_lru, &dispose); in invalidate_inodes()
820 struct inode *inode = container_of(item, struct inode, i_lru); in inode_lru_isolate() local
826 if (!spin_trylock(&inode->i_lock)) in inode_lru_isolate()
835 if (atomic_read(&inode->i_count) || in inode_lru_isolate()
836 (inode->i_state & ~I_REFERENCED) || in inode_lru_isolate()
837 !mapping_shrinkable(&inode->i_data)) { in inode_lru_isolate()
838 list_lru_isolate(lru, &inode->i_lru); in inode_lru_isolate()
839 spin_unlock(&inode->i_lock); in inode_lru_isolate()
845 if (inode->i_state & I_REFERENCED) { in inode_lru_isolate()
846 inode->i_state &= ~I_REFERENCED; in inode_lru_isolate()
847 spin_unlock(&inode->i_lock); in inode_lru_isolate()
856 if (inode_has_buffers(inode) || !mapping_empty(&inode->i_data)) { in inode_lru_isolate()
857 __iget(inode); in inode_lru_isolate()
858 spin_unlock(&inode->i_lock); in inode_lru_isolate()
860 if (remove_inode_buffers(inode)) { in inode_lru_isolate()
862 reap = invalidate_mapping_pages(&inode->i_data, 0, -1); in inode_lru_isolate()
870 iput(inode); in inode_lru_isolate()
875 WARN_ON(inode->i_state & I_NEW); in inode_lru_isolate()
876 inode->i_state |= I_FREEING; in inode_lru_isolate()
877 list_lru_isolate_move(lru, &inode->i_lru, freeable); in inode_lru_isolate()
878 spin_unlock(&inode->i_lock); in inode_lru_isolate()
901 static void __wait_on_freeing_inode(struct inode *inode);
905 static struct inode *find_inode(struct super_block *sb, in find_inode()
907 int (*test)(struct inode *, void *), in find_inode() argument
910 struct inode *inode = NULL; in find_inode() local
913 hlist_for_each_entry(inode, head, i_hash) { in find_inode()
914 if (inode->i_sb != sb) in find_inode()
916 if (!test(inode, data)) in find_inode()
918 spin_lock(&inode->i_lock); in find_inode()
919 if (inode->i_state & (I_FREEING|I_WILL_FREE)) { in find_inode()
920 __wait_on_freeing_inode(inode); in find_inode()
923 if (unlikely(inode->i_state & I_CREATING)) { in find_inode()
924 spin_unlock(&inode->i_lock); in find_inode()
927 __iget(inode); in find_inode()
928 spin_unlock(&inode->i_lock); in find_inode()
929 return inode; in find_inode()
938 static struct inode *find_inode_fast(struct super_block *sb, in find_inode_fast()
941 struct inode *inode = NULL; in find_inode_fast() local
944 hlist_for_each_entry(inode, head, i_hash) { in find_inode_fast()
945 if (inode->i_ino != ino) in find_inode_fast()
947 if (inode->i_sb != sb) in find_inode_fast()
949 spin_lock(&inode->i_lock); in find_inode_fast()
950 if (inode->i_state & (I_FREEING|I_WILL_FREE)) { in find_inode_fast()
951 __wait_on_freeing_inode(inode); in find_inode_fast()
954 if (unlikely(inode->i_state & I_CREATING)) { in find_inode_fast()
955 spin_unlock(&inode->i_lock); in find_inode_fast()
958 __iget(inode); in find_inode_fast()
959 spin_unlock(&inode->i_lock); in find_inode_fast()
960 return inode; in find_inode_fast()
1017 struct inode *new_inode_pseudo(struct super_block *sb) in new_inode_pseudo()
1019 struct inode *inode = alloc_inode(sb); in new_inode_pseudo() local
1021 if (inode) { in new_inode_pseudo()
1022 spin_lock(&inode->i_lock); in new_inode_pseudo()
1023 inode->i_state = 0; in new_inode_pseudo()
1024 spin_unlock(&inode->i_lock); in new_inode_pseudo()
1026 return inode; in new_inode_pseudo()
1041 struct inode *new_inode(struct super_block *sb) in new_inode()
1043 struct inode *inode; in new_inode() local
1047 inode = new_inode_pseudo(sb); in new_inode()
1048 if (inode) in new_inode()
1049 inode_sb_list_add(inode); in new_inode()
1050 return inode; in new_inode()
1055 void lockdep_annotate_inode_mutex_key(struct inode *inode) in lockdep_annotate_inode_mutex_key() argument
1057 if (S_ISDIR(inode->i_mode)) { in lockdep_annotate_inode_mutex_key()
1058 struct file_system_type *type = inode->i_sb->s_type; in lockdep_annotate_inode_mutex_key()
1061 if (lockdep_match_class(&inode->i_rwsem, &type->i_mutex_key)) { in lockdep_annotate_inode_mutex_key()
1066 init_rwsem(&inode->i_rwsem); in lockdep_annotate_inode_mutex_key()
1067 lockdep_set_class(&inode->i_rwsem, in lockdep_annotate_inode_mutex_key()
1082 void unlock_new_inode(struct inode *inode) in unlock_new_inode() argument
1084 lockdep_annotate_inode_mutex_key(inode); in unlock_new_inode()
1085 spin_lock(&inode->i_lock); in unlock_new_inode()
1086 WARN_ON(!(inode->i_state & I_NEW)); in unlock_new_inode()
1087 inode->i_state &= ~I_NEW & ~I_CREATING; in unlock_new_inode()
1089 wake_up_bit(&inode->i_state, __I_NEW); in unlock_new_inode()
1090 spin_unlock(&inode->i_lock); in unlock_new_inode()
1094 void discard_new_inode(struct inode *inode) in discard_new_inode() argument
1096 lockdep_annotate_inode_mutex_key(inode); in discard_new_inode()
1097 spin_lock(&inode->i_lock); in discard_new_inode()
1098 WARN_ON(!(inode->i_state & I_NEW)); in discard_new_inode()
1099 inode->i_state &= ~I_NEW; in discard_new_inode()
1101 wake_up_bit(&inode->i_state, __I_NEW); in discard_new_inode()
1102 spin_unlock(&inode->i_lock); in discard_new_inode()
1103 iput(inode); in discard_new_inode()
1116 void lock_two_nondirectories(struct inode *inode1, struct inode *inode2) in lock_two_nondirectories()
1133 void unlock_two_nondirectories(struct inode *inode1, struct inode *inode2) in unlock_two_nondirectories()
1162 struct inode *inode_insert5(struct inode *inode, unsigned long hashval, in inode_insert5() argument
1163 int (*test)(struct inode *, void *), in inode_insert5() argument
1164 int (*set)(struct inode *, void *), void *data) in inode_insert5() argument
1166 struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); in inode_insert5()
1167 struct inode *old; in inode_insert5()
1171 old = find_inode(inode->i_sb, head, test, data); in inode_insert5()
1188 if (set && unlikely(set(inode, data))) { in inode_insert5()
1189 inode = NULL; in inode_insert5()
1197 spin_lock(&inode->i_lock); in inode_insert5()
1198 inode->i_state |= I_NEW; in inode_insert5()
1199 hlist_add_head_rcu(&inode->i_hash, head); in inode_insert5()
1200 spin_unlock(&inode->i_lock); in inode_insert5()
1206 if (list_empty(&inode->i_sb_list)) in inode_insert5()
1207 inode_sb_list_add(inode); in inode_insert5()
1211 return inode; in inode_insert5()
1235 struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, in iget5_locked()
1236 int (*test)(struct inode *, void *), in iget5_locked() argument
1237 int (*set)(struct inode *, void *), void *data) in iget5_locked() argument
1239 struct inode *inode = ilookup5(sb, hashval, test, data); in iget5_locked() local
1241 if (!inode) { in iget5_locked()
1242 struct inode *new = alloc_inode(sb); in iget5_locked()
1246 inode = inode_insert5(new, hashval, test, set, data); in iget5_locked()
1247 if (unlikely(inode != new)) in iget5_locked()
1251 return inode; in iget5_locked()
1268 struct inode *iget_locked(struct super_block *sb, unsigned long ino) in iget_locked()
1271 struct inode *inode; in iget_locked() local
1274 inode = find_inode_fast(sb, head, ino); in iget_locked()
1276 if (inode) { in iget_locked()
1277 if (IS_ERR(inode)) in iget_locked()
1279 wait_on_inode(inode); in iget_locked()
1280 if (unlikely(inode_unhashed(inode))) { in iget_locked()
1281 iput(inode); in iget_locked()
1284 return inode; in iget_locked()
1287 inode = alloc_inode(sb); in iget_locked()
1288 if (inode) { in iget_locked()
1289 struct inode *old; in iget_locked()
1295 inode->i_ino = ino; in iget_locked()
1296 spin_lock(&inode->i_lock); in iget_locked()
1297 inode->i_state = I_NEW; in iget_locked()
1298 hlist_add_head_rcu(&inode->i_hash, head); in iget_locked()
1299 spin_unlock(&inode->i_lock); in iget_locked()
1300 inode_sb_list_add(inode); in iget_locked()
1306 return inode; in iget_locked()
1315 destroy_inode(inode); in iget_locked()
1318 inode = old; in iget_locked()
1319 wait_on_inode(inode); in iget_locked()
1320 if (unlikely(inode_unhashed(inode))) { in iget_locked()
1321 iput(inode); in iget_locked()
1325 return inode; in iget_locked()
1339 struct inode *inode; in test_inode_iunique() local
1341 hlist_for_each_entry_rcu(inode, b, i_hash) { in test_inode_iunique()
1342 if (inode->i_ino == ino && inode->i_sb == sb) in test_inode_iunique()
1387 struct inode *igrab(struct inode *inode) in igrab() argument
1389 spin_lock(&inode->i_lock); in igrab()
1390 if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) { in igrab()
1391 __iget(inode); in igrab()
1392 spin_unlock(&inode->i_lock); in igrab()
1394 spin_unlock(&inode->i_lock); in igrab()
1400 inode = NULL; in igrab()
1402 return inode; in igrab()
1422 struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, in ilookup5_nowait()
1423 int (*test)(struct inode *, void *), void *data) in ilookup5_nowait() argument
1426 struct inode *inode; in ilookup5_nowait() local
1429 inode = find_inode(sb, head, test, data); in ilookup5_nowait()
1432 return IS_ERR(inode) ? NULL : inode; in ilookup5_nowait()
1453 struct inode *ilookup5(struct super_block *sb, unsigned long hashval, in ilookup5()
1454 int (*test)(struct inode *, void *), void *data) in ilookup5() argument
1456 struct inode *inode; in ilookup5() local
1458 inode = ilookup5_nowait(sb, hashval, test, data); in ilookup5()
1459 if (inode) { in ilookup5()
1460 wait_on_inode(inode); in ilookup5()
1461 if (unlikely(inode_unhashed(inode))) { in ilookup5()
1462 iput(inode); in ilookup5()
1466 return inode; in ilookup5()
1478 struct inode *ilookup(struct super_block *sb, unsigned long ino) in ilookup()
1481 struct inode *inode; in ilookup() local
1484 inode = find_inode_fast(sb, head, ino); in ilookup()
1487 if (inode) { in ilookup()
1488 if (IS_ERR(inode)) in ilookup()
1490 wait_on_inode(inode); in ilookup()
1491 if (unlikely(inode_unhashed(inode))) { in ilookup()
1492 iput(inode); in ilookup()
1496 return inode; in ilookup()
1523 struct inode *find_inode_nowait(struct super_block *sb, in find_inode_nowait()
1525 int (*match)(struct inode *, unsigned long, in find_inode_nowait() argument
1530 struct inode *inode, *ret_inode = NULL; in find_inode_nowait() local
1534 hlist_for_each_entry(inode, head, i_hash) { in find_inode_nowait()
1535 if (inode->i_sb != sb) in find_inode_nowait()
1537 mval = match(inode, hashval, data); in find_inode_nowait()
1541 ret_inode = inode; in find_inode_nowait()
1571 struct inode *find_inode_rcu(struct super_block *sb, unsigned long hashval, in find_inode_rcu()
1572 int (*test)(struct inode *, void *), void *data) in find_inode_rcu() argument
1575 struct inode *inode; in find_inode_rcu() local
1580 hlist_for_each_entry_rcu(inode, head, i_hash) { in find_inode_rcu()
1581 if (inode->i_sb == sb && in find_inode_rcu()
1582 !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)) && in find_inode_rcu()
1583 test(inode, data)) in find_inode_rcu()
1584 return inode; in find_inode_rcu()
1609 struct inode *find_inode_by_ino_rcu(struct super_block *sb, in find_inode_by_ino_rcu()
1613 struct inode *inode; in find_inode_by_ino_rcu() local
1618 hlist_for_each_entry_rcu(inode, head, i_hash) { in find_inode_by_ino_rcu()
1619 if (inode->i_ino == ino && in find_inode_by_ino_rcu()
1620 inode->i_sb == sb && in find_inode_by_ino_rcu()
1621 !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE))) in find_inode_by_ino_rcu()
1622 return inode; in find_inode_by_ino_rcu()
1628 int insert_inode_locked(struct inode *inode) in insert_inode_locked() argument
1630 struct super_block *sb = inode->i_sb; in insert_inode_locked()
1631 ino_t ino = inode->i_ino; in insert_inode_locked()
1635 struct inode *old = NULL; in insert_inode_locked()
1650 spin_lock(&inode->i_lock); in insert_inode_locked()
1651 inode->i_state |= I_NEW | I_CREATING; in insert_inode_locked()
1652 hlist_add_head_rcu(&inode->i_hash, head); in insert_inode_locked()
1653 spin_unlock(&inode->i_lock); in insert_inode_locked()
1675 int insert_inode_locked4(struct inode *inode, unsigned long hashval, in insert_inode_locked4() argument
1676 int (*test)(struct inode *, void *), void *data) in insert_inode_locked4() argument
1678 struct inode *old; in insert_inode_locked4()
1680 inode->i_state |= I_CREATING; in insert_inode_locked4()
1681 old = inode_insert5(inode, hashval, test, NULL, data); in insert_inode_locked4()
1683 if (old != inode) { in insert_inode_locked4()
1692 int generic_delete_inode(struct inode *inode) in generic_delete_inode() argument
1708 static void iput_final(struct inode *inode) in iput_final() argument
1710 struct super_block *sb = inode->i_sb; in iput_final()
1711 const struct super_operations *op = inode->i_sb->s_op; in iput_final()
1715 WARN_ON(inode->i_state & I_NEW); in iput_final()
1718 drop = op->drop_inode(inode); in iput_final()
1720 drop = generic_drop_inode(inode); in iput_final()
1723 !(inode->i_state & I_DONTCACHE) && in iput_final()
1725 __inode_add_lru(inode, true); in iput_final()
1726 spin_unlock(&inode->i_lock); in iput_final()
1730 state = inode->i_state; in iput_final()
1732 WRITE_ONCE(inode->i_state, state | I_WILL_FREE); in iput_final()
1733 spin_unlock(&inode->i_lock); in iput_final()
1735 write_inode_now(inode, 1); in iput_final()
1737 spin_lock(&inode->i_lock); in iput_final()
1738 state = inode->i_state; in iput_final()
1743 WRITE_ONCE(inode->i_state, state | I_FREEING); in iput_final()
1744 if (!list_empty(&inode->i_lru)) in iput_final()
1745 inode_lru_list_del(inode); in iput_final()
1746 spin_unlock(&inode->i_lock); in iput_final()
1748 evict(inode); in iput_final()
1760 void iput(struct inode *inode) in iput() argument
1762 if (!inode) in iput()
1764 BUG_ON(inode->i_state & I_CLEAR); in iput()
1766 if (atomic_dec_and_lock(&inode->i_count, &inode->i_lock)) { in iput()
1767 if (inode->i_nlink && (inode->i_state & I_DIRTY_TIME)) { in iput()
1768 atomic_inc(&inode->i_count); in iput()
1769 spin_unlock(&inode->i_lock); in iput()
1770 trace_writeback_lazytime_iput(inode); in iput()
1771 mark_inode_dirty_sync(inode); in iput()
1774 iput_final(inode); in iput()
1794 int bmap(struct inode *inode, sector_t *block) in bmap() argument
1796 if (!inode->i_mapping->a_ops->bmap) in bmap()
1799 *block = inode->i_mapping->a_ops->bmap(inode->i_mapping, *block); in bmap()
1810 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, in relatime_need_update() argument
1819 if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0) in relatime_need_update()
1824 if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0) in relatime_need_update()
1831 if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60) in relatime_need_update()
1839 int generic_update_time(struct inode *inode, struct timespec64 *time, int flags) in generic_update_time() argument
1845 inode->i_atime = *time; in generic_update_time()
1847 inode->i_ctime = *time; in generic_update_time()
1849 inode->i_mtime = *time; in generic_update_time()
1851 if (inode->i_sb->s_flags & SB_LAZYTIME) in generic_update_time()
1857 if ((flags & S_VERSION) && inode_maybe_inc_iversion(inode, false)) in generic_update_time()
1860 __mark_inode_dirty(inode, dirty_flags); in generic_update_time()
1869 int inode_update_time(struct inode *inode, struct timespec64 *time, int flags) in inode_update_time() argument
1871 if (inode->i_op->update_time) in inode_update_time()
1872 return inode->i_op->update_time(inode, time, flags); in inode_update_time()
1873 return generic_update_time(inode, time, flags); in inode_update_time()
1886 bool atime_needs_update(const struct path *path, struct inode *inode) in atime_needs_update() argument
1891 if (inode->i_flags & S_NOATIME) in atime_needs_update()
1897 if (HAS_UNMAPPED_ID(mnt_idmap(mnt), inode)) in atime_needs_update()
1900 if (IS_NOATIME(inode)) in atime_needs_update()
1902 if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode)) in atime_needs_update()
1907 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) in atime_needs_update()
1910 now = current_time(inode); in atime_needs_update()
1912 if (!relatime_need_update(mnt, inode, now)) in atime_needs_update()
1915 if (timespec64_equal(&inode->i_atime, &now)) in atime_needs_update()
1924 struct inode *inode = d_inode(path->dentry); in touch_atime() local
1927 if (!atime_needs_update(path, inode)) in touch_atime()
1930 if (!sb_start_write_trylock(inode->i_sb)) in touch_atime()
1944 now = current_time(inode); in touch_atime()
1945 inode_update_time(inode, &now, S_ATIME); in touch_atime()
1948 sb_end_write(inode->i_sb); in touch_atime()
1960 struct inode *inode = d_inode(dentry); in dentry_needs_remove_privs() local
1964 if (IS_NOSEC(inode)) in dentry_needs_remove_privs()
1967 mask = setattr_should_drop_suidgid(idmap, inode); in dentry_needs_remove_privs()
1992 struct inode *inode = file_inode(file); in __file_remove_privs() local
1996 if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode)) in __file_remove_privs()
2011 inode_has_no_xattr(inode); in __file_remove_privs()
2030 static int inode_needs_update_time(struct inode *inode, struct timespec64 *now) in inode_needs_update_time() argument
2035 if (IS_NOCMTIME(inode)) in inode_needs_update_time()
2038 if (!timespec64_equal(&inode->i_mtime, now)) in inode_needs_update_time()
2041 if (!timespec64_equal(&inode->i_ctime, now)) in inode_needs_update_time()
2044 if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) in inode_needs_update_time()
2054 struct inode *inode = file_inode(file); in __file_update_time() local
2058 ret = inode_update_time(inode, now, sync_mode); in __file_update_time()
2082 struct inode *inode = file_inode(file); in file_update_time() local
2083 struct timespec64 now = current_time(inode); in file_update_time()
2085 ret = inode_needs_update_time(inode, &now); in file_update_time()
2111 struct inode *inode = file_inode(file); in file_modified_flags() local
2112 struct timespec64 now = current_time(inode); in file_modified_flags()
2125 ret = inode_needs_update_time(inode, &now); in file_modified_flags()
2168 int inode_needs_sync(struct inode *inode) in inode_needs_sync() argument
2170 if (IS_SYNC(inode)) in inode_needs_sync()
2172 if (S_ISDIR(inode->i_mode) && IS_DIRSYNC(inode)) in inode_needs_sync()
2189 static void __wait_on_freeing_inode(struct inode *inode) in __wait_on_freeing_inode() argument
2192 DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW); in __wait_on_freeing_inode()
2193 wq = bit_waitqueue(&inode->i_state, __I_NEW); in __wait_on_freeing_inode()
2195 spin_unlock(&inode->i_lock); in __wait_on_freeing_inode()
2239 sizeof(struct inode), in inode_init()
2261 void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) in init_special_inode() argument
2263 inode->i_mode = mode; in init_special_inode()
2265 inode->i_fop = &def_chr_fops; in init_special_inode()
2266 inode->i_rdev = rdev; in init_special_inode()
2268 inode->i_fop = &def_blk_fops; in init_special_inode()
2269 inode->i_rdev = rdev; in init_special_inode()
2271 inode->i_fop = &pipefifo_fops; in init_special_inode()
2276 " inode %s:%lu\n", mode, inode->i_sb->s_id, in init_special_inode()
2277 inode->i_ino); in init_special_inode()
2294 void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode, in inode_init_owner() argument
2295 const struct inode *dir, umode_t mode) in inode_init_owner()
2297 inode_fsuid_set(inode, idmap); in inode_init_owner()
2299 inode->i_gid = dir->i_gid; in inode_init_owner()
2305 inode_fsgid_set(inode, idmap); in inode_init_owner()
2306 inode->i_mode = mode; in inode_init_owner()
2325 const struct inode *inode) in inode_owner_or_capable() argument
2330 vfsuid = i_uid_into_vfsuid(idmap, inode); in inode_owner_or_capable()
2344 static void __inode_dio_wait(struct inode *inode) in __inode_dio_wait() argument
2346 wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); in __inode_dio_wait()
2347 DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); in __inode_dio_wait()
2351 if (atomic_read(&inode->i_dio_count)) in __inode_dio_wait()
2353 } while (atomic_read(&inode->i_dio_count)); in __inode_dio_wait()
2367 void inode_dio_wait(struct inode *inode) in inode_dio_wait() argument
2369 if (atomic_read(&inode->i_dio_count)) in inode_dio_wait()
2370 __inode_dio_wait(inode); in inode_dio_wait()
2390 void inode_set_flags(struct inode *inode, unsigned int flags, in inode_set_flags() argument
2394 set_mask_bits(&inode->i_flags, mask, flags); in inode_set_flags()
2398 void inode_nohighmem(struct inode *inode) in inode_nohighmem() argument
2400 mapping_set_gfp_mask(inode->i_mapping, GFP_USER); in inode_nohighmem()
2413 struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) in timestamp_truncate() argument
2415 struct super_block *sb = inode->i_sb; in timestamp_truncate()
2445 struct timespec64 current_time(struct inode *inode) in current_time() argument
2451 if (unlikely(!inode->i_sb)) { in current_time()
2456 return timestamp_truncate(now, inode); in current_time()
2473 const struct inode *inode, vfsgid_t vfsgid) in in_group_or_capable() argument
2477 if (capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID)) in in_group_or_capable()
2497 const struct inode *dir, umode_t mode) in mode_strip_sgid()