composite volume: add subvolume iterator API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
6907abeba2
commit
82c8d4f45c
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright(c) 2022 Intel Corporation
|
* Copyright(c) 2022 Intel Corporation
|
||||||
|
* Copyright(c) 2024 Huawei Technologies
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -54,4 +55,19 @@ int ocf_composite_volume_add(ocf_composite_volume_t cvolume,
|
|||||||
ocf_volume_type_t type, struct ocf_volume_uuid *uuid,
|
ocf_volume_type_t type, struct ocf_volume_uuid *uuid,
|
||||||
void *volume_params);
|
void *volume_params);
|
||||||
|
|
||||||
|
typedef int (*ocf_composite_volume_member_visitor_t)(ocf_volume_t subvolume,
|
||||||
|
void *priv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*
|
||||||
|
* @return subvolume in composite volume
|
||||||
|
*/
|
||||||
|
int ocf_composite_volume_member_visit(ocf_composite_volume_t cvolume,
|
||||||
|
ocf_composite_volume_member_visitor_t visitor, void *priv);
|
||||||
|
|
||||||
#endif /* __OCF_COMPOSITE_VOLUME_H__ */
|
#endif /* __OCF_COMPOSITE_VOLUME_H__ */
|
||||||
|
@ -393,3 +393,19 @@ int ocf_composite_volume_add(ocf_composite_volume_t cvolume,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ocf_composite_volume_member_visit(ocf_composite_volume_t cvolume,
|
||||||
|
ocf_composite_volume_member_visitor_t visitor, void *priv)
|
||||||
|
{
|
||||||
|
struct ocf_composite_volume *composite = ocf_volume_get_priv(cvolume);
|
||||||
|
int i;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
for (i = 0 ; i < composite->members_cnt; i++) {
|
||||||
|
res = visitor(&composite->member[i].volume, priv);
|
||||||
|
if (res != 0)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user