Motr  M0
mdstore.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2011-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 #pragma once
24 
25 #ifndef __MOTR_MDSTORE_MDSTORE_H__
26 #define __MOTR_MDSTORE_MDSTORE_H__
27 
28 #include "cob/cob.h"
29 
30 struct m0_sm_group;
31 struct m0_cob_domain_id;
32 struct m0_be_tx;
33 struct m0_fid;
34 struct m0_fop;
35 struct m0_cob;
36 
43 #define M0_MD_MAX_NAME_LEN 256
44 
45 struct m0_statfs {
46  uint64_t sf_type;
47  uint32_t sf_bsize;
48  uint64_t sf_blocks;
49  uint64_t sf_bfree;
50  uint64_t sf_bavail;
51  uint64_t sf_files;
52  uint64_t sf_ffree;
53  uint32_t sf_namelen;
54  struct m0_fid sf_root;
55 };
56 
57 struct m0_mdstore {
59  struct m0_cob *md_root;
60 };
61 
73 };
74 
76 
80 M0_INTERNAL int m0_mdstore_statfs(struct m0_mdstore *md,
81  struct m0_statfs *statfs);
82 
87 M0_INTERNAL int m0_mdstore_init(struct m0_mdstore *md,
88  struct m0_be_seg *db,
89  bool init_root);
90 
94 M0_INTERNAL void m0_mdstore_fini(struct m0_mdstore *md);
95 
99 M0_INTERNAL int m0_mdstore_create(struct m0_mdstore *md,
100  struct m0_sm_group *grp,
101  struct m0_cob_domain_id *id,
102  struct m0_be_domain *bedom,
103  struct m0_be_seg *db);
104 
108 M0_INTERNAL int m0_mdstore_destroy(struct m0_mdstore *md,
109  struct m0_sm_group *grp,
110  struct m0_be_domain *bedom);
111 
117 M0_INTERNAL int m0_mdstore_link(struct m0_mdstore *md,
118  struct m0_fid *pfid,
119  struct m0_cob *cob,
120  struct m0_buf *name,
121  struct m0_be_tx *tx);
122 
128 M0_INTERNAL int m0_mdstore_unlink(struct m0_mdstore *md,
129  struct m0_fid *pfid,
130  struct m0_cob *cob,
131  struct m0_buf *name,
132  struct m0_be_tx *tx);
133 
141 M0_INTERNAL int m0_mdstore_rename(struct m0_mdstore *md,
142  struct m0_fid *pfid_tgt,
143  struct m0_fid *pfid_src,
144  struct m0_cob *cob_tgt,
145  struct m0_cob *cob_src,
146  struct m0_buf *tname,
147  struct m0_buf *sname,
148  struct m0_be_tx *tx);
149 
156 M0_INTERNAL int m0_mdstore_fcreate(struct m0_mdstore *md,
157  struct m0_fid *pfid,
158  struct m0_cob_attr *attr,
159  struct m0_cob **out,
160  struct m0_be_tx *tx);
161 
167 M0_INTERNAL int m0_mdstore_open(struct m0_mdstore *md,
168  struct m0_cob *cob,
170  struct m0_be_tx *tx);
171 
178 M0_INTERNAL int m0_mdstore_close(struct m0_mdstore *md,
179  struct m0_cob *cob,
180  struct m0_be_tx *tx);
181 
188 M0_INTERNAL int m0_mdstore_setattr(struct m0_mdstore *md,
189  struct m0_cob *cob,
190  struct m0_cob_attr *attr,
191  struct m0_be_tx *tx);
192 
199 M0_INTERNAL int m0_mdstore_getattr(struct m0_mdstore *md,
200  struct m0_cob *cob,
201  struct m0_cob_attr *attr);
202 
209 M0_INTERNAL int m0_mdstore_readdir(struct m0_mdstore *md,
210  struct m0_cob *cob,
211  struct m0_rdpg *rdpg);
212 
216 M0_INTERNAL int m0_mdstore_locate(struct m0_mdstore *md,
217  const struct m0_fid *fid,
218  struct m0_cob **cob,
219  int flags);
220 
224 M0_INTERNAL int m0_mdstore_lookup(struct m0_mdstore *md,
225  struct m0_fid *pfid,
226  struct m0_buf *name,
227  struct m0_cob **cob);
228 
235 M0_INTERNAL int m0_mdstore_path(struct m0_mdstore *md,
236  struct m0_fid *fid,
237  char **path);
238 
239 M0_INTERNAL void
241  struct m0_be_tx_credit *accum);
242 
243 M0_INTERNAL void
245  struct m0_be_tx_credit *accum);
246 
247 M0_INTERNAL void
249  struct m0_be_tx_credit *accum);
250 
251 M0_INTERNAL void
253  struct m0_be_tx_credit *accum);
254 
255 M0_INTERNAL void
257  struct m0_be_tx_credit *accum);
258 
259 M0_INTERNAL int m0_mdstore_mod_init(void);
260 M0_INTERNAL void m0_mdstore_mod_fini(void);
261  /* end of mdstore group */
263 
264 /* __MOTR_MDSTORE_MDSTORE_H__ */
265 #endif
266 
267 /*
268  * Local variables:
269  * c-indentation-style: "K&R"
270  * c-basic-offset: 8
271  * tab-width: 8
272  * fill-column: 80
273  * scroll-step: 1
274  * End:
275  */
M0_INTERNAL void m0_mdstore_fini(struct m0_mdstore *md)
Definition: mdstore.c:130
Definition: cob.h:581
struct m0_cob_domain * md_dom
Definition: mdstore.h:58
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL int m0_mdstore_init(struct m0_mdstore *md, struct m0_be_seg *db, bool init_root)
Definition: mdstore.c:78
static struct m0_sm_group * grp
Definition: bytecount.c:38
M0_INTERNAL int m0_mdstore_locate(struct m0_mdstore *md, const struct m0_fid *fid, struct m0_cob **cob, int flags)
Definition: mdstore.c:819
uint64_t sf_files
Definition: mdstore.h:51
static struct m0_mdstore md
Definition: sd_common.c:42
M0_INTERNAL int m0_mdstore_statfs(struct m0_mdstore *md, struct m0_statfs *statfs)
Definition: mdstore.c:55
uint32_t sf_bsize
Definition: mdstore.h:47
M0_INTERNAL int m0_mdstore_close(struct m0_mdstore *md, struct m0_cob *cob, struct m0_be_tx *tx)
Definition: mdstore.c:536
struct m0_fid fid
Definition: di.c:46
M0_INTERNAL int m0_mdstore_fcreate(struct m0_mdstore *md, struct m0_fid *pfid, struct m0_cob_attr *attr, struct m0_cob **out, struct m0_be_tx *tx)
Definition: mdstore.c:209
M0_INTERNAL void m0_mdstore_unlink_credit(struct m0_mdstore *md, struct m0_be_tx_credit *accum)
Definition: mdstore.c:380
Definition: buf.h:37
M0_INTERNAL int m0_mdstore_link(struct m0_mdstore *md, struct m0_fid *pfid, struct m0_cob *cob, struct m0_buf *name, struct m0_be_tx *tx)
Definition: mdstore.c:295
M0_INTERNAL void m0_mdstore_create_credit(struct m0_mdstore *md, struct m0_be_tx_credit *accum)
Definition: mdstore.c:202
const char * name
Definition: trace.c:110
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
uint64_t sf_bfree
Definition: mdstore.h:49
static struct m0_cob * cob
Definition: bytecount.c:40
uint32_t sf_namelen
Definition: mdstore.h:53
uint64_t sf_ffree
Definition: mdstore.h:52
m0_mdstore_locate_flags
Definition: mdstore.h:66
uint64_t sf_blocks
Definition: mdstore.h:48
M0_INTERNAL int m0_mdstore_open(struct m0_mdstore *md, struct m0_cob *cob, m0_mdstore_locate_flags_t flags, struct m0_be_tx *tx)
Definition: mdstore.c:525
M0_INTERNAL int m0_mdstore_mod_init(void)
Definition: mdstore.c:41
M0_INTERNAL int m0_mdstore_readdir(struct m0_mdstore *md, struct m0_cob *cob, struct m0_rdpg *rdpg)
Definition: mdstore.c:705
Definition: seg.h:66
struct m0_fid sf_root
Definition: mdstore.h:54
M0_INTERNAL void m0_mdstore_mod_fini(void)
Definition: mdstore.c:46
M0_INTERNAL int m0_mdstore_path(struct m0_mdstore *md, struct m0_fid *fid, char **path)
Definition: mdstore.c:900
M0_INTERNAL int m0_mdstore_rename(struct m0_mdstore *md, struct m0_fid *pfid_tgt, struct m0_fid *pfid_src, struct m0_cob *cob_tgt, struct m0_cob *cob_src, struct m0_buf *tname, struct m0_buf *sname, struct m0_be_tx *tx)
Definition: mdstore.c:560
struct m0_cob * md_root
Definition: mdstore.h:59
M0_INTERNAL void m0_mdstore_rename_credit(struct m0_mdstore *md, struct m0_be_tx_credit *accum)
Definition: mdstore.c:553
Definition: fid.h:38
M0_INTERNAL int m0_mdstore_create(struct m0_mdstore *md, struct m0_sm_group *grp, struct m0_cob_domain_id *id, struct m0_be_domain *bedom, struct m0_be_seg *db)
Definition: mdstore.c:135
M0_INTERNAL void m0_mdstore_setattr_credit(struct m0_mdstore *md, struct m0_be_tx_credit *accum)
Definition: mdstore.c:626
M0_INTERNAL int m0_mdstore_unlink(struct m0_mdstore *md, struct m0_fid *pfid, struct m0_cob *cob, struct m0_buf *name, struct m0_be_tx *tx)
Definition: mdstore.c:388
enum m0_mdstore_locate_flags m0_mdstore_locate_flags_t
Definition: mdstore.h:75
Definition: cob.h:607
uint64_t sf_bavail
Definition: mdstore.h:50
M0_INTERNAL void m0_mdstore_link_credit(struct m0_mdstore *md, struct m0_be_tx_credit *accum)
Definition: mdstore.c:288
M0_INTERNAL int m0_mdstore_destroy(struct m0_mdstore *md, struct m0_sm_group *grp, struct m0_be_domain *bedom)
Definition: mdstore.c:146
M0_INTERNAL int m0_mdstore_setattr(struct m0_mdstore *md, struct m0_cob *cob, struct m0_cob_attr *attr, struct m0_be_tx *tx)
Definition: mdstore.c:632
#define out(...)
Definition: gen.c:41
M0_INTERNAL int m0_mdstore_lookup(struct m0_mdstore *md, struct m0_fid *pfid, struct m0_buf *name, struct m0_cob **cob)
Definition: mdstore.c:863
M0_INTERNAL int m0_mdstore_getattr(struct m0_mdstore *md, struct m0_cob *cob, struct m0_cob_attr *attr)
Definition: mdstore.c:642
uint64_t sf_type
Definition: mdstore.h:46
Definition: fop.h:79
Definition: tx.h:280