Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d71a10a
checkpatch: Ignore MULTILINE_DEREFERENCE
robertbaldyga Feb 16, 2026
4e9e54b
lru: Get clines by id from user parts only
mmichal10 Nov 10, 2023
0b3e26b
lru: Introduce free detached partition
mmichal10 Aug 8, 2023
3e5128f
flush: Allow to flush a range of cache lines
mmichal10 Aug 8, 2023
85e66ec
Add utility to detach range of cache lines
mmichal10 Aug 8, 2023
22e9026
Add utlility to restore detached cache lines
mmichal10 Sep 6, 2023
b99e564
volume: Add 'composite' flag to capabilities
mmichal10 Aug 22, 2023
2ee0ae5
Store ctx pointer in volume type
robertbaldyga Nov 7, 2023
4d57284
core: Introduce core volume uuid
robertbaldyga Nov 7, 2023
b3aab83
composite_volume: Move OCF_COMPOSITE_VOLUME_MEMBERS_MAX to inc/
robertbaldyga Feb 9, 2026
509a16d
volume: Fix on_init()
robertbaldyga Feb 16, 2026
d310c79
composite_volume: Move length and max io size calculation to add
robertbaldyga Feb 16, 2026
36229b3
volume: Add option to copy uuid on ocf_volume_set_uuid()
robertbaldyga Feb 13, 2026
7b94c4b
composite_volume: Enhance composite volume API
Aug 31, 2022
bb0d24d
composite_volume: Add 'detached' field for subvolumes
mmichal10 Aug 21, 2023
04e1db5
composite_volume: Move composite_volume_add() to volume ops
mmichal10 Nov 20, 2023
de7d7d8
composite_volume: Introduce iter macros
mmichal10 Oct 12, 2023
b11c5b9
composite_volume: Extend visitor capabilities
mmichal10 Nov 22, 2023
5845a0a
composite_volume: Util to retrieve member volume id
mmichal10 Aug 21, 2023
dbccc03
composite_volume: Utility for getting range of subvolume addresses
mmichal10 Aug 23, 2023
0a7174f
composite_volume: Introduce attach_member volume ops
mmichal10 Sep 6, 2023
33a00ff
composite_volume: Implement attach_member ops
mmichal10 Nov 22, 2023
e5b04e3
composite_volume: Enable attaching composite cache subvolumes
robertbaldyga Feb 7, 2026
285d7d0
composite_volume: Introduce detach_member volume ops
mmichal10 Aug 23, 2023
2818dcf
composite_volume: Implement detach_member ops
mmichal10 Nov 22, 2023
a2bcac4
Enable detaching composite cache subvolumes
mmichal10 Nov 22, 2023
44fc769
pyocf: test for reattaching composite members
mmichal10 Oct 20, 2023
43f020b
pyocf: composite cache tests
mmichal10 Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .checkpatch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--ignore NEW_TYPEDEFS
--ignore PREFER_DEFINED_ATTRIBUTE_MACRO
--ignore REPEATED_WORD
--ignore MULTILINE_DEREFERENCE

--exclude .github
--exclude doc
Expand Down
2 changes: 2 additions & 0 deletions example/simple/src/volume.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright(c) 2019-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -103,6 +104,7 @@ const struct ocf_volume_properties volume_properties = {
.volume_priv_size = sizeof(struct myvolume),
.caps = {
.atomic_writes = 0,
.composite_volume = 0,
},
.ops = {
.open = volume_open,
Expand Down
82 changes: 67 additions & 15 deletions inc/ocf_composite_volume.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright(c) 2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -41,33 +42,84 @@ int ocf_composite_volume_create(ocf_composite_volume_t *cvolume, ocf_ctx_t ctx);
*/
void ocf_composite_volume_destroy(ocf_composite_volume_t cvolume);

typedef enum {
ocf_composite_member_state_attached = 1,
/* If subvolume is opened it must be attached as well */
ocf_composite_member_state_opened = 3,
ocf_composite_member_state_detached = 4,
ocf_composite_member_state_any = 7,
} ocf_composite_member_state_t;

/**
* @brief Add subvolume to composite volume
*
* @param[in] cvolume composite volume handle
* @param[in] type type of added subvolume
* @param[in] uuid UUID of added subvolume
* @param[in] volume_params params to be passed to subvolume open
*
* @return Zero when success, othewise an error
* @param[in] subvolume Pointer to a subvolume
* @param[in] priv Priv
* @param[in] subvol_status flag with the info if current subvolume is opened,
* attached or detached
*/
int ocf_composite_volume_add(ocf_composite_volume_t cvolume,
ocf_volume_type_t type, struct ocf_volume_uuid *uuid,
void *volume_params);

typedef int (*ocf_composite_volume_member_visitor_t)(ocf_volume_t subvolume,
void *priv);
void *priv, ocf_composite_member_state_t subvol_status);

/**
* @brief Call @visitor on every valid member of composite volume
*
* @param[in] cvolume composite volume handle
* @param[in] visitor function callback
* @param[in] priv pointer to be passed to the callback
* @param[in] subvol_status info whether iterate over
* opened/attached/detached/all volumes
*
* @return subvolume in composite volume
* @return 0 if the visitor function was called for all subvolumes, error code
* otherwise
*/
int ocf_composite_volume_member_visit(ocf_composite_volume_t cvolume,
ocf_composite_volume_member_visitor_t visitor, void *priv);
ocf_composite_volume_member_visitor_t visitor, void *priv,
ocf_composite_member_state_t subvolume_status);

/**
* @brief Get subvolume by index in composite volume
*
* @param[in] cvolume composite volume handle
* @param[in] index subvolume index
*
* @return subvolume in composite volume
*/
ocf_volume_t ocf_composite_volume_get_subvolume_by_index(
ocf_composite_volume_t cvolume, int index);

/**
* @brief Get range of addresses from a subvolume
*
* @param[in] cvolume composite volume handle
* @param[in] subvolume_id subvolume index
* @param[out] begin_addr beginning of the address range
* @param[out] end_addr end of the address range
*
* @return 0 in case of success, error code otherwise
*/
int ocf_composite_volume_get_subvolume_addr_range(
ocf_composite_volume_t cvolume, uint8_t subvolume_id,
uint64_t *begin_addr, uint64_t *end_addr);

/**
* @brief Set composite volume UUID
*
* @param[in] cvolume Volume
* @param[in] uuid UUID
*
* @return 0 in case of success, error code otherwise
*/
int ocf_composite_volume_set_uuid(ocf_composite_volume_t cvolume,
struct ocf_volume_uuid *uuid);

/**
* @brief Get volume's id by UUID
*
* @param[in] volume Volume
* @param[in] uuid UUID
*
* @return id of the matching subvolume or error if the volume wasn't found
*/
int ocf_composite_volume_get_id_from_uuid(ocf_composite_volume_t cvolume,
ocf_uuid_t target_uuid);

#endif /* __OCF_COMPOSITE_VOLUME_H__ */
17 changes: 17 additions & 0 deletions inc/ocf_def.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -93,6 +94,22 @@
* @}
*/

/**
* @name Composite volume defines
* @{
*/
/*
* Maximum value of a composite volume member id
*/
#define OCF_COMPOSITE_VOLUME_MEMBERS_MAX 16
/*
* Invalid value of composite volume member
*/
#define OCF_COMPOSITE_VOLUME_MEMBER_ID_INVALID OCF_COMPOSITE_VOLUME_MEMBERS_MAX
/**
* @}
*/

/**
* @name Miscellaneous defines
* @{
Expand Down
22 changes: 22 additions & 0 deletions inc/ocf_err.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -72,6 +73,27 @@ typedef enum {
/** Core ID/name does not exist */
OCF_ERR_CORE_NOT_EXIST,

/** Composite volume member ID does not exist */
OCF_ERR_COMPOSITE_VOLUME_MEMBER_NOT_EXIST,

/** The volume is not a composite */
OCF_ERR_NOT_COMPOSITE_VOLUME,

/** Invalid subvolume ID */
OCF_ERR_COMPOSITE_INVALID_ID,

/** The target subvolume isn't initialised */
OCF_ERR_COMPOSITE_UNINITIALISED_VOLUME,

/** The target subvolume is already attached */
OCF_ERR_COMPOSITE_ATTACHED,

/** The target subvolume is already detached */
OCF_ERR_COMPOSITE_DETACHED,

/** The target subvolume has invalid size */
OCF_ERR_COMPOSITE_INVALID_SIZE,

/** Cache ID/name already exists */
OCF_ERR_CACHE_EXIST,

Expand Down
29 changes: 29 additions & 0 deletions inc/ocf_mngt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024-2025 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -513,6 +514,34 @@ typedef void (*ocf_mngt_cache_detach_end_t)(ocf_cache_t cache,
void ocf_mngt_cache_detach(ocf_cache_t cache,
ocf_mngt_cache_detach_end_t cmpl, void *priv);

/**
* @brief Add a new member to composite cache
*
* @param[in] cache Cache handle
* @param[in] vol_uuid UUID of the new volume to be added as a member
* of composite
* @param[in] tgt_id Target subvolume id
* @param[in] vol_type Type of the new volume
* @param[in] vol_params Params of the new volume
* @param[in] cmpl Completion callback
* @param[in] priv Completion callback context
*/
void ocf_mngt_cache_attach_composite(ocf_cache_t cache, ocf_uuid_t vol_uuid,
uint8_t tgt_id, ocf_volume_type_t vol_type, void *vol_params,
ocf_mngt_cache_detach_end_t cmpl, void *priv);

/**
* @brief Detach a member of composite cache
*
* @param[in] cache Cache handle
* @param[in] cmpl Completion callback
* @param[in] target_uuid uuid of the target subvolume
* @param[in] priv Completion callback context
*/
void ocf_mngt_cache_detach_composite(ocf_cache_t cache,
ocf_mngt_cache_detach_end_t cmpl, ocf_uuid_t target_uuid,
void *priv);

/**
* @brief Completion callback of cache load operation
*
Expand Down
92 changes: 91 additions & 1 deletion inc/ocf_volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct ocf_volume_uuid {
struct ocf_volume_caps {
uint32_t atomic_writes : 1;
/*!< Volume supports atomic writes */

uint32_t composite_volume : 1;
/*!< Volume may be composed of multiple sub-volumes */
};

/**
Expand Down Expand Up @@ -211,6 +214,46 @@ struct ocf_volume_ops {
* @return Maximum io size in bytes
*/
unsigned int (*get_max_io_size)(ocf_volume_t volume);

/**
* @brief Add subvolume to composite volume
*
* @param[in] volume composite volume handle
* @param[in] type type of added subvolume
* @param[in] uuid UUID of added subvolume
* @param[in] volume_params params to be passed to subvolume open
*
* @return Zero when success, otherwise an error
*/
int (*composite_volume_add)(ocf_volume_t cvolume,
ocf_volume_type_t type, struct ocf_volume_uuid *uuid,
void *volume_params);

/**
* @brief Attach subvolume to composite volume
*
* @param[in] volume composite volume handle
* @param[in] uuid UUID of added subvolume
* @param[in] tgt_id Target subvolume id
* @param[in] type type of added subvolume
* @param[in] volume_params params to be passed to subvolume open
*
* @return Zero when success, otherwise an error
*/
int (*composite_volume_attach_member)(ocf_volume_t volume,
struct ocf_volume_uuid *uuid, uint8_t tgt_id,
ocf_volume_type_t type, void *volume_params);

/**
* @brief Detach composite member volume
*
* @param[in] volume composite volume handle
* @param[in] subvolume_id volume to be detached
*
* @return Zero on success, otherwise error code
*/
int (*composite_volume_detach_member)(ocf_volume_t volume,
uint8_t subvolume_id);
};

/**
Expand Down Expand Up @@ -337,6 +380,15 @@ ocf_cache_t ocf_volume_get_cache(ocf_volume_t volume);
*/
int ocf_volume_is_atomic(ocf_volume_t volume);

/**
* @brief Check if volume is composited of multiple sub-volumes
*
* @param[in] volume Volume
*
* @return True if volume is composite, otherwise false
*/
bool ocf_volume_is_composite(ocf_volume_t volume);

/**
* @brief Allocate new io
*
Expand Down Expand Up @@ -387,12 +439,37 @@ void ocf_volume_submit_discard(ocf_io_t io);
int ocf_volume_open(ocf_volume_t volume, void *volume_params);

/**
* @brief Get volume max io size
* @brief Close volume
*
* @param[in] volume Volume
*/
void ocf_volume_close(ocf_volume_t volume);

/**
* @brief Attach subvolume to composite volume
*
* @param[in] volume composite volume handle
* @param[in] tgt_id Target subvolume id
* @param[in] uuid UUID of added subvolume
* @param[in] type type of added subvolume
* @param[in] volume_params params to be passed to subvolume open
*
* @return Zero when success, otherwise an error
*/
int ocf_composite_volume_attach_member(ocf_volume_t volume, ocf_uuid_t uuid,
uint8_t tgt_id, ocf_volume_type_t vol_type, void *vol_params);

/**
* @brief Detach composite member volume
*
* @param[in] volume composite volume handle
* @param[in] subvolume_id volume to be detached
*
* @return Zero when success, otherwise an error
*/
int ocf_composite_volume_detach_member(ocf_volume_t volume,
uint8_t subvolume_id);

/**
* @brief Get volume max io size
*
Expand All @@ -402,6 +479,19 @@ void ocf_volume_close(ocf_volume_t volume);
*/
unsigned int ocf_volume_get_max_io_size(ocf_volume_t volume);

/**
* @brief Add subvolume to composite volume
*
* @param[in] volume composite volume handle
* @param[in] type type of added subvolume
* @param[in] uuid UUID of added subvolume
* @param[in] volume_params params to be passed to subvolume open
*
* @return Zero when success, otherwise an error
*/
int ocf_composite_volume_add(ocf_volume_t volume, ocf_volume_type_t type,
struct ocf_volume_uuid *uuid, void *volume_params);

/**
* @brief Get volume length
*
Expand Down
2 changes: 2 additions & 0 deletions src/metadata/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
&part_runtime_meta[i].runtime;
}
cache->free.runtime= &part_runtime_meta[PARTITION_FREELIST].runtime;
cache->free_detached.runtime =
&part_runtime_meta[PARTITION_FREE_DETACHED].runtime;

/* Set core metadata */
core_meta_config = METADATA_MEM_POOL(ctrl,
Expand Down
Loading
Loading