aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2016-05-18 00:11:41 -0400
committerDave Chinner <david@fromorbit.com>2016-05-18 00:11:41 -0400
commit545c0889d26d47e1139c527002eb131343d13b63 (patch)
tree1ee76da796b161893b1228bc4a6fc136f3bc9c12 /fs/xfs
parent194293631d009254348f43710a7673bbb84a4172 (diff)
xfs: simplify inode reclaim tagging interfaces
Inode radix tree tagging for reclaim passes a lot of unnecessary variables around. Over time the xfs-perag has grown a xfs_mount backpointer, and an internal agno so we don't need to pass other variables into the tagging functions to supply this information. Rework the functions to pass the minimal variable set required and simplify the internal logic and flow. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_icache.c98
1 files changed, 50 insertions, 48 deletions
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 57fcd5917a66..789f8c32e65f 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -37,8 +37,7 @@
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/freezer.h> 38#include <linux/freezer.h>
39 39
40STATIC void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, 40STATIC void xfs_inode_clear_reclaim_tag(struct xfs_perag *pag, xfs_ino_t ino);
41 struct xfs_perag *pag, struct xfs_inode *ip);
42 41
43/* 42/*
44 * Allocate and initialise an xfs_inode. 43 * Allocate and initialise an xfs_inode.
@@ -271,7 +270,7 @@ xfs_iget_cache_hit(
271 */ 270 */
272 ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS; 271 ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS;
273 ip->i_flags |= XFS_INEW; 272 ip->i_flags |= XFS_INEW;
274 __xfs_inode_clear_reclaim_tag(mp, pag, ip); 273 xfs_inode_clear_reclaim_tag(pag, ip->i_ino);
275 inode->i_state = I_NEW; 274 inode->i_state = I_NEW;
276 275
277 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock)); 276 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
@@ -768,30 +767,46 @@ xfs_reclaim_worker(
768} 767}
769 768
770static void 769static void
771__xfs_inode_set_reclaim_tag( 770xfs_perag_set_reclaim_tag(
772 struct xfs_perag *pag, 771 struct xfs_perag *pag)
773 struct xfs_inode *ip)
774{ 772{
775 radix_tree_tag_set(&pag->pag_ici_root, 773 struct xfs_mount *mp = pag->pag_mount;
776 XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), 774
775 ASSERT(spin_is_locked(&pag->pag_ici_lock));
776 if (pag->pag_ici_reclaimable++)
777 return;
778
779 /* propagate the reclaim tag up into the perag radix tree */
780 spin_lock(&mp->m_perag_lock);
781 radix_tree_tag_set(&mp->m_perag_tree, pag->pag_agno,
777 XFS_ICI_RECLAIM_TAG); 782 XFS_ICI_RECLAIM_TAG);
783 spin_unlock(&mp->m_perag_lock);
778 784
779 if (!pag->pag_ici_reclaimable) { 785 /* schedule periodic background inode reclaim */
780 /* propagate the reclaim tag up into the perag radix tree */ 786 xfs_reclaim_work_queue(mp);
781 spin_lock(&ip->i_mount->m_perag_lock);
782 radix_tree_tag_set(&ip->i_mount->m_perag_tree, pag->pag_agno,
783 XFS_ICI_RECLAIM_TAG);
784 spin_unlock(&ip->i_mount->m_perag_lock);
785 787
786 /* schedule periodic background inode reclaim */ 788 trace_xfs_perag_set_reclaim(mp, pag->pag_agno, -1, _RET_IP_);
787 xfs_reclaim_work_queue(ip->i_mount); 789}
788 790
789 trace_xfs_perag_set_reclaim(ip->i_mount, pag->pag_agno, 791static void
790 -1, _RET_IP_); 792xfs_perag_clear_reclaim_tag(
791 } 793 struct xfs_perag *pag)
792 pag->pag_ici_reclaimable++; 794{
795 struct xfs_mount *mp = pag->pag_mount;
796
797 ASSERT(spin_is_locked(&pag->pag_ici_lock));
798 if (--pag->pag_ici_reclaimable)
799 return;
800
801 /* clear the reclaim tag from the perag radix tree */
802 spin_lock(&mp->m_perag_lock);
803 radix_tree_tag_clear(&mp->m_perag_tree, pag->pag_agno,
804 XFS_ICI_RECLAIM_TAG);
805 spin_unlock(&mp->m_perag_lock);
806 trace_xfs_perag_clear_reclaim(mp, pag->pag_agno, -1, _RET_IP_);
793} 807}
794 808
809
795/* 810/*
796 * We set the inode flag atomically with the radix tree tag. 811 * We set the inode flag atomically with the radix tree tag.
797 * Once we get tag lookups on the radix tree, this inode flag 812 * Once we get tag lookups on the radix tree, this inode flag
@@ -799,47 +814,34 @@ __xfs_inode_set_reclaim_tag(
799 */ 814 */
800void 815void
801xfs_inode_set_reclaim_tag( 816xfs_inode_set_reclaim_tag(
802 xfs_inode_t *ip) 817 struct xfs_inode *ip)
803{ 818{
804 struct xfs_mount *mp = ip->i_mount; 819 struct xfs_mount *mp = ip->i_mount;
805 struct xfs_perag *pag; 820 struct xfs_perag *pag;
806 821
807 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); 822 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
808 spin_lock(&pag->pag_ici_lock); 823 spin_lock(&pag->pag_ici_lock);
809 spin_lock(&ip->i_flags_lock); 824 spin_lock(&ip->i_flags_lock);
810 __xfs_inode_set_reclaim_tag(pag, ip); 825
826 radix_tree_tag_set(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino),
827 XFS_ICI_RECLAIM_TAG);
828 xfs_perag_set_reclaim_tag(pag);
811 __xfs_iflags_set(ip, XFS_IRECLAIMABLE); 829 __xfs_iflags_set(ip, XFS_IRECLAIMABLE);
830
812 spin_unlock(&ip->i_flags_lock); 831 spin_unlock(&ip->i_flags_lock);
813 spin_unlock(&pag->pag_ici_lock); 832 spin_unlock(&pag->pag_ici_lock);
814 xfs_perag_put(pag); 833 xfs_perag_put(pag);
815} 834}
816 835
817STATIC void 836STATIC void
818__xfs_inode_clear_reclaim( 837xfs_inode_clear_reclaim_tag(
819 xfs_perag_t *pag, 838 struct xfs_perag *pag,
820 xfs_inode_t *ip) 839 xfs_ino_t ino)
821{
822 pag->pag_ici_reclaimable--;
823 if (!pag->pag_ici_reclaimable) {
824 /* clear the reclaim tag from the perag radix tree */
825 spin_lock(&ip->i_mount->m_perag_lock);
826 radix_tree_tag_clear(&ip->i_mount->m_perag_tree, pag->pag_agno,
827 XFS_ICI_RECLAIM_TAG);
828 spin_unlock(&ip->i_mount->m_perag_lock);
829 trace_xfs_perag_clear_reclaim(ip->i_mount, pag->pag_agno,
830 -1, _RET_IP_);
831 }
832}
833
834STATIC void
835__xfs_inode_clear_reclaim_tag(
836 xfs_mount_t *mp,
837 xfs_perag_t *pag,
838 xfs_inode_t *ip)
839{ 840{
840 radix_tree_tag_clear(&pag->pag_ici_root, 841 radix_tree_tag_clear(&pag->pag_ici_root,
841 XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG); 842 XFS_INO_TO_AGINO(pag->pag_mount, ino),
842 __xfs_inode_clear_reclaim(pag, ip); 843 XFS_ICI_RECLAIM_TAG);
844 xfs_perag_clear_reclaim_tag(pag);
843} 845}
844 846
845/* 847/*
@@ -1030,7 +1032,7 @@ reclaim:
1030 if (!radix_tree_delete(&pag->pag_ici_root, 1032 if (!radix_tree_delete(&pag->pag_ici_root,
1031 XFS_INO_TO_AGINO(ip->i_mount, ino))) 1033 XFS_INO_TO_AGINO(ip->i_mount, ino)))
1032 ASSERT(0); 1034 ASSERT(0);
1033 __xfs_inode_clear_reclaim(pag, ip); 1035 xfs_perag_clear_reclaim_tag(pag);
1034 spin_unlock(&pag->pag_ici_lock); 1036 spin_unlock(&pag->pag_ici_lock);
1035 1037
1036 /* 1038 /*