diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 157 |
1 files changed, 79 insertions, 78 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 997963e53622..df0cba239dd5 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -61,12 +61,13 @@ | |||
61 | * File wide globals | 61 | * File wide globals |
62 | */ | 62 | */ |
63 | 63 | ||
64 | STATIC kmem_cache_t *pagebuf_cache; | 64 | STATIC kmem_cache_t *pagebuf_zone; |
65 | STATIC kmem_shaker_t pagebuf_shake; | 65 | STATIC kmem_shaker_t pagebuf_shake; |
66 | STATIC int pagebuf_daemon_wakeup(int, unsigned int); | 66 | STATIC int xfsbufd_wakeup(int, unsigned int); |
67 | STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); | 67 | STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); |
68 | STATIC struct workqueue_struct *pagebuf_logio_workqueue; | 68 | |
69 | STATIC struct workqueue_struct *pagebuf_dataio_workqueue; | 69 | STATIC struct workqueue_struct *xfslogd_workqueue; |
70 | STATIC struct workqueue_struct *xfsdatad_workqueue; | ||
70 | 71 | ||
71 | /* | 72 | /* |
72 | * Pagebuf debugging | 73 | * Pagebuf debugging |
@@ -123,9 +124,9 @@ ktrace_t *pagebuf_trace_buf; | |||
123 | 124 | ||
124 | 125 | ||
125 | #define pagebuf_allocate(flags) \ | 126 | #define pagebuf_allocate(flags) \ |
126 | kmem_zone_alloc(pagebuf_cache, pb_to_km(flags)) | 127 | kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) |
127 | #define pagebuf_deallocate(pb) \ | 128 | #define pagebuf_deallocate(pb) \ |
128 | kmem_zone_free(pagebuf_cache, (pb)); | 129 | kmem_zone_free(pagebuf_zone, (pb)); |
129 | 130 | ||
130 | /* | 131 | /* |
131 | * Page Region interfaces. | 132 | * Page Region interfaces. |
@@ -425,7 +426,7 @@ _pagebuf_lookup_pages( | |||
425 | __FUNCTION__, gfp_mask); | 426 | __FUNCTION__, gfp_mask); |
426 | 427 | ||
427 | XFS_STATS_INC(pb_page_retries); | 428 | XFS_STATS_INC(pb_page_retries); |
428 | pagebuf_daemon_wakeup(0, gfp_mask); | 429 | xfsbufd_wakeup(0, gfp_mask); |
429 | blk_congestion_wait(WRITE, HZ/50); | 430 | blk_congestion_wait(WRITE, HZ/50); |
430 | goto retry; | 431 | goto retry; |
431 | } | 432 | } |
@@ -1136,8 +1137,8 @@ pagebuf_iodone( | |||
1136 | if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { | 1137 | if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { |
1137 | if (schedule) { | 1138 | if (schedule) { |
1138 | INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); | 1139 | INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); |
1139 | queue_work(dataio ? pagebuf_dataio_workqueue : | 1140 | queue_work(dataio ? xfsdatad_workqueue : |
1140 | pagebuf_logio_workqueue, &pb->pb_iodone_work); | 1141 | xfslogd_workqueue, &pb->pb_iodone_work); |
1141 | } else { | 1142 | } else { |
1142 | pagebuf_iodone_work(pb); | 1143 | pagebuf_iodone_work(pb); |
1143 | } | 1144 | } |
@@ -1562,16 +1563,6 @@ xfs_free_buftarg( | |||
1562 | kmem_free(btp, sizeof(*btp)); | 1563 | kmem_free(btp, sizeof(*btp)); |
1563 | } | 1564 | } |
1564 | 1565 | ||
1565 | void | ||
1566 | xfs_incore_relse( | ||
1567 | xfs_buftarg_t *btp, | ||
1568 | int delwri_only, | ||
1569 | int wait) | ||
1570 | { | ||
1571 | invalidate_bdev(btp->pbr_bdev, 1); | ||
1572 | truncate_inode_pages(btp->pbr_mapping, 0LL); | ||
1573 | } | ||
1574 | |||
1575 | STATIC int | 1566 | STATIC int |
1576 | xfs_setsize_buftarg_flags( | 1567 | xfs_setsize_buftarg_flags( |
1577 | xfs_buftarg_t *btp, | 1568 | xfs_buftarg_t *btp, |
@@ -1742,27 +1733,27 @@ pagebuf_runall_queues( | |||
1742 | } | 1733 | } |
1743 | 1734 | ||
1744 | /* Defines for pagebuf daemon */ | 1735 | /* Defines for pagebuf daemon */ |
1745 | STATIC DECLARE_COMPLETION(pagebuf_daemon_done); | 1736 | STATIC DECLARE_COMPLETION(xfsbufd_done); |
1746 | STATIC struct task_struct *pagebuf_daemon_task; | 1737 | STATIC struct task_struct *xfsbufd_task; |
1747 | STATIC int pagebuf_daemon_active; | 1738 | STATIC int xfsbufd_active; |
1748 | STATIC int force_flush; | 1739 | STATIC int xfsbufd_force_flush; |
1749 | STATIC int force_sleep; | 1740 | STATIC int xfsbufd_force_sleep; |
1750 | 1741 | ||
1751 | STATIC int | 1742 | STATIC int |
1752 | pagebuf_daemon_wakeup( | 1743 | xfsbufd_wakeup( |
1753 | int priority, | 1744 | int priority, |
1754 | unsigned int mask) | 1745 | unsigned int mask) |
1755 | { | 1746 | { |
1756 | if (force_sleep) | 1747 | if (xfsbufd_force_sleep) |
1757 | return 0; | 1748 | return 0; |
1758 | force_flush = 1; | 1749 | xfsbufd_force_flush = 1; |
1759 | barrier(); | 1750 | barrier(); |
1760 | wake_up_process(pagebuf_daemon_task); | 1751 | wake_up_process(xfsbufd_task); |
1761 | return 0; | 1752 | return 0; |
1762 | } | 1753 | } |
1763 | 1754 | ||
1764 | STATIC int | 1755 | STATIC int |
1765 | pagebuf_daemon( | 1756 | xfsbufd( |
1766 | void *data) | 1757 | void *data) |
1767 | { | 1758 | { |
1768 | struct list_head tmp; | 1759 | struct list_head tmp; |
@@ -1774,17 +1765,17 @@ pagebuf_daemon( | |||
1774 | daemonize("xfsbufd"); | 1765 | daemonize("xfsbufd"); |
1775 | current->flags |= PF_MEMALLOC; | 1766 | current->flags |= PF_MEMALLOC; |
1776 | 1767 | ||
1777 | pagebuf_daemon_task = current; | 1768 | xfsbufd_task = current; |
1778 | pagebuf_daemon_active = 1; | 1769 | xfsbufd_active = 1; |
1779 | barrier(); | 1770 | barrier(); |
1780 | 1771 | ||
1781 | INIT_LIST_HEAD(&tmp); | 1772 | INIT_LIST_HEAD(&tmp); |
1782 | do { | 1773 | do { |
1783 | if (unlikely(current->flags & PF_FREEZE)) { | 1774 | if (unlikely(freezing(current))) { |
1784 | force_sleep = 1; | 1775 | xfsbufd_force_sleep = 1; |
1785 | refrigerator(PF_FREEZE); | 1776 | refrigerator(); |
1786 | } else { | 1777 | } else { |
1787 | force_sleep = 0; | 1778 | xfsbufd_force_sleep = 0; |
1788 | } | 1779 | } |
1789 | 1780 | ||
1790 | set_current_state(TASK_INTERRUPTIBLE); | 1781 | set_current_state(TASK_INTERRUPTIBLE); |
@@ -1797,7 +1788,7 @@ pagebuf_daemon( | |||
1797 | ASSERT(pb->pb_flags & PBF_DELWRI); | 1788 | ASSERT(pb->pb_flags & PBF_DELWRI); |
1798 | 1789 | ||
1799 | if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) { | 1790 | if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) { |
1800 | if (!force_flush && | 1791 | if (!xfsbufd_force_flush && |
1801 | time_before(jiffies, | 1792 | time_before(jiffies, |
1802 | pb->pb_queuetime + age)) { | 1793 | pb->pb_queuetime + age)) { |
1803 | pagebuf_unlock(pb); | 1794 | pagebuf_unlock(pb); |
@@ -1824,10 +1815,10 @@ pagebuf_daemon( | |||
1824 | if (as_list_len > 0) | 1815 | if (as_list_len > 0) |
1825 | purge_addresses(); | 1816 | purge_addresses(); |
1826 | 1817 | ||
1827 | force_flush = 0; | 1818 | xfsbufd_force_flush = 0; |
1828 | } while (pagebuf_daemon_active); | 1819 | } while (xfsbufd_active); |
1829 | 1820 | ||
1830 | complete_and_exit(&pagebuf_daemon_done, 0); | 1821 | complete_and_exit(&xfsbufd_done, 0); |
1831 | } | 1822 | } |
1832 | 1823 | ||
1833 | /* | 1824 | /* |
@@ -1844,8 +1835,8 @@ xfs_flush_buftarg( | |||
1844 | xfs_buf_t *pb, *n; | 1835 | xfs_buf_t *pb, *n; |
1845 | int pincount = 0; | 1836 | int pincount = 0; |
1846 | 1837 | ||
1847 | pagebuf_runall_queues(pagebuf_dataio_workqueue); | 1838 | pagebuf_runall_queues(xfsdatad_workqueue); |
1848 | pagebuf_runall_queues(pagebuf_logio_workqueue); | 1839 | pagebuf_runall_queues(xfslogd_workqueue); |
1849 | 1840 | ||
1850 | INIT_LIST_HEAD(&tmp); | 1841 | INIT_LIST_HEAD(&tmp); |
1851 | spin_lock(&pbd_delwrite_lock); | 1842 | spin_lock(&pbd_delwrite_lock); |
@@ -1898,43 +1889,43 @@ xfs_flush_buftarg( | |||
1898 | } | 1889 | } |
1899 | 1890 | ||
1900 | STATIC int | 1891 | STATIC int |
1901 | pagebuf_daemon_start(void) | 1892 | xfs_buf_daemons_start(void) |
1902 | { | 1893 | { |
1903 | int rval; | 1894 | int error = -ENOMEM; |
1904 | 1895 | ||
1905 | pagebuf_logio_workqueue = create_workqueue("xfslogd"); | 1896 | xfslogd_workqueue = create_workqueue("xfslogd"); |
1906 | if (!pagebuf_logio_workqueue) | 1897 | if (!xfslogd_workqueue) |
1907 | return -ENOMEM; | 1898 | goto out; |
1908 | 1899 | ||
1909 | pagebuf_dataio_workqueue = create_workqueue("xfsdatad"); | 1900 | xfsdatad_workqueue = create_workqueue("xfsdatad"); |
1910 | if (!pagebuf_dataio_workqueue) { | 1901 | if (!xfsdatad_workqueue) |
1911 | destroy_workqueue(pagebuf_logio_workqueue); | 1902 | goto out_destroy_xfslogd_workqueue; |
1912 | return -ENOMEM; | ||
1913 | } | ||
1914 | 1903 | ||
1915 | rval = kernel_thread(pagebuf_daemon, NULL, CLONE_FS|CLONE_FILES); | 1904 | error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES); |
1916 | if (rval < 0) { | 1905 | if (error < 0) |
1917 | destroy_workqueue(pagebuf_logio_workqueue); | 1906 | goto out_destroy_xfsdatad_workqueue; |
1918 | destroy_workqueue(pagebuf_dataio_workqueue); | 1907 | return 0; |
1919 | } | ||
1920 | 1908 | ||
1921 | return rval; | 1909 | out_destroy_xfsdatad_workqueue: |
1910 | destroy_workqueue(xfsdatad_workqueue); | ||
1911 | out_destroy_xfslogd_workqueue: | ||
1912 | destroy_workqueue(xfslogd_workqueue); | ||
1913 | out: | ||
1914 | return error; | ||
1922 | } | 1915 | } |
1923 | 1916 | ||
1924 | /* | 1917 | /* |
1925 | * pagebuf_daemon_stop | ||
1926 | * | ||
1927 | * Note: do not mark as __exit, it is called from pagebuf_terminate. | 1918 | * Note: do not mark as __exit, it is called from pagebuf_terminate. |
1928 | */ | 1919 | */ |
1929 | STATIC void | 1920 | STATIC void |
1930 | pagebuf_daemon_stop(void) | 1921 | xfs_buf_daemons_stop(void) |
1931 | { | 1922 | { |
1932 | pagebuf_daemon_active = 0; | 1923 | xfsbufd_active = 0; |
1933 | barrier(); | 1924 | barrier(); |
1934 | wait_for_completion(&pagebuf_daemon_done); | 1925 | wait_for_completion(&xfsbufd_done); |
1935 | 1926 | ||
1936 | destroy_workqueue(pagebuf_logio_workqueue); | 1927 | destroy_workqueue(xfslogd_workqueue); |
1937 | destroy_workqueue(pagebuf_dataio_workqueue); | 1928 | destroy_workqueue(xfsdatad_workqueue); |
1938 | } | 1929 | } |
1939 | 1930 | ||
1940 | /* | 1931 | /* |
@@ -1944,27 +1935,37 @@ pagebuf_daemon_stop(void) | |||
1944 | int __init | 1935 | int __init |
1945 | pagebuf_init(void) | 1936 | pagebuf_init(void) |
1946 | { | 1937 | { |
1947 | pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0, | 1938 | int error = -ENOMEM; |
1948 | SLAB_HWCACHE_ALIGN, NULL, NULL); | 1939 | |
1949 | if (pagebuf_cache == NULL) { | 1940 | pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf"); |
1950 | printk("XFS: couldn't init xfs_buf_t cache\n"); | 1941 | if (!pagebuf_zone) |
1951 | pagebuf_terminate(); | 1942 | goto out; |
1952 | return -ENOMEM; | ||
1953 | } | ||
1954 | 1943 | ||
1955 | #ifdef PAGEBUF_TRACE | 1944 | #ifdef PAGEBUF_TRACE |
1956 | pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); | 1945 | pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); |
1957 | #endif | 1946 | #endif |
1958 | 1947 | ||
1959 | pagebuf_daemon_start(); | 1948 | error = xfs_buf_daemons_start(); |
1949 | if (error) | ||
1950 | goto out_free_buf_zone; | ||
1960 | 1951 | ||
1961 | pagebuf_shake = kmem_shake_register(pagebuf_daemon_wakeup); | 1952 | pagebuf_shake = kmem_shake_register(xfsbufd_wakeup); |
1962 | if (pagebuf_shake == NULL) { | 1953 | if (!pagebuf_shake) { |
1963 | pagebuf_terminate(); | 1954 | error = -ENOMEM; |
1964 | return -ENOMEM; | 1955 | goto out_stop_daemons; |
1965 | } | 1956 | } |
1966 | 1957 | ||
1967 | return 0; | 1958 | return 0; |
1959 | |||
1960 | out_stop_daemons: | ||
1961 | xfs_buf_daemons_stop(); | ||
1962 | out_free_buf_zone: | ||
1963 | #ifdef PAGEBUF_TRACE | ||
1964 | ktrace_free(pagebuf_trace_buf); | ||
1965 | #endif | ||
1966 | kmem_zone_destroy(pagebuf_zone); | ||
1967 | out: | ||
1968 | return error; | ||
1968 | } | 1969 | } |
1969 | 1970 | ||
1970 | 1971 | ||
@@ -1976,12 +1977,12 @@ pagebuf_init(void) | |||
1976 | void | 1977 | void |
1977 | pagebuf_terminate(void) | 1978 | pagebuf_terminate(void) |
1978 | { | 1979 | { |
1979 | pagebuf_daemon_stop(); | 1980 | xfs_buf_daemons_stop(); |
1980 | 1981 | ||
1981 | #ifdef PAGEBUF_TRACE | 1982 | #ifdef PAGEBUF_TRACE |
1982 | ktrace_free(pagebuf_trace_buf); | 1983 | ktrace_free(pagebuf_trace_buf); |
1983 | #endif | 1984 | #endif |
1984 | 1985 | ||
1985 | kmem_zone_destroy(pagebuf_cache); | 1986 | kmem_zone_destroy(pagebuf_zone); |
1986 | kmem_shake_deregister(pagebuf_shake); | 1987 | kmem_shake_deregister(pagebuf_shake); |
1987 | } | 1988 | } |