Motr  M0
di.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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_FILE_DI_H__
26 #define __MOTR_FILE_DI_H__
27 
28 #include "lib/types.h"
29 #include "lib/vec.h"
30 #include "ioservice/io_fops.h"
31 
32 struct m0_file;
33 
60 struct m0_di_type {
64  const char *dt_name;
65 };
66 
70 };
71 
81 };
82 
83 enum {
85 #ifdef ENABLE_DATA_INTEGRITY
87 #else
89 #endif
90 };
91 
92 struct m0_di_ops {
93  const struct m0_di_type *do_type;
98  uint64_t (*do_mask) (const struct m0_file *file);
104  uint64_t (*do_in_shift) (const struct m0_file *file);
109  uint64_t (*do_out_shift)(const struct m0_file *file);
122  void (*do_sum) (const struct m0_file *file,
123  const struct m0_indexvec *io_info,
124  const struct m0_bufvec *in,
125  struct m0_bufvec *out);
131  bool (*do_check) (const struct m0_file *file,
132  const struct m0_indexvec *io_info,
133  const struct m0_bufvec *in,
134  const struct m0_bufvec *out);
135 };
136 
138 M0_INTERNAL const struct m0_di_ops *m0_di_ops_get(enum m0_di_types di_type);
139 
146 M0_INTERNAL void m0_md_di_set(void *addr, m0_bcount_t nob,
147  uint64_t *cksum_field);
148 
155 M0_INTERNAL bool m0_md_di_chk(void *addr, m0_bcount_t nob,
156  uint64_t *cksum_field);
157 
158 #define M0_MD_DI_SET(obj, field) \
159 ({ \
160  void *__obj = (obj); \
161  m0_md_di_set(__obj, sizeof *(obj), &__obj->field); \
162 })
163 
164 #define M0_MD_DI_CHK(obj, field) \
165 ({ \
166  void *__obj = (obj); \
167  m0_md_di_chk(__obj, sizeof *(obj), &__obj->field); \
168 })
169 
177 M0_INTERNAL void m0_crc32(const void *data, uint64_t len,
178  uint64_t *cksum);
179 
188 M0_INTERNAL bool m0_crc32_chk(const void *data, uint64_t len,
189  const uint64_t *cksum);
190 
191 M0_INTERNAL m0_bcount_t m0_di_size_get(const struct m0_file *file,
192  const m0_bcount_t size);
193 
195 #endif /* __MOTR_FILE_DI_H__ */
196 
197 /*
198  * Local variables:
199  * c-indentation-style: "K&R"
200  * c-basic-offset: 8
201  * tab-width: 8
202  * fill-column: 79
203  * scroll-step: 1
204  * End:
205  */
struct m0_file file
Definition: di.c:36
uint64_t(* do_out_shift)(const struct m0_file *file)
Definition: di.h:109
struct m0_bufvec data
Definition: di.c:40
uint64_t m0_bcount_t
Definition: types.h:77
uint64_t(* do_mask)(const struct m0_file *file)
Definition: di.h:98
Definition: di.h:92
const struct m0_di_type * do_type
Definition: di.h:93
void(* do_sum)(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in, struct m0_bufvec *out)
Definition: di.h:122
M0_INTERNAL bool m0_crc32_chk(const void *data, uint64_t len, const uint64_t *cksum)
Definition: crc.c:93
m0_di_types
Definition: di.h:72
Definition: di.h:80
const char * dt_name
Definition: di.h:64
M0_INTERNAL void m0_crc32(const void *data, uint64_t len, uint64_t *cksum)
Definition: crc.c:83
m0_di_checksum_len
Definition: di.h:67
Definition: xcode.h:73
uint64_t(* do_in_shift)(const struct m0_file *file)
Definition: di.h:104
bool(* do_check)(const struct m0_file *file, const struct m0_indexvec *io_info, const struct m0_bufvec *in, const struct m0_bufvec *out)
Definition: di.h:131
M0_INTERNAL m0_bcount_t m0_di_size_get(const struct m0_file *file, const m0_bcount_t size)
Definition: di.c:384
M0_INTERNAL const struct m0_di_ops * m0_di_ops_get(enum m0_di_types di_type)
Definition: di.c:365
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL bool m0_md_di_chk(void *addr, m0_bcount_t nob, uint64_t *cksum_field)
Definition: di.c:378
#define out(...)
Definition: gen.c:41
Definition: file.h:81
Definition: di.h:73
M0_INTERNAL void m0_md_di_set(void *addr, m0_bcount_t nob, uint64_t *cksum_field)
Definition: di.c:372
Definition: vec.h:145
Definition: di.h:60