Motr  M0
fops.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-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 #include "lib/memory.h"
24 #include "fop/fop.h"
25 #include "fop/fom.h"
26 #include "fop/fom_generic.h"
27 #include "rpc/rpc_opcodes.h"
28 
29 #include "rpc/ut/fops_xc.h"
30 
32 
33 static int arrow_fom_create(struct m0_fop *fop, struct m0_fom **m,
34  struct m0_reqh *reqh);
35 static void arrow_fom_fini(struct m0_fom *fom);
36 static int arrow_fom_tick(struct m0_fom *fom);
37 static size_t arrow_fom_home_locality(const struct m0_fom *fom);
38 
40 
43 
44 static const struct m0_fom_type_ops arrow_fom_type_ops = {
46 };
47 
48 static const struct m0_fom_ops arrow_fom_ops = {
50  .fo_tick = arrow_fom_tick,
51  .fo_home_locality = arrow_fom_home_locality,
52 };
53 
54 M0_INTERNAL void m0_rpc_test_fops_init(void)
55 {
56  m0_xc_rpc_ut_fops_init();
58  .name = "RPC_arrow",
60  .xt = arrow_xc,
61  .rpc_flags = M0_RPC_ITEM_TYPE_ONEWAY,
62  .fom_ops = &arrow_fom_type_ops,
63  .sm = &m0_generic_conf,
64  .svc_type = &m0_rpc_service_type);
67 }
68 
69 M0_INTERNAL void m0_rpc_test_fops_fini(void)
70 {
74  m0_xc_rpc_ut_fops_fini();
75 }
76 
77 
78 static int arrow_fom_create(struct m0_fop *fop, struct m0_fom **m,
79  struct m0_reqh *reqh)
80 {
81  struct m0_fom *fom;
82 
84  M0_ASSERT(fom != NULL);
85 
87  fop, NULL, reqh);
88  *m = fom;
89  return 0;
90 }
91 
92 static void arrow_fom_fini(struct m0_fom *fom)
93 {
95  m0_free(fom);
97 }
98 
99 static int arrow_fom_tick(struct m0_fom *fom)
100 {
103  return M0_FSO_WAIT;
104 }
105 
106 static size_t arrow_fom_home_locality(const struct m0_fom *fom)
107 {
108  return 0;
109 }
110 
111 /*
112  * Local variables:
113  * c-indentation-style: "K&R"
114  * c-basic-offset: 8
115  * tab-width: 8
116  * fill-column: 80
117  * scroll-step: 1
118  * End:
119  */
120 /*
121  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
122  */
static const struct m0_fom_type_ops arrow_fom_type_ops
Definition: fops.c:44
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
struct m0_semaphore arrow_hit
Definition: fops.c:41
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
static const struct m0_fom_ops arrow_fom_ops
Definition: fops.c:48
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
const struct m0_sm_conf m0_generic_conf
Definition: fom_generic.c:838
struct m0_fom_type ft_fom_type
Definition: fop.h:232
int opcode
Definition: crate.c:301
void m0_fom_init(struct m0_fom *fom, const struct m0_fom_type *fom_type, const struct m0_fom_ops *ops, struct m0_fop *fop, struct m0_fop *reply, struct m0_reqh *reqh)
Definition: fom.c:1372
struct m0_fop_type m0_rpc_arrow_fopt
Definition: fops.c:39
const char * name
Definition: trace.c:110
M0_INTERNAL void m0_rpc_test_fops_fini(void)
Definition: fops.c:69
void m0_fom_fini(struct m0_fom *fom)
Definition: fom.c:1324
#define M0_ASSERT(cond)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
Definition: reqh.h:94
Definition: dump.c:103
static int arrow_fom_create(struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
Definition: fops.c:78
struct m0_semaphore arrow_destroyed
Definition: fops.c:42
Definition: fom.h:481
struct m0_reqh reqh
Definition: rm_foms.c:48
struct m0_reqh_service_type m0_rpc_service_type
Definition: service.c:120
static size_t arrow_fom_home_locality(const struct m0_fom *fom)
Definition: fops.c:106
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
static struct m0_fop * fop
Definition: item.c:57
static int arrow_fom_tick(struct m0_fom *fom)
Definition: fops.c:99
void(* fo_fini)(struct m0_fom *fom)
Definition: fom.h:657
static void arrow_fom_fini(struct m0_fom *fom)
Definition: fops.c:92
void m0_fom_phase_set(struct m0_fom *fom, int phase)
Definition: fom.c:1688
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
M0_INTERNAL void m0_rpc_test_fops_init(void)
Definition: fops.c:54
void m0_free(void *data)
Definition: memory.c:146
Definition: fop.h:79