aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-04-07 22:45:07 -0400
committerDave Chinner <david@fromorbit.com>2011-04-07 22:45:07 -0400
commit0bf6a5bd4b55b466964ead6fa566d8f346a828ee (patch)
tree661f2bcc36458c807752243c6f2a76b43a64302c /fs/xfs/linux-2.6
parenta7b339f1b8698667eada006e717cdb4523be2ed5 (diff)
xfs: convert the xfsaild threads to a workqueue
Similar to the xfssyncd, the per-filesystem xfsaild threads can be converted to a global workqueue and run periodically by delayed works. This makes sense for the AIL pushing because it uses variable timeouts depending on the work that needs to be done. By removing the xfsaild, we simplify the AIL pushing code and remove the need to spread the code to implement the threading and pushing across multiple files. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c127
1 files changed, 43 insertions, 84 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index ee0e981aa9d1..67d5b2cddb98 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -816,75 +816,6 @@ xfs_setup_devices(
816 return 0; 816 return 0;
817} 817}
818 818
819/*
820 * XFS AIL push thread support
821 */
822void
823xfsaild_wakeup(
824 struct xfs_ail *ailp,
825 xfs_lsn_t threshold_lsn)
826{
827 /* only ever move the target forwards */
828 if (XFS_LSN_CMP(threshold_lsn, ailp->xa_target) > 0) {
829 ailp->xa_target = threshold_lsn;
830 wake_up_process(ailp->xa_task);
831 }
832}
833
834STATIC int
835xfsaild(
836 void *data)
837{
838 struct xfs_ail *ailp = data;
839 xfs_lsn_t last_pushed_lsn = 0;
840 long tout = 0; /* milliseconds */
841
842 while (!kthread_should_stop()) {
843 /*
844 * for short sleeps indicating congestion, don't allow us to
845 * get woken early. Otherwise all we do is bang on the AIL lock
846 * without making progress.
847 */
848 if (tout && tout <= 20)
849 __set_current_state(TASK_KILLABLE);
850 else
851 __set_current_state(TASK_INTERRUPTIBLE);
852 schedule_timeout(tout ?
853 msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT);
854
855 /* swsusp */
856 try_to_freeze();
857
858 ASSERT(ailp->xa_mount->m_log);
859 if (XFS_FORCED_SHUTDOWN(ailp->xa_mount))
860 continue;
861
862 tout = xfsaild_push(ailp, &last_pushed_lsn);
863 }
864
865 return 0;
866} /* xfsaild */
867
868int
869xfsaild_start(
870 struct xfs_ail *ailp)
871{
872 ailp->xa_target = 0;
873 ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild/%s",
874 ailp->xa_mount->m_fsname);
875 if (IS_ERR(ailp->xa_task))
876 return -PTR_ERR(ailp->xa_task);
877 return 0;
878}
879
880void
881xfsaild_stop(
882 struct xfs_ail *ailp)
883{
884 kthread_stop(ailp->xa_task);
885}
886
887
888/* Catch misguided souls that try to use this interface on XFS */ 819/* Catch misguided souls that try to use this interface on XFS */
889STATIC struct inode * 820STATIC struct inode *
890xfs_fs_alloc_inode( 821xfs_fs_alloc_inode(
@@ -1786,6 +1717,38 @@ xfs_destroy_zones(void)
1786} 1717}
1787 1718
1788STATIC int __init 1719STATIC int __init
1720xfs_init_workqueues(void)
1721{
1722 /*
1723 * max_active is set to 8 to give enough concurency to allow
1724 * multiple work operations on each CPU to run. This allows multiple
1725 * filesystems to be running sync work concurrently, and scales with
1726 * the number of CPUs in the system.
1727 */
1728 xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_CPU_INTENSIVE, 8);
1729 if (!xfs_syncd_wq)
1730 goto out;
1731
1732 xfs_ail_wq = alloc_workqueue("xfsail", WQ_CPU_INTENSIVE, 8);
1733 if (!xfs_ail_wq)
1734 goto out_destroy_syncd;
1735
1736 return 0;
1737
1738out_destroy_syncd:
1739 destroy_workqueue(xfs_syncd_wq);
1740out:
1741 return -ENOMEM;
1742}
1743
1744STATIC void __exit
1745xfs_destroy_workqueues(void)
1746{
1747 destroy_workqueue(xfs_ail_wq);
1748 destroy_workqueue(xfs_syncd_wq);
1749}
1750
1751STATIC int __init
1789init_xfs_fs(void) 1752init_xfs_fs(void)
1790{ 1753{
1791 int error; 1754 int error;
@@ -1800,10 +1763,14 @@ init_xfs_fs(void)
1800 if (error) 1763 if (error)
1801 goto out; 1764 goto out;
1802 1765
1803 error = xfs_mru_cache_init(); 1766 error = xfs_init_workqueues();
1804 if (error) 1767 if (error)
1805 goto out_destroy_zones; 1768 goto out_destroy_zones;
1806 1769
1770 error = xfs_mru_cache_init();
1771 if (error)
1772 goto out_destroy_wq;
1773
1807 error = xfs_filestream_init(); 1774 error = xfs_filestream_init();
1808 if (error) 1775 if (error)
1809 goto out_mru_cache_uninit; 1776 goto out_mru_cache_uninit;
@@ -1820,27 +1787,17 @@ init_xfs_fs(void)
1820 if (error) 1787 if (error)
1821 goto out_cleanup_procfs; 1788 goto out_cleanup_procfs;
1822 1789
1823 /* 1790 error = xfs_init_workqueues();
1824 * max_active is set to 8 to give enough concurency to allow 1791 if (error)
1825 * multiple work operations on each CPU to run. This allows multiple
1826 * filesystems to be running sync work concurrently, and scales with
1827 * the number of CPUs in the system.
1828 */
1829 xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_CPU_INTENSIVE, 8);
1830 if (!xfs_syncd_wq) {
1831 error = -ENOMEM;
1832 goto out_sysctl_unregister; 1792 goto out_sysctl_unregister;
1833 }
1834 1793
1835 vfs_initquota(); 1794 vfs_initquota();
1836 1795
1837 error = register_filesystem(&xfs_fs_type); 1796 error = register_filesystem(&xfs_fs_type);
1838 if (error) 1797 if (error)
1839 goto out_destroy_xfs_syncd; 1798 goto out_sysctl_unregister;
1840 return 0; 1799 return 0;
1841 1800
1842 out_destroy_xfs_syncd:
1843 destroy_workqueue(xfs_syncd_wq);
1844 out_sysctl_unregister: 1801 out_sysctl_unregister:
1845 xfs_sysctl_unregister(); 1802 xfs_sysctl_unregister();
1846 out_cleanup_procfs: 1803 out_cleanup_procfs:
@@ -1851,6 +1808,8 @@ init_xfs_fs(void)
1851 xfs_filestream_uninit(); 1808 xfs_filestream_uninit();
1852 out_mru_cache_uninit: 1809 out_mru_cache_uninit:
1853 xfs_mru_cache_uninit(); 1810 xfs_mru_cache_uninit();
1811 out_destroy_wq:
1812 xfs_destroy_workqueues();
1854 out_destroy_zones: 1813 out_destroy_zones:
1855 xfs_destroy_zones(); 1814 xfs_destroy_zones();
1856 out: 1815 out:
@@ -1862,12 +1821,12 @@ exit_xfs_fs(void)
1862{ 1821{
1863 vfs_exitquota(); 1822 vfs_exitquota();
1864 unregister_filesystem(&xfs_fs_type); 1823 unregister_filesystem(&xfs_fs_type);
1865 destroy_workqueue(xfs_syncd_wq);
1866 xfs_sysctl_unregister(); 1824 xfs_sysctl_unregister();
1867 xfs_cleanup_procfs(); 1825 xfs_cleanup_procfs();
1868 xfs_buf_terminate(); 1826 xfs_buf_terminate();
1869 xfs_filestream_uninit(); 1827 xfs_filestream_uninit();
1870 xfs_mru_cache_uninit(); 1828 xfs_mru_cache_uninit();
1829 xfs_destroy_workqueues();
1871 xfs_destroy_zones(); 1830 xfs_destroy_zones();
1872} 1831}
1873 1832