|
Lines 54-59
Link Here
|
| 54 |
#include <linux/percpu.h> |
54 |
#include <linux/percpu.h> |
| 55 |
#include <linux/blkdev.h> |
55 |
#include <linux/blkdev.h> |
| 56 |
#include <linux/hash.h> |
56 |
#include <linux/hash.h> |
|
|
57 |
#include <linux/kthread.h> |
| 57 |
|
58 |
|
| 58 |
#include "xfs_linux.h" |
59 |
#include "xfs_linux.h" |
| 59 |
|
60 |
|
|
Lines 1733-1741
Link Here
|
| 1733 |
} |
1734 |
} |
| 1734 |
|
1735 |
|
| 1735 |
/* Defines for pagebuf daemon */ |
1736 |
/* Defines for pagebuf daemon */ |
| 1736 |
STATIC DECLARE_COMPLETION(xfsbufd_done); |
|
|
| 1737 |
STATIC struct task_struct *xfsbufd_task; |
1737 |
STATIC struct task_struct *xfsbufd_task; |
| 1738 |
STATIC int xfsbufd_active; |
|
|
| 1739 |
STATIC int xfsbufd_force_flush; |
1738 |
STATIC int xfsbufd_force_flush; |
| 1740 |
STATIC int xfsbufd_force_sleep; |
1739 |
STATIC int xfsbufd_force_sleep; |
| 1741 |
|
1740 |
|
|
Lines 1744-1753
Link Here
|
| 1744 |
int priority, |
1743 |
int priority, |
| 1745 |
unsigned int mask) |
1744 |
unsigned int mask) |
| 1746 |
{ |
1745 |
{ |
| 1747 |
if (xfsbufd_force_sleep) |
1746 |
if (xfsbufd_force_sleep || !priority) |
| 1748 |
return 0; |
1747 |
return 0; |
|
|
1748 |
if (!xfsbufd_task) { |
| 1749 |
WARN_ON(1); |
| 1750 |
return 0; |
| 1751 |
} |
| 1752 |
|
| 1749 |
xfsbufd_force_flush = 1; |
1753 |
xfsbufd_force_flush = 1; |
| 1750 |
barrier(); |
1754 |
wmb(); |
| 1751 |
wake_up_process(xfsbufd_task); |
1755 |
wake_up_process(xfsbufd_task); |
| 1752 |
return 0; |
1756 |
return 0; |
| 1753 |
} |
1757 |
} |
|
Lines 1761-1774
Link Here
|
| 1761 |
xfs_buftarg_t *target; |
1765 |
xfs_buftarg_t *target; |
| 1762 |
xfs_buf_t *pb, *n; |
1766 |
xfs_buf_t *pb, *n; |
| 1763 |
|
1767 |
|
| 1764 |
/* Set up the thread */ |
|
|
| 1765 |
daemonize("xfsbufd"); |
| 1766 |
current->flags |= PF_MEMALLOC; |
1768 |
current->flags |= PF_MEMALLOC; |
| 1767 |
|
1769 |
|
| 1768 |
xfsbufd_task = current; |
|
|
| 1769 |
xfsbufd_active = 1; |
| 1770 |
barrier(); |
| 1771 |
|
| 1772 |
INIT_LIST_HEAD(&tmp); |
1770 |
INIT_LIST_HEAD(&tmp); |
| 1773 |
do { |
1771 |
do { |
| 1774 |
if (unlikely(freezing(current))) { |
1772 |
if (unlikely(freezing(current))) { |
|
Lines 1816-1824
Link Here
|
| 1816 |
purge_addresses(); |
1814 |
purge_addresses(); |
| 1817 |
|
1815 |
|
| 1818 |
xfsbufd_force_flush = 0; |
1816 |
xfsbufd_force_flush = 0; |
| 1819 |
} while (xfsbufd_active); |
1817 |
} while (!kthread_should_stop()); |
| 1820 |
|
1818 |
|
| 1821 |
complete_and_exit(&xfsbufd_done, 0); |
1819 |
return 0; |
| 1822 |
} |
1820 |
} |
| 1823 |
|
1821 |
|
| 1824 |
/* |
1822 |
/* |
|
Lines 1901-1909
Link Here
|
| 1901 |
if (!xfsdatad_workqueue) |
1899 |
if (!xfsdatad_workqueue) |
| 1902 |
goto out_destroy_xfslogd_workqueue; |
1900 |
goto out_destroy_xfslogd_workqueue; |
| 1903 |
|
1901 |
|
| 1904 |
error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES); |
1902 |
xfsbufd_task = kthread_run(xfsbufd, NULL, "xfsbufd"); |
| 1905 |
if (error < 0) |
1903 |
if (IS_ERR(xfsbufd_task)) { |
|
|
1904 |
error = PTR_ERR(xfsbufd_task); |
| 1906 |
goto out_destroy_xfsdatad_workqueue; |
1905 |
goto out_destroy_xfsdatad_workqueue; |
|
|
1906 |
} |
| 1907 |
return 0; |
1907 |
return 0; |
| 1908 |
|
1908 |
|
| 1909 |
out_destroy_xfsdatad_workqueue: |
1909 |
out_destroy_xfsdatad_workqueue: |
|
Lines 1920-1929
Link Here
|
| 1920 |
STATIC void |
1920 |
STATIC void |
| 1921 |
xfs_buf_daemons_stop(void) |
1921 |
xfs_buf_daemons_stop(void) |
| 1922 |
{ |
1922 |
{ |
| 1923 |
xfsbufd_active = 0; |
1923 |
kthread_stop(xfsbufd_task); |
| 1924 |
barrier(); |
|
|
| 1925 |
wait_for_completion(&xfsbufd_done); |
| 1926 |
|
| 1927 |
destroy_workqueue(xfslogd_workqueue); |
1924 |
destroy_workqueue(xfslogd_workqueue); |
| 1928 |
destroy_workqueue(xfsdatad_workqueue); |
1925 |
destroy_workqueue(xfsdatad_workqueue); |
| 1929 |
} |
1926 |
} |