Motr  M0
stats_fops.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 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_STATS
24 #include "lib/trace.h"
25 #include "lib/assert.h"
26 #include "lib/memory.h"
27 #include "rpc/item.h"
28 #include "fop/fop_item_type.h"
29 #include "rpc/rpc_opcodes.h"
30 #include "fop/fop.h"
31 #include "stats/stats_srv.h"
32 #include "stats/stats_fops_xc.h"
33 
35 extern const struct m0_sm_conf stats_update_fom_sm_conf;
37 extern const struct m0_sm_conf stats_query_fom_sm_conf;
38 extern const struct m0_fom_type_ops stats_update_fom_type_ops;
39 extern const struct m0_fom_type_ops stats_query_fom_type_ops;
40 
44 
47 };
48 
51 };
52 
55 
56 M0_INTERNAL int m0_stats_fops_init(void)
57 {
58 #ifndef __KERNEL__
61 #endif
63  .name = "Stats update fop",
65  .xt = m0_stats_update_fop_xc,
66  .rpc_flags = M0_RPC_ITEM_TYPE_ONEWAY,
67  .fop_ops = &stats_update_fop_ops,
68 #ifndef __KERNEL__
69  .fom_ops = &stats_update_fom_type_ops,
71  .svc_type = &m0_stats_svc_type,
72 #endif
75  .name = "Stats query fop",
77  .xt = m0_stats_query_fop_xc,
78  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
79  .fop_ops = &stats_query_fop_ops,
80 #ifndef __KERNEL__
81  .fom_ops = &stats_query_fom_type_ops,
83  .svc_type = &m0_stats_svc_type,
84 #endif
87  .name = "Stats query rep fop",
89  .xt = m0_stats_query_rep_fop_xc,
90  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
91  return 0;
92 }
93 
94 M0_INTERNAL void m0_stats_fops_fini(void)
95 {
99 }
100 
101 M0_INTERNAL struct m0_stats_update_fop *
103 {
104  return (struct m0_stats_update_fop *)m0_fop_data(fop);
105 }
106 
107 M0_INTERNAL struct m0_stats_query_fop *
109 {
110  return (struct m0_stats_query_fop *)m0_fop_data(fop);
111 }
112 
113 M0_INTERNAL struct m0_stats_query_rep_fop *
115 {
116  return (struct m0_stats_query_rep_fop *)m0_fop_data(fop);
117 }
118 
119 M0_INTERNAL void m0_stats_query_fop_release(struct m0_ref *ref)
120 {
121  struct m0_fop *fop = container_of(ref, struct m0_fop, f_ref);
122 
123  M0_PRE(fop != NULL);
124  m0_fop_fini(fop);
125  m0_free(fop);
126 }
127 
128 #undef M0_TRACE_SUBSYSTEM
129 /*
130  * Local variables:
131  * c-indentation-style: "K&R"
132  * c-basic-offset: 8
133  * tab-width: 8
134  * fill-column: 80
135  * scroll-step: 1
136  * End:
137  */
const struct m0_fom_type_ops stats_query_fom_type_ops
Definition: stats_srv.c:551
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
const struct m0_sm_conf stats_update_fom_sm_conf
Definition: stats_srv.c:360
const struct m0_sm_conf stats_query_fom_sm_conf
Definition: stats_srv.c:562
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
Definition: sm.h:350
M0_INTERNAL void m0_stats_fops_fini(void)
Definition: stats_fops.c:94
struct m0_sm_state_descr stats_query_phases[]
Definition: stats_srv.c:555
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
M0_INTERNAL void m0_sm_conf_extend(const struct m0_sm_state_descr *base, struct m0_sm_state_descr *sub, uint32_t nr)
Definition: sm.c:763
static const struct m0_rpc_item_type_ops stats_update_item_type_ops
Definition: stats_fops.c:45
#define container_of(ptr, type, member)
Definition: misc.h:33
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
const struct m0_sm_conf m0_generic_conf
Definition: fom_generic.c:838
int opcode
Definition: crate.c:301
static const struct m0_reqh_service_ops rpc_ops
Definition: service.c:92
const char * name
Definition: trace.c:110
Definition: refs.h:34
const struct m0_fop_type_ops stats_query_fop_ops
Definition: stats_fops.c:54
uint32_t scf_nr_states
Definition: sm.h:354
M0_INTERNAL struct m0_stats_query_rep_fop * m0_stats_query_rep_fop_get(struct m0_fop *fop)
Definition: stats_fops.c:114
struct m0_fop_type m0_fop_stats_update_fopt
Definition: stats_fops.c:41
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
M0_INTERNAL struct m0_stats_query_fop * m0_stats_query_fop_get(struct m0_fop *fop)
Definition: stats_fops.c:108
const struct m0_fom_type_ops stats_update_fom_type_ops
Definition: stats_srv.c:339
struct m0_sm_state_descr * scf_state
Definition: sm.h:356
struct m0_ref f_ref
Definition: fop.h:80
struct m0_sm_state_descr stats_update_phases[]
Definition: stats_srv.c:343
M0_INTERNAL int m0_stats_fops_init(void)
Definition: stats_fops.c:56
struct m0_reqh_service_type m0_stats_svc_type
Definition: stats_srv.c:297
static struct m0_fop * fop
Definition: item.c:57
static const struct m0_rpc_item_type_ops stats_query_item_type_ops
Definition: stats_fops.c:49
const struct m0_fop_type_ops stats_update_fop_ops
Definition: stats_fops.c:53
struct m0_fop_type m0_fop_stats_query_fopt
Definition: stats_fops.c:42
M0_INTERNAL void m0_stats_query_fop_release(struct m0_ref *ref)
Definition: stats_fops.c:119
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL struct m0_stats_update_fop * m0_stats_update_fop_get(struct m0_fop *fop)
Definition: stats_fops.c:102
#define M0_FOP_DEFAULT_ITEM_TYPE_OPS
Definition: fop.h:184
Definition: fop.h:79
struct m0_fop_type m0_fop_stats_query_rep_fopt
Definition: stats_fops.c:43