Merge pull request #1512 from robertbaldyga/various_fixes

Bunch of smaller fixes
This commit is contained in:
Robert Baldyga 2024-09-10 15:20:24 +02:00 committed by GitHub
commit 7c7e7bff3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 70 additions and 62 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@
*.ko.*
*.obj
*.a
tags
Module.symvers
Module.markers
*.mod.c

View File

@ -1,5 +1,6 @@
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
@ -20,6 +21,8 @@ ifneq ($(MAKECMDGOALS),srpm)
ifneq ($(MAKECMDGOALS),deb)
ifneq ($(MAKECMDGOALS),dsc)
cd $@ && $(MAKE) $(MAKECMDGOALS)
casadm: modules
cd $@ && $(MAKE) $(MAKECMDGOALS)
endif
endif
endif

View File

@ -152,7 +152,9 @@ $(OBJDIR)%.o: %.c
ifeq ($(strip $(CAS_VERSION_MAIN)),)
$(error "No version file")
endif
@$(CC) -c $(CFLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@$(CC) -c $(CFLAGS) -MMD -o "$@" "$<"
-include $(addprefix $(OBJDIR),$(OBJS:.o=.d))
clean:
@echo " CLEAN "

View File

@ -88,7 +88,7 @@ Stop cache instance.
Set runtime parameter for cache/core instance.
.TP
.B -G, --set-param
.B -G, --get-param
Get runtime parameter for cache/core instance.
.TP

View File

@ -82,7 +82,7 @@ static int _cas_page_get_cpu(struct page *page)
/*
*
*/
static ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
static ctx_data_t *__cas_ctx_data_alloc(uint32_t pages)
{
struct blk_data *data;
uint32_t i;
@ -116,14 +116,6 @@ static ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
if (!data->vec[i].bv_page)
break;
if (zalloc) {
if (!page_addr) {
page_addr = page_address(
data->vec[i].bv_page);
}
memset(page_addr, 0, PAGE_SIZE);
}
data->vec[i].bv_len = PAGE_SIZE;
data->vec[i].bv_offset = 0;
}
@ -153,12 +145,7 @@ static ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
ctx_data_t *cas_ctx_data_alloc(uint32_t pages)
{
return __cas_ctx_data_alloc(pages, false);
}
ctx_data_t *cas_ctx_data_zalloc(uint32_t pages)
{
return __cas_ctx_data_alloc(pages, true);
return __cas_ctx_data_alloc(pages);
}
/*

View File

@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -69,7 +70,6 @@ struct blk_data *cas_alloc_blk_data(uint32_t size, gfp_t flags);
void cas_free_blk_data(struct blk_data *data);
ctx_data_t *cas_ctx_data_alloc(uint32_t pages);
ctx_data_t *cas_ctx_data_zalloc(uint32_t pages);
void cas_ctx_data_free(ctx_data_t *ctx_data);
void cas_ctx_data_secure_erase(ctx_data_t *ctx_data);

View File

@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __CASDISK_DEBUG_H__
@ -12,7 +13,7 @@
printk(KERN_INFO "%s\n", __func__)
#define CAS_DEBUG_DISK_TRACE(dsk) \
printk(KERN_INFO "[%u] %s\n", dsk->id, __func__)
printk(KERN_INFO "[%s] %s\n", dsk->path, __func__)
#define CAS_DEBUG_MSG(msg) \
printk(KERN_INFO "%s - %s\n", __func__, msg)
@ -22,8 +23,8 @@
__func__, ##__VA_ARGS__)
#define CAS_DEBUG_DISK(dsk, format, ...) \
printk(KERN_INFO "[%u] %s - "format"\n", \
dsk->id, \
printk(KERN_INFO "[%s] %s - "format"\n", \
dsk->path, \
__func__, ##__VA_ARGS__)
#define CAS_DEBUG_ERROR(error, ...) \

View File

@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __CASDISK_EXP_OBJ_H__
@ -46,9 +47,6 @@ struct cas_exp_obj {
struct blk_mq_tag_set tag_set;
atomic_t pt_ios;
atomic_t *pending_rqs;
void *private;
};

View File

@ -1075,6 +1075,9 @@ int cache_mngt_core_pool_get_paths(struct kcas_core_pool_path *cmd_info)
struct get_paths_ctx visitor_ctx = {0};
int result;
if (visitor_ctx->core_path_name_tab == NULL)
return -EINVAL;
visitor_ctx.core_path_name_tab = cmd_info->core_path_tab;
visitor_ctx.max_count = cmd_info->core_pool_count;
@ -2058,6 +2061,7 @@ static int _cache_mngt_start_queues(ocf_cache_t cache)
cache_priv->mngt_queue, CAS_CPUS_ALL);
if (result) {
ocf_queue_put(cache_priv->mngt_queue);
cache_priv->mngt_queue = NULL;
goto err;
}
@ -2697,17 +2701,21 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
switch (cmd->init_cache) {
case CACHE_INIT_STANDBY_NEW:
case CACHE_INIT_STANDBY_LOAD:
ocf_volume_destroy(attach_cfg->device.volume);
printk(KERN_ERR "Standby mode is not supported!\n");
return -ENOTSUP;
default:
break;
}
if (!try_module_get(THIS_MODULE))
if (!try_module_get(THIS_MODULE)) {
ocf_volume_destroy(attach_cfg->device.volume);
return -KCAS_ERR_SYSTEM;
}
result = cache_mngt_check_bdev(&attach_cfg->device, attach_cfg->force, false, NULL);
if (result) {
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return result;
}
@ -2719,6 +2727,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
cache_name_meta, &cache_mode_meta,
&cache_line_size_meta);
if (result) {
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return result;
}
@ -2729,6 +2738,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
printk(KERN_ERR "Improper cache name format on %s.\n",
cmd->cache_path_name);
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return -OCF_ERR_START_CACHE_FAIL;
}
@ -2741,6 +2751,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
"already exists.\n", cache_name_meta);
ocf_mngt_cache_put(tmp_cache);
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return -OCF_ERR_CACHE_EXIST;
}
@ -2755,6 +2766,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context) {
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return -ENOMEM;
}
@ -2764,6 +2776,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
if (IS_ERR(context->rollback_thread)) {
result = PTR_ERR(context->rollback_thread);
kfree(context);
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return result;
}
@ -2779,6 +2792,7 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
if (result) {
cas_lazy_thread_stop(context->rollback_thread);
kfree(context);
ocf_volume_destroy(attach_cfg->device.volume);
module_put(THIS_MODULE);
return result;
}
@ -2786,12 +2800,12 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
result = _cache_mngt_cache_priv_init(cache);
if (result)
goto err;
goto err_deinit_config;
context->priv_inited = true;
result = _cache_mngt_start_queues(cache);
if (result)
goto err;
goto err_deinit_config;
cache_priv = ocf_cache_get_priv(cache);
cache_priv->attach_context = context;
@ -2838,6 +2852,9 @@ int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
ocf_mngt_cache_unlock(cache);
return result;
err_deinit_config:
ocf_volume_destroy(attach_cfg->device.volume);
err:
cmd->min_free_ram = context->min_free_ram;
@ -3196,10 +3213,6 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
if (status)
return status;
cache_priv = ocf_cache_get_priv(cache);
mngt_queue = cache_priv->mngt_queue;
context = cache_priv->stop_context;
/*
* Flush cache. Flushing may take a long time, so we allow user
* to interrupt this operation. Hence we do first flush before
@ -3218,6 +3231,10 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
if (status)
goto put;
cache_priv = ocf_cache_get_priv(cache);
mngt_queue = cache_priv->mngt_queue;
context = cache_priv->stop_context;
context->finish_thread = cas_lazy_thread_create(exit_instance_finish,
context, "cas_%s_stop", cache_name);
if (IS_ERR(context->finish_thread)) {
@ -3504,22 +3521,6 @@ put:
return result;
}
static int cache_mngt_wait_for_rq_finish_visitor(ocf_core_t core, void *cntx)
{
ocf_volume_t obj = ocf_core_get_volume(core);
struct bd_object *bdobj = bd_object(obj);
while (atomic64_read(&bdobj->pending_rqs))
io_schedule();
return 0;
}
void cache_mngt_wait_for_rq_finish(ocf_cache_t cache)
{
ocf_core_visit(cache, cache_mngt_wait_for_rq_finish_visitor, NULL, true);
}
int cache_mngt_set_core_params(struct kcas_set_core_param *info)
{
ocf_cache_t cache;

View File

@ -32,7 +32,7 @@
return map_cas_err_to_generic(ret); \
})
/* this handles IOctl for /dev/cas */
/* this handles IOctl for /dev/cas_ctrl */
/*********************************************/
long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
unsigned long arg)

View File

@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -25,12 +26,6 @@ struct bd_object {
uint32_t opened_by_bdev : 1;
/*!< Opened by supplying bdev manually */
atomic64_t pending_rqs;
/*!< This fields describes in flight IO requests */
struct workqueue_struct *btm_wq;
/*< Workqueue for I/O internally trigerred in bottom vol */
struct workqueue_struct *expobj_wq;
/*< Workqueue for I/O handled by top vol */

View File

@ -310,6 +310,21 @@ static inline bool cas_bd_io_prepare(int *dir, struct ocf_io *io)
return true;
}
/*
* Returns only flags that are relevant to request's direction.
*/
static inline uint64_t filter_req_flags(int dir, uint64_t flags)
{
/* Remove REQ_RAHEAD flag from write request to cache which are a
result of a missed read-head request. This flag caused the nvme
driver to send write command with access frequency value that is
reserved */
if (dir == WRITE)
flags &= ~REQ_RAHEAD;
return flags;
}
/*
*
*/
@ -359,7 +374,7 @@ static void block_dev_submit_io(struct ocf_io *io)
CAS_BIO_BISECTOR(bio) = addr / SECTOR_SIZE;
bio->bi_next = NULL;
bio->bi_private = io;
CAS_BIO_OP_FLAGS(bio) |= io->flags;
CAS_BIO_OP_FLAGS(bio) |= filter_req_flags(dir, io->flags);
bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end);
/* Add pages */

View File

@ -370,10 +370,7 @@ static void blkdev_complete_flush(struct ocf_io *io, int error)
return;
}
if (in_interrupt())
blkdev_defer_bio(bvol, bio, blkdev_handle_bio_noflush);
else
blkdev_handle_bio_noflush(bvol, bio);
}
static void blkdev_handle_flush(struct bd_object *bvol, struct bio *bio)

View File

@ -1,5 +1,6 @@
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
@ -14,7 +15,7 @@ EXTRA_CFLAGS += -DCAS_VERSION_MAIN=$(CAS_VERSION_MAIN)
EXTRA_CFLAGS += -DCAS_VERSION_MAJOR=$(CAS_VERSION_MAJOR)
EXTRA_CFLAGS += -DCAS_VERSION_MINOR=$(CAS_VERSION_MINOR)
EXTRA_CFLAGS += -DCAS_VERSION=\"$(CAS_VERSION)\"
EXTRA_CFLAGS += -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
EXTRA_CFLAGS += -Ofast -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
EXTRA_CFLAGS += -I$(M)
EXTRA_CFLAGS += -I$(M)/cas_cache

View File

@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
@ -30,13 +31,19 @@ if [[ -d "$SOURCES_DIR/.git" ]] && which git &>/dev/null &&\
if [[ ! -r "$MANUAL_VERSION_INPUT" ]]; then
error "can't read version input file '$MANUAL_VERSION_INPUT'"
fi
. "$MANUAL_VERSION_INPUT"
source "$MANUAL_VERSION_INPUT"
if [[ ! "$CAS_VERSION_MAIN" || ! "$CAS_VERSION_MAJOR" || ! "$CAS_VERSION_MINOR" ]]; then
error "'$MANUAL_VERSION_INPUT' - wrong version input file format;"\
"file should contain CAS_VERSION_MAIN, CAS_VERSION_MAJOR and CAS_VERSION_MINOR"\
"variables along with their respective values"
fi
# Make sure version numbers are interpreted by bash as decimal numbers in case any of
# them were being input with leading zeros, which is interpreted as an octal by default.
CAS_VERSION_MAIN=$((10#$CAS_VERSION_MAIN))
CAS_VERSION_MAJOR=$((10#$CAS_VERSION_MAJOR))
CAS_VERSION_MINOR=$((10#$CAS_VERSION_MINOR))
CAS_VERSION_BUILD=$(cd "$SOURCES_DIR" && git log --merges --oneline | wc -l)
LAST_COMMIT_HASH=$(cd "$SOURCES_DIR" && git log -1 --pretty=format:%H)
LAST_COMMIT_HASH_ABBR=$(cd "$SOURCES_DIR" && git log -1 --pretty=format:%h)
@ -80,7 +87,7 @@ if [[ -d "$SOURCES_DIR/.git" ]] && which git &>/dev/null &&\
echo "FILE_CREATION_DATE=$FILE_CREATION_DATE" >> "$VERSION_FILE"
echo "FILE_CREATION_TIMESTAMP=$FILE_CREATION_TIMESTAMP" >> "$VERSION_FILE"
elif [[ -r "$VERSION_FILE" ]]; then
. "$VERSION_FILE" >/dev/null
source "$VERSION_FILE" >/dev/null
if [[ ! "$CAS_VERSION" ]]; then
error "'$VERSION_FILE' - wrong version file format; file does not contain CAS_VERSION"
fi