Motr  M0
locality.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
29 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB
30 #include "lib/trace.h"
31 #include "sm/sm.h"
32 #include "lib/chan.h"
33 #include "lib/arith.h" /* max_check */
34 #include "lib/errno.h" /* ENOMEM */
35 #include "lib/thread.h"
36 #include "lib/memory.h"
37 #include "lib/processor.h"
38 #include "lib/locality.h"
39 #include "module/instance.h"
40 #include "fop/fom.h"
41 #include "reqh/reqh.h"
42 #include "addb2/addb2.h"
43 #include "addb2/identifier.h"
44 
50 M0_LOCKERS_DEFINE(M0_INTERNAL, m0_locality, lo_lockers);
51 
52 static struct {
53  size_t ld_nob;
54  int (*ld_ctor)(void *, void *);
55  void (*ld_dtor)(void *, void *);
56  void *ld_datum;
58 
59 struct chore_local {
61  void *lo_data;
64  uint64_t lo_magix;
65 };
66 
73  struct m0_mutex lg_lock;
74  struct m0_tl lg_chore;
75 };
76 
79 
80 M0_TL_DESCR_DEFINE(chore_l, "chores-local", static, struct chore_local,
81  lo_linkage, lo_magix,
83 M0_TL_DEFINE(chore_l, static, struct chore_local);
84 
85 M0_TL_DESCR_DEFINE(chores_g, "chores-global", static, struct m0_locality_chore,
86  lc_linkage, lc_magix,
88 M0_TL_DEFINE(chores_g, static, struct m0_locality_chore);
89 
90 static struct locality_global *loc_glob(void);
91 static int loc_nr(void);
92 
93 static void chore_del(struct m0_locality *loc, struct m0_locality_chore *chore);
94 static int chore_add(struct m0_locality *loc, struct m0_locality_chore *chore);
95 static void chore_post(struct m0_locality *loc, struct m0_locality_chore *chore,
96  void (*cb)(struct m0_sm_group *, struct m0_sm_ast *));
97 static int chore_add_all(struct m0_locality_chore *chore);
98 static void chore_del_all(struct m0_locality_chore *chore);
99 static void chore_add_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast);
100 static void chore_del_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast);
101 
102 static int locality_data_alloc(int key);
103 static void locality_data_free(int key);
104 static void locality_data_free_all(void);
105 
106 static int ldata_alloc(struct m0_locality *loc, int key);
107 static void ldata_free(struct m0_locality *loc, int key);
108 
109 #define LOC_FOR(idx_var, loc_var) \
110 do { \
111  int idx_var; \
112  \
113  for (idx_var = 0; idx_var < loc_nr(); ++idx_var) { \
114  struct m0_locality *loc_var = m0_locality_get(idx_var);
115 
116 #define LOC_ENDFOR } } while (0)
117 
118 #define CHORES_FOR(chvar) \
119 do { \
120  struct m0_locality_chore *chvar; \
121  struct m0_tl *__chlist = &loc_glob()->lg_chore; \
122  m0_tl_for(chores_g, __chlist, chvar)
123 
124 #define CHORES_ENDFOR m0_tl_endfor; } while (0)
125 
126 M0_INTERNAL void m0_locality_init(struct m0_locality *loc,
127  struct m0_sm_group *grp,
128  struct m0_fom_domain *dom, size_t idx)
129 {
130  M0_PRE(M0_IS0(loc));
131  *loc = (struct m0_locality) {
132  .lo_grp = grp,
133  .lo_dom = dom,
134  .lo_idx = idx
135  };
136  m0_locality_lockers_init(loc);
137  chore_l_tlist_init(&loc->lo_chores);
138 }
139 
140 M0_INTERNAL void m0_locality_fini(struct m0_locality *loc)
141 {
142  chore_l_tlist_fini(&loc->lo_chores);
143  m0_locality_lockers_fini(loc);
144 }
145 
146 M0_INTERNAL struct m0_locality *m0_locality_here(void)
147 {
148  struct locality_global *glob = loc_glob();
149 
150  if (glob->lg_dom == NULL || m0_thread_self() == &glob->lg_ast_thread)
151  return &glob->lg_fallback;
152  else
154 }
155 
156 M0_INTERNAL struct m0_locality *m0_locality_get(uint64_t value)
157 {
158  struct locality_global *glob = loc_glob();
159  struct m0_fom_domain *dom = glob->lg_dom;
160  struct m0_fom_locality *floc;
161  int idx = value % dom->fd_localities_nr;
162 
163  M0_PRE(dom != NULL);
164  floc = dom->fd_localities[idx];
165  M0_ASSERT(m0_bitmap_get(&floc->fl_processors, idx));
166  return &floc->fl_locality;
167 }
168 
169 M0_INTERNAL struct m0_locality *m0_locality0_get(void)
170 {
171  return &loc_glob()->lg_fallback;
172 }
173 
174 M0_INTERNAL void m0_locality_dom_set(struct m0_fom_domain *dom)
175 {
176  struct locality_global *glob = loc_glob();
177 
178  M0_PRE(glob->lg_dom == NULL);
179  glob->lg_dom = dom;
180 }
181 
182 M0_INTERNAL void m0_locality_dom_unset(struct m0_fom_domain *dom)
183 {
184  struct locality_global *glob = loc_glob();
185 
186  M0_PRE(dom == glob->lg_dom);
187  glob->lg_dom = NULL;
188 }
189 
190 static void locs_ast_handler(void *__unused)
191 {
192  struct locality_global *glob = loc_glob();
193  struct m0_sm_group *grp = &glob->lg_grp;
194 
196  while (!glob->lg_shutdown) {
200  if (glob->lg_dom == NULL)
203  }
205 }
206 
207 static int ast_thread_init(void *__unused)
208 {
209  return 0;
210 }
211 
212 M0_INTERNAL int m0_localities_init(void)
213 {
214  struct locality_global *glob;
215  int result;
216 
217  M0_ALLOC_PTR(glob);
218  if (glob != NULL) {
219  m0_mutex_init(&glob->lg_lock);
220  chores_g_tlist_init(&glob->lg_chore);
221  m0_sm_group_init(&glob->lg_grp);
222  m0_locality_init(&glob->lg_fallback, &glob->lg_grp, NULL, 0);
224  /*
225  * Start fall-back ast processing thread. Dummy init function
226  * (ast_thread_init()) is used to guarantee that the thread has
227  * started by the time M0_THREAD_INIT() returns. This is needed
228  * to make initialisation order deterministic.
229  */
230  result = M0_THREAD_INIT(&glob->lg_ast_thread, void *,
232  NULL, "m0_fallback_ast");
233  if (result == 0)
234  result = m0_fom_domain_init(&glob->lg_dom);
235  else
236  m0_free(glob);
237  } else
238  result = M0_ERR(-ENOMEM);
239  return result;
240 }
241 
242 M0_INTERNAL void m0_localities_fini(void)
243 {
244  struct locality_global *glob = loc_glob();
245 
246  M0_PRE(glob->lg_dom != NULL);
247 
249  if (glob->lg_dom != NULL)
250  m0_fom_domain_fini(glob->lg_dom);
251 
252  M0_ASSERT(chores_g_tlist_is_empty(&glob->lg_chore));
253  glob->lg_dom = NULL;
254  glob->lg_shutdown = true;
259  m0_sm_group_fini(&glob->lg_grp);
260  chores_g_tlist_fini(&glob->lg_chore);
261  m0_mutex_fini(&glob->lg_lock);
262  m0_free(glob);
264 }
265 
266 /*
267  * Chores interface.
268  */
269 
271  const struct m0_locality_chore_ops *ops,
272  void *datum, m0_time_t interval,
273  size_t datasize)
274 {
275  struct locality_global *glob = loc_glob();
276  int result;
277 
278  M0_PRE(M0_IS0(chore));
279  M0_PRE(m0_fom_dom() != NULL);
280 
281  chore->lc_ops = ops;
282  chore->lc_datum = datum;
283  chore->lc_interval = interval;
284  chore->lc_datasize = datasize;
285  m0_mutex_init(&chore->lc_lock);
286  m0_chan_init(&chore->lc_signal, &chore->lc_lock);
287  m0_mutex_lock(&glob->lg_lock);
288  chores_g_tlink_init_at_tail(chore, &glob->lg_chore);
289  m0_mutex_unlock(&glob->lg_lock);
290  result = chore_add_all(chore);
291  if (result != 0)
292  m0_locality_chore_fini(chore);
293  return result;
294 }
295 
297 {
298  if (chore->lc_active > 0)
299  chore_del_all(chore);
300  m0_chan_fini_lock(&chore->lc_signal);
301  chores_g_tlink_del_fini(chore);
302  m0_mutex_fini(&chore->lc_lock);
303 }
304 
305 M0_INTERNAL void m0_locality_chores_run(struct m0_locality *locality)
306 {
307  struct chore_local *chloc;
308 
311 
312  m0_tl_for(chore_l, &locality->lo_chores, chloc) {
313  struct m0_locality_chore *chore = chloc->lo_chore;
314 
315  if (chore->lc_interval == 0 ||
317  chore->lc_interval))) {
318  chore->lc_ops->co_tick(chore,
319  locality, chloc->lo_data);
320  chloc->lo_last = m0_time_now();
321  }
322  } m0_tl_endfor;
323 }
324 
325 static struct locality_global *loc_glob(void)
326 {
328 }
329 
330 static int loc_nr(void)
331 {
332  struct locality_global *glob = loc_glob();
333  M0_PRE(glob->lg_dom != NULL);
334  return glob->lg_dom->fd_localities_nr;
335 }
336 
337 static int chore_add_all(struct m0_locality_chore *chore)
338 {
339  int result = 0;
340 
341  M0_PRE(chore->lc_active == 0);
342 
343  LOC_FOR(i, loc) {
344  result = chore_add(loc, chore);
345  if (result != 0) {
346  LOC_FOR(i, scan) {
347  if (scan == loc)
348  break;
349  chore_del(scan, chore);
350  } LOC_ENDFOR;
351  break;
352  }
353  } LOC_ENDFOR;
354 
355  M0_POST((result == 0) == (chore->lc_active == loc_nr()));
356  M0_POST(M0_IN(chore->lc_active, (0, loc_nr())));
357  return result;
358 }
359 
360 static void chore_del_all(struct m0_locality_chore *chore)
361 {
362  M0_POST(chore->lc_active == loc_nr());
363  LOC_FOR(i, loc) {
364  chore_del(loc, chore);
365  } LOC_ENDFOR;
366  M0_POST(chore->lc_active == 0);
367 }
368 
369 static void chore_post(struct m0_locality *loc, struct m0_locality_chore *chore,
370  void (*cb)(struct m0_sm_group *, struct m0_sm_ast *))
371 {
372  struct m0_sm_ast *ast = &chore->lc_ast;
373  struct m0_clink clink;
374 
375  M0_PRE(ast->sa_next == NULL);
376  ast->sa_cb = cb;
377  ast->sa_datum = loc;
379  m0_clink_add_lock(&chore->lc_signal, &clink);
380  m0_sm_ast_post(loc->lo_grp, &chore->lc_ast);
384 }
385 
386 static int chore_add(struct m0_locality *loc, struct m0_locality_chore *chore)
387 {
388  chore_post(loc, chore, &chore_add_cb);
389  return chore->lc_rc;
390 }
391 
392 static void chore_del(struct m0_locality *loc, struct m0_locality_chore *chore)
393 {
394  chore_post(loc, chore, &chore_del_cb);
395 }
396 
397 static void chore_add_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast)
398 {
399  struct m0_locality_chore *chore = M0_AMB(chore, ast, lc_ast);
400  struct m0_locality *loc = ast->sa_datum;
401  struct chore_local *chloc;
402  int result;
403 
404  M0_PRE(loc == m0_locality_here());
405  M0_PRE(m0_tl_forall(chore_l, scan, &loc->lo_chores,
406  scan->lo_chore != chore));
407 
408  chloc = m0_alloc(sizeof *chloc + chore->lc_datasize);
409  if (chloc != NULL) {
410  chloc->lo_chore = chore;
411  chloc->lo_data = chloc + 1;
412  result = chore->lc_ops->co_enter == NULL ? 0 :
413  chore->lc_ops->co_enter(chore, loc, chloc->lo_data);
414  if (result == 0) {
415  chore_l_tlink_init_at_tail(chloc, &loc->lo_chores);
416  chore->lc_active++;
417  } else
418  m0_free(chloc);
419  } else
420  result = M0_ERR(-ENOMEM);
421  chore->lc_rc = result;
423 }
424 
425 static void chore_del_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast)
426 {
427  struct m0_locality_chore *chore = M0_AMB(chore, ast, lc_ast);
428  struct m0_locality *loc = ast->sa_datum;
429  struct chore_local *chloc;
430 
431  chloc = m0_tl_find(chore_l, scan, &loc->lo_chores,
432  scan->lo_chore == chore);
433  M0_PRE(chloc != NULL);
434  if (chore->lc_ops->co_leave != NULL)
435  chore->lc_ops->co_leave(chore, loc, chloc->lo_data);
436  chore_l_tlink_del_fini(chloc);
437  chore->lc_active--;
438  m0_free(chloc);
440 }
441 
442 int m0_locality_data_alloc(size_t nob, int (*ctor)(void *, void *),
443  void (*dtor)(void *, void *), void *datum)
444 {
445  int key;
446 
447  M0_PRE(nob > 0);
448  M0_PRE(m0_fom_dom() != NULL);
449  key = m0_locality_lockers_allot();
451  M0_ASSERT(ldata[key].ld_nob == 0);
452  ldata[key] = (typeof(ldata[key])) {
453  .ld_nob = nob,
454  .ld_ctor = ctor,
455  .ld_dtor = dtor,
456  .ld_datum = datum
457  };
458 
459  return ldata_alloc(&loc_glob()->lg_fallback, key) ?:
461 }
462 
464 {
466  M0_PRE(ldata[key].ld_nob > 0);
467  M0_PRE(m0_fom_dom() != NULL);
469  ldata_free(&loc_glob()->lg_fallback, key);
470  ldata[key].ld_nob = 0;
471  m0_locality_lockers_free(key);
472 }
473 
475 {
476  M0_PRE(m0_fom_dom() != NULL);
477  return m0_locality_lockers_get(m0_locality_here(), key);
478 }
479 
481  void (*func)(int idx, void *data, void *datum),
482  void *datum)
483 {
484  LOC_FOR(i, loc) {
485  (*func)(i, m0_locality_lockers_get(loc, key), datum);
486  } LOC_ENDFOR;
487 }
488 
489 static int locality_data_alloc(int key)
490 {
491  int result = 0;
492 
493  LOC_FOR(i, loc) {
494  result = ldata_alloc(loc, key);
495  if (result != 0)
496  break;
497  } LOC_ENDFOR;
498  return result;
499 }
500 
501 static void locality_data_free(int key)
502 {
503  LOC_FOR(i, loc) {
504  ldata_free(loc, key);
505  } LOC_ENDFOR;
506 }
507 
508 static int ctor_cb(void *arg)
509 {
510  int key = *(int *)arg;
511  void *data = m0_locality_data(key);
512 
514  M0_ASSERT(data != NULL);
515  return ldata[key].ld_ctor(data, ldata[key].ld_datum);
516 }
517 
518 static int dtor_cb(void *arg)
519 {
520  int key = *(int *)arg;
521  void *data = m0_locality_data(key);
522 
524  M0_ASSERT(data != NULL);
525  ldata[key].ld_dtor(data, ldata[key].ld_datum);
526  return 0;
527 }
528 
529 static int ldata_alloc(struct m0_locality *loc, int key)
530 {
531  int result = 0;
532 
533  if (m0_locality_lockers_get(loc, key) == NULL) {
534  void *data = m0_alloc(ldata[key].ld_nob);
535 
536  if (data != NULL) {
537  m0_locality_lockers_set(loc, key, data);
538  if (ldata[key].ld_ctor != NULL)
539  result = m0_locality_call(loc, &ctor_cb, &key);
540  } else
541  result = M0_ERR(-ENOMEM);
542  }
543  if (result != 0)
545  return result;
546 }
547 
548 static void ldata_free(struct m0_locality *loc, int key)
549 {
550  void *data = m0_locality_lockers_get(loc, key);
551 
552  if (data != NULL) {
553  if (ldata[key].ld_dtor != NULL)
554  m0_locality_call(loc, &dtor_cb, &key);
555  m0_free(data);
556  m0_locality_lockers_set(loc, key, NULL);
557  }
558 }
559 
560 static void locality_data_free_all(void)
561 {
562  int i;
563 
564  for (i = 0; i < ARRAY_SIZE(ldata); ++i) {
565  if (ldata[i].ld_nob > 0)
567  }
568 }
569 
570 int m0_locality_call(struct m0_locality *loc, int (*cb)(void *), void *data)
571 {
572  return m0_sm_group_call(loc->lo_grp, cb, data);
573 }
574 
575 M0_INTERNAL struct m0_fom_domain *m0_fom_dom(void)
576 {
577  struct locality_global *glob = loc_glob();
578  M0_PRE(glob->lg_dom != NULL);
579  return glob->lg_dom;
580 }
581 
582 #undef M0_TRACE_SUBSYSTEM
583 
586 /*
587  * Local variables:
588  * c-indentation-style: "K&R"
589  * c-basic-offset: 8
590  * tab-width: 8
591  * fill-column: 80
592  * scroll-step: 1
593  * End:
594  */
595 /*
596  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
597  */
static void locality_data_free_all(void)
Definition: locality.c:560
M0_INTERNAL void m0_fom_domain_fini(struct m0_fom_domain *dom)
Definition: fom.c:1256
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
Definition: chan.c:336
#define M0_PRE(cond)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
M0_INTERNAL struct m0_locality * m0_locality_get(uint64_t value)
Definition: locality.c:156
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
Definition: chan.c:293
struct m0_fom_domain * lg_dom
Definition: locality.c:72
static size_t locality(const struct m0_fom *fom)
Definition: rm_foms.c:269
void * m0_locality_data(int key)
Definition: locality.c:474
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
struct m0_bitmap fl_processors
Definition: fom.h:295
void(* sa_cb)(struct m0_sm_group *grp, struct m0_sm_ast *)
Definition: sm.h:506
static struct @252 ldata[M0_LOCALITY_LOCKERS_NR]
static struct m0_sm_group * grp
Definition: bytecount.c:38
M0_INTERNAL void m0_locality_fini(struct m0_locality *loc)
Definition: locality.c:140
uint64_t m0_time_t
Definition: time.h:37
M0_INTERNAL void m0_sm_ast_post(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: sm.c:135
M0_INTERNAL int m0_localities_init(void)
Definition: locality.c:212
M0_INTERNAL void m0_locality_dom_unset(struct m0_fom_domain *dom)
Definition: locality.c:182
M0_INTERNAL int m0_fom_domain_init(struct m0_fom_domain **out)
Definition: fom.c:1173
static int chore_add(struct m0_locality *loc, struct m0_locality_chore *chore)
Definition: locality.c:386
struct m0_clink s_clink
Definition: sm.h:516
#define M0_ADDB2_PUSH(id,...)
Definition: addb2.h:261
struct m0_sm_group lg_grp
Definition: locality.c:69
void(* ld_dtor)(void *, void *)
Definition: locality.c:55
struct m0_bufvec data
Definition: di.c:40
struct m0_tl lg_chore
Definition: locality.c:74
int const char const void * value
Definition: dir.c:325
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
Definition: sm.h:504
M0_INTERNAL m0_processor_nr_t m0_processor_id_get(void)
Definition: processor.c:1139
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
int m0_locality_call(struct m0_locality *loc, int(*cb)(void *), void *data)
Definition: locality.c:570
M0_INTERNAL void m0_locality_chores_run(struct m0_locality *locality)
Definition: locality.c:305
static void locality_data_free(int key)
Definition: locality.c:501
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
#define m0_tl_endfor
Definition: tlist.h:700
int(* co_enter)(struct m0_locality_chore *chore, struct m0_locality *loc, void *place)
Definition: locality.h:126
m0_time_t lc_interval
Definition: locality.h:113
static int locality_data_alloc(int key)
Definition: locality.c:489
struct m0_thread lg_ast_thread
Definition: locality.c:70
static struct m0_sm_ast ast[NR]
Definition: locality.c:44
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
void m0_locality_data_free(int key)
Definition: locality.c:463
struct m0_locality fl_locality
Definition: fom.h:302
int i
Definition: dir.c:1033
bool m0_time_is_in_past(m0_time_t t)
Definition: time.c:102
return M0_ERR(-EOPNOTSUPP)
void * sa_datum
Definition: sm.h:508
static void chore_del_all(struct m0_locality_chore *chore)
Definition: locality.c:360
static int key
Definition: locality.c:283
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
int m0_sm_group_call(struct m0_sm_group *group, int(*cb)(void *), void *data)
Definition: sm.c:801
struct m0_tlink lo_linkage
Definition: locality.c:63
void(* co_leave)(struct m0_locality_chore *chore, struct m0_locality *loc, void *place)
Definition: locality.h:128
static int dtor_cb(void *arg)
Definition: locality.c:518
static void chore_add_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: locality.c:397
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
Definition: chan.c:96
#define M0_ASSERT(cond)
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
size_t ld_nob
Definition: locality.c:53
m0_time_t m0_time_now(void)
Definition: time.c:134
Definition: tlist.h:251
M0_INTERNAL void m0_locality_dom_set(struct m0_fom_domain *dom)
Definition: locality.c:174
void m0_thread_fini(struct m0_thread *q)
Definition: thread.c:92
static struct m0_stob_domain * dom
Definition: storage.c:38
static void chore_del(struct m0_locality *loc, struct m0_locality_chore *chore)
Definition: locality.c:392
bool lg_shutdown
Definition: locality.c:71
static struct locality_global * loc_glob(void)
Definition: locality.c:325
M0_INTERNAL void m0_clink_signal(struct m0_clink *clink)
Definition: chan.c:326
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
const struct m0_locality_chore_ops * lc_ops
Definition: locality.h:111
#define M0_POST(cond)
int m0_locality_chore_init(struct m0_locality_chore *chore, const struct m0_locality_chore_ops *ops, void *datum, m0_time_t interval, size_t datasize)
Definition: locality.c:270
struct m0_sm_group * lo_grp
Definition: locality.h:67
struct m0_sm_ast * sa_next
Definition: sm.h:509
static int ctor(void *area, void *cookie)
Definition: locality.c:287
static struct m0_clink clink[RDWR_REQUEST_MAX]
m0_time_t m0_time_add(const m0_time_t t1, const m0_time_t t2)
Definition: time.c:47
void * ld_datum
Definition: locality.c:56
#define LOC_FOR(idx_var, loc_var)
Definition: locality.c:109
void m0_addb2_pop(uint64_t id)
Definition: addb2.c:440
M0_INTERNAL void m0_chan_signal_lock(struct m0_chan *chan)
Definition: chan.c:165
M0_INTERNAL struct m0_locality * m0_locality_here(void)
Definition: locality.c:146
#define LOC_ENDFOR
Definition: locality.c:116
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:255
int(* ld_ctor)(void *, void *)
Definition: locality.c:54
struct m0_locality lg_fallback
Definition: locality.c:68
void m0_locality_chore_fini(struct m0_locality_chore *chore)
Definition: locality.c:296
M0_INTERNAL void m0_localities_fini(void)
Definition: locality.c:242
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
static void locs_ast_handler(void *__unused)
Definition: locality.c:190
struct m0_sm_ast lc_ast
Definition: locality.h:118
static int ast_thread_init(void *__unused)
Definition: locality.c:207
#define M0_IS0(obj)
Definition: misc.h:70
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
struct m0_mutex lg_lock
Definition: locality.c:73
void * i_moddata[M0_MODULE_NR]
Definition: instance.h:94
static void ldata_free(struct m0_locality *loc, int key)
Definition: locality.c:548
struct m0_locality_chore * lo_chore
Definition: locality.c:60
M0_INTERNAL struct m0_thread * m0_thread_self(void)
Definition: thread.c:122
struct m0_tl lo_chores
Definition: locality.h:72
M0_INTERNAL struct m0_fom_domain * m0_fom_dom(void)
Definition: locality.c:575
static void chore_post(struct m0_locality *loc, struct m0_locality_chore *chore, void(*cb)(struct m0_sm_group *, struct m0_sm_ast *))
Definition: locality.c:369
M0_INTERNAL bool m0_bitmap_get(const struct m0_bitmap *map, size_t idx)
Definition: bitmap.c:105
M0_INTERNAL void m0_locality_init(struct m0_locality *loc, struct m0_sm_group *grp, struct m0_fom_domain *dom, size_t idx)
Definition: locality.c:126
struct m0_chan lc_signal
Definition: locality.h:115
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
m0_time_t lo_last
Definition: locality.c:62
#define IS_IN_ARRAY(idx, array)
Definition: misc.h:311
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
static int ctor_cb(void *arg)
Definition: locality.c:508
void m0_locality_data_iterate(int key, void(*func)(int idx, void *data, void *datum), void *datum)
Definition: locality.c:480
int m0_locality_data_alloc(size_t nob, int(*ctor)(void *, void *), void(*dtor)(void *, void *), void *datum)
Definition: locality.c:442
void(* co_tick)(struct m0_locality_chore *chore, struct m0_locality *loc, void *place)
Definition: locality.h:130
void * lo_data
Definition: locality.c:61
static int ldata_alloc(struct m0_locality *loc, int key)
Definition: locality.c:529
struct m0_fom_ops ops
Definition: io_foms.c:623
uint64_t lo_magix
Definition: locality.c:64
M0_INTERNAL void m0_sm_asts_run(struct m0_sm_group *grp)
Definition: sm.c:150
static int loc_nr(void)
Definition: locality.c:330
M0_LOCKERS_DEFINE(M0_INTERNAL, m0_locality, lo_lockers)
static int scan(struct scanner *s)
Definition: beck.c:963
#define m0_tl_find(name, var, head,...)
Definition: tlist.h:757
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
Definition: chan.c:112
void m0_free(void *data)
Definition: memory.c:146
Definition: mutex.h:47
size_t fd_localities_nr
Definition: fom.h:333
static int chore_add_all(struct m0_locality_chore *chore)
Definition: locality.c:337
#define ARRAY_SIZE(a)
Definition: misc.h:45
M0_INTERNAL bool m0_sm_group_is_locked(const struct m0_sm_group *grp)
Definition: sm.c:107
Definition: idx_mock.c:47
size_t lc_datasize
Definition: locality.h:119
struct m0_mutex lc_lock
Definition: locality.h:114
M0_TL_DESCR_DEFINE(chore_l, "chores-local", static, struct chore_local, lo_linkage, lo_magix, M0_CHORE_L_MAGIC, M0_CHORE_L_HEAD_MAGIC)
#define m0_tl_forall(name, var, head,...)
Definition: tlist.h:735
static void chore_del_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: locality.c:425
M0_TL_DEFINE(chore_l, static, struct chore_local)