Lines Matching +full:auto +full:- +full:detects

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
97 ip = alloc_inode_sb(mp->m_super, xfs_inode_cache, GFP_KERNEL | __GFP_NOFAIL); in xfs_inode_alloc()
99 if (inode_init_always(mp->m_super, VFS_I(ip))) { in xfs_inode_alloc()
105 VFS_I(ip)->i_mode = 0; in xfs_inode_alloc()
106 mapping_set_folio_min_order(VFS_I(ip)->i_mapping, in xfs_inode_alloc()
107 M_IGEO(mp)->min_folio_order); in xfs_inode_alloc()
110 ASSERT(atomic_read(&ip->i_pincount) == 0); in xfs_inode_alloc()
111 ASSERT(ip->i_ino == 0); in xfs_inode_alloc()
114 ip->i_ino = ino; in xfs_inode_alloc()
115 ip->i_mount = mp; in xfs_inode_alloc()
116 memset(&ip->i_imap, 0, sizeof(struct xfs_imap)); in xfs_inode_alloc()
117 ip->i_cowfp = NULL; in xfs_inode_alloc()
118 memset(&ip->i_af, 0, sizeof(ip->i_af)); in xfs_inode_alloc()
119 ip->i_af.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_inode_alloc()
120 memset(&ip->i_df, 0, sizeof(ip->i_df)); in xfs_inode_alloc()
121 ip->i_flags = 0; in xfs_inode_alloc()
122 ip->i_delayed_blks = 0; in xfs_inode_alloc()
123 ip->i_diflags2 = mp->m_ino_geo.new_diflags2; in xfs_inode_alloc()
124 ip->i_nblocks = 0; in xfs_inode_alloc()
125 ip->i_forkoff = 0; in xfs_inode_alloc()
126 ip->i_sick = 0; in xfs_inode_alloc()
127 ip->i_checked = 0; in xfs_inode_alloc()
128 INIT_WORK(&ip->i_ioend_work, xfs_end_io); in xfs_inode_alloc()
129 INIT_LIST_HEAD(&ip->i_ioend_list); in xfs_inode_alloc()
130 spin_lock_init(&ip->i_ioend_lock); in xfs_inode_alloc()
131 ip->i_next_unlinked = NULLAGINO; in xfs_inode_alloc()
132 ip->i_prev_unlinked = 0; in xfs_inode_alloc()
144 switch (VFS_I(ip)->i_mode & S_IFMT) { in xfs_inode_free_callback()
148 xfs_idestroy_fork(&ip->i_df); in xfs_inode_free_callback()
154 if (ip->i_cowfp) { in xfs_inode_free_callback()
155 xfs_idestroy_fork(ip->i_cowfp); in xfs_inode_free_callback()
156 kmem_cache_free(xfs_ifork_cache, ip->i_cowfp); in xfs_inode_free_callback()
158 if (ip->i_itemp) { in xfs_inode_free_callback()
160 &ip->i_itemp->ili_item.li_flags)); in xfs_inode_free_callback()
162 ip->i_itemp = NULL; in xfs_inode_free_callback()
173 ASSERT(atomic_read(&ip->i_pincount) == 0); in __xfs_inode_free()
174 ASSERT(!ip->i_itemp || list_empty(&ip->i_itemp->ili_item.li_bio_list)); in __xfs_inode_free()
175 XFS_STATS_DEC(ip->i_mount, vn_active); in __xfs_inode_free()
177 call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); in __xfs_inode_free()
189 * free state. The ip->i_flags_lock provides the barrier against lookup in xfs_inode_free()
192 spin_lock(&ip->i_flags_lock); in xfs_inode_free()
193 ip->i_flags = XFS_IRECLAIM; in xfs_inode_free()
194 ip->i_ino = 0; in xfs_inode_free()
195 spin_unlock(&ip->i_flags_lock); in xfs_inode_free()
211 queue_delayed_work(mp->m_reclaim_workqueue, &mp->m_reclaim_work, in xfs_reclaim_work_queue()
231 if (radix_tree_tagged(&pag->pag_ici_root, XFS_ICI_BLOCKGC_TAG)) in xfs_blockgc_queue()
232 queue_delayed_work(mp->m_blockgc_wq, &pag->pag_blockgc_work, in xfs_blockgc_queue()
246 lockdep_assert_held(&pag->pag_ici_lock); in xfs_perag_set_inode_tag()
248 was_tagged = radix_tree_tagged(&pag->pag_ici_root, tag); in xfs_perag_set_inode_tag()
249 radix_tree_tag_set(&pag->pag_ici_root, agino, tag); in xfs_perag_set_inode_tag()
252 pag->pag_ici_reclaimable++; in xfs_perag_set_inode_tag()
280 lockdep_assert_held(&pag->pag_ici_lock); in xfs_perag_clear_inode_tag()
287 radix_tree_tag_clear(&pag->pag_ici_root, agino, tag); in xfs_perag_clear_inode_tag()
292 pag->pag_ici_reclaimable--; in xfs_perag_clear_inode_tag()
294 if (radix_tree_tagged(&pag->pag_ici_root, tag)) in xfs_perag_clear_inode_tag()
317 * When we recycle a reclaimable inode, we need to re-initialise the VFS inode
319 * information about the on-disk values in the VFS inode and so we can't just
330 uint32_t nlink = inode->i_nlink; in xfs_reinit_inode()
331 uint32_t generation = inode->i_generation; in xfs_reinit_inode()
333 umode_t mode = inode->i_mode; in xfs_reinit_inode()
334 dev_t dev = inode->i_rdev; in xfs_reinit_inode()
335 kuid_t uid = inode->i_uid; in xfs_reinit_inode()
336 kgid_t gid = inode->i_gid; in xfs_reinit_inode()
337 unsigned long state = inode->i_state; in xfs_reinit_inode()
339 error = inode_init_always(mp->m_super, inode); in xfs_reinit_inode()
342 inode->i_generation = generation; in xfs_reinit_inode()
344 inode->i_mode = mode; in xfs_reinit_inode()
345 inode->i_rdev = dev; in xfs_reinit_inode()
346 inode->i_uid = uid; in xfs_reinit_inode()
347 inode->i_gid = gid; in xfs_reinit_inode()
348 inode->i_state = state; in xfs_reinit_inode()
349 mapping_set_folio_min_order(inode->i_mapping, in xfs_reinit_inode()
350 M_IGEO(mp)->min_folio_order); in xfs_reinit_inode()
361 struct xfs_inode *ip) __releases(&ip->i_flags_lock) in xfs_iget_recycle()
363 struct xfs_mount *mp = ip->i_mount; in xfs_iget_recycle()
370 return -EAGAIN; in xfs_iget_recycle()
378 ip->i_flags |= XFS_IRECLAIM; in xfs_iget_recycle()
380 spin_unlock(&ip->i_flags_lock); in xfs_iget_recycle()
383 ASSERT(!rwsem_is_locked(&inode->i_rwsem)); in xfs_iget_recycle()
388 * Re-initializing the inode failed, and we are in deep in xfs_iget_recycle()
389 * trouble. Try to re-add it to the reclaim list. in xfs_iget_recycle()
392 spin_lock(&ip->i_flags_lock); in xfs_iget_recycle()
393 ip->i_flags &= ~(XFS_INEW | XFS_IRECLAIM); in xfs_iget_recycle()
394 ASSERT(ip->i_flags & XFS_IRECLAIMABLE); in xfs_iget_recycle()
395 spin_unlock(&ip->i_flags_lock); in xfs_iget_recycle()
402 spin_lock(&pag->pag_ici_lock); in xfs_iget_recycle()
403 spin_lock(&ip->i_flags_lock); in xfs_iget_recycle()
406 * Clear the per-lifetime state in the inode as we are now effectively in xfs_iget_recycle()
410 ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS; in xfs_iget_recycle()
411 ip->i_flags |= XFS_INEW; in xfs_iget_recycle()
412 xfs_perag_clear_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), in xfs_iget_recycle()
414 inode->i_state = I_NEW; in xfs_iget_recycle()
415 spin_unlock(&ip->i_flags_lock); in xfs_iget_recycle()
416 spin_unlock(&pag->pag_ici_lock); in xfs_iget_recycle()
428 * -ENOENT if the inode is free and we are not allocating
429 * -EFSCORRUPTED if there is any state mismatch at all
438 if (VFS_I(ip)->i_mode != 0) { in xfs_iget_check_free_state()
439 xfs_warn(ip->i_mount, in xfs_iget_check_free_state()
441 ip->i_ino, VFS_I(ip)->i_mode); in xfs_iget_check_free_state()
442 xfs_agno_mark_sick(ip->i_mount, in xfs_iget_check_free_state()
443 XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), in xfs_iget_check_free_state()
445 return -EFSCORRUPTED; in xfs_iget_check_free_state()
448 if (ip->i_nblocks != 0) { in xfs_iget_check_free_state()
449 xfs_warn(ip->i_mount, in xfs_iget_check_free_state()
451 ip->i_ino); in xfs_iget_check_free_state()
452 xfs_agno_mark_sick(ip->i_mount, in xfs_iget_check_free_state()
453 XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), in xfs_iget_check_free_state()
455 return -EFSCORRUPTED; in xfs_iget_check_free_state()
461 if (VFS_I(ip)->i_mode == 0) in xfs_iget_check_free_state()
462 return -ENOENT; in xfs_iget_check_free_state()
476 for_each_cpu(cpu, &mp->m_inodegc_cpumask) { in xfs_inodegc_queue_all()
477 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_queue_all()
478 if (!llist_empty(&gc->list)) { in xfs_inodegc_queue_all()
479 mod_delayed_work_on(cpu, mp->m_inodegc_wq, &gc->work, 0); in xfs_inodegc_queue_all()
495 flush_workqueue(mp->m_inodegc_wq); in xfs_inodegc_wait_all()
496 for_each_cpu(cpu, &mp->m_inodegc_cpumask) { in xfs_inodegc_wait_all()
499 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_wait_all()
500 if (gc->error && !error) in xfs_inodegc_wait_all()
501 error = gc->error; in xfs_inodegc_wait_all()
502 gc->error = 0; in xfs_inodegc_wait_all()
520 struct xfs_mount *mp = ip->i_mount; in xfs_iget_cache_hit()
524 * check for re-use of an inode within an RCU grace period due to the in xfs_iget_cache_hit()
530 spin_lock(&ip->i_flags_lock); in xfs_iget_cache_hit()
531 if (ip->i_ino != ino) in xfs_iget_cache_hit()
552 if (ip->i_flags & (XFS_INEW | XFS_IRECLAIM | XFS_INACTIVATING)) in xfs_iget_cache_hit()
555 if (ip->i_flags & XFS_NEED_INACTIVE) { in xfs_iget_cache_hit()
556 /* Unlinked inodes cannot be re-grabbed. */ in xfs_iget_cache_hit()
557 if (VFS_I(ip)->i_nlink == 0) { in xfs_iget_cache_hit()
558 error = -ENOENT; in xfs_iget_cache_hit()
565 * Check the inode free state is valid. This also detects lookup in xfs_iget_cache_hit()
574 (ip->i_flags & XFS_IRECLAIMABLE)) in xfs_iget_cache_hit()
578 if (ip->i_flags & XFS_IRECLAIMABLE) { in xfs_iget_cache_hit()
581 if (error == -EAGAIN) in xfs_iget_cache_hit()
591 spin_unlock(&ip->i_flags_lock); in xfs_iget_cache_hit()
608 error = -EAGAIN; in xfs_iget_cache_hit()
610 spin_unlock(&ip->i_flags_lock); in xfs_iget_cache_hit()
615 spin_unlock(&ip->i_flags_lock); in xfs_iget_cache_hit()
623 return -EAGAIN; in xfs_iget_cache_hit()
642 return -ENOMEM; in xfs_iget_cache_miss()
644 error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, flags); in xfs_iget_cache_miss()
654 * the i_flushiter field being initialised from the current on-disk in xfs_iget_cache_miss()
660 VFS_I(ip)->i_generation = get_random_u32(); in xfs_iget_cache_miss()
664 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp); in xfs_iget_cache_miss()
669 xfs_buf_offset(bp, ip->i_imap.im_boffset)); in xfs_iget_cache_miss()
683 * Check the inode free state is valid. This also detects lookup in xfs_iget_cache_miss()
696 error = -EAGAIN; in xfs_iget_cache_miss()
701 * Because the inode hasn't been added to the radix-tree yet it can't in xfs_iget_cache_miss()
702 * be found by another thread, so we can do the non-sleeping lock here. in xfs_iget_cache_miss()
714 * The ip->i_flags_lock that protects the XFS_INEW flag forms the in xfs_iget_cache_miss()
720 ip->i_udquot = NULL; in xfs_iget_cache_miss()
721 ip->i_gdquot = NULL; in xfs_iget_cache_miss()
722 ip->i_pdquot = NULL; in xfs_iget_cache_miss()
726 spin_lock(&pag->pag_ici_lock); in xfs_iget_cache_miss()
727 error = radix_tree_insert(&pag->pag_ici_root, agino, ip); in xfs_iget_cache_miss()
729 WARN_ON(error != -EEXIST); in xfs_iget_cache_miss()
731 error = -EAGAIN; in xfs_iget_cache_miss()
734 spin_unlock(&pag->pag_ici_lock); in xfs_iget_cache_miss()
741 spin_unlock(&pag->pag_ici_lock); in xfs_iget_cache_miss()
781 return -EINVAL; in xfs_iget()
792 ip = radix_tree_lookup(&pag->pag_ici_root, agino); in xfs_iget()
801 error = -ENODATA; in xfs_iget()
816 * If we have a real type for an on-disk inode, we can setup the inode in xfs_iget()
820 if (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0) in xfs_iget()
826 error == -EAGAIN) { in xfs_iget()
847 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_metafile_iget()
853 if (error == -EFSCORRUPTED || error == -EINVAL) in xfs_trans_metafile_iget()
858 if (VFS_I(ip)->i_nlink == 0) in xfs_trans_metafile_iget()
870 if (metafile_type != ip->i_metatype) in xfs_trans_metafile_iget()
882 return -EFSCORRUPTED; in xfs_trans_metafile_iget()
929 spin_lock(&ip->i_flags_lock); in xfs_reclaim_igrab()
933 spin_unlock(&ip->i_flags_lock); in xfs_reclaim_igrab()
938 if (ip->i_sick && in xfs_reclaim_igrab()
939 (!icw || !(icw->icw_flags & XFS_ICWALK_FLAG_RECLAIM_SICK))) { in xfs_reclaim_igrab()
940 spin_unlock(&ip->i_flags_lock); in xfs_reclaim_igrab()
945 spin_unlock(&ip->i_flags_lock); in xfs_reclaim_igrab()
950 * Inode reclaim is non-blocking, so the default action if progress cannot be
956 * We do no IO here - if callers require inodes to be cleaned they must push the
958 * done in the background in a non-blocking manner, and enables memory reclaim
966 xfs_ino_t ino = ip->i_ino; /* for radix_tree_delete */ in xfs_reclaim_inode()
977 * then the in-memory log tail movement caused by the abort can be in xfs_reclaim_inode()
980 if (xlog_is_shutdown(ip->i_mount->m_log)) { in xfs_reclaim_inode()
1004 spin_lock(&ip->i_flags_lock); in xfs_reclaim_inode()
1005 ip->i_flags = XFS_IRECLAIM; in xfs_reclaim_inode()
1006 ip->i_ino = 0; in xfs_reclaim_inode()
1007 ip->i_sick = 0; in xfs_reclaim_inode()
1008 ip->i_checked = 0; in xfs_reclaim_inode()
1009 spin_unlock(&ip->i_flags_lock); in xfs_reclaim_inode()
1011 ASSERT(!ip->i_itemp || ip->i_itemp->ili_item.li_buf == NULL); in xfs_reclaim_inode()
1014 XFS_STATS_INC(ip->i_mount, xs_ig_reclaims); in xfs_reclaim_inode()
1016 * Remove the inode from the per-AG radix tree. in xfs_reclaim_inode()
1022 spin_lock(&pag->pag_ici_lock); in xfs_reclaim_inode()
1023 if (!radix_tree_delete(&pag->pag_ici_root, in xfs_reclaim_inode()
1024 XFS_INO_TO_AGINO(ip->i_mount, ino))) in xfs_reclaim_inode()
1027 spin_unlock(&pag->pag_ici_lock); in xfs_reclaim_inode()
1038 ASSERT(!ip->i_udquot && !ip->i_gdquot && !ip->i_pdquot); in xfs_reclaim_inode()
1074 xfs_ail_push_all_sync(mp->m_ail); in xfs_reclaim_inodes()
1101 xfs_ail_push_all(mp->m_ail); in xfs_reclaim_inodes_nr()
1115 XA_STATE (xas, &mp->m_groups[XG_TYPE_AG].xa, 0); in xfs_reclaim_inodes_count()
1122 reclaimable += pag->pag_ici_reclaimable; in xfs_reclaim_inodes_count()
1134 if ((icw->icw_flags & XFS_ICWALK_FLAG_UID) && in xfs_icwalk_match_id()
1135 !uid_eq(VFS_I(ip)->i_uid, icw->icw_uid)) in xfs_icwalk_match_id()
1138 if ((icw->icw_flags & XFS_ICWALK_FLAG_GID) && in xfs_icwalk_match_id()
1139 !gid_eq(VFS_I(ip)->i_gid, icw->icw_gid)) in xfs_icwalk_match_id()
1142 if ((icw->icw_flags & XFS_ICWALK_FLAG_PRID) && in xfs_icwalk_match_id()
1143 ip->i_projid != icw->icw_prid) in xfs_icwalk_match_id()
1150 * A union-based inode filtering algorithm. Process the inode if any of the
1158 if ((icw->icw_flags & XFS_ICWALK_FLAG_UID) && in xfs_icwalk_match_id_union()
1159 uid_eq(VFS_I(ip)->i_uid, icw->icw_uid)) in xfs_icwalk_match_id_union()
1162 if ((icw->icw_flags & XFS_ICWALK_FLAG_GID) && in xfs_icwalk_match_id_union()
1163 gid_eq(VFS_I(ip)->i_gid, icw->icw_gid)) in xfs_icwalk_match_id_union()
1166 if ((icw->icw_flags & XFS_ICWALK_FLAG_PRID) && in xfs_icwalk_match_id_union()
1167 ip->i_projid == icw->icw_prid) in xfs_icwalk_match_id_union()
1188 if (icw->icw_flags & XFS_ICWALK_FLAG_UNION) in xfs_icwalk_match()
1196 if ((icw->icw_flags & XFS_ICWALK_FLAG_MINFILESIZE) && in xfs_icwalk_match()
1197 XFS_ISIZE(ip) < icw->icw_min_file_size) in xfs_icwalk_match()
1228 wait = icw && (icw->icw_flags & XFS_ICWALK_FLAG_SYNC); in xfs_inode_free_eofblocks()
1237 if (!wait && mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY)) in xfs_inode_free_eofblocks()
1244 * If the caller is waiting, return -EAGAIN to keep the background in xfs_inode_free_eofblocks()
1249 return -EAGAIN; in xfs_inode_free_eofblocks()
1268 struct xfs_mount *mp = ip->i_mount; in xfs_blockgc_set_iflag()
1277 if (ip->i_flags & iflag) in xfs_blockgc_set_iflag()
1279 spin_lock(&ip->i_flags_lock); in xfs_blockgc_set_iflag()
1280 ip->i_flags |= iflag; in xfs_blockgc_set_iflag()
1281 spin_unlock(&ip->i_flags_lock); in xfs_blockgc_set_iflag()
1283 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_blockgc_set_iflag()
1284 spin_lock(&pag->pag_ici_lock); in xfs_blockgc_set_iflag()
1286 xfs_perag_set_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), in xfs_blockgc_set_iflag()
1289 spin_unlock(&pag->pag_ici_lock); in xfs_blockgc_set_iflag()
1306 struct xfs_mount *mp = ip->i_mount; in xfs_blockgc_clear_iflag()
1312 spin_lock(&ip->i_flags_lock); in xfs_blockgc_clear_iflag()
1313 ip->i_flags &= ~iflag; in xfs_blockgc_clear_iflag()
1314 clear_tag = (ip->i_flags & (XFS_IEOFBLOCKS | XFS_ICOWBLOCKS)) == 0; in xfs_blockgc_clear_iflag()
1315 spin_unlock(&ip->i_flags_lock); in xfs_blockgc_clear_iflag()
1320 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_blockgc_clear_iflag()
1321 spin_lock(&pag->pag_ici_lock); in xfs_blockgc_clear_iflag()
1323 xfs_perag_clear_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), in xfs_blockgc_clear_iflag()
1326 spin_unlock(&pag->pag_ici_lock); in xfs_blockgc_clear_iflag()
1348 sync = icw && (icw->icw_flags & XFS_ICWALK_FLAG_SYNC); in xfs_prep_free_cowblocks()
1365 * in-flight I/O under any circumstances, because outstanding writeback in xfs_prep_free_cowblocks()
1370 * currently opened for write from background (i.e. non-sync) scans. For in xfs_prep_free_cowblocks()
1400 wait = icw && (icw->icw_flags & XFS_ICWALK_FLAG_SYNC); in xfs_inode_free_cowblocks()
1412 * If the caller is waiting, return -EAGAIN to keep the background in xfs_inode_free_cowblocks()
1418 return -EAGAIN; in xfs_inode_free_cowblocks()
1425 return -EAGAIN; in xfs_inode_free_cowblocks()
1455 /* Disable post-EOF and CoW block auto-reclamation. */
1466 cancel_delayed_work_sync(&pag->pag_blockgc_work); in xfs_blockgc_stop()
1470 /* Enable post-EOF and CoW block auto-reclamation. */
1505 spin_lock(&ip->i_flags_lock); in xfs_blockgc_igrab()
1506 if (!ip->i_ino) in xfs_blockgc_igrab()
1509 if (ip->i_flags & XFS_BLOCKGC_NOGRAB_IFLAGS) in xfs_blockgc_igrab()
1511 spin_unlock(&ip->i_flags_lock); in xfs_blockgc_igrab()
1514 if (xfs_is_shutdown(ip->i_mount)) in xfs_blockgc_igrab()
1525 spin_unlock(&ip->i_flags_lock); in xfs_blockgc_igrab()
1606 mod_delayed_work(mp->m_blockgc_wq, &pag->pag_blockgc_work, 0); in xfs_blockgc_flush_all()
1609 flush_delayed_work(&pag->pag_blockgc_work); in xfs_blockgc_flush_all()
1645 icw.icw_uid = make_kuid(mp->m_super->s_user_ns, udqp->q_id); in xfs_blockgc_free_dquots()
1651 icw.icw_gid = make_kgid(mp->m_super->s_user_ns, gdqp->q_id); in xfs_blockgc_free_dquots()
1657 icw.icw_prid = pdqp->q_id; in xfs_blockgc_free_dquots()
1674 return xfs_blockgc_free_dquots(ip->i_mount, in xfs_blockgc_free_quota()
1713 * made by the icwalk igrab function. Return -EAGAIN to skip an inode.
1736 * For a given per-AG structure @pag and a goal, grab qualifying inodes and
1756 first_index = READ_ONCE(pag->pag_ici_reclaim_cursor); in xfs_icwalk_ag()
1767 nr_found = radix_tree_gang_lookup_tag(&pag->pag_ici_root, in xfs_icwalk_ag()
1798 if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag)) in xfs_icwalk_ag()
1800 first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1); in xfs_icwalk_ag()
1801 if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) in xfs_icwalk_ag()
1813 if (error == -EAGAIN) { in xfs_icwalk_ag()
1817 if (error && last_error != -EFSCORRUPTED) in xfs_icwalk_ag()
1822 if (error == -EFSCORRUPTED) in xfs_icwalk_ag()
1827 if (icw && (icw->icw_flags & XFS_ICWALK_FLAG_SCAN_LIMIT)) { in xfs_icwalk_ag()
1828 icw->icw_scan_limit -= XFS_LOOKUP_BATCH; in xfs_icwalk_ag()
1829 if (icw->icw_scan_limit <= 0) in xfs_icwalk_ag()
1837 WRITE_ONCE(pag->pag_ici_reclaim_cursor, first_index); in xfs_icwalk_ag()
1862 if (error == -EFSCORRUPTED) { in xfs_icwalk()
1886 xfs_warn(ip->i_mount, in xfs_check_delalloc()
1888 ip->i_ino, in xfs_check_delalloc()
1903 struct xfs_mount *mp = ip->i_mount; in xfs_inodegc_set_reclaimable()
1906 if (!xfs_is_shutdown(mp) && ip->i_delayed_blks) { in xfs_inodegc_set_reclaimable()
1912 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_inodegc_set_reclaimable()
1913 spin_lock(&pag->pag_ici_lock); in xfs_inodegc_set_reclaimable()
1914 spin_lock(&ip->i_flags_lock); in xfs_inodegc_set_reclaimable()
1917 ip->i_flags &= ~(XFS_NEED_INACTIVE | XFS_INACTIVATING); in xfs_inodegc_set_reclaimable()
1918 ip->i_flags |= XFS_IRECLAIMABLE; in xfs_inodegc_set_reclaimable()
1919 xfs_perag_set_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), in xfs_inodegc_set_reclaimable()
1922 spin_unlock(&ip->i_flags_lock); in xfs_inodegc_set_reclaimable()
1923 spin_unlock(&pag->pag_ici_lock); in xfs_inodegc_set_reclaimable()
1951 struct llist_node *node = llist_del_all(&gc->list); in xfs_inodegc_worker()
1953 struct xfs_mount *mp = gc->mp; in xfs_inodegc_worker()
1962 cpumask_clear_cpu(gc->cpu, &mp->m_inodegc_cpumask); in xfs_inodegc_worker()
1965 WRITE_ONCE(gc->items, 0); in xfs_inodegc_worker()
1973 * task-wide nofs context for the following operations. in xfs_inodegc_worker()
1978 trace_xfs_inodegc_worker(mp, READ_ONCE(gc->shrinker_hits)); in xfs_inodegc_worker()
1980 WRITE_ONCE(gc->shrinker_hits, 0); in xfs_inodegc_worker()
1986 if (error && !gc->error) in xfs_inodegc_worker()
1987 gc->error = error; in xfs_inodegc_worker()
2022 * workers and wait for them to stop. Caller must hold sb->s_umount to
2046 flush_workqueue(mp->m_inodegc_wq); in xfs_inodegc_stop()
2055 * inactivation work if there is any. Caller must hold sb->s_umount to
2074 struct xfs_mount *mp = ip->i_mount; in xfs_inodegc_want_queue_rt_file()
2079 if (__percpu_counter_compare(&mp->m_frextents, in xfs_inodegc_want_queue_rt_file()
2080 mp->m_low_rtexts[XFS_LOWSP_5_PCNT], in xfs_inodegc_want_queue_rt_file()
2093 * - We've accumulated more than one inode cluster buffer's worth of inodes.
2094 * - There is less than 5% free space left.
2095 * - Any of the quotas for this inode are near an enforcement limit.
2102 struct xfs_mount *mp = ip->i_mount; in xfs_inodegc_want_queue_work()
2104 if (items > mp->m_ino_geo.inodes_per_cluster) in xfs_inodegc_want_queue_work()
2107 if (__percpu_counter_compare(&mp->m_fdblocks, in xfs_inodegc_want_queue_work()
2108 mp->m_low_space[XFS_LOWSP_5_PCNT], in xfs_inodegc_want_queue_work()
2136 * - Memory shrinkers queued the inactivation worker and it hasn't finished.
2137 * - The queue depth exceeds the maximum allowable percpu backlog.
2150 if (current->flags & PF_MEMALLOC_NOFS) in xfs_inodegc_want_flush_work()
2171 struct xfs_mount *mp = ip->i_mount; in xfs_inodegc_queue()
2179 spin_lock(&ip->i_flags_lock); in xfs_inodegc_queue()
2180 ip->i_flags |= XFS_NEED_INACTIVE; in xfs_inodegc_queue()
2181 spin_unlock(&ip->i_flags_lock); in xfs_inodegc_queue()
2184 gc = this_cpu_ptr(mp->m_inodegc); in xfs_inodegc_queue()
2185 llist_add(&ip->i_gclist, &gc->list); in xfs_inodegc_queue()
2186 items = READ_ONCE(gc->items); in xfs_inodegc_queue()
2187 WRITE_ONCE(gc->items, items + 1); in xfs_inodegc_queue()
2188 shrinker_hits = READ_ONCE(gc->shrinker_hits); in xfs_inodegc_queue()
2196 if (!cpumask_test_cpu(cpu_nr, &mp->m_inodegc_cpumask)) in xfs_inodegc_queue()
2197 cpumask_test_and_set_cpu(cpu_nr, &mp->m_inodegc_cpumask); in xfs_inodegc_queue()
2212 mod_delayed_work_on(current_cpu(), mp->m_inodegc_wq, &gc->work, in xfs_inodegc_queue()
2218 flush_delayed_work(&gc->work); in xfs_inodegc_queue()
2236 struct xfs_mount *mp = ip->i_mount; in xfs_inode_mark_reclaimable()
2275 struct xfs_mount *mp = shrink->private_data; in xfs_inodegc_shrinker_count()
2282 for_each_cpu(cpu, &mp->m_inodegc_cpumask) { in xfs_inodegc_shrinker_count()
2283 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_shrinker_count()
2284 if (!llist_empty(&gc->list)) in xfs_inodegc_shrinker_count()
2296 struct xfs_mount *mp = shrink->private_data; in xfs_inodegc_shrinker_scan()
2306 for_each_cpu(cpu, &mp->m_inodegc_cpumask) { in xfs_inodegc_shrinker_scan()
2307 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_shrinker_scan()
2308 if (!llist_empty(&gc->list)) { in xfs_inodegc_shrinker_scan()
2309 unsigned int h = READ_ONCE(gc->shrinker_hits); in xfs_inodegc_shrinker_scan()
2311 WRITE_ONCE(gc->shrinker_hits, h + 1); in xfs_inodegc_shrinker_scan()
2312 mod_delayed_work_on(cpu, mp->m_inodegc_wq, &gc->work, 0); in xfs_inodegc_shrinker_scan()
2332 mp->m_inodegc_shrinker = shrinker_alloc(SHRINKER_NONSLAB, in xfs_inodegc_register_shrinker()
2333 "xfs-inodegc:%s", in xfs_inodegc_register_shrinker()
2334 mp->m_super->s_id); in xfs_inodegc_register_shrinker()
2335 if (!mp->m_inodegc_shrinker) in xfs_inodegc_register_shrinker()
2336 return -ENOMEM; in xfs_inodegc_register_shrinker()
2338 mp->m_inodegc_shrinker->count_objects = xfs_inodegc_shrinker_count; in xfs_inodegc_register_shrinker()
2339 mp->m_inodegc_shrinker->scan_objects = xfs_inodegc_shrinker_scan; in xfs_inodegc_register_shrinker()
2340 mp->m_inodegc_shrinker->seeks = 0; in xfs_inodegc_register_shrinker()
2341 mp->m_inodegc_shrinker->batch = XFS_INODEGC_SHRINKER_BATCH; in xfs_inodegc_register_shrinker()
2342 mp->m_inodegc_shrinker->private_data = mp; in xfs_inodegc_register_shrinker()
2344 shrinker_register(mp->m_inodegc_shrinker); in xfs_inodegc_register_shrinker()