]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/utils/utils_device.h
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef UTILS_DEVICE_H_
7 #define UTILS_DEVICE_H_
9 static inline int _ocf_uuid_set(const struct ocf_volume_uuid
*uuid
,
10 struct ocf_metadata_uuid
*muuid
)
14 if (!uuid
|| !muuid
) {
18 if (!uuid
->data
|| !muuid
->data
) {
22 if (uuid
->size
> sizeof(muuid
->data
)) {
26 result
= env_memcpy(muuid
->data
, sizeof(muuid
->data
), uuid
->data
, uuid
->size
);
29 result
= env_memset(muuid
->data
+ uuid
->size
,
30 sizeof(muuid
->data
) - uuid
->size
, 0);
33 muuid
->size
= uuid
->size
;
38 static inline int ocf_metadata_set_core_uuid(ocf_core_t core
,
39 const struct ocf_volume_uuid
*uuid
,
40 struct ocf_volume_uuid
*new_uuid
)
42 ocf_cache_t cache
= ocf_core_get_cache(core
);
43 struct ocf_metadata_uuid
*muuid
= ocf_metadata_get_core_uuid(cache
,
44 ocf_core_get_id(core
));
46 if (_ocf_uuid_set(uuid
, muuid
))
50 new_uuid
->data
= muuid
->data
;
51 new_uuid
->size
= muuid
->size
;
57 static inline void ocf_metadata_clear_core_uuid(ocf_core_t core
)
59 struct ocf_volume_uuid uuid
= { .size
= 0, };
61 ocf_metadata_set_core_uuid(core
, &uuid
, NULL
);
64 #endif /* UTILS_MEM_H_ */