Motr  M0
rdwr_fom.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-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 
22 #include "lib/errno.h"
23 #include "lib/memory.h"
24 #include "ut/ut.h"
25 #include "fop/fom_long_lock.h"
26 
27 struct test_request;
28 
33 struct fom_rdwr {
35  struct m0_fom fr_gen;
37 
38  /* Long lock UT test data */
40  size_t fr_seqn;
41 };
42 
43 static size_t fom_rdwr_home_locality(const struct m0_fom *fom);
44 static void fop_rdwr_fom_fini(struct m0_fom *fom);
45 static int fom_rdwr_tick(struct m0_fom *fom);
46 
49 static const struct m0_fom_ops fom_rdwr_ops = {
51  .fo_tick = fom_rdwr_tick,
52  .fo_home_locality = fom_rdwr_home_locality
53 };
54 
57  .fto_create = NULL
58 };
59 
62 
63 static size_t fom_rdwr_home_locality(const struct m0_fom *fom)
64 {
65  static size_t locality = 0;
66 
67  M0_PRE(fom != NULL);
68  return locality++;
69 }
70 
71 static int rdwr_fom_create(struct m0_fom **m, struct m0_reqh *reqh)
72 {
73  struct m0_fom *fom;
74  struct fom_rdwr *fom_obj;
75 
76  M0_PRE(m != NULL);
77 
78  M0_ALLOC_PTR(fom_obj);
79  M0_UT_ASSERT(fom_obj != NULL);
80 
81  fom = &fom_obj->fr_gen;
84 
85  *m = fom;
86  return 0;
87 }
88 
89 static void fop_rdwr_fom_fini(struct m0_fom *fom)
90 {
91  struct fom_rdwr *fom_obj;
92 
93  fom_obj = container_of(fom, struct fom_rdwr, fr_gen);
96  m0_free(fom_obj);
97 
98  return;
99 }
100 
101 /*
102  * Local variables:
103  * c-indentation-style: "K&R"
104  * c-basic-offset: 8
105  * tab-width: 8
106  * fill-column: 80
107  * scroll-step: 1
108  * End:
109  */
M0_INTERNAL void m0_long_lock_link_init(struct m0_long_lock_link *link, struct m0_fom *fom, struct m0_long_lock_addb2 *addb2)
Definition: fom_long_lock.c:66
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
static size_t locality(const struct m0_fom *fom)
Definition: rm_foms.c:269
struct m0_long_lock_link fr_link
Definition: rdwr_fom.c:36
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
#define container_of(ptr, type, member)
Definition: misc.h:33
size_t fr_seqn
Definition: rdwr_fom.c:40
struct m0_reqh_service_type ut_long_lock_service_type
Definition: long_lock_ut.c:108
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
static int fom_rdwr_tick(struct m0_fom *fom)
void m0_fom_fini(struct m0_fom *fom)
Definition: fom.c:1324
M0_INTERNAL void m0_long_lock_link_fini(struct m0_long_lock_link *link)
Definition: fom_long_lock.c:76
static const struct m0_fom_ops fom_rdwr_ops
Definition: rdwr_fom.c:49
static int rdwr_fom_create(struct m0_fom **m, struct m0_reqh *reqh)
Definition: rdwr_fom.c:71
static void fop_rdwr_fom_fini(struct m0_fom *fom)
Definition: rdwr_fom.c:89
Definition: reqh.h:94
const struct m0_fom_type_ops fom_rdwr_type_ops
Definition: rdwr_fom.c:56
Definition: dump.c:103
static size_t fom_rdwr_home_locality(const struct m0_fom *fom)
Definition: rdwr_fom.c:63
Definition: fom.h:481
struct m0_reqh reqh
Definition: rm_foms.c:48
struct m0_fom_type rdwr_fom_type
Definition: rdwr_fom.c:61
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
void(* fo_fini)(struct m0_fom *fom)
Definition: fom.h:657
struct m0_fom fr_gen
Definition: rdwr_fom.c:35
void m0_free(void *data)
Definition: memory.c:146
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct test_request * fr_req
Definition: rdwr_fom.c:39