Motr  M0
md_fops.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-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/string.h"
23 #include "lib/memory.h"
24 #include "lib/errno.h"
25 #include "fop/fop.h"
26 #include "fop/fom_generic.h"
27 #include "fop/fop_item_type.h"
28 #include "rpc/rpc_opcodes.h"
29 #include "mdservice/md_foms.h"
30 #include "mdservice/md_fops.h"
31 #include "mdservice/md_fops_xc.h"
32 
33 static int md_fol_frag_undo(struct m0_fop_fol_frag *ffrag,
34  struct m0_fol *fol);
35 static int md_fol_frag_redo(struct m0_fop_fol_frag *ffrag,
36  struct m0_fol *fol);
37 
40  .fto_redo = md_fol_frag_redo,
41 };
42 
43 #ifndef __KERNEL__
45  /* This field is patched by UT. */
47 };
48 
49 extern struct m0_reqh_service_type m0_mds_type;
50 #endif
51 
67 
83 
84 M0_INTERNAL int m0_mdservice_fopts_init(void)
85 {
87 
89  .name = "create",
91  .xt = m0_fop_create_xc,
92  .rpc_flags = M0_RPC_MUTABO_REQ,
93  .fop_ops = &m0_md_fop_ops,
94 #ifndef __KERNEL__
95  .fom_ops = &m0_md_fom_ops,
96  .svc_type = &m0_mds_type,
97 #endif
98  .sm = &m0_generic_conf);
100  .name = "lookup",
102  .xt = m0_fop_lookup_xc,
103  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
104  .fop_ops = &m0_md_fop_ops,
105 #ifndef __KERNEL__
106  .fom_ops = &m0_md_fom_ops,
107  .svc_type = &m0_mds_type,
108 #endif
109  .sm = &m0_generic_conf);
111  .name = "hardlink",
113  .xt = m0_fop_link_xc,
114  .rpc_flags = M0_RPC_MUTABO_REQ,
115  .fop_ops = &m0_md_fop_ops,
116 #ifndef __KERNEL__
117  .fom_ops = &m0_md_fom_ops,
118  .svc_type = &m0_mds_type,
119 #endif
120  .sm = &m0_generic_conf);
122  .name = "unlink",
124  .xt = m0_fop_unlink_xc,
125  .rpc_flags = M0_RPC_MUTABO_REQ,
126  .fop_ops = &m0_md_fop_ops,
127 #ifndef __KERNEL__
128  .fom_ops = &m0_md_fom_ops,
129  .svc_type = &m0_mds_type,
130 #endif
131  .sm = &m0_generic_conf);
133  .name = "open",
135  .xt = m0_fop_open_xc,
136  .rpc_flags = M0_RPC_MUTABO_REQ,
137  .fop_ops = &m0_md_fop_ops,
138 #ifndef __KERNEL__
139  .fom_ops = &m0_md_fom_ops,
140  .svc_type = &m0_mds_type,
141 #endif
142  .sm = &m0_generic_conf);
144  .name = "close",
146  .xt = m0_fop_close_xc,
147  /*
148  * Close needs transactions for open-unlinked case.
149  */
150  .rpc_flags = M0_RPC_MUTABO_REQ,
151  .fop_ops = &m0_md_fop_ops,
152 #ifndef __KERNEL__
153  .fom_ops = &m0_md_fom_ops,
154  .svc_type = &m0_mds_type,
155 #endif
156  .sm = &m0_generic_conf);
158  .name = "setattr",
160  .xt = m0_fop_setattr_xc,
161  .rpc_flags = M0_RPC_MUTABO_REQ,
162  .fop_ops = &m0_md_fop_ops,
163 #ifndef __KERNEL__
164  .fom_ops = &m0_md_fom_ops,
165  .svc_type = &m0_mds_type,
166 #endif
167  .sm = &m0_generic_conf);
169  .name = "getattr",
171  .xt = m0_fop_getattr_xc,
172  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
173  .fop_ops = &m0_md_fop_ops,
174 #ifndef __KERNEL__
175  .fom_ops = &m0_md_fom_ops,
176  .svc_type = &m0_mds_type,
177 #endif
178  .sm = &m0_generic_conf);
180  .name = "setxattr",
182  .xt = m0_fop_setxattr_xc,
183  .rpc_flags = M0_RPC_MUTABO_REQ,
184  .fop_ops = &m0_md_fop_ops,
185 #ifndef __KERNEL__
186  .fom_ops = &m0_md_fom_ops,
187  .svc_type = &m0_mds_type,
188 #endif
189  .sm = &m0_generic_conf);
191  .name = "getxattr",
193  .xt = m0_fop_getxattr_xc,
194  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
195  .fop_ops = &m0_md_fop_ops,
196 #ifndef __KERNEL__
197  .fom_ops = &m0_md_fom_ops,
198  .svc_type = &m0_mds_type,
199 #endif
200  .sm = &m0_generic_conf);
202  .name = "delxattr",
204  .xt = m0_fop_delxattr_xc,
205  .rpc_flags = M0_RPC_MUTABO_REQ,
206  .fop_ops = &m0_md_fop_ops,
207 #ifndef __KERNEL__
208  .fom_ops = &m0_md_fom_ops,
209  .svc_type = &m0_mds_type,
210 #endif
211  .sm = &m0_generic_conf);
213  .name = "listxattr",
215  .xt = m0_fop_listxattr_xc,
216  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
217  .fop_ops = &m0_md_fop_ops,
218 #ifndef __KERNEL__
219  .fom_ops = &m0_md_fom_ops,
220  .svc_type = &m0_mds_type,
221 #endif
222  .sm = &m0_generic_conf);
224  .name = "statfs",
226  .xt = m0_fop_statfs_xc,
227  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
228  .fop_ops = &m0_md_fop_ops,
229 #ifndef __KERNEL__
230  .fom_ops = &m0_md_fom_ops,
231  .svc_type = &m0_mds_type,
232 #endif
233  .sm = &m0_generic_conf);
235  .name = "rename",
237  .xt = m0_fop_rename_xc,
238  .rpc_flags = M0_RPC_MUTABO_REQ,
239  .fop_ops = &m0_md_fop_ops,
240 #ifndef __KERNEL__
241  .fom_ops = &m0_md_fom_ops,
242  .svc_type = &m0_mds_type,
243 #endif
244  .sm = &m0_generic_conf);
246  .name = "readdir",
248  .xt = m0_fop_readdir_xc,
249  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST,
250  .fop_ops = &m0_md_fop_ops,
251 #ifndef __KERNEL__
252  .fom_ops = &m0_md_fom_ops,
253  .svc_type = &m0_mds_type,
254 #endif
255  .sm = &m0_generic_conf);
256  return 0;
257 }
258 
259 M0_INTERNAL int m0_mdservice_rep_fopts_init(void)
260 {
262 
264  .name = "create-reply",
266  .xt = m0_fop_create_rep_xc,
267  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
269  .name = "lookup-reply",
271  .xt = m0_fop_lookup_rep_xc,
272  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
274  .name = "hardlink-reply",
276  .xt = m0_fop_link_rep_xc,
277  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
279  .name = "unlink-reply",
281  .xt = m0_fop_unlink_rep_xc,
282  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
284  .name = "open-reply",
286  .xt = m0_fop_open_rep_xc,
287  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
289  .name = "close-reply",
291  .xt = m0_fop_close_rep_xc,
292  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
294  .name = "setattr-reply",
296  .xt = m0_fop_setattr_rep_xc,
297  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
299  .name = "getattr-reply",
301  .xt = m0_fop_getattr_rep_xc,
302  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
304  .name = "setxattr-reply",
306  .xt = m0_fop_setxattr_rep_xc,
307  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
309  .name = "getxattr-reply",
311  .xt = m0_fop_getxattr_rep_xc,
312  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
314  .name = "delxattr-reply",
316  .xt = m0_fop_delxattr_rep_xc,
317  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
319  .name = "listxattr-reply",
321  .xt = m0_fop_listxattr_rep_xc,
322  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
324  .name = "statfs-reply",
326  .xt = m0_fop_statfs_rep_xc,
327  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
329  .name = "rename-reply",
331  .xt = m0_fop_rename_rep_xc,
332  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
334  .name = "readdir-reply",
336  .xt = m0_fop_readdir_rep_xc,
337  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
338  return 0;
339 }
340 
341 M0_INTERNAL int m0_mdservice_fop_init(void)
342 {
343  return m0_mdservice_fopts_init() ?:
345 }
346 M0_EXPORTED(m0_mdservice_fop_init);
347 
348 M0_INTERNAL void m0_mdservice_fop_fini(void)
349 {
365 
381 
382  m0_xc_mdservice_md_fops_fini();
383 }
384 M0_EXPORTED(m0_mdservice_fop_fini);
385 
386 static int md_fol_frag_undo(struct m0_fop_fol_frag *ffrag,
387  struct m0_fol *fol)
388 {
393  return 0;
394 }
395 
396 static int md_fol_frag_redo(struct m0_fop_fol_frag *ffrag,
397  struct m0_fol *fol)
398 {
403  return 0;
404 }
405 
406 /*
407  * Local variables:
408  * c-indentation-style: "K&R"
409  * c-basic-offset: 8
410  * tab-width: 8
411  * fill-column: 80
412  * scroll-step: 1
413  * End:
414  */
const struct m0_fop_type_ops m0_md_fop_ops
Definition: md_fops.c:38
struct m0_fop_type m0_fop_setxattr_fopt
Definition: md_fops.c:60
Definition: fol.h:140
struct m0_fop_type m0_fop_statfs_fopt
Definition: md_fops.c:64
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
M0_INTERNAL int m0_mdservice_rep_fopts_init(void)
Definition: md_fops.c:259
struct m0_fop_type m0_fop_getattr_fopt
Definition: md_fops.c:59
M0_INTERNAL int m0_mdservice_fop_init(void)
Definition: md_fops.c:341
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
struct m0_reqh_service_type m0_mds_type
Definition: md_service.c:72
struct m0_fop_type m0_fop_create_fopt
Definition: md_fops.c:52
struct m0_fop_type m0_fop_create_rep_fopt
Definition: md_fops.c:68
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
M0_INTERNAL int m0_mdservice_fopts_init(void)
Definition: md_fops.c:84
struct m0_fop_type m0_fop_getxattr_fopt
Definition: md_fops.c:61
const struct m0_sm_conf m0_generic_conf
Definition: fom_generic.c:838
M0_INTERNAL int m0_md_req_fom_create(struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
Definition: md_foms.c:1437
int opcode
Definition: crate.c:301
M0_INTERNAL void m0_mdservice_fop_fini(void)
Definition: md_fops.c:348
struct m0_fop_type m0_fop_getxattr_rep_fopt
Definition: md_fops.c:77
struct m0_fop_type m0_fop_getattr_rep_fopt
Definition: md_fops.c:75
const char * name
Definition: trace.c:110
struct m0_fop_type m0_fop_unlink_rep_fopt
Definition: md_fops.c:71
struct m0_fop_type m0_fop_unlink_fopt
Definition: md_fops.c:55
struct m0_fop_type m0_fop_close_rep_fopt
Definition: md_fops.c:73
struct m0_fop_type m0_fop_delxattr_rep_fopt
Definition: md_fops.c:78
struct m0_fom_type_ops m0_md_fom_ops
Definition: md_fops.c:44
struct m0_fop_type m0_fop_rename_rep_fopt
Definition: md_fops.c:81
static int md_fol_frag_undo(struct m0_fop_fol_frag *ffrag, struct m0_fol *fol)
Definition: md_fops.c:386
struct m0_fop_type m0_fop_setxattr_rep_fopt
Definition: md_fops.c:76
struct m0_fop_type m0_fop_listxattr_fopt
Definition: md_fops.c:63
struct m0_fop_type m0_fop_rename_fopt
Definition: md_fops.c:65
struct m0_fop_type m0_fop_link_rep_fopt
Definition: md_fops.c:70
struct m0_fop_type m0_fop_listxattr_rep_fopt
Definition: md_fops.c:79
struct m0_fop_type m0_fop_setattr_fopt
Definition: md_fops.c:58
#define M0_FOP_TYPE_INIT2_DECL
Definition: fop.h:316
struct m0_fop_type m0_fop_readdir_fopt
Definition: md_fops.c:66
static int md_fol_frag_redo(struct m0_fop_fol_frag *ffrag, struct m0_fol *fol)
Definition: md_fops.c:396
struct m0_fop_type m0_fop_open_fopt
Definition: md_fops.c:56
struct m0_fop_type m0_fop_delxattr_fopt
Definition: md_fops.c:62
struct m0_fop_type m0_fop_lookup_fopt
Definition: md_fops.c:53
#define M0_FOP_TYPE_INIT2(ft,...)
Definition: fop.h:317
struct m0_fop_type m0_fop_setattr_rep_fopt
Definition: md_fops.c:74
struct m0_fop_type m0_fop_open_rep_fopt
Definition: md_fops.c:72
int(* fto_undo)(struct m0_fop_fol_frag *ffrag, struct m0_fol *fol)
Definition: fop.h:273
struct m0_fop_type m0_fop_lookup_rep_fopt
Definition: md_fops.c:69
struct m0_fop_type m0_fop_statfs_rep_fopt
Definition: md_fops.c:80
struct m0_fop_type m0_fop_close_fopt
Definition: md_fops.c:57
struct m0_fop_type m0_fop_link_fopt
Definition: md_fops.c:54
struct m0_fop_type m0_fop_readdir_rep_fopt
Definition: md_fops.c:82