Motr  M0
ss_fops.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2014-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 "lib/misc.h"
25 #include "lib/types.h"
26 #include "lib/refs.h"
27 #include "motr/magic.h"
28 #include "sm/sm.h"
29 #include "fop/fop.h"
30 #include "fop/fom.h"
31 #include "fop/fop_item_type.h"
32 #include "fop/fom_generic.h"
33 #include "rpc/rpc_opcodes.h"
34 #include "rpc/item.h"
35 #include "sss/ss_svc.h"
36 #include "sss/ss_fops.h"
37 #include "sss/ss_fops_xc.h"
38 
41 
42 extern struct m0_sm_state_descr ss_fom_phases[];
43 M0_EXTERN struct m0_sm_conf ss_fom_conf;
44 extern const struct m0_fom_type_ops ss_fom_type_ops;
46 
47 static const struct m0_rpc_item_type_ops ss_item_type_ops = {
49 };
50 
51 M0_INTERNAL int m0_ss_fops_init(void)
52 {
53 #ifndef __KERNEL__
56 
57  /*
58  * Extend phases this FOM needs to open separate BE transaction.
59  * Because extend phases execute before M0_FOPH_TXN_INIT phase.
60  * FOM handler catch M0_FOPH_TXN_INIT phase. If it first time then
61  * move to extended phase else simple way.
62  */
64 
65 #endif
68  .name = "Start Stop fop",
70  .xt = m0_sss_req_xc,
71  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
72  .fop_ops = &ss_fop_type_ops,
73  .fom_ops = &ss_fom_type_ops,
74  .sm = &ss_fom_conf,
75  .svc_type = &m0_ss_svc_type,
78  .name = "Start Stop reply fop",
80  .xt = m0_sss_rep_xc,
81  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY,
82  .fop_ops = &ss_fop_type_ops,
83  .fom_ops = &ss_fom_type_ops,
84  .sm = &ss_fom_conf,
85  .svc_type = &m0_ss_svc_type,
87  return 0;
88 }
89 
90 M0_INTERNAL void m0_ss_fops_fini(void)
91 {
94 }
95 
96 M0_INTERNAL void m0_ss_fop_release(struct m0_ref *ref)
97 {
98  struct m0_fop *fop = container_of(ref, struct m0_fop, f_ref);
99 
100  M0_PRE(fop != NULL);
101 
103  fop->f_data.fd_data = NULL;
104 
105  m0_fop_fini(fop);
106  m0_free(fop);
107 }
108 
109 /*
110  * Local variables:
111  * c-indentation-style: "K&R"
112  * c-basic-offset: 8
113  * tab-width: 8
114  * fill-column: 80
115  * scroll-step: 1
116  * End:
117  */
M0_INTERNAL int m0_ss_fops_init(void)
Definition: ss_fops.c:51
void * fd_data
Definition: fop.h:75
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
Definition: sm.h:350
ss_fom_phases
Definition: ss_svc.h:118
const struct m0_fom_type_ops ss_fom_type_ops
Definition: ss_svc.c:222
const struct m0_fop_type_ops ss_fop_type_ops
Definition: ss_fops.c:45
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
#define M0_BITS(...)
Definition: misc.h:236
struct m0_fop_type m0_fop_ss_fopt
Definition: ss_fops.c:39
#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
struct m0_fop_type m0_fop_ss_rep_fopt
Definition: ss_fops.c:40
const char * name
Definition: trace.c:110
Definition: refs.h:34
uint32_t scf_nr_states
Definition: sm.h:354
M0_EXTERN struct m0_sm_conf ss_fom_conf
Definition: ss_fops.c:43
static const struct m0_rpc_item_type_ops ss_item_type_ops
Definition: ss_fops.c:47
struct m0_reqh_service_type m0_ss_svc_type
Definition: ss_svc.c:159
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
M0_INTERNAL void m0_ss_fop_release(struct m0_ref *ref)
Definition: ss_fops.c:96
struct m0_fop_data f_data
Definition: fop.h:82
struct m0_sm_state_descr * scf_state
Definition: sm.h:356
struct m0_ref f_ref
Definition: fop.h:80
static struct m0_fop * fop
Definition: item.c:57
M0_INTERNAL void m0_ss_fops_fini(void)
Definition: ss_fops.c:90
void m0_free(void *data)
Definition: memory.c:146
uint64_t ft_magix
Definition: fop.h:236
#define M0_FOP_DEFAULT_ITEM_TYPE_OPS
Definition: fop.h:184
Definition: fop.h:79