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/locks.h>
27 #include <linux/kmod.h>
28 #include <linux/quotaops.h>
29 #include <asm/unistd.h>
30 #include <asm/uaccess.h>
32 #define DEBUG_SUBSYSTEM S_LLITE
34 #include <linux/lustre_lite.h>
35 #include <linux/lustre_lib.h>
37 static int ll_commitcbd_check_event(struct ll_sb_info *sbi)
42 spin_lock(&sbi->ll_commitcbd_lock);
43 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) {
48 spin_unlock(&sbi->ll_commitcbd_lock);
52 static int ll_commitcbd_main(void *arg)
54 struct ll_sb_info *sbi = (struct ll_sb_info *)arg;
60 spin_lock_irq(¤t->sigmask_lock);
61 sigfillset(¤t->blocked);
62 recalc_sigpending(current);
63 spin_unlock_irq(¤t->sigmask_lock);
65 sprintf(current->comm, "lustre_commitcbd");
67 /* Record that the thread is running */
68 sbi->ll_commitcbd_waketime = CURRENT_TIME;
69 sbi->ll_commitcbd_timeout = 10 * HZ;
70 sbi->ll_commitcbd_thread = current;
71 sbi->ll_commitcbd_flags = LL_COMMITCBD_RUNNING;
72 wake_up(&sbi->ll_commitcbd_ctl_waitq);
74 /* And now, loop forever on requests */
76 wait_event_interruptible
77 (sbi->ll_commitcbd_waitq,
78 ll_commitcbd_check_event(sbi));
80 spin_lock(&sbi->ll_commitcbd_lock);
81 if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) {
82 spin_unlock(&sbi->ll_commitcbd_lock);
83 CERROR("lustre_commitd quitting\n");
87 if (!list_empty(&sbi->ll_mds_client.cli_replied_head))
88 CERROR("** clean up committed reqs here **\n");
90 schedule_timeout(sbi->ll_commitcbd_timeout);
91 CERROR("commit callback daemon woken up - FIXME\n");
92 spin_unlock(&sbi->ll_commitcbd_lock);
95 sbi->ll_commitcbd_thread = NULL;
96 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPED;
97 wake_up(&sbi->ll_commitcbd_ctl_waitq);
98 CDEBUG(D_NET, "commit callback daemon exiting %d\n", current->pid);
104 int ll_commitcbd_setup(struct ll_sb_info *sbi)
109 rc = kernel_thread(ll_commitcbd_main, (void *) sbi,
110 CLONE_VM | CLONE_FS | CLONE_FILES);
112 CERROR("cannot start thread\n");
115 wait_event(sbi->ll_commitcbd_ctl_waitq,
116 sbi->ll_commitcbd_flags & LL_COMMITCBD_RUNNING);
121 int ll_commitcbd_cleanup(struct ll_sb_info *sbi)
123 sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPING;
125 wake_up(&sbi->ll_commitcbd_waitq);
126 wait_event_interruptible
127 (sbi->ll_commitcbd_ctl_waitq,
128 sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED);