Motr  M0
io.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 
24 #pragma once
25 
26 #ifndef __MOTR_BE_IO_H__
27 #define __MOTR_BE_IO_H__
28 
29 #include "lib/chan.h" /* m0_clink */
30 #include "lib/types.h" /* m0_bcount_t */
31 #include "lib/atomic.h" /* m0_atomic64 */
32 #include "lib/ext.h" /* m0_ext */
33 #include "lib/tlist.h" /* m0_tlink */
34 #include "lib/ext.h" /* m0_ext */
35 
36 #include "be/op.h" /* m0_be_op */
37 
38 #include "stob/io.h" /* m0_stob_io */
39 #include "sm/sm.h" /* m0_sm_ast */
40 
53 struct m0_stob;
54 struct m0_be_io;
55 struct m0_be_io_sched;
56 
57 struct m0_be_io_part {
61  struct m0_stob *bip_stob;
62  uint32_t bip_bshift;
63  struct m0_be_io *bip_bio;
64  int bip_rc;
65 };
66 
71  uint64_t bic_reg_nr;
73  uint64_t bic_part_nr;
74 };
75 
76 #define M0_BE_IO_CREDIT(reg_nr, reg_size, part_nr) (struct m0_be_io_credit){ \
77  .bic_reg_nr = (reg_nr), \
78  .bic_reg_size = (reg_size), \
79  .bic_part_nr = (part_nr), \
80 }
81 
82 #define BE_IOCRED_F "(reg_nr=%" PRIu64 " reg_size=%" PRIu64 \
83  " part_nr=%" PRIu64 ")"
84 #define BE_IOCRED_P(iocred) \
85  (iocred)->bic_reg_nr, (iocred)->bic_reg_size, (iocred)->bic_part_nr
86 
87 struct m0_be_io {
93  uint32_t bio_vec_pos;
97  unsigned bio_stob_nr;
108  struct m0_be_op *bio_op;
110  bool bio_sync;
113 
115 
116  /* m0_be_io_sched fields */
119  uint64_t bio_sched_magic;
123  struct m0_ext bio_ext;
124 };
125 
126 M0_INTERNAL int m0_be_io_init(struct m0_be_io *bio);
127 M0_INTERNAL void m0_be_io_fini(struct m0_be_io *bio);
128 M0_INTERNAL bool m0_be_io__invariant(struct m0_be_io *bio);
129 
130 M0_INTERNAL int m0_be_io_allocate(struct m0_be_io *bio,
131  struct m0_be_io_credit *iocred);
132 M0_INTERNAL void m0_be_io_deallocate(struct m0_be_io *bio);
133 
134 
135 M0_INTERNAL void m0_be_io_add(struct m0_be_io *bio,
136  struct m0_stob *stob,
137  void *ptr_user,
138  m0_bindex_t offset_stob,
139  m0_bcount_t size);
140 
141 M0_INTERNAL void m0_be_io_add_nostob(struct m0_be_io *bio,
142  void *ptr_user,
143  m0_bindex_t offset_stob,
144  m0_bcount_t size);
145 M0_INTERNAL void m0_be_io_stob_assign(struct m0_be_io *bio,
146  struct m0_stob *stob,
148  m0_bcount_t size);
153 M0_INTERNAL void m0_be_io_stob_move(struct m0_be_io *bio,
154  struct m0_stob *stob,
156  m0_bindex_t win_start,
157  m0_bcount_t win_size);
164 M0_INTERNAL void m0_be_io_vec_pack(struct m0_be_io *bio);
165 M0_INTERNAL m0_bcount_t m0_be_io_size(struct m0_be_io *bio);
166 
168 M0_INTERNAL void m0_be_io_sync_enable(struct m0_be_io *bio);
169 M0_INTERNAL bool m0_be_io_sync_is_enabled(struct m0_be_io *bio);
170 
171 M0_INTERNAL enum m0_stob_io_opcode m0_be_io_opcode(struct m0_be_io *io);
172 
173 M0_INTERNAL void m0_be_io_configure(struct m0_be_io *bio,
175 
176 M0_INTERNAL void m0_be_io_launch(struct m0_be_io *bio, struct m0_be_op *op);
177 
178 M0_INTERNAL bool m0_be_io_is_empty(struct m0_be_io *bio);
179 M0_INTERNAL void m0_be_io_reset(struct m0_be_io *bio);
180 M0_INTERNAL void m0_be_io_sort(struct m0_be_io *bio);
181 
182 M0_INTERNAL void m0_be_io_user_data_set(struct m0_be_io *bio, void *data);
183 M0_INTERNAL void *m0_be_io_user_data(struct m0_be_io *bio);
184 
185 M0_INTERNAL int m0_be_io_single(struct m0_stob *stob,
187  void *ptr_user,
188  m0_bindex_t offset_stob,
189  m0_bcount_t size);
190 
191 M0_INTERNAL bool m0_be_io_intersect(const struct m0_be_io *bio1,
192  const struct m0_be_io *bio2);
193 
194 M0_INTERNAL bool m0_be_io_ptr_user_is_eq(const struct m0_be_io *bio1,
195  const struct m0_be_io *bio2);
196 M0_INTERNAL bool m0_be_io_offset_stob_is_eq(const struct m0_be_io *bio1,
197  const struct m0_be_io *bio2);
198 
199 
201 M0_INTERNAL void m0_be_io_credit_add(struct m0_be_io_credit *iocred0,
202  const struct m0_be_io_credit *iocred1);
203 
205 M0_INTERNAL bool m0_be_io_credit_le(const struct m0_be_io_credit *iocred0,
206  const struct m0_be_io_credit *iocred1);
207 
210 #endif /* __MOTR_BE_IO_H__ */
211 
212 
213 /*
214  * Local variables:
215  * c-indentation-style: "K&R"
216  * c-basic-offset: 8
217  * tab-width: 8
218  * fill-column: 80
219  * scroll-step: 1
220  * End:
221  */
222 /*
223  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
224  */
struct m0_be_io * bip_bio
Definition: io.h:63
struct m0_be_io_part * bio_part
Definition: io.h:89
struct m0_stob_io bip_sio
Definition: io.h:58
M0_INTERNAL m0_bcount_t m0_be_io_size(struct m0_be_io *bio)
Definition: io.c:500
M0_INTERNAL void m0_be_io_vec_pack(struct m0_be_io *bio)
Definition: io.c:470
struct m0_clink bip_clink
Definition: io.h:60
M0_INTERNAL void m0_be_io_sync_enable(struct m0_be_io *bio)
Definition: io.c:631
struct m0_tlink bio_sched_link
Definition: io.h:118
bool bio_sync
Definition: io.h:110
unsigned bio_stob_nr
Definition: io.h:97
struct m0_be_io_credit bio_used
Definition: io.h:95
uint32_t bio_vec_pos
Definition: io.h:93
struct m0_bufvec data
Definition: di.c:40
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
Definition: sm.h:504
struct m0_sm_ast bio_ast
Definition: io.h:112
op
Definition: libdemo.c:64
m0_bcount_t bic_reg_size
Definition: io.h:72
uint64_t bic_reg_nr
Definition: io.h:71
M0_INTERNAL void m0_be_io_configure(struct m0_be_io *bio, enum m0_stob_io_opcode opcode)
Definition: io.c:516
uint64_t bio_sched_magic
Definition: io.h:119
struct m0_be_op bio_sched_op
Definition: io.h:120
int opcode
Definition: crate.c:301
M0_INTERNAL void m0_be_io_add_nostob(struct m0_be_io *bio, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
Definition: io.c:313
M0_INTERNAL void m0_be_io_fini(struct m0_be_io *bio)
Definition: io.c:224
uint64_t bic_part_nr
Definition: io.h:73
M0_INTERNAL void * m0_be_io_user_data(struct m0_be_io *bio)
Definition: io.c:677
struct m0_atomic64 bio_stob_io_finished_nr
Definition: io.h:103
Definition: stob.h:163
static struct m0_stob * stob
Definition: storage.c:39
m0_stob_io_opcode
Definition: io.h:227
M0_INTERNAL int m0_be_io_single(struct m0_stob *stob, enum m0_stob_io_opcode opcode, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
Definition: io.c:682
M0_INTERNAL void m0_be_io_credit_add(struct m0_be_io_credit *iocred0, const struct m0_be_io_credit *iocred1)
Definition: io.c:779
M0_INTERNAL void m0_be_io_stob_move(struct m0_be_io *bio, struct m0_stob *stob, m0_bindex_t offset, m0_bindex_t win_start, m0_bcount_t win_size)
Definition: io.c:416
uint32_t bip_bshift
Definition: io.h:62
struct m0_bufvec bio_bv_user
Definition: io.h:90
M0_INTERNAL bool m0_be_io_offset_stob_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:764
M0_INTERNAL int m0_be_io_init(struct m0_be_io *bio)
Definition: io.c:175
M0_INTERNAL bool m0_be_io_credit_le(const struct m0_be_io_credit *iocred0, const struct m0_be_io_credit *iocred1)
Definition: io.c:787
struct m0_ext bio_ext
Definition: io.h:123
M0_INTERNAL bool m0_be_io_sync_is_enabled(struct m0_be_io *bio)
Definition: io.c:636
M0_INTERNAL bool m0_be_io_intersect(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:732
static m0_bindex_t offset
Definition: dump.c:173
Definition: io.h:285
struct m0_stob * bip_stob
Definition: io.h:61
static struct m0_stob_io io
Definition: ad.c:59
enum m0_stob_io_opcode bio_opcode
Definition: io.h:111
M0_INTERNAL void m0_be_io_user_data_set(struct m0_be_io *bio, void *data)
Definition: io.c:672
struct m0_be_op * bio_op
Definition: io.h:108
M0_INTERNAL bool m0_be_io_is_empty(struct m0_be_io *bio)
Definition: io.c:646
struct m0_be_op * bio_sched_op_user
Definition: io.h:122
M0_INTERNAL bool m0_be_io_ptr_user_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:748
int bip_rc
Definition: io.h:64
Definition: ext.h:37
M0_INTERNAL int m0_be_io_allocate(struct m0_be_io *bio, struct m0_be_io_credit *iocred)
Definition: io.c:180
M0_INTERNAL void m0_be_io_deallocate(struct m0_be_io *bio)
Definition: io.c:215
M0_INTERNAL enum m0_stob_io_opcode m0_be_io_opcode(struct m0_be_io *io)
Definition: io.c:641
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL bool m0_be_io__invariant(struct m0_be_io *bio)
Definition: io.c:228
struct m0_indexvec bio_iv_stob
Definition: io.h:91
Definition: io.h:87
struct m0_be_io_credit bio_iocred
Definition: io.h:94
Definition: op.h:74
void * bio_user_data
Definition: io.h:114
M0_INTERNAL void m0_be_io_add(struct m0_be_io *bio, struct m0_stob *stob, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
Definition: io.c:280
M0_INTERNAL void m0_be_io_stob_assign(struct m0_be_io *bio, struct m0_stob *stob, m0_bindex_t offset, m0_bcount_t size)
Definition: io.c:389
M0_INTERNAL void m0_be_io_launch(struct m0_be_io *bio, struct m0_be_op *op)
Definition: io.c:599
M0_INTERNAL void m0_be_io_reset(struct m0_be_io *bio)
Definition: io.c:651
struct m0_be_io_sched * bio_sched
Definition: io.h:117
M0_INTERNAL void m0_be_io_sort(struct m0_be_io *bio)
Definition: io.c:664
Definition: vec.h:145