1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * The daemon that causes completed but not committed transactions
5 * on the MDS to be flushed periodically when they are committed.
6 * A gratuitous getattr RPC is made to the MDS to discover the
7 * last committed record.
9 * Lustre High Availability Daemon
11 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
13 * This code is issued under the GNU General Public License.
14 * See the file COPYING in this distribution
16 * by Peter Braam <braam@clusterfs.com>
22 #include <linux/version.h>
23 #include <linux/module.h>
25 #include <linux/stat.h>
26 #include <linux/sched.h>
27 #include <linux/smp_lock.h>
28 #include <linux/kmod.h>
29 #include <linux/quotaops.h>
30 #include <asm/unistd.h>
31 #include <asm/uaccess.h>
33 #define DEBUG_SUBSYSTEM S_LLITE
35 #include <linux/lustre_lite.h>
36 #include <linux/lustre_lib.h>
37 #include <linux/lustre_compat25.h>
39 static int ll_commitcbd_check_event(struct ll_sb_info *sbi)
44 spin_lock(&sbi->ll_commitcbd_lock);
45 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING)
50 spin_unlock(&sbi->ll_commitcbd_lock);
54 static int ll_commitcbd_main(void *arg)
56 struct ll_sb_info *sbi = (struct ll_sb_info *)arg;
61 kportal_daemonize("lustre_commitcbd");
63 SIGNAL_MASK_LOCK(current, flags);
64 sigfillset(¤t->blocked);
66 SIGNAL_MASK_UNLOCK(current, flags);
70 /* Record that the thread is running */
71 sbi->ll_commitcbd_waketime = LTIME_S(CURRENT_TIME);
72 sbi->ll_commitcbd_timeout = 10 * HZ;
73 sbi->ll_commitcbd_thread = current;
74 sbi->ll_commitcbd_flags = LL_COMMITCBD_RUNNING;
75 wake_up(&sbi->ll_commitcbd_ctl_waitq);
77 /* And now, loop forever on requests */
79 struct l_wait_info lwi = { 0 };
80 l_wait_event(sbi->ll_commitcbd_waitq,
81 ll_commitcbd_check_event(sbi), &lwi);
83 spin_lock(&sbi->ll_commitcbd_lock);
84 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) {
85 spin_unlock(&sbi->ll_commitcbd_lock);
86 CERROR("lustre_commitd quitting\n");
91 schedule_timeout(sbi->ll_commitcbd_timeout);
92 CERROR("commit callback daemon woken up - FIXME\n");
93 spin_unlock(&sbi->ll_commitcbd_lock);
96 sbi->ll_commitcbd_thread = NULL;
97 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPED;
98 wake_up(&sbi->ll_commitcbd_ctl_waitq);
99 CDEBUG(D_NET, "commit callback daemon exiting %d\n", current->pid);
105 int ll_commitcbd_setup(struct ll_sb_info *sbi)
108 struct l_wait_info lwi = { 0 };
111 rc = kernel_thread(ll_commitcbd_main, (void *) sbi,
112 CLONE_VM | CLONE_FS | CLONE_FILES);
114 CERROR("cannot start thread\n");
117 l_wait_event(sbi->ll_commitcbd_ctl_waitq,
118 sbi->ll_commitcbd_flags & LL_COMMITCBD_RUNNING, &lwi);
123 int ll_commitcbd_cleanup(struct ll_sb_info *sbi)
125 struct l_wait_info lwi = { 0 };
126 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPING;
128 wake_up(&sbi->ll_commitcbd_waitq);
129 l_wait_event(sbi->ll_commitcbd_ctl_waitq,
130 sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED, &lwi);