Motr  M0
ag.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2017-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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_DIXCM
24 #include "lib/trace.h"
25 
26 #include "lib/memory.h"
27 #include "lib/errno.h"
28 #include "lib/misc.h"
29 
30 #include "fid/fid.h"
31 #include "dix/cm/cp.h"
32 #include "dix/cm/cm.h"
33 #include "cm/proxy.h"
34 
41 static uint64_t dix_cp_ag_local_cp_nr(const struct m0_cm_aggr_group *ag)
42 {
43  /* There is always one aggregation group per copy packet. */
44  return 1;
45 }
46 
47 static void dix_cp_ag_fini(struct m0_cm_aggr_group *ag)
48 {
49  M0_PRE(ag != NULL);
50  M0_ENTRY("ag %p", ag);
52  m0_free(ag);
53  M0_LEAVE();
54 }
55 
56 static bool dix_cp_ag_can_fini(const struct m0_cm_aggr_group *ag)
57 {
58  return true;
59 }
60 
62  struct m0_cm_proxy *pxy)
63 {
65  return false;
66 }
67 
68 static const struct m0_cm_aggr_group_ops dix_cm_ag_ops = {
70  .cago_fini = &dix_cp_ag_fini,
71  .cago_ag_can_fini = &dix_cp_ag_can_fini,
72  .cago_is_frozen_on = &dix_cm_ag_is_frozen_on
73 };
74 
88 M0_INTERNAL int m0_dix_cm_ag_alloc(struct m0_cm *cm,
89  const struct m0_cm_ag_id *id,
90  bool has_incoming,
91  struct m0_cm_aggr_group **out)
92 {
93  struct m0_cm_aggr_group *ag = NULL;
94 
95  M0_ENTRY("cm: %p, ag id:%p", cm, id);
96  M0_PRE(cm != NULL && id != NULL && out != NULL);
98 
99  ID_INCOMING_LOG("ag alloc", id, has_incoming);
100 
101  *out = NULL;
102 
103  /* Allocate new aggregation group. */
104  M0_ALLOC_PTR(ag);
105  if (ag == NULL)
106  return M0_ERR(-ENOMEM);
107 
108  m0_cm_aggr_group_init(ag, cm, id, has_incoming, &dix_cm_ag_ops);
109  *out = ag;
110 
111  M0_LEAVE("ag: %p", ag);
112  return M0_RC(0);
113 }
114 
116 #undef M0_TRACE_SUBSYSTEM
117 
118 /*
119  * Local variables:
120  * c-indentation-style: "K&R"
121  * c-basic-offset: 8
122  * tab-width: 8
123  * fill-column: 79
124  * scroll-step: 1
125  * End:
126  */
#define M0_PRE(cond)
static bool dix_cm_ag_is_frozen_on(struct m0_cm_aggr_group *ag, struct m0_cm_proxy *pxy)
Definition: ag.c:61
#define NULL
Definition: misc.h:38
M0_LEAVE()
static uint64_t dix_cp_ag_local_cp_nr(const struct m0_cm_aggr_group *ag)
Definition: ag.c:41
static const struct m0_cm_aggr_group_ops dix_cm_ag_ops
Definition: ag.c:68
uint64_t(* cago_local_cp_nr)(const struct m0_cm_aggr_group *ag)
Definition: ag.h:146
M0_INTERNAL void m0_cm_aggr_group_init(struct m0_cm_aggr_group *ag, struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming, const struct m0_cm_aggr_group_ops *ag_ops)
Definition: ag.c:153
return M0_RC(rc)
static struct m0_cm * cm
Definition: cm.c:63
#define M0_ENTRY(...)
Definition: trace.h:170
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL int m0_dix_cm_ag_alloc(struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming, struct m0_cm_aggr_group **out)
Definition: ag.c:88
#define ID_INCOMING_LOG(prefix, id, has_incoming)
Definition: ag.h:58
M0_INTERNAL void m0_cm_aggr_group_fini(struct m0_cm_aggr_group *ag)
Definition: ag.c:180
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
Definition: cm.h:166
#define out(...)
Definition: gen.c:41
static void dix_cp_ag_fini(struct m0_cm_aggr_group *ag)
Definition: ag.c:47
M0_INTERNAL bool m0_cm_is_locked(const struct m0_cm *cm)
Definition: cm.c:560
void m0_free(void *data)
Definition: memory.c:146
static bool dix_cp_ag_can_fini(const struct m0_cm_aggr_group *ag)
Definition: ag.c:56
Definition: ag.h:49