Remove remains of atomic writes support

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2021-08-12 16:30:27 +02:00
parent d87b2c6be7
commit c68de77799
21 changed files with 9 additions and 1704 deletions

View File

@ -281,12 +281,6 @@ static struct name_to_val_mapping promotion_policy_names[] = {
{ NULL} { NULL}
}; };
static struct name_to_val_mapping metadata_mode_names[] = {
{ .short_name = "normal", .value = CAS_METADATA_MODE_NORMAL },
{ .short_name = "atomic", .value = CAS_METADATA_MODE_ATOMIC },
{ NULL }
};
static struct name_to_val_mapping seq_cutoff_policy_names[] = { static struct name_to_val_mapping seq_cutoff_policy_names[] = {
{ .short_name = "always", .value = ocf_seq_cutoff_policy_always }, { .short_name = "always", .value = ocf_seq_cutoff_policy_always },
{ .short_name = "full", .value = ocf_seq_cutoff_policy_full }, { .short_name = "full", .value = ocf_seq_cutoff_policy_full },
@ -310,12 +304,6 @@ static struct name_to_val_mapping output_formats_names[] = {
{ NULL } { NULL }
}; };
static struct name_to_val_mapping metadata_modes_names[] = {
{ .short_name = "normal", .value = METADATA_MODE_NORMAL },
{ .short_name = "atomic", .value = METADATA_MODE_ATOMIC },
{ NULL }
};
static int validate_str_val_mapping(const char* s, static int validate_str_val_mapping(const char* s,
const struct name_to_val_mapping* mappings, const struct name_to_val_mapping* mappings,
int invalid_value) int invalid_value)
@ -447,11 +435,6 @@ inline const char *promotion_policy_to_name(uint8_t policy)
return val_to_short_name(policy, promotion_policy_names, "Unknown"); return val_to_short_name(policy, promotion_policy_names, "Unknown");
} }
const char *metadata_mode_to_name(uint8_t metadata_mode)
{
return val_to_short_name(metadata_mode, metadata_mode_names, "Invalid");
}
const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy) const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy)
{ {
return val_to_short_name(seq_cutoff_policy, return val_to_short_name(seq_cutoff_policy,
@ -495,15 +478,6 @@ int validate_str_output_format(const char* s)
OUTPUT_FORMAT_INVALID); OUTPUT_FORMAT_INVALID);
} }
/* Returns one of METADATA_MODE values
* or METADATA_MODE_INVALID in case of error.
*/
int validate_str_metadata_mode(const char* s)
{
return validate_str_val_mapping(s, metadata_modes_names,
METADATA_MODE_INVALID);
}
void print_err(int error_code) void print_err(int error_code)
{ {
const char *msg = cas_strerr(error_code); const char *msg = cas_strerr(error_code);
@ -534,21 +508,6 @@ const char *get_core_state_name(int core_state)
} }
/* check if device is atomic and print information about potential slow start */
void print_slow_atomic_cache_start_info(const char *device_path)
{
struct kcas_cache_check_device cmd_info;
int ret;
ret = _check_cache_device(device_path, &cmd_info);
if (!ret && cmd_info.format_atomic) {
cas_printf(LOG_INFO,
"Starting new cache instance on a device with atomic metadata format may take \n"
"several minutes depending on device model and size.\n");
}
}
/** /**
* Save to dest an absolute device file path of src. * Save to dest an absolute device file path of src.
* Return number of characters copied to dest if succeed, negative value if failed. * Return number of characters copied to dest if succeed, negative value if failed.
@ -1015,9 +974,6 @@ int start_cache(uint16_t cache_id, unsigned int cache_init,
} }
close(fd); close(fd);
if (cache_init == CACHE_INIT_NEW)
print_slow_atomic_cache_start_info(cache_device);
fd = open_ctrl_device(); fd = open_ctrl_device();
if (fd == -1) if (fd == -1)
return FAILURE; return FAILURE;
@ -1080,11 +1036,6 @@ int start_cache(uint16_t cache_id, unsigned int cache_init,
} }
} }
if (!cmd.metadata_mode_optimal)
cas_printf(LOG_NOTICE, "Selected metadata mode is not optimal for device %s.\n"
"You can improve cache performance by formatting your device\n",
cache_device);
check_cache_scheduler(cache_device, check_cache_scheduler(cache_device,
cmd.cache_elevator); cmd.cache_elevator);

View File

@ -68,13 +68,6 @@ enum output_format_t {
OUTPUT_FORMAT_DEFAULT = OUTPUT_FORMAT_TABLE OUTPUT_FORMAT_DEFAULT = OUTPUT_FORMAT_TABLE
}; };
enum metadata_mode_t {
METADATA_MODE_INVALID = 0,
METADATA_MODE_NORMAL,
METADATA_MODE_ATOMIC,
METADATA_MODE_DEFAULT = METADATA_MODE_NORMAL,
};
#define STATS_FILTER_INVALID 0 #define STATS_FILTER_INVALID 0
#define STATS_FILTER_CONF (1 << 0) #define STATS_FILTER_CONF (1 << 0)
#define STATS_FILTER_USAGE (1 << 1) #define STATS_FILTER_USAGE (1 << 1)
@ -96,8 +89,6 @@ const char *promotion_policy_to_name(uint8_t policy);
const char *cache_mode_to_name(uint8_t cache_mode); const char *cache_mode_to_name(uint8_t cache_mode);
const char *get_cache_state_name(int cache_state); const char *get_cache_state_name(int cache_state);
const char *get_core_state_name(int core_state); const char *get_core_state_name(int core_state);
const char *metadata_variant_to_name(uint8_t variant);
const char *metadata_mode_to_name(uint8_t metadata_mode);
const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy); const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy);
__attribute__((format(printf, 2, 3))) __attribute__((format(printf, 2, 3)))
@ -264,10 +255,8 @@ int validate_path(const char *path, int exist);
int validate_str_cache_mode(const char *s); int validate_str_cache_mode(const char *s);
int validate_str_cln_policy(const char *s); int validate_str_cln_policy(const char *s);
int validate_str_promotion_policy(const char *s); int validate_str_promotion_policy(const char *s);
int validate_str_meta_variant(const char *s);
int validate_str_stats_filters(const char* s); int validate_str_stats_filters(const char* s);
int validate_str_output_format(const char* s); int validate_str_output_format(const char* s);
int validate_str_metadata_mode(const char* s);
/** /**
* @brief clear metadata * @brief clear metadata

View File

@ -208,10 +208,6 @@ struct {
KCAS_ERR_ROLLBACK, KCAS_ERR_ROLLBACK,
"Cannot restore previous configuration" "Cannot restore previous configuration"
}, },
{
KCAS_ERR_NVME_BAD_FORMAT,
"NVMe is formatted to unsupported format"
},
{ {
KCAS_ERR_CONTAINS_PART, KCAS_ERR_CONTAINS_PART,
"Device contains partitions.\nIf you want to continue, " "Device contains partitions.\nIf you want to continue, "

View File

@ -581,9 +581,6 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info,
print_kv_pair_time(outfile, "Dirty for", cache_info->info.dirty_for); print_kv_pair_time(outfile, "Dirty for", cache_info->info.dirty_for);
print_kv_pair(outfile, "Metadata Mode", "%s",
metadata_mode_to_name(cache_info->metadata_mode));
if (flush_progress) { if (flush_progress) {
print_kv_pair(outfile, "Status", "%s (%3.1f %%)", print_kv_pair(outfile, "Status", "%s (%3.1f %%)",
"Flushing", flush_progress); "Flushing", flush_progress);

View File

@ -15,7 +15,6 @@
#include "control.h" #include "control.h"
#include "layer_cache_management.h" #include "layer_cache_management.h"
#include "service_ui_ioctl.h" #include "service_ui_ioctl.h"
#include "utils/cas_cache_utils.h"
#include "volume/vol_blk_utils.h" #include "volume/vol_blk_utils.h"
#include "classifier.h" #include "classifier.h"
#include "context.h" #include "context.h"
@ -45,11 +44,8 @@
* cache/core object types */ * cache/core object types */
enum { enum {
BLOCK_DEVICE_VOLUME = 1, /**< block device volume */ BLOCK_DEVICE_VOLUME = 1, /**< block device volume */
ATOMIC_DEVICE_VOLUME, /**< block device volume with atomic
metadata support */
/** \cond SKIP_IN_DOC */ /** \cond SKIP_IN_DOC */
OBJECT_TYPE_MAX, OBJECT_TYPE_MAX,
NVME_CONTROLLER
/** \endcond */ /** \endcond */
}; };

View File

@ -440,12 +440,6 @@ int cas_initialize_context(void)
} }
ret = atomic_dev_init();
if (ret) {
printk(KERN_ERR "Cannot initialize atomic device layer\n");
goto err_rpool;
}
return 0; return 0;
err_rpool: err_rpool:

View File

@ -1136,9 +1136,6 @@ int cache_mngt_cache_check_device(struct kcas_cache_check_device *cmd_info)
if (result) if (result)
goto out_bdev; goto out_bdev;
cmd_info->format_atomic = (ocf_ctx_get_volume_type_id(cas_ctx,
ocf_volume_get_type(volume)) == ATOMIC_DEVICE_VOLUME);
init_completion(&context.cmpl); init_completion(&context.cmpl);
context.cmd_info = cmd_info; context.cmd_info = cmd_info;
context.result = &result; context.result = &result;
@ -1198,8 +1195,6 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
return 0; return 0;
result = cas_blk_identify_type(cfg->uuid.data, &cfg->volume_type); result = cas_blk_identify_type(cfg->uuid.data, &cfg->volume_type);
if (!result && cfg->volume_type == ATOMIC_DEVICE_VOLUME)
result = -KCAS_ERR_NVME_BAD_FORMAT;
if (OCF_ERR_NOT_OPEN_EXC == abs(result)) { if (OCF_ERR_NOT_OPEN_EXC == abs(result)) {
printk(KERN_WARNING OCF_PREFIX_SHORT printk(KERN_WARNING OCF_PREFIX_SHORT
"Cannot open device %s exclusively. " "Cannot open device %s exclusively. "
@ -1761,7 +1756,6 @@ static int cache_mngt_initialize_core_objects(ocf_cache_t cache)
int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg, int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg, struct ocf_mngt_cache_device_config *device_cfg,
struct atomic_dev_params *atomic_params,
struct kcas_start_cache *cmd) struct kcas_start_cache *cmd)
{ {
int init_cache, result; int init_cache, result;
@ -1790,7 +1784,6 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
memset(cfg, 0, sizeof(*cfg)); memset(cfg, 0, sizeof(*cfg));
memset(device_cfg, 0, sizeof(*device_cfg)); memset(device_cfg, 0, sizeof(*device_cfg));
memset(atomic_params, 0, sizeof(*atomic_params));
strncpy(cfg->name, cache_name, OCF_CACHE_NAME_SIZE - 1); strncpy(cfg->name, cache_name, OCF_CACHE_NAME_SIZE - 1);
cfg->cache_mode = cmd->caching_mode; cfg->cache_mode = cmd->caching_mode;
@ -1811,6 +1804,7 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
device_cfg->cache_line_size = cmd->line_size; device_cfg->cache_line_size = cmd->line_size;
device_cfg->force = cmd->force; device_cfg->force = cmd->force;
device_cfg->discard_on_start = true; device_cfg->discard_on_start = true;
device_cfg->perform_test = false;
init_cache = cmd->init_cache; init_cache = cmd->init_cache;
@ -1838,22 +1832,11 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
if (!is_part && part_count > 1 && !device_cfg->force) if (!is_part && part_count > 1 && !device_cfg->force)
return -KCAS_ERR_CONTAINS_PART; return -KCAS_ERR_CONTAINS_PART;
result = cas_blk_identify_type_atomic(device_cfg->uuid.data, result = cas_blk_identify_type(device_cfg->uuid.data,
&device_cfg->volume_type, atomic_params); &device_cfg->volume_type);
if (result) if (result)
return result; return result;
if (device_cfg->volume_type == ATOMIC_DEVICE_VOLUME) {
device_cfg->volume_params = atomic_params;
device_cfg->perform_test = true;
} else {
device_cfg->perform_test = false;
}
cmd->metadata_mode_optimal =
block_dev_is_metadata_mode_optimal(atomic_params,
device_cfg->volume_type);
return 0; return 0;
} }
@ -2684,18 +2667,6 @@ int cache_mngt_get_info(struct kcas_cache_info *info)
BUG_ON(!uuid); BUG_ON(!uuid);
strlcpy(info->cache_path_name, uuid->data, strlcpy(info->cache_path_name, uuid->data,
min(sizeof(info->cache_path_name), uuid->size)); min(sizeof(info->cache_path_name), uuid->size));
switch (info->info.volume_type) {
case BLOCK_DEVICE_VOLUME:
info->metadata_mode = CAS_METADATA_MODE_NORMAL;
break;
case ATOMIC_DEVICE_VOLUME:
info->metadata_mode = CAS_METADATA_MODE_ATOMIC;
break;
default:
info->metadata_mode = CAS_METADATA_MODE_INVALID;
break;
}
} }
/* Collect cores IDs */ /* Collect cores IDs */

View File

@ -8,8 +8,6 @@
#define CAS_BLK_DEV_REQ_TYPE_BIO 1 #define CAS_BLK_DEV_REQ_TYPE_BIO 1
#define CAS_BLK_DEV_REQ_TYPE_REQ 3 #define CAS_BLK_DEV_REQ_TYPE_REQ 3
struct atomic_dev_params;
int cache_mngt_set_cleaning_policy(ocf_cache_t cache, uint32_t type); int cache_mngt_set_cleaning_policy(ocf_cache_t cache, uint32_t type);
int cache_mngt_get_cleaning_policy(ocf_cache_t cache, uint32_t *type); int cache_mngt_get_cleaning_policy(ocf_cache_t cache, uint32_t *type);
@ -49,7 +47,6 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len,
int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg, int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg, struct ocf_mngt_cache_device_config *device_cfg,
struct atomic_dev_params *atomic_params,
struct kcas_start_cache *cmd); struct kcas_start_cache *cmd);
int cache_mngt_core_pool_get_paths(struct kcas_core_pool_path *cmd_info); int cache_mngt_core_pool_get_paths(struct kcas_core_pool_path *cmd_info);

View File

@ -51,12 +51,10 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
struct kcas_start_cache *cmd_info; struct kcas_start_cache *cmd_info;
struct ocf_mngt_cache_config cfg; struct ocf_mngt_cache_config cfg;
struct ocf_mngt_cache_device_config device_cfg; struct ocf_mngt_cache_device_config device_cfg;
struct atomic_dev_params atomic_params;
GET_CMD_INFO(cmd_info, arg); GET_CMD_INFO(cmd_info, arg);
retval = cache_mngt_prepare_cache_cfg(&cfg, &device_cfg, retval = cache_mngt_prepare_cache_cfg(&cfg, &device_cfg, cmd_info);
&atomic_params, cmd_info);
if (retval) if (retval)
RETURN_CMD_RESULT(cmd_info, arg, retval); RETURN_CMD_RESULT(cmd_info, arg, retval);

View File

@ -1,12 +0,0 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __CAS_UTILS_H__
#define __CAS_UTILS_H__
#include "utils_nvme.h"
#endif /* __CAS_UTILS_H__ */

View File

@ -1,68 +0,0 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#if defined(CAS_NVME_PARTIAL)
#include "cas_cache.h"
#include "utils_nvme.h"
#include "utils_blk.h"
#include <linux/ioctl.h>
#include <linux/file.h>
int cas_nvme_get_nsid(struct block_device *bdev, unsigned int *nsid)
{
int ret = 0;
/*
* Maximum NSID is 0xFFFFFFFF, so theoretically there is no free
* room for error code. However it's unlikely that there will ever
* be device with such number of namespaces, so we treat this value
* as it was signed. Then in case of negative value we interpret it
* as an error code. Moreover in case of error we can be sure, that
* we deal with non-NVMe device, because this ioctl should never
* fail with NVMe driver.
*/
ret = ioctl_by_bdev(bdev, NVME_IOCTL_ID, (unsigned long)NULL);
if (ret < 0)
return ret;
*nsid = (unsigned int)ret;
return 0;
}
#define NVME_ID_CNS_NS 0x00
#define NVME_ID_CNS_CTRL 0x01
int cas_nvme_identify_ns(struct block_device *bdev, unsigned int nsid,
struct nvme_id_ns *ns)
{
struct nvme_admin_cmd cmd = { };
unsigned long __user buffer;
int ret = 0;
buffer = cas_vm_mmap(NULL, 0, sizeof(*ns));
if (IS_ERR((void *)buffer))
return PTR_ERR((void *)buffer);
cmd.opcode = nvme_admin_identify;
cmd.nsid = cpu_to_le32(nsid);
cmd.addr = (__u64)buffer;
cmd.data_len = sizeof(*ns);
cmd.cdw10 = NVME_ID_CNS_NS;
ret = ioctl_by_bdev(bdev, NVME_IOCTL_ADMIN_CMD, (unsigned long)&cmd);
if (ret < 0)
goto out;
ret = copy_from_user(ns, (void *)buffer, sizeof(*ns));
if (ret > 0)
ret = -EINVAL;
out:
cas_vm_munmap(buffer, sizeof(*ns));
return ret;
}
#endif

View File

@ -1,28 +0,0 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef UTILS_NVME_H_
#define UTILS_NVME_H_
#if defined(CAS_UAPI_NVME)
#include <uapi/nvme.h>
#endif
#if defined(CAS_UAPI_LINUX_NVME)
#include <uapi/linux/nvme.h>
#endif
#if defined(CAS_UAPI_LINUX_NVME_IOCTL)
#include <uapi/linux/nvme_ioctl.h>
#endif
#include <linux/nvme.h>
int cas_nvme_get_nsid(struct block_device *bdev, unsigned int *nsid);
int cas_nvme_identify_ns(struct block_device *bdev, unsigned int nsid,
struct nvme_id_ns *ns);
#endif /* UTILS_NVME_H_ */

View File

@ -6,7 +6,6 @@
#ifndef __OBJ_BLK_H__ #ifndef __OBJ_BLK_H__
#define __OBJ_BLK_H__ #define __OBJ_BLK_H__
#include "vol_atomic_dev_bottom.h"
#include "vol_block_dev_bottom.h" #include "vol_block_dev_bottom.h"
#include "vol_block_dev_top.h" #include "vol_block_dev_top.h"
@ -26,8 +25,6 @@ struct bd_object {
uint32_t opened_by_bdev : 1; uint32_t opened_by_bdev : 1;
/*!< Opened by supplying bdev manually */ /*!< Opened by supplying bdev manually */
struct atomic_dev_params atomic_params;
atomic64_t pending_rqs; atomic64_t pending_rqs;
/*!< This fields describes in flight IO requests */ /*!< This fields describes in flight IO requests */

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __VOL_ATOMIC_DEV_BOTTOM_H__
#define __VOL_ATOMIC_DEV_BOTTOM_H__
#include "../cas_cache.h"
enum atomic_metadata_mode {
ATOMIC_METADATA_MODE_ELBA,
ATOMIC_METADATA_MODE_SEPBUF,
ATOMIC_METADATA_MODE_NONE,
};
struct atomic_dev_params {
unsigned int nsid;
uint64_t size;
enum atomic_metadata_mode metadata_mode;
unsigned is_mode_optimal : 1;
/* IMPORTANT: If this field is 0, the other fields are invalid! */
unsigned is_atomic_capable : 1;
};
int atomic_dev_init(void);
#endif /* __VOL_ATOMIC_DEV_BOTTOM_H__ */

View File

@ -227,183 +227,12 @@ ctx_data_t *cas_blk_io_get_data(struct ocf_io *io)
return blkio->data; return blkio->data;
} }
#if defined(CAS_NVME_PARTIAL) int cas_blk_open_volume_by_bdev(ocf_volume_t *vol, struct block_device *bdev)
#include "utils/utils_nvme.h"
int cas_blk_identify_type_by_bdev(struct block_device *bdev,
uint8_t *type, struct atomic_dev_params *atomic_params)
{ {
struct nvme_id_ns *ns;
unsigned int nsid, selected, ms, ds, pi, elba, sbsupp;
long long int ret = 0;
struct atomic_dev_params atomic_params_int = {0};
ns = kmalloc(sizeof(*ns), GFP_KERNEL);
if (!ns)
return -OCF_ERR_NO_MEM;
ret = cas_nvme_get_nsid(bdev, &nsid);
if (ret < 0) {
/*
* We cannot obtain NSID which means we are not dealing with
* NVMe device
*/
goto out1;
}
ret = cas_nvme_identify_ns(bdev, nsid, ns);
if (ret < 0) {
/*
* We cannot obtain ns structure which means we ARE dealing with
* NVMe device but can not recognize format so let's treat that
* device as block device
*/
goto out1;
}
selected = ns->flbas & 0xf;
ms = ns->lbaf[selected].ms;
ds = ns->lbaf[selected].ds;
pi = ns->dps & 0x7;
elba = !!(ns->flbas & (1<<4));
sbsupp = !!(ns->mc & (1<<1));
atomic_params_int.is_atomic_capable = 1;
atomic_params_int.nsid = nsid;
atomic_params_int.size = (ns->nsze << (ds - 9)) * SECTOR_SIZE;
if (pi != 0) {
/* We don't support formats which have
* enable Protection Information feature.
*/
ret = -KCAS_ERR_NVME_BAD_FORMAT;
goto out2;
}
switch (ms) {
case 0:
/* NVMe metadata features disabled, so we handle it as
* regular block device
*/
if (ds != 9 && ds != 12) {
ret = -KCAS_ERR_NVME_BAD_FORMAT;
goto out2;
}
*type = BLOCK_DEVICE_VOLUME;
atomic_params_int.metadata_mode = ATOMIC_METADATA_MODE_NONE;
#if !defined(CAS_NVME_FULL)
/*
* Only partial support user can't using
* device in atomic mode, so mode is optimal
*/
atomic_params_int.is_mode_optimal = 1;
break;
#else
if (bdev == cas_bdev_whole(bdev)) {
/*
* Entire device - format isn't optimal
*/
atomic_params_int.is_mode_optimal = 0;
} else {
/*
* Partition - format is optimal, user can't using
* partitions in atomic mode
*/
atomic_params_int.is_mode_optimal = 1;
}
break;
case 8:
/* For atomic writes we support only metadata size 8B and
* data size 512B
*/
if (ds != 9) {
ret = -KCAS_ERR_NVME_BAD_FORMAT;
goto out2;
}
*type = ATOMIC_DEVICE_VOLUME;
atomic_params_int.metadata_mode = elba ?
ATOMIC_METADATA_MODE_ELBA :
ATOMIC_METADATA_MODE_SEPBUF;
atomic_params_int.is_mode_optimal = sbsupp ? !elba : 1;
break;
#endif
default:
ret = -KCAS_ERR_NVME_BAD_FORMAT;
}
if (atomic_params)
*atomic_params = atomic_params_int;
goto out2;
out1:
*type = BLOCK_DEVICE_VOLUME;
ret = 0;
out2:
kfree(ns);
return ret;
}
static inline int _cas_detect_blk_type(const char *path, uint8_t *type,
struct atomic_dev_params *atomic_params)
{
int ret;
struct block_device *bdev;
char holder[] = "CAS DETECT\n";
bdev = blkdev_get_by_path(path, (FMODE_EXCL|FMODE_READ), holder);
if (IS_ERR(bdev))
return -OCF_ERR_NOT_OPEN_EXC;
ret = cas_blk_identify_type_by_bdev(bdev, type, atomic_params);
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
return ret;
}
#else
static inline int _cas_detect_blk_type(const char *path, uint8_t *type,
struct atomic_dev_params *atomic_params)
{
/*
* NVMe is not supported with given kernel version, so we
* have no way to figure out what the current NVMe format
* is. In this situation we make a naive assumption that
* it's formatted to LBA size 512B, and try to treat it
* as regular block device.
*/
*type = BLOCK_DEVICE_VOLUME;
return 0;
}
int cas_blk_identify_type_by_bdev(struct block_device *bdev,
uint8_t *type, struct atomic_dev_params *atomic_params)
{
*type = BLOCK_DEVICE_VOLUME;
return 0;
}
#endif
int cas_blk_open_volume_by_bdev(ocf_volume_t *vol,
struct block_device *bdev)
{
struct atomic_dev_params atomic_params = {0};
struct bd_object *bdobj; struct bd_object *bdobj;
uint8_t type;
int ret; int ret;
ret = cas_blk_identify_type_by_bdev(bdev, &type, &atomic_params); ret = ocf_ctx_volume_create(cas_ctx, vol, NULL, BLOCK_DEVICE_VOLUME);
if (ret)
goto err;
ret = ocf_ctx_volume_create(cas_ctx, vol, NULL, type);
if (ret) if (ret)
goto err; goto err;
@ -412,7 +241,7 @@ int cas_blk_open_volume_by_bdev(ocf_volume_t *vol,
bdobj->btm_bd = bdev; bdobj->btm_bd = bdev;
bdobj->opened_by_bdev = true; bdobj->opened_by_bdev = true;
return ocf_volume_open(*vol, &atomic_params); return ocf_volume_open(*vol, NULL);
err: err:
return ret; return ret;
@ -425,8 +254,7 @@ void cas_blk_close_volume(ocf_volume_t vol)
env_free(vol); env_free(vol);
} }
int _cas_blk_identify_type(const char *path, uint8_t *type, int _cas_blk_identify_type(const char *path, uint8_t *type)
struct atomic_dev_params *atomic_params)
{ {
struct file *file; struct file *file;
int result = 0; int result = 0;
@ -437,8 +265,6 @@ int _cas_blk_identify_type(const char *path, uint8_t *type,
if (S_ISBLK(CAS_FILE_INODE(file)->i_mode)) if (S_ISBLK(CAS_FILE_INODE(file)->i_mode))
*type = BLOCK_DEVICE_VOLUME; *type = BLOCK_DEVICE_VOLUME;
else if (S_ISCHR(CAS_FILE_INODE(file)->i_mode))
*type = NVME_CONTROLLER;
else else
result = -OCF_ERR_INVAL_VOLUME_TYPE; result = -OCF_ERR_INVAL_VOLUME_TYPE;
@ -446,23 +272,10 @@ int _cas_blk_identify_type(const char *path, uint8_t *type,
if (result) if (result)
return result; return result;
if (*type == BLOCK_DEVICE_VOLUME) {
result = _cas_detect_blk_type(path, type, atomic_params);
if (result < 0)
return result;
}
return 0; return 0;
} }
int cas_blk_identify_type(const char *path, uint8_t *type) int cas_blk_identify_type(const char *path, uint8_t *type)
{ {
return _cas_blk_identify_type(path, type, NULL); return _cas_blk_identify_type(path, type);
} }
int cas_blk_identify_type_atomic(const char *path, uint8_t *type,
struct atomic_dev_params *atomic_params)
{
return _cas_blk_identify_type(path, type, atomic_params);
}

View File

@ -30,18 +30,12 @@ int cas_blk_io_set_data(struct ocf_io *io, ctx_data_t *data,
uint32_t offset); uint32_t offset);
ctx_data_t *cas_blk_io_get_data(struct ocf_io *io); ctx_data_t *cas_blk_io_get_data(struct ocf_io *io);
int cas_blk_identify_type_by_bdev(struct block_device *bdev,
uint8_t *type, struct atomic_dev_params *atomic_params);
int cas_blk_open_volume_by_bdev(ocf_volume_t *vol, int cas_blk_open_volume_by_bdev(ocf_volume_t *vol,
struct block_device *bdev); struct block_device *bdev);
void cas_blk_close_volume(ocf_volume_t vol); void cas_blk_close_volume(ocf_volume_t vol);
int cas_blk_identify_type(const char *path, uint8_t *type); int cas_blk_identify_type(const char *path, uint8_t *type);
int cas_blk_identify_type_atomic(const char *path, uint8_t *type,
struct atomic_dev_params *atomic_params);
static inline void cas_io_iter_init(struct bio_vec_iter *iter, static inline void cas_io_iter_init(struct bio_vec_iter *iter,
struct bio_vec *vec, uint32_t vec_size) struct bio_vec *vec, uint32_t vec_size)
{ {

View File

@ -124,22 +124,6 @@ const char *block_dev_get_elevator_name(struct request_queue *q)
return __block_dev_get_elevator_name(q); return __block_dev_get_elevator_name(q);
} }
/*
*
*/
int block_dev_is_metadata_mode_optimal(struct atomic_dev_params *atomic_params,
uint8_t type)
{
if (type == BLOCK_DEVICE_VOLUME) {
if (atomic_params->is_atomic_capable)
return atomic_params->is_mode_optimal;
} else if (type == ATOMIC_DEVICE_VOLUME) {
return atomic_params->is_mode_optimal;
}
return 1;
}
/* /*
* *
*/ */

View File

@ -14,9 +14,6 @@ void block_dev_close_object(ocf_volume_t vol);
const char *block_dev_get_elevator_name(struct request_queue *q); const char *block_dev_get_elevator_name(struct request_queue *q);
int block_dev_is_metadata_mode_optimal(struct atomic_dev_params *atomic_params,
uint8_t type);
int block_dev_try_get_io_class(struct bio *bio, int *io_class); int block_dev_try_get_io_class(struct bio *bio, int *io_class);
int block_dev_init(void); int block_dev_init(void);

View File

@ -27,57 +27,9 @@ check_header=$(shell echo "\#include <${1}>" | \
INCDIR = $(PWD)/include INCDIR = $(PWD)/include
NVME_FULL = 0
SLES ?= $(shell cat /etc/SuSE-release 2>/dev/null)
ifneq ($(SLES),)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME_IOCTL
EXTRA_CFLAGS += -DCAS_SLES
SLES_VERSION := $(shell cat /etc/os-release |\
sed -n 's/VERSION="\([0-9]\+\)-\(.\+\)"/\1\2/p')
EXTRA_CFLAGS += -DCAS_SLES$(SLES_VERSION)
INCDIR = ""
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/nvme.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_NVME_IOCTL
EXTRA_CFLAGS += -DCAS_UAPI_NVME
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/linux/nvme.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME
NVME_PARTIAL = 1
endif
ifeq ($(call check_header,$(INCDIR)/uapi/linux/nvme_ioctl.h), 1)
EXTRA_CFLAGS += -DCAS_UAPI_LINUX_NVME_IOCTL
NVME_PARTIAL = 1
ifeq ($(shell cat /etc/redhat-release 2>/dev/null | grep "\(Red Hat\|CentOS\) [a-zA-Z ]* 7\.[45]" | wc -l), 1)
NVME_FULL = 1
endif
endif
KERNEL_VERSION = $(shell echo $(KERNELRELEASE) | cut -d'.' -f1) KERNEL_VERSION = $(shell echo $(KERNELRELEASE) | cut -d'.' -f1)
KERNEL_MAJOR = $(shell echo $(KERNELRELEASE) | cut -d'.' -f2) KERNEL_MAJOR = $(shell echo $(KERNELRELEASE) | cut -d'.' -f2)
ifeq ($(shell expr $(KERNEL_VERSION) \> 4 \| $(KERNEL_VERSION) \== 4 \& $(KERNEL_MAJOR) \> 11),1)
NVME_FULL = 0
endif
ifeq ($(shell expr $(KERNEL_VERSION) \> 5 \| $(KERNEL_VERSION) \== 5 \& $(KERNEL_MAJOR) \> 7),1)
NVME_PARTIAL = 0
endif
ifeq ($(NVME_PARTIAL),1)
EXTRA_CFLAGS += -DCAS_NVME_PARTIAL
endif
ifeq ($(NVME_FULL),1)
EXTRA_CFLAGS += -DCAS_NVME_FULL
endif
EXTRA_CFLAGS += -Werror EXTRA_CFLAGS += -Werror
EXTRA_LDFLAGS += -z noexecstack -z relro -z now EXTRA_LDFLAGS += -z noexecstack -z relro -z now

View File

@ -74,8 +74,6 @@ struct kcas_start_cache {
uint64_t min_free_ram; /**< Minimum free RAM memory for cache metadata */ uint64_t min_free_ram; /**< Minimum free RAM memory for cache metadata */
uint8_t metadata_mode_optimal; /**< Current metadata mode is optimal */
char cache_elevator[MAX_ELEVATOR_NAME]; char cache_elevator[MAX_ELEVATOR_NAME];
int ext_err_code; int ext_err_code;
@ -188,8 +186,6 @@ struct kcas_cache_info {
struct ocf_cache_info info; struct ocf_cache_info info;
uint8_t metadata_mode; /**< metadata mode (normal/atomic) */
int ext_err_code; int ext_err_code;
}; };
@ -280,31 +276,6 @@ struct kcas_cache_list {
int ext_err_code; int ext_err_code;
}; };
/**
* CAS capabilities.
*/
struct kcas_capabilites {
uint8_t nvme_format : 1;
/**< NVMe format support */
int ext_err_code;
};
/**
* Format NVMe namespace.
*/
#define CAS_METADATA_MODE_NORMAL 0
#define CAS_METADATA_MODE_ATOMIC 1
#define CAS_METADATA_MODE_INVALID 255
struct kcas_nvme_format {
char device_path_name[MAX_STR_LEN]; /**< path to NVMe device*/
int metadata_mode; /**< selected metadata mode */
int force;
int ext_err_code;
};
struct kcas_core_pool_remove { struct kcas_core_pool_remove {
char core_path_name[MAX_STR_LEN]; /**< path to a core object */ char core_path_name[MAX_STR_LEN]; /**< path to a core object */
@ -321,7 +292,6 @@ struct kcas_cache_check_device {
/* following bool flags are defined iff is_metadata_compatible == 1 */ /* following bool flags are defined iff is_metadata_compatible == 1 */
bool clean_shutdown; bool clean_shutdown;
bool cache_dirty; bool cache_dirty;
bool format_atomic;
int ext_err_code; int ext_err_code;
}; };
@ -458,12 +428,6 @@ struct kcas_get_cache_param {
/** List valid cache ids within Open CAS module */ /** List valid cache ids within Open CAS module */
#define KCAS_IOCTL_LIST_CACHE _IOWR(KCAS_IOCTL_MAGIC, 17, struct kcas_cache_list) #define KCAS_IOCTL_LIST_CACHE _IOWR(KCAS_IOCTL_MAGIC, 17, struct kcas_cache_list)
/** Provides capabilites of installed open cas module */
#define KCAS_IOCTL_GET_CAPABILITIES _IOWR(KCAS_IOCTL_MAGIC, 18, struct kcas_capabilites)
/** Format NVMe namespace to support selected metadata mode */
#define KCAS_IOCTL_NVME_FORMAT _IOWR(KCAS_IOCTL_MAGIC, 20, struct kcas_nvme_format)
/** Start new cache instance, load cache or recover cache */ /** Start new cache instance, load cache or recover cache */
#define KCAS_IOCTL_START_CACHE _IOWR(KCAS_IOCTL_MAGIC, 21, struct kcas_start_cache) #define KCAS_IOCTL_START_CACHE _IOWR(KCAS_IOCTL_MAGIC, 21, struct kcas_start_cache)