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>
38 static int ll_commitcbd_check_event(struct ll_sb_info *sbi)
43 spin_lock(&sbi->ll_commitcbd_lock);
44 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING)
49 spin_unlock(&sbi->ll_commitcbd_lock);
53 static int ll_commitcbd_main(void *arg)
55 struct ll_sb_info *sbi = (struct ll_sb_info *)arg;
61 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
62 spin_lock_irqsave(¤t->sigmask_lock, flags);
63 sigfillset(¤t->blocked);
64 our_recalc_sigpending(current);
65 spin_unlock_irqrestore(¤t->sigmask_lock, flags);
67 sigfillset(¤t->blocked);
68 our_recalc_sigpending(current);
71 sprintf(current->comm, "lustre_commitcbd");
74 /* Record that the thread is running */
75 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
76 sbi->ll_commitcbd_waketime = CURRENT_TIME;
78 sbi->ll_commitcbd_waketime = CURRENT_TIME.tv_sec;
80 sbi->ll_commitcbd_timeout = 10 * HZ;
81 sbi->ll_commitcbd_thread = current;
82 sbi->ll_commitcbd_flags = LL_COMMITCBD_RUNNING;
83 wake_up(&sbi->ll_commitcbd_ctl_waitq);
85 /* And now, loop forever on requests */
87 struct l_wait_info lwi = { 0 };
88 l_wait_event(sbi->ll_commitcbd_waitq,
89 ll_commitcbd_check_event(sbi), &lwi);
91 spin_lock(&sbi->ll_commitcbd_lock);
92 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) {
93 spin_unlock(&sbi->ll_commitcbd_lock);
94 CERROR("lustre_commitd quitting\n");
99 schedule_timeout(sbi->ll_commitcbd_timeout);
100 CERROR("commit callback daemon woken up - FIXME\n");
101 spin_unlock(&sbi->ll_commitcbd_lock);
104 sbi->ll_commitcbd_thread = NULL;
105 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPED;
106 wake_up(&sbi->ll_commitcbd_ctl_waitq);
107 CDEBUG(D_NET, "commit callback daemon exiting %d\n", current->pid);
113 int ll_commitcbd_setup(struct ll_sb_info *sbi)
116 struct l_wait_info lwi = { 0 };
119 rc = kernel_thread(ll_commitcbd_main, (void *) sbi,
120 CLONE_VM | CLONE_FS | CLONE_FILES);
122 CERROR("cannot start thread\n");
125 l_wait_event(sbi->ll_commitcbd_ctl_waitq,
126 sbi->ll_commitcbd_flags & LL_COMMITCBD_RUNNING, &lwi);
131 int ll_commitcbd_cleanup(struct ll_sb_info *sbi)
133 struct l_wait_info lwi = { 0 };
134 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPING;
136 wake_up(&sbi->ll_commitcbd_waitq);
137 l_wait_event(sbi->ll_commitcbd_ctl_waitq,
138 sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED, &lwi);