openEuler的nfs+代码重构

点击这里查看配套的教学视频

点击跳转到nfs课程所有目录

1 宏定义DEFINE_CLEAR_LIST_FUNC

0dab7a7f535d !17266 unify log function usage of enfs版本时,fs/nfs/enfs/shard_route.c文件中释放struct view_table时发生内在泄露。

struct view_table中有几个链表:

2 宏定义DEFINE_CLEAR_LIST_FUNC

用以下脚本删除函数的一些公共内容(注意脚本执行后还需要手动再处理一下):

file_name=fs/nfs/enfs/shard_route.c
array=(
        "^static const struct nfs_fh \*parse_" "parse_"
        "(struct rpc_message \*msg)$" ""
        " \*args = msg->rpc_argp;" ""
        "return args->" ""
)

del_common_str() {
        local element_count="${#array[@]}"
        local count_per_line=2

        for ((index=0; index<${element_count}; index=$((index + ${count_per_line})))); do
                local old_str=${array[${index}]}
                local new_str=${array[${index}+1]}

                sed -i "s|${old_str}|${new_str}|g" ${file_name}
        done
}

del_common_str