Motr  M0
note.h
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 
23 #pragma once
24 
25 #ifndef __MOTR___HA_NOTE_H__
26 #define __MOTR___HA_NOTE_H__
27 
96 /* import */
97 #include "fid/fid.h"
98 #include "fid/fid_xc.h"
99 #include "lib/chan.h"
100 #include "lib/types.h"
101 #include "lib/buf.h" /* m0_buf, m0_bufs */
102 #include "lib/buf_xc.h" /* m0_buf_xc, m0_bufs_xc */
103 #include "lib/mutex.h" /* m0_mutex */
104 #include "lib/tlist.h" /* m0_tl */
105 #include "lib/atomic.h" /* m0_atomic64 */
106 #include "xcode/xcode_attr.h"
107 #include "ha/dispatcher.h" /* m0_ha_handler */
108 
109 /* export */
110 struct m0_ha_note;
111 struct m0_ha_nvec;
112 
113 /* foward declaration */
114 struct m0_conf_obj;
115 
171 
173 };
174 
178 struct m0_ha_note {
180  struct m0_fid no_id;
182  uint32_t no_state;
183 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
184 
188 struct m0_ha_nvec {
196  int32_t nv_nr;
198 } M0_XCA_SEQUENCE M0_XCA_DOMAIN(rpc);
199 
209 };
210 
213 };
214 
215 enum {
218 };
219 
223 
226  uint64_t hmnv_type;
227  uint64_t hmnv_id_of_get;
264  uint64_t hmnv_nr;
266 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
267 
268 #define M0_NVEC_PRINT(nvec_, label, level) ({ \
269  int i; \
270  struct m0_ha_nvec *nvec = nvec_; \
271  char *lbl = label; \
272  for (i = 0; i < nvec->nv_nr; i++) { \
273  M0_LOG(level, "%s [%d] " FID_F ", (%d)", lbl, i, \
274  FID_P(&nvec->nv_note[i].no_id), \
275  nvec->nv_note[i].no_state); \
276  } \
277 })
278 
305 M0_INTERNAL int m0_ha_state_get(struct m0_ha_nvec *note, struct m0_chan *chan);
332 M0_INTERNAL void m0_ha_state_set(const struct m0_ha_nvec *note);
336 M0_INTERNAL void m0_ha_local_state_set(const struct m0_ha_nvec *nvec);
337 
341 M0_INTERNAL void m0_ha_state_single_post(struct m0_ha_nvec *nvec);
375 M0_INTERNAL void m0_ha_state_accept(const struct m0_ha_nvec *note,
376  bool ignore_same_state);
377 
378 M0_INTERNAL void m0_conf_ha_callback(struct m0_conf_obj *obj);
379 
380 struct m0_ha_link;
381 
382 M0_INTERNAL void m0_ha_msg_accept(const struct m0_ha_msg *msg,
383  struct m0_ha_link *hl);
384 M0_INTERNAL uint64_t
385 m0_ha_msg_nvec_send(const struct m0_ha_nvec *nvec,
386  uint64_t id_of_get,
387  bool ignore_same_state,
388  int direction,
389  struct m0_ha_link *hl);
390 
392  struct m0_tl hnh_gets;
396  uint64_t hnh_id_of_get;
397 };
398 
399 M0_INTERNAL int m0_ha_note_handler_init(struct m0_ha_note_handler *hnh,
400  struct m0_ha_dispatcher *hd);
401 M0_INTERNAL void m0_ha_note_handler_fini(struct m0_ha_note_handler *hnh);
402 
403 M0_INTERNAL uint64_t m0_ha_note_handler_add(struct m0_ha_note_handler *hnh,
404  struct m0_ha_nvec *nvec_req,
405  struct m0_chan *chan);
406 M0_INTERNAL void m0_ha_note_handler_signal(struct m0_ha_note_handler *hnh,
407  struct m0_ha_nvec *nvec_rep,
408  uint64_t id);
409 
410 M0_INTERNAL const char *m0_ha_state2str(enum m0_ha_obj_state state);
411 
413 #endif /* __MOTR___HA_NOTE_H__ */
414 
415 /*
416  * Local variables:
417  * c-indentation-style: "K&R"
418  * c-basic-offset: 8
419  * tab-width: 8
420  * fill-column: 80
421  * scroll-step: 1
422  * End:
423  */
424 /*
425  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
426  */
M0_INTERNAL int m0_ha_state_get(struct m0_ha_nvec *note, struct m0_chan *chan)
Definition: note.c:74
M0_INTERNAL uint64_t m0_ha_msg_nvec_send(const struct m0_ha_nvec *nvec, uint64_t id_of_get, bool ignore_same_state, int direction, struct m0_ha_link *hl)
Definition: note.c:279
M0_INTERNAL void m0_conf_ha_callback(struct m0_conf_obj *obj)
uint64_t hmnv_type
Definition: note.h:226
uint64_t hnh_id_of_get
Definition: note.h:396
struct m0_ha_msg_nvec_array hmnv_arr
Definition: note.h:265
struct m0_ha_dispatcher * hnh_dispatcher
Definition: note.h:395
struct m0_ha_handler hnh_handler
Definition: note.h:394
Definition: note.h:172
M0_INTERNAL void m0_ha_note_handler_fini(struct m0_ha_note_handler *hnh)
Definition: note.c:364
struct m0_ha_note hmna_arr[M0_HA_STATE_UPDATE_LIMIT]
Definition: note.h:221
M0_INTERNAL void m0_ha_state_set(const struct m0_ha_nvec *note)
Definition: note.c:95
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL int m0_ha_note_handler_init(struct m0_ha_note_handler *hnh, struct m0_ha_dispatcher *hd)
Definition: note.c:345
int32_t nv_nr
Definition: note.h:196
M0_INTERNAL uint64_t m0_ha_note_handler_add(struct m0_ha_note_handler *hnh, struct m0_ha_nvec *nvec_req, struct m0_chan *chan)
Definition: note.c:382
Definition: tlist.h:251
m0_ha_obj_state
Definition: note.h:119
m0_ha_state_update_defaults
Definition: note.h:211
uint64_t hmnv_ignore_same_state
Definition: note.h:263
Definition: msg.h:115
uint64_t hmnv_id_of_get
Definition: note.h:227
Definition: chan.h:229
struct m0_ha_nvec hss_nvec
Definition: note.h:208
struct m0_fid no_id
Definition: note.h:180
struct m0_mutex hnh_lock
Definition: note.h:393
static struct m0_chan chan[RDWR_REQUEST_MAX]
struct m0_ha_state_single M0_XCA_DOMAIN
Definition: fid.h:38
struct m0_ha_note hss_note
Definition: note.h:207
uint64_t hmnv_nr
Definition: note.h:264
M0_INTERNAL void m0_ha_note_handler_signal(struct m0_ha_note_handler *hnh, struct m0_ha_nvec *nvec_rep, uint64_t id)
Definition: note.c:401
M0_INTERNAL const char * m0_ha_state2str(enum m0_ha_obj_state state)
Definition: note.c:433
struct m0_tl hnh_gets
Definition: note.h:392
struct m0_ha_note * nv_note
Definition: note.h:197
M0_INTERNAL void m0_ha_state_accept(const struct m0_ha_nvec *note, bool ignore_same_state)
Definition: note.c:189
struct inlinearray M0_XCA_ARRAY
M0_INTERNAL void m0_ha_state_single_post(struct m0_ha_nvec *nvec)
Definition: note.c:134
Definition: mutex.h:47
M0_INTERNAL void m0_ha_msg_accept(const struct m0_ha_msg *msg, struct m0_ha_link *hl)
Definition: note.c:196
M0_INTERNAL void m0_ha_local_state_set(const struct m0_ha_nvec *nvec)
Definition: note.c:105
uint32_t no_state
Definition: note.h:182