Motr  M0
helper.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 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 #pragma once
23 
24 #ifndef __MOTR_ST_UTILS_HELPER_H__
25 #define __MOTR_ST_UTILS_HELPER_H__
26 
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <fcntl.h>
32 #include <sys/time.h>
33 
34 #include "conf/obj.h"
35 #include "fid/fid.h"
36 #include "motr/client.h"
37 #include "motr/idx.h"
38 
43 enum { M0_MAX_BLOCK_COUNT = 100 };
44 
45 enum {
47  BLK_SIZE_4k = 4096,
49  BLK_SIZE_32m = 32 * 1024 * 1024
50 };
51 
52 /* It is used for allignment in help messages */
53 enum { WIDTH = 32 };
54 
55 struct m0_cc_io_args {
58  uint32_t cia_block_count;
59  uint32_t cia_block_size;
60  char **cia_files;
61  int cia_index;
62 };
63 
66  uint64_t cup_block_size;
67  uint64_t cup_block_count;
68  int cup_n_obj;
69  uint64_t cup_offset;
71  uint64_t cup_trunc_len;
72  char *cup_file;
75  struct m0_fid cup_pver;
76  uint32_t flags;
77 };
78 
83  int *cma_rc;
84  int cma_index;
85 };
86 
88  int (*olo_lock_init)(struct m0_obj *obj);
89 
90  void (*olo_lock_fini)(struct m0_obj *obj);
91 
93  struct m0_rm_lock_req *req,
94  struct m0_clink *clink);
95 
97  struct m0_rm_lock_req *req);
98 
100  struct m0_rm_lock_req *req,
101  struct m0_clink *clink);
102 
104  struct m0_rm_lock_req *req);
105 
106  void (*olo_lock_put)(struct m0_rm_lock_req *req);
107 };
108 
109 int client_init(struct m0_config *config,
110  struct m0_container *container,
111  struct m0_client **m0_instance);
112 
113 void client_fini(struct m0_client *m0_instance);
114 
115 int touch(struct m0_container *container,
116  struct m0_uint128 id, bool take_locks);
117 
118 int m0_write(struct m0_container *container,
119  char *src, struct m0_uint128 id, uint32_t block_size,
120  uint32_t block_count, uint64_t update_offset, int blks_per_io,
121  bool take_locks, bool update_mode);
122 
123 int m0_read(struct m0_container *container,
124  struct m0_uint128 id, char *dest, uint32_t block_size,
125  uint32_t block_count, uint64_t offset, int blks_per_io,
126  bool take_locks, uint32_t flags, struct m0_fid *read_pver);
127 
129  struct m0_uint128 id, uint32_t block_size,
130  uint32_t trunc_count, uint32_t trunc_len, int blks_per_io,
131  bool take_locks);
132 
133 int m0_unlink(struct m0_container *container,
134  struct m0_uint128 id, bool take_locks);
136  char **src, struct m0_uint128 id, int *index,
137  uint32_t block_size, uint32_t block_count);
138 
139 int m0_read_cc(struct m0_container *container,
140  struct m0_uint128 id, char **dest, int *index,
141  uint32_t block_size, uint32_t block_count);
142 
143 
144 int m0_obj_id_sscanf(char *idstr, struct m0_uint128 *obj_id);
145 
146 int m0_utility_args_init(int argc, char **argv,
147  struct m0_utility_param *params,
148  struct m0_idx_dix_config *dix_conf,
149  struct m0_config *conf,
150  void (*utility_usage) (FILE*, char*));
151 #endif /* __MOTR_ST_UTILS_HELPER_H__ */
152 
153 /*
154  * Local variables:
155  * c-indentation-style: "K&R"
156  * c-basic-offset: 8
157  * tab-width: 8
158  * fill-column: 80
159  * scroll-step: 1
160  * End:
161  */
uint64_t cup_trunc_len
Definition: helper.h:71
int m0_write(struct m0_container *container, char *src, struct m0_uint128 id, uint32_t block_size, uint32_t block_count, uint64_t update_offset, int blks_per_io, bool take_locks, bool update_mode)
Definition: helper.c:352
Definition: client.h:788
int const char const void size_t int flags
Definition: dir.c:328
int m0_obj_id_sscanf(char *idstr, struct m0_uint128 *obj_id)
Definition: helper.c:199
static struct io_request req
Definition: file.c:100
struct m0_container container
void(* olo_lock_fini)(struct m0_obj *obj)
Definition: helper.h:90
uint64_t cup_block_size
Definition: helper.h:66
void(* olo_lock_put)(struct m0_rm_lock_req *req)
Definition: helper.h:106
struct m0_container * cia_container
Definition: helper.h:56
int cia_index
Definition: helper.h:61
int m0_read_cc(struct m0_container *container, struct m0_uint128 id, char **dest, int *index, uint32_t block_size, uint32_t block_count)
Definition: helper.c:814
int touch(struct m0_container *container, struct m0_uint128 id, bool take_locks)
Definition: helper.c:310
Definition: conf.py:1
struct m0_utility_param * cma_utility
Definition: helper.h:80
Definition: config.py:1
static struct foo * obj
Definition: tlist.c:302
bool cup_take_locks
Definition: helper.h:70
int(* olo_write_lock_get)(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
Definition: helper.h:92
int(* olo_read_lock_get_sync)(struct m0_obj *obj, struct m0_rm_lock_req *req)
Definition: helper.h:103
uint64_t cup_block_count
Definition: helper.h:67
int m0_write_cc(struct m0_container *container, char **src, struct m0_uint128 id, int *index, uint32_t block_size, uint32_t block_count)
Definition: helper.c:741
uint32_t cia_block_size
Definition: helper.h:59
int(* olo_read_lock_get)(struct m0_obj *obj, struct m0_rm_lock_req *req, struct m0_clink *clink)
Definition: helper.h:99
bool cup_update_mode
Definition: helper.h:74
struct m0_mutex cma_mutex
Definition: helper.h:82
struct m0_uint128 * cma_ids
Definition: helper.h:81
int m0_truncate(struct m0_container *container, struct m0_uint128 id, uint32_t block_size, uint32_t trunc_count, uint32_t trunc_len, int blks_per_io, bool take_locks)
Definition: helper.c:607
static struct m0_idx_dix_config dix_conf
Definition: m0hsm.c:51
int m0_utility_args_init(int argc, char **argv, struct m0_utility_param *params, struct m0_idx_dix_config *dix_conf, struct m0_config *conf, void(*utility_usage)(FILE *, char *))
Definition: helper.c:915
struct m0_uint128 cia_id
Definition: helper.h:57
uint32_t flags
Definition: helper.h:76
static m0_bindex_t offset
Definition: dump.c:173
struct m0_uint128 cup_id
Definition: helper.h:65
struct m0_uint128 obj_id
Definition: example1.c:53
static struct m0_clink clink[RDWR_REQUEST_MAX]
uint64_t cup_offset
Definition: helper.h:69
int(* olo_lock_init)(struct m0_obj *obj)
Definition: helper.h:88
char ** cia_files
Definition: helper.h:60
int cup_blks_per_io
Definition: helper.h:73
int m0_read(struct m0_container *container, struct m0_uint128 id, char *dest, uint32_t block_size, uint32_t block_count, uint64_t offset, int blks_per_io, bool take_locks, uint32_t flags, struct m0_fid *read_pver)
Definition: helper.c:466
int client_init(struct m0_config *config, struct m0_container *container, struct m0_client **m0_instance)
Definition: helper.c:170
char * cup_file
Definition: helper.h:72
Definition: fid.h:38
int * cma_rc
Definition: helper.h:83
uint32_t cia_block_count
Definition: helper.h:58
Definition: common.h:34
int(* olo_write_lock_get_sync)(struct m0_obj *obj, struct m0_rm_lock_req *req)
Definition: helper.h:96
Definition: helper.h:53
struct m0_fid cup_pver
Definition: helper.h:75
void client_fini(struct m0_client *m0_instance)
Definition: helper.c:194
Definition: mutex.h:47
struct m0_pdclust_src_addr src
Definition: fd.c:108
int m0_unlink(struct m0_container *container, struct m0_uint128 id, bool take_locks)
Definition: helper.c:683
int cma_index
Definition: helper.h:84