Motr  M0
m0hsm_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 Seagate Technology LLC and/or its Affiliates
3  * COPYRIGHT 2017-2018 CEA[1] and SAGE partners
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  * [1]Commissariat a l'energie atomique et aux energies alternatives
21  *
22  * Original author: Thomas Leibovici <thomas.leibovici@cea.fr>
23  */
24 
25 #pragma once
26 
27 #ifndef __MOTR_HSM_M0HSM_API_H__
28 #define __MOTR_HSM_M0HSM_API_H__
29 
30 #include <stdio.h>
31 #include <stdint.h>
32 
33 #include "motr/client.h"
34 
35 /*
36  * Before using HSM calls, application should initialize Motr client API
37  * with DIX index enabled (see m0_client_init()). It should then pass the
38  * created client context to HSM by using m0hsm_init().
39  */
40 
43  LOG_NONE = 0,
48 };
49 
50 struct m0hsm_options {
54  time_t op_timeout;
56  FILE *log_stream;
58  FILE *rcfile;
59 };
60 
62 enum {MAX_M0_BUFSZ = 128*1024*1024};
63 
65 #define HSM_TIER_MAX (UINT8_MAX - 1)
66 
72 int m0hsm_init(struct m0_client *instance, struct m0_realm *uber_realm,
73  const struct m0hsm_options *options);
74 
82 int m0hsm_create(struct m0_uint128 id, struct m0_obj *obj,
83  uint8_t tier_idx, bool keep_open);
84 
98 int m0hsm_pwrite(struct m0_obj *obj, void *buf, size_t len, off_t off);
99 
105 int m0hsm_set_write_tier(struct m0_uint128 id, uint8_t tier_idx);
106 
107 
108 /* -------------- HSM low-level calls ------------ */
109 
112  HSM_MOVE = (1 << 0),
115  HSM_KEEP_OLD_VERS = (1 << 1),
119  HSM_WRITE_TO_DEST = (1 << 2),
128 };
129 
141 int m0hsm_copy(struct m0_uint128 obj_id, uint8_t src_tier_idx,
142  uint8_t tgt_tier_idx, off_t offset, size_t length,
143  enum hsm_cp_flags flags);
144 
147  HSM_KEEP_LATEST = (1 << 0),
154 };
155 
164 int m0hsm_release(struct m0_uint128 obj_id, uint8_t tier_idx,
165  off_t offset, size_t length, enum hsm_rls_flags flags);
166 
167 /* -------------- HSM higer-level calls ------------ */
168 
178 int m0hsm_stage(struct m0_uint128 obj_id, uint8_t target_tier,
179  off_t offset, size_t length, enum hsm_cp_flags flags);
180 
189 int m0hsm_archive(struct m0_uint128 obj_id, uint8_t target_tier,
190  off_t offset, size_t length, enum hsm_cp_flags flags);
191 
201 int m0hsm_multi_release(struct m0_uint128 obj_id, uint8_t max_tier,
202  off_t offset, size_t length, enum hsm_rls_flags flags);
203 
204 
211 int m0hsm_dump(FILE *stream, struct m0_uint128 id, bool details);
212 
213 #endif /* __M0HSM_API_H__ */
214 /*
215  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
216  */
Definition: client.h:788
int const char const void size_t int flags
Definition: dir.c:328
FILE * log_stream
Definition: m0hsm_api.h:56
int m0hsm_init(struct m0_client *instance, struct m0_realm *uber_realm, const struct m0hsm_options *options)
Definition: m0hsm_api.c:166
struct m0hsm_options options
Definition: m0hsm_api.c:56
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52
static struct m0_realm uber_realm
Definition: m0hsm.c:49
hsm_cp_flags
Definition: m0hsm_api.h:111
int m0hsm_dump(FILE *stream, struct m0_uint128 id, bool details)
Definition: m0hsm_api.c:875
static struct foo * obj
Definition: tlist.c:302
Definition: sock.c:887
int m0hsm_set_write_tier(struct m0_uint128 id, uint8_t tier_idx)
Definition: m0hsm_api.c:1224
time_t op_timeout
Definition: m0hsm_api.h:54
static m0_bindex_t offset
Definition: dump.c:173
struct m0_uint128 obj_id
Definition: example1.c:53
int m0hsm_stage(struct m0_uint128 obj_id, uint8_t target_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2773
int m0hsm_multi_release(struct m0_uint128 obj_id, uint8_t max_tier, off_t offset, size_t length, enum hsm_rls_flags flags)
Definition: m0hsm_api.c:2499
int m0hsm_pwrite(struct m0_obj *obj, void *buf, size_t len, off_t off)
Definition: m0hsm_api.c:1968
int m0hsm_copy(struct m0_uint128 obj_id, uint8_t src_tier_idx, uint8_t tgt_tier_idx, off_t offset, size_t length, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2715
int m0hsm_release(struct m0_uint128 obj_id, uint8_t tier_idx, off_t offset, size_t length, enum hsm_rls_flags flags)
Definition: m0hsm_api.c:2493
hsm_log_level
Definition: m0hsm_api.h:42
int m0hsm_create(struct m0_uint128 id, struct m0_obj *obj, uint8_t tier_idx, bool keep_open)
Definition: m0hsm_api.c:1571
static struct m0 instance
Definition: main.c:78
FILE * rcfile
Definition: m0hsm_api.h:58
int m0hsm_archive(struct m0_uint128 obj_id, uint8_t target_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2831
hsm_rls_flags
Definition: m0hsm_api.h:146