]>
Commit | Line | Data |
---|---|---|
b3b94faa DT |
1 | /* |
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
3a8a9a10 | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
b3b94faa DT |
4 | * |
5 | * This copyrighted material is made available to anyone wishing to use, | |
6 | * modify, copy, or redistribute it subject to the terms and conditions | |
e9fc2aa0 | 7 | * of the GNU General Public License version 2. |
b3b94faa DT |
8 | */ |
9 | ||
10 | #include <linux/sched.h> | |
11 | #include <linux/slab.h> | |
12 | #include <linux/spinlock.h> | |
13 | #include <linux/completion.h> | |
14 | #include <linux/buffer_head.h> | |
15 | #include <linux/kthread.h> | |
16 | #include <linux/delay.h> | |
5c676f6d | 17 | #include <linux/gfs2_ondisk.h> |
7d308590 | 18 | #include <linux/lm_interface.h> |
b3657629 | 19 | #include <linux/freezer.h> |
b3b94faa DT |
20 | |
21 | #include "gfs2.h" | |
5c676f6d | 22 | #include "incore.h" |
b3b94faa DT |
23 | #include "daemon.h" |
24 | #include "glock.h" | |
25 | #include "log.h" | |
26 | #include "quota.h" | |
27 | #include "recovery.h" | |
28 | #include "super.h" | |
5c676f6d | 29 | #include "util.h" |
b3b94faa DT |
30 | |
31 | /* This uses schedule_timeout() instead of msleep() because it's good for | |
32 | the daemons to wake up more often than the timeout when unmounting so | |
33 | the user's unmount doesn't sit there forever. | |
907b9bce | 34 | |
b3b94faa DT |
35 | The kthread functions used to start these daemons block and flush signals. */ |
36 | ||
b3b94faa DT |
37 | /** |
38 | * gfs2_glockd - Reclaim unused glock structures | |
39 | * @sdp: Pointer to GFS2 superblock | |
40 | * | |
41 | * One or more of these daemons run, reclaiming glocks on sd_reclaim_list. | |
42 | * Number of daemons can be set by user, with num_glockd mount option. | |
43 | */ | |
44 | ||
45 | int gfs2_glockd(void *data) | |
46 | { | |
b800a1cb | 47 | struct gfs2_sbd *sdp = data; |
b3b94faa DT |
48 | |
49 | while (!kthread_should_stop()) { | |
50 | while (atomic_read(&sdp->sd_reclaim_count)) | |
51 | gfs2_reclaim_glock(sdp); | |
52 | ||
b800a1cb SW |
53 | wait_event_interruptible(sdp->sd_reclaim_wq, |
54 | (atomic_read(&sdp->sd_reclaim_count) || | |
55 | kthread_should_stop())); | |
b3657629 AD |
56 | if (freezing(current)) |
57 | refrigerator(); | |
b3b94faa DT |
58 | } |
59 | ||
60 | return 0; | |
61 | } | |
62 | ||
63 | /** | |
64 | * gfs2_recoverd - Recover dead machine's journals | |
65 | * @sdp: Pointer to GFS2 superblock | |
66 | * | |
67 | */ | |
68 | ||
69 | int gfs2_recoverd(void *data) | |
70 | { | |
b800a1cb | 71 | struct gfs2_sbd *sdp = data; |
b3b94faa DT |
72 | unsigned long t; |
73 | ||
74 | while (!kthread_should_stop()) { | |
75 | gfs2_check_journals(sdp); | |
76 | t = gfs2_tune_get(sdp, gt_recoverd_secs) * HZ; | |
b3657629 AD |
77 | if (freezing(current)) |
78 | refrigerator(); | |
b3b94faa DT |
79 | schedule_timeout_interruptible(t); |
80 | } | |
81 | ||
82 | return 0; | |
83 | } | |
84 | ||
b3b94faa DT |
85 | /** |
86 | * gfs2_quotad - Write cached quota changes into the quota file | |
87 | * @sdp: Pointer to GFS2 superblock | |
88 | * | |
89 | */ | |
90 | ||
91 | int gfs2_quotad(void *data) | |
92 | { | |
b800a1cb | 93 | struct gfs2_sbd *sdp = data; |
b3b94faa DT |
94 | unsigned long t; |
95 | int error; | |
96 | ||
97 | while (!kthread_should_stop()) { | |
98 | /* Update the master statfs file */ | |
99 | ||
100 | t = sdp->sd_statfs_sync_time + | |
101 | gfs2_tune_get(sdp, gt_statfs_quantum) * HZ; | |
102 | ||
103 | if (time_after_eq(jiffies, t)) { | |
104 | error = gfs2_statfs_sync(sdp); | |
105 | if (error && | |
106 | error != -EROFS && | |
107 | !test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | |
108 | fs_err(sdp, "quotad: (1) error=%d\n", error); | |
109 | sdp->sd_statfs_sync_time = jiffies; | |
110 | } | |
111 | ||
112 | /* Update quota file */ | |
113 | ||
114 | t = sdp->sd_quota_sync_time + | |
115 | gfs2_tune_get(sdp, gt_quota_quantum) * HZ; | |
116 | ||
117 | if (time_after_eq(jiffies, t)) { | |
118 | error = gfs2_quota_sync(sdp); | |
119 | if (error && | |
120 | error != -EROFS && | |
121 | !test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | |
122 | fs_err(sdp, "quotad: (2) error=%d\n", error); | |
123 | sdp->sd_quota_sync_time = jiffies; | |
124 | } | |
125 | ||
126 | gfs2_quota_scan(sdp); | |
127 | ||
128 | t = gfs2_tune_get(sdp, gt_quotad_secs) * HZ; | |
b3657629 AD |
129 | if (freezing(current)) |
130 | refrigerator(); | |
b3b94faa DT |
131 | schedule_timeout_interruptible(t); |
132 | } | |
133 | ||
134 | return 0; | |
135 | } | |
136 |