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" | |
b3b94faa DT |
26 | #include "recovery.h" |
27 | #include "super.h" | |
5c676f6d | 28 | #include "util.h" |
b3b94faa DT |
29 | |
30 | /* This uses schedule_timeout() instead of msleep() because it's good for | |
31 | the daemons to wake up more often than the timeout when unmounting so | |
32 | the user's unmount doesn't sit there forever. | |
907b9bce | 33 | |
b3b94faa DT |
34 | The kthread functions used to start these daemons block and flush signals. */ |
35 | ||
b3b94faa DT |
36 | /** |
37 | * gfs2_glockd - Reclaim unused glock structures | |
38 | * @sdp: Pointer to GFS2 superblock | |
39 | * | |
40 | * One or more of these daemons run, reclaiming glocks on sd_reclaim_list. | |
41 | * Number of daemons can be set by user, with num_glockd mount option. | |
42 | */ | |
43 | ||
44 | int gfs2_glockd(void *data) | |
45 | { | |
b800a1cb | 46 | struct gfs2_sbd *sdp = data; |
b3b94faa DT |
47 | |
48 | while (!kthread_should_stop()) { | |
49 | while (atomic_read(&sdp->sd_reclaim_count)) | |
50 | gfs2_reclaim_glock(sdp); | |
51 | ||
b800a1cb SW |
52 | wait_event_interruptible(sdp->sd_reclaim_wq, |
53 | (atomic_read(&sdp->sd_reclaim_count) || | |
54 | kthread_should_stop())); | |
b3657629 AD |
55 | if (freezing(current)) |
56 | refrigerator(); | |
b3b94faa DT |
57 | } |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
62 | /** | |
63 | * gfs2_recoverd - Recover dead machine's journals | |
64 | * @sdp: Pointer to GFS2 superblock | |
65 | * | |
66 | */ | |
67 | ||
68 | int gfs2_recoverd(void *data) | |
69 | { | |
b800a1cb | 70 | struct gfs2_sbd *sdp = data; |
b3b94faa DT |
71 | unsigned long t; |
72 | ||
73 | while (!kthread_should_stop()) { | |
74 | gfs2_check_journals(sdp); | |
75 | t = gfs2_tune_get(sdp, gt_recoverd_secs) * HZ; | |
b3657629 AD |
76 | if (freezing(current)) |
77 | refrigerator(); | |
b3b94faa DT |
78 | schedule_timeout_interruptible(t); |
79 | } | |
80 | ||
81 | return 0; | |
82 | } | |
83 |