Motr  M0
fid_convert.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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 #include "dix/fid_convert.h"
24 
25 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_DIX
26 #include "lib/trace.h"
27 #include "lib/assert.h" /* M0_PRE */
28 
29 #include "fid/fid.h" /* m0_fid */
30 #include "cas/cas.h" /* m0_dix_fid_type, m0_cctg_fid_type */
31 
38 /* extract bits [32, 56) from fid->f_container */
39 M0_INTERNAL uint32_t m0_dix_fid__device_id_extract(const struct m0_fid *fid)
40 {
43 }
44 
45 M0_INTERNAL void m0_dix_fid_dix_make(struct m0_fid *dix_fid,
46  uint32_t container,
47  uint64_t key)
48 {
50 
52 }
53 
54 M0_INTERNAL void m0_dix_fid_convert_dix2cctg(const struct m0_fid *dix_fid,
55  struct m0_fid *cctg_fid,
56  uint32_t device_id)
57 {
59  M0_PRE(device_id <= M0_DIX_FID_DEVICE_ID_MAX);
60 
61  *cctg_fid = *dix_fid;
62  m0_fid_tassume(cctg_fid, &m0_cctg_fid_type);
63  cctg_fid->f_container |= (uint64_t)device_id <<
65 
67 }
68 
69 M0_INTERNAL void m0_dix_fid_convert_cctg2dix(const struct m0_fid *cctg_fid,
70  struct m0_fid *dix_fid)
71 {
73 
76  cctg_fid->f_key);
77 
79 }
80 
81 M0_INTERNAL uint32_t m0_dix_fid_cctg_device_id(const struct m0_fid *cctg_fid)
82 {
84 
85  return m0_dix_fid__device_id_extract(cctg_fid);
86 }
87 
88 M0_INTERNAL bool m0_dix_fid_validate_dix(const struct m0_fid *dix_fid)
89 {
90  return m0_fid_tget(dix_fid) == m0_dix_fid_type.ft_id &&
91  m0_dix_fid__device_id_extract(dix_fid) == 0;
92 }
93 
94 M0_INTERNAL bool m0_dix_fid_validate_cctg(const struct m0_fid *cctg_fid)
95 {
96  return m0_fid_tget(cctg_fid) == m0_cctg_fid_type.ft_id;
97 }
98 
99 #undef M0_TRACE_SUBSYSTEM
100 
102 /*
103  * Local variables:
104  * c-indentation-style: "K&R"
105  * c-basic-offset: 8
106  * tab-width: 8
107  * fill-column: 80
108  * scroll-step: 1
109  * End:
110  */
111 /*
112  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
113  */
#define M0_PRE(cond)
M0_INTERNAL bool m0_dix_fid_validate_dix(const struct m0_fid *dix_fid)
Definition: fid_convert.c:88
M0_INTERNAL void m0_dix_fid_convert_cctg2dix(const struct m0_fid *cctg_fid, struct m0_fid *dix_fid)
Definition: fid_convert.c:69
M0_INTERNAL void m0_fid_tset(struct m0_fid *fid, uint8_t tid, uint64_t container, uint64_t key)
Definition: fid.c:126
struct m0_container container
uint8_t ft_id
Definition: fid.h:101
M0_INTERNAL bool m0_dix_fid_validate_cctg(const struct m0_fid *cctg_fid)
Definition: fid_convert.c:94
M0_INTERNAL uint8_t m0_fid_tget(const struct m0_fid *fid)
Definition: fid.c:133
struct m0_fid fid
Definition: di.c:46
M0_INTERNAL const struct m0_fid_type m0_dix_fid_type
Definition: cas.c:168
M0_INTERNAL const struct m0_fid_type m0_cctg_fid_type
Definition: cas.c:163
uint64_t f_container
Definition: fid.h:39
#define M0_POST(cond)
M0_INTERNAL uint32_t m0_dix_fid_cctg_device_id(const struct m0_fid *cctg_fid)
Definition: fid_convert.c:81
M0_INTERNAL void m0_dix_fid_dix_make(struct m0_fid *dix_fid, uint32_t container, uint64_t key)
Definition: fid_convert.c:45
Definition: fid.h:38
uint64_t f_key
Definition: fid.h:40
M0_INTERNAL uint32_t m0_dix_fid__device_id_extract(const struct m0_fid *fid)
Definition: fid_convert.c:39
M0_INTERNAL void m0_dix_fid_convert_dix2cctg(const struct m0_fid *dix_fid, struct m0_fid *cctg_fid, uint32_t device_id)
Definition: fid_convert.c:54
Definition: idx_mock.c:47
M0_INTERNAL void m0_fid_tassume(struct m0_fid *fid, const struct m0_fid_type *ft)
Definition: fid.c:146