972310a0创建于 2025年4月21日历史提交
/*
 * Copyright (c) 2022 Huawei Technologies Co.,Ltd.
 *
 * DSS is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *          http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * -------------------------------------------------------------------------
 *
 * dss_open_file.h
 *
 *
 * IDENTIFICATION
 *    src/common/dss_open_file.h
 *
 * -------------------------------------------------------------------------
 */

#ifndef __DSS_OPEN_FILE_H__
#define __DSS_OPEN_FILE_H__

#include "dss_diskgroup.h"
#include "dss_file_def.h"
#include "dss_malloc.h"
#include "dss_session.h"

typedef struct st_dss_open_file_info_t {
    uint64 ftid;
    uint64 pid;
    uint64 ref;
    int64 start_time;
    bilist_node_t link;
} dss_open_file_info_t;

status_t dss_init_open_file_index(dss_vg_info_item_t *vg_item);
void dss_destroy_open_file_index(dss_vg_info_item_t *vg_item);

status_t dss_insert_open_file_index(
    dss_session_t *session, dss_vg_info_item_t *vg_item, uint64 ftid, uint64 pid, int64 start_time);
status_t dss_delete_open_file_index(
    dss_session_t *session, dss_vg_info_item_t *vg_item, uint64 ftid, uint64 pid, int64 start_time);
status_t dss_check_open_file(dss_session_t *session, dss_vg_info_item_t *vg_item, uint64 ftid, bool32 *is_open);
static inline void dss_free_open_file_node(bilist_node_t *node, bilist_t *bilist)
{
    cm_bilist_del(node, bilist);
    dss_open_file_info_t *open_file = BILIST_NODE_OF(dss_open_file_info_t, node, link);
    CM_FREE_PTR(open_file);
}
#endif