Whamcloud - gitweb
b=11089
[fs/lustre-release.git] / lustre / mds / commit_confd.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2005 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  */
24
25 void commit_add(struct )
26 {
27         struct obd_import *import = commit_uuid2import(rec->  uuid);
28
29         if (!import) {
30                 CERROR("unaware of OST UUID %s - dorpping\n", rec-> uuid);
31                 EXIT;
32                 return;
33         }
34
35         spin_lock(&import->llcconf_lock);
36         list_add(&rec->  &import);
37         spin_unlock(&import->llcconf_lock);
38         EXIT;
39         return;
40 }
41
42 void commit_confd_conf_import(struct obd_import *import,
43                               struct llog_commit_confirm_daemon *lccd)
44 {
45         struct list_head *tmp, *save;
46
47
48         list_for_each_safe(&import->import_cc_list, tmp, save) {
49                 struct llog_canceld_ctxt *cd;
50
51                 if (atomic_read(import->import_cc_count) <=
52                     lccd->llcconf_lowwater)
53                         break;
54
55                 cd = list_entry(tmp, struct llog_canceld_ctxt *, llcconf_entry);
56                 atomic_dec(&import->import_cc_count);
57                 commit_confd_add_and_fire(cd);
58         }
59         EXIT;
60         return;
61 }
62
63
64 int commit_confd_main(void *data)
65 {
66         struct llog_commit_confirm_daemon *lccd = data;
67
68         while (1) {
69                 /* something has happened */
70                 event_wait();
71
72                 if (lccd->flags & LCCD_STOP)
73                         break;
74
75
76                 /* lock llccd imporlist */
77                 spin_lock(&lccd->llcconf_lock);
78                 list_for_each_safe(&lccd->llcconf_list,   ) {
79                         struct obd_import *import;
80                         import = list_entry(&lccd->llcconf_list,
81                                             struct obd_import,
82                                             import_entry);
83                         get_import(import);
84                         spin_unlock(&lccd->llcconf_lock);
85                         if (atomic_read(import->import_cc_count) >
86                             lccd->llcconf_highwater)
87                                 commit_confd_conf_import(import);
88                         put_import(import);
89                         spin_lock(&lccd->llcconf_lock);
90
91                 }
92                 spin_unlock(&lccd->llcconf_lock);
93
94         }
95
96         lccd->flags = LCCD_STOPPED;
97         RETURN(0);
98 }