Motr  M0
reqhut_fom.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 static struct m0_semaphore sem;
22 
23 static int reqhut_fom_create(struct m0_fop *fop, struct m0_fom **out,
24  struct m0_reqh *reqh);
25 static int reqhut_fom_tick(struct m0_fom *fom);
26 static void reqhut_fom_fini(struct m0_fom *fom);
27 static size_t reqhut_find_fom_home_locality(const struct m0_fom *fom);
28 
29 static const struct m0_fom_ops reqhut_fom_ops = {
31  .fo_tick = reqhut_fom_tick,
32  .fo_home_locality = reqhut_find_fom_home_locality
33 };
34 
35 static const struct m0_fom_type_ops reqhut_fom_type_ops = {
37 };
38 
39 static int reqhut_fom_create(struct m0_fop *fop,
40  struct m0_fom **out,
41  struct m0_reqh *reqh)
42 {
43  struct m0_fom *fom;
44 
45  M0_PRE(fop != NULL);
46  M0_PRE(out != NULL);
47 
49  if (fom == NULL)
50  return -ENOMEM;
51 
53  fop, NULL, reqh);
54 
55  *out = fom;
56 
57  return 0;
58 }
59 
60 static size_t reqhut_find_fom_home_locality(const struct m0_fom *fom)
61 {
62  return m0_fop_opcode(fom->fo_fop);
63 }
64 
65 
66 static int reqhut_fom_tick(struct m0_fom *fom)
67 {
70  return M0_FSO_WAIT;
71 }
72 
73 static void reqhut_fom_fini(struct m0_fom *fom)
74 {
76  m0_free(fom);
77 }
78 
79 /*
80  * Local variables:
81  * c-indentation-style: "K&R"
82  * c-basic-offset: 8
83  * tab-width: 8
84  * fill-column: 80
85  * scroll-step: 1
86  * End:
87  */
uint32_t m0_fop_opcode(const struct m0_fop *fop)
Definition: fop.c:226
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
static const struct m0_fom_ops reqhut_fom_ops
Definition: reqhut_fom.c:29
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
static int reqhut_fom_create(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: reqhut_fom.c:39
struct m0_fom_type ft_fom_type
Definition: fop.h:232
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 * f_type
Definition: fop.h:81
void m0_fom_fini(struct m0_fom *fom)
Definition: fom.c:1324
Definition: reqh.h:94
Definition: dump.c:103
static int reqhut_fom_tick(struct m0_fom *fom)
Definition: reqhut_fom.c:66
Definition: fom.h:481
struct m0_reqh reqh
Definition: rm_foms.c:48
static const struct m0_fom_type_ops reqhut_fom_type_ops
Definition: reqhut_fom.c:35
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static void reqhut_fom_fini(struct m0_fom *fom)
Definition: reqhut_fom.c:73
static struct m0_fop * fop
Definition: item.c:57
void(* fo_fini)(struct m0_fom *fom)
Definition: fom.h:657
#define out(...)
Definition: gen.c:41
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
void m0_free(void *data)
Definition: memory.c:146
static size_t reqhut_find_fom_home_locality(const struct m0_fom *fom)
Definition: reqhut_fom.c:60
static struct m0_semaphore sem
Definition: reqhut_fom.c:21
Definition: fop.h:79