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 "ioservice/fid_convert.h"
24 
25 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_IOSERVICE
26 #include "lib/trace.h"
27 #include "lib/assert.h" /* M0_PRE */
28 
29 #include "fid/fid.h" /* m0_fid */
30 #include "file/file.h" /* m0_file_fid_type */
31 #include "cob/cob.h" /* m0_cob_fid_type */
32 
39 /* extract bits [32, 56) from fid->f_container */
40 M0_INTERNAL uint32_t m0_fid__device_id_extract(const struct m0_fid *fid)
41 {
44 }
45 
46 M0_INTERNAL void m0_fid_gob_make(struct m0_fid *gob_fid,
47  uint32_t container,
48  uint64_t key)
49 {
51 
53 }
54 
55 M0_INTERNAL void m0_fid_convert_gob2cob(const struct m0_fid *gob_fid,
56  struct m0_fid *cob_fid,
57  uint32_t device_id)
58 {
60  M0_PRE(device_id <= M0_FID_DEVICE_ID_MAX);
61 
62  *cob_fid = *gob_fid;
64  cob_fid->f_container |= (uint64_t)device_id << M0_FID_DEVICE_ID_OFFSET;
65 
67 }
68 
69 M0_INTERNAL void m0_fid_convert_cob2gob(const struct m0_fid *cob_fid,
70  struct m0_fid *gob_fid)
71 {
73 
76  cob_fid->f_key);
77 
79 }
80 
81 M0_INTERNAL uint32_t m0_fid_cob_device_id(const struct m0_fid *cob_fid)
82 {
84 
86 }
87 
88 M0_INTERNAL uint64_t m0_fid_conf_sdev_device_id(const struct m0_fid *sdev_fid)
89 {
90  return sdev_fid->f_key & ((1ULL << M0_FID_DEVICE_ID_BITS) - 1);
91 }
92 
93 M0_INTERNAL bool m0_fid_validate_gob(const struct m0_fid *gob_fid)
94 {
97 }
98 
99 M0_INTERNAL bool m0_fid_validate_cob(const struct m0_fid *cob_fid)
100 {
102 }
103 
104 #undef M0_TRACE_SUBSYSTEM
105 
107 /*
108  * Local variables:
109  * c-indentation-style: "K&R"
110  * c-basic-offset: 8
111  * tab-width: 8
112  * fill-column: 80
113  * scroll-step: 1
114  * End:
115  */
116 /*
117  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
118  */
static struct m0_fid gob_fid
Definition: net.c:115
#define M0_PRE(cond)
M0_INTERNAL void m0_fid_gob_make(struct m0_fid *gob_fid, uint32_t container, uint64_t key)
Definition: fid_convert.c:46
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 uint64_t m0_fid_conf_sdev_device_id(const struct m0_fid *sdev_fid)
Definition: fid_convert.c:88
const struct m0_fid_type m0_cob_fid_type
Definition: cob.c:117
const struct m0_fid_type m0_file_fid_type
Definition: file.c:569
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 uint32_t m0_fid__device_id_extract(const struct m0_fid *fid)
Definition: fid_convert.c:40
static struct m0_fid cob_fid
Definition: net.c:116
M0_INTERNAL uint32_t m0_fid_cob_device_id(const struct m0_fid *cob_fid)
Definition: fid_convert.c:81
uint64_t f_container
Definition: fid.h:39
#define M0_POST(cond)
M0_INTERNAL bool m0_fid_validate_gob(const struct m0_fid *gob_fid)
Definition: fid_convert.c:93
Definition: fid.h:38
uint64_t f_key
Definition: fid.h:40
M0_INTERNAL void m0_fid_convert_cob2gob(const struct m0_fid *cob_fid, struct m0_fid *gob_fid)
Definition: fid_convert.c:69
M0_INTERNAL void m0_fid_convert_gob2cob(const struct m0_fid *gob_fid, struct m0_fid *cob_fid, uint32_t device_id)
Definition: fid_convert.c:55
M0_INTERNAL bool m0_fid_validate_cob(const struct m0_fid *cob_fid)
Definition: fid_convert.c:99
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