Merge pull request #1549 from robertbaldyga/kernel-6.11

Support kernel 6.13
This commit is contained in:
Robert Baldyga 2025-02-28 16:26:19 +01:00 committed by GitHub
commit 372a29d562
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 344 additions and 90 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright(c) 2012-2022 Intel Corporation # Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies # Copyright(c) 2024-2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -10,16 +10,19 @@
check() { check() {
cur_name=$(basename $2) cur_name=$(basename $2)
config_file_path=$1 config_file_path=$1
if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" || if compile_module $cur_name "struct block_device bd; bdev_partno;" "linux/blkdev.h"
compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h"
then then
echo $cur_name "1" >> $config_file_path echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct block_device bd; bd = *disk_part_iter_next(NULL);" "linux/blk_types.h" "linux/genhd.h" elif compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h" ||
compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/blkdev.h"
then then
echo $cur_name "2" >> $config_file_path echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "struct hd_struct hd; hd = *disk_part_iter_next(NULL);" "linux/genhd.h" elif compile_module $cur_name "struct block_device bd; bd = *disk_part_iter_next(NULL);" "linux/blk_types.h" "linux/genhd.h"
then then
echo $cur_name "3" >> $config_file_path echo $cur_name "3" >> $config_file_path
elif compile_module $cur_name "struct hd_struct hd; hd = *disk_part_iter_next(NULL);" "linux/genhd.h"
then
echo $cur_name "4" >> $config_file_path
else else
echo $cur_name "X" >> $config_file_path echo $cur_name "X" >> $config_file_path
fi fi
@ -37,7 +40,7 @@ apply() {
unsigned long idx; unsigned long idx;
xa_for_each(&disk->part_tbl, idx, part) { xa_for_each(&disk->part_tbl, idx, part) {
if ((part_no = part->bd_partno)) { if ((part_no = bdev_partno(part))) {
break; break;
} }
} }
@ -47,6 +50,23 @@ apply() {
"2") "2")
add_function " add_function "
static inline int cas_bd_get_next_part(struct block_device *bd) static inline int cas_bd_get_next_part(struct block_device *bd)
{
int part_no = 0;
struct gendisk *disk = bd->bd_disk;
struct block_device *part;
unsigned long idx;
xa_for_each(&disk->part_tbl, idx, part) {
if ((part_no = part->bd_partno)) {
break;
}
}
return part_no;
}" ;;
"3")
add_function "
static inline int cas_bd_get_next_part(struct block_device *bd)
{ {
int part_no = 0; int part_no = 0;
struct gendisk *disk = bd->bd_disk; struct gendisk *disk = bd->bd_disk;
@ -66,7 +86,7 @@ apply() {
return part_no; return part_no;
}" ;; }" ;;
"3") "4")
add_function " add_function "
static inline int cas_bd_get_next_part(struct block_device *bd) static inline int cas_bd_get_next_part(struct block_device *bd)
{ {

View File

@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework.sh
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_queue_max_discard_sectors(NULL, 0);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline void cas_queue_max_discard_sectors(
struct request_queue *q,
unsigned int max_discard_sectors)
{
blk_queue_max_discard_sectors(q, max_discard_sectors);
}" ;;
"2")
add_function "
static inline void cas_queue_max_discard_sectors(
struct request_queue *q,
unsigned int max_discard_sectors)
{
struct queue_limits *lim = &q->limits;
lim->max_hw_discard_sectors = max_discard_sectors;
lim->max_discard_sectors =
min(max_discard_sectors, lim->max_user_discard_sectors);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright(c) 2012-2022 Intel Corporation # Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies # Copyright(c) 2024-2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -12,18 +12,18 @@ check() {
cur_name=$(basename $2) cur_name=$(basename $2)
config_file_path=$1 config_file_path=$1
if compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h" if compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
then then
if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h" if compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
then then
echo $cur_name "2" >> $config_file_path echo $cur_name "1" >> $config_file_path
else else
echo $cur_name "3" >> $config_file_path echo $cur_name "2" >> $config_file_path
fi fi
elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h" elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
elif compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h"
then then
echo $cur_name "4" >> $config_file_path echo $cur_name "4" >> $config_file_path
else else
@ -37,6 +37,55 @@ apply() {
add_function " add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q, static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q) struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
exp_q->limits.max_write_zeroes_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
"2")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_zeroes_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
"3")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
"4")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{ {
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux; struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
exp_q->limits = *cache_q_limits; exp_q->limits = *cache_q_limits;
@ -63,55 +112,6 @@ apply() {
if (queue_virt_boundary(cache_q)) if (queue_virt_boundary(cache_q))
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q); queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
}" ;; }" ;;
"2")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
exp_q->limits.max_write_zeroes_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
"3")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_zeroes_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
"4")
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct queue_limits *cache_q_limits, struct request_queue *core_q)
{
exp_q->limits = *cache_q_limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
}"
add_function "
static inline void cas_cache_set_no_merges_flag(struct request_queue *cache_q)
{
}" ;;
*) *)

View File

@ -0,0 +1,42 @@
#!/bin/bash
#
# Copyright(c) 2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework.sh
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct queue_limits q; q.misaligned;" "linux/blkdev.h"
then
echo $cur_name 1 >> $config_file_path
else
echo $cur_name 2 >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline bool cas_queue_limits_is_misaligned(
struct queue_limits *lim)
{
return lim->misaligned;
}" ;;
"2")
add_function "
static inline bool cas_queue_limits_is_misaligned(
struct queue_limits *lim)
{
return lim->features & BLK_FLAG_MISALIGNED;
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause
#
. $(dirname $3)/conf_framework.sh
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "(int)QUEUE_FLAG_NONROT;" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
else
echo $cur_name "2" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline void cas_queue_set_nonrot(struct request_queue *q)
{
q->queue_flags |= (1 << QUEUE_FLAG_NONROT);
}" ;;
"2")
add_function "
static inline void cas_queue_set_nonrot(struct request_queue *q)
{
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright(c) 2012-2022 Intel Corporation # Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2024 Huawei Technologies # Copyright(c) 2024-2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -28,13 +28,14 @@ check() {
apply() { apply() {
case "$1" in case "$1" in
"1") "1")
add_typedef "struct queue_limits cas_queue_limits_t;"
add_function " add_function "
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue, static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set) struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{ {
*gd = blk_mq_alloc_disk(tag_set, NULL, NULL); *gd = blk_mq_alloc_disk(tag_set, lim, NULL);
if (!(*gd)) if (IS_ERR(*gd))
return -ENOMEM; return PTR_ERR(*gd);
*queue = (*gd)->queue; *queue = (*gd)->queue;
@ -48,13 +49,14 @@ apply() {
;; ;;
"2") "2")
add_typedef "void* cas_queue_limits_t;"
add_function " add_function "
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue, static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set) struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{ {
*gd = blk_mq_alloc_disk(tag_set, NULL); *gd = blk_mq_alloc_disk(tag_set, NULL);
if (!(*gd)) if (IS_ERR(*gd))
return -ENOMEM; return PTR_ERR(*gd);
*queue = (*gd)->queue; *queue = (*gd)->queue;
@ -68,10 +70,10 @@ apply() {
;; ;;
"3") "3")
add_typedef "void* cas_queue_limits_t;"
add_function " add_function "
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue, static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
struct blk_mq_tag_set *tag_set) struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
{ {
*gd = alloc_disk(1); *gd = alloc_disk(1);
if (!(*gd)) if (!(*gd))

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright(c) 2012-2022 Intel Corporation # Copyright(c) 2012-2022 Intel Corporation
# Copyright(c) 2025 Huawei Technologies
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -9,12 +10,15 @@
check() { check() {
cur_name=$(basename $2) cur_name=$(basename $2)
config_file_path=$1 config_file_path=$1
if compile_module $cur_name "blk_queue_write_cache(NULL, 0, 0);" "linux/blkdev.h" if compile_module $cur_name "BLK_FEAT_WRITE_CACHE;" "linux/blk-mq.h"
then then
echo $cur_name "1" >> $config_file_path echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct request_queue rq; rq.flush_flags;" "linux/blkdev.h" elif compile_module $cur_name "blk_queue_write_cache(NULL, 0, 0);" "linux/blkdev.h"
then then
echo $cur_name "2" >> $config_file_path echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "struct request_queue rq; rq.flush_flags;" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
else else
echo $cur_name "X" >> $config_file_path echo $cur_name "X" >> $config_file_path
fi fi
@ -23,21 +27,39 @@ check() {
apply() { apply() {
case "$1" in case "$1" in
"1") "1")
add_define "CAS_CHECK_QUEUE_FLUSH(q) \\
(q->limits.features & BLK_FEAT_WRITE_CACHE)"
add_define "CAS_CHECK_QUEUE_FUA(q) \\
(q->limits.features & BLK_FEAT_FUA)"
add_define "CAS_BLK_FEAT_WRITE_CACHE BLK_FEAT_WRITE_CACHE"
add_define "CAS_BLK_FEAT_FUA BLK_FEAT_FUA"
add_define "CAS_SET_QUEUE_LIMIT(lim, flag) \\
({ lim->features |= flag; })"
add_function "
static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua) {}" ;;
"2")
add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ add_define "CAS_CHECK_QUEUE_FLUSH(q) \\
test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)" test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)"
add_define "CAS_CHECK_QUEUE_FUA(q) \\ add_define "CAS_CHECK_QUEUE_FUA(q) \\
test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)" test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)"
add_define "CAS_BLK_FEAT_WRITE_CACHE 0"
add_define "CAS_BLK_FEAT_FUA 0"
add_define "CAS_SET_QUEUE_LIMIT(lim, flag)"
add_function " add_function "
static inline void cas_set_queue_flush_fua(struct request_queue *q, static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua) bool flush, bool fua)
{ {
blk_queue_write_cache(q, flush, fua); blk_queue_write_cache(q, flush, fua);
}" ;; }" ;;
"2") "3")
add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ add_define "CAS_CHECK_QUEUE_FLUSH(q) \\
CAS_IS_SET_FLUSH((q)->flush_flags)" CAS_IS_SET_FLUSH((q)->flush_flags)"
add_define "CAS_CHECK_QUEUE_FUA(q) \\ add_define "CAS_CHECK_QUEUE_FUA(q) \\
((q)->flush_flags & REQ_FUA)" ((q)->flush_flags & REQ_FUA)"
add_define "CAS_BLK_FEAT_WRITE_CACHE 0"
add_define "CAS_BLK_FEAT_FUA 0"
add_define "CAS_SET_QUEUE_LIMIT(lim, flag)"
add_function "static inline void cas_set_queue_flush_fua(struct request_queue *q, add_function "static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua) bool flush, bool fua)
{ {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2019-2021 Intel Corporation * Copyright(c) 2019-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -29,8 +29,8 @@
trace_printk(format, ##__VA_ARGS__) trace_printk(format, ##__VA_ARGS__)
#else #else
#define CAS_CLS_DEBUG_MSG(format, ...) #define CAS_CLS_DEBUG_MSG(format, ...) ({})
#define CAS_CLS_DEBUG_TRACE(format, ...) #define CAS_CLS_DEBUG_TRACE(format, ...) ({})
#endif #endif
/* Done condition test - always accepts and stops evaluation */ /* Done condition test - always accepts and stops evaluation */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <linux/module.h> #include <linux/module.h>
@ -417,6 +417,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
struct cas_exp_obj *exp_obj; struct cas_exp_obj *exp_obj;
struct request_queue *queue; struct request_queue *queue;
struct gendisk *gd; struct gendisk *gd;
cas_queue_limits_t queue_limits;
int result = 0; int result = 0;
BUG_ON(!owner); BUG_ON(!owner);
@ -465,7 +466,15 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
goto error_init_tag_set; goto error_init_tag_set;
} }
result = cas_alloc_mq_disk(&gd, &queue, &exp_obj->tag_set); if (exp_obj->ops->set_queue_limits) {
result = exp_obj->ops->set_queue_limits(dsk, priv,
&queue_limits);
if (result)
goto error_set_queue_limits;
}
result = cas_alloc_mq_disk(&gd, &queue, &exp_obj->tag_set,
&queue_limits);
if (result) { if (result) {
goto error_alloc_mq_disk; goto error_alloc_mq_disk;
} }
@ -521,6 +530,7 @@ error_exp_obj_set_dev_t:
cas_cleanup_mq_disk(gd); cas_cleanup_mq_disk(gd);
exp_obj->gd = NULL; exp_obj->gd = NULL;
error_alloc_mq_disk: error_alloc_mq_disk:
error_set_queue_limits:
blk_mq_free_tag_set(&exp_obj->tag_set); blk_mq_free_tag_set(&exp_obj->tag_set);
error_init_tag_set: error_init_tag_set:
module_put(owner); module_put(owner);

View File

@ -1,11 +1,12 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifndef __CASDISK_EXP_OBJ_H__ #ifndef __CASDISK_EXP_OBJ_H__
#define __CASDISK_EXP_OBJ_H__ #define __CASDISK_EXP_OBJ_H__
#include "linux_kernel_version.h"
#include <linux/fs.h> #include <linux/fs.h>
struct cas_disk; struct cas_disk;
@ -17,6 +18,12 @@ struct cas_exp_obj_ops {
*/ */
int (*set_geometry)(struct cas_disk *dsk, void *private); int (*set_geometry)(struct cas_disk *dsk, void *private);
/**
* @brief Set queue limits of exported object (top) block device.
*/
int (*set_queue_limits)(struct cas_disk *dsk, void *private,
cas_queue_limits_t *lim);
/** /**
* @brief submit_bio of exported object (top) block device. * @brief submit_bio of exported object (top) block device.
* *

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -2405,7 +2405,8 @@ static int cache_mngt_check_bdev(struct ocf_mngt_cache_device_config *cfg,
printk(KERN_WARNING "New cache device block properties " printk(KERN_WARNING "New cache device block properties "
"differ from the previous one.\n"); "differ from the previous one.\n");
} }
if (tmp_limits.misaligned) {
if (cas_queue_limits_is_misaligned(&tmp_limits)) {
reattach_properties_diff = true; reattach_properties_diff = true;
printk(KERN_WARNING "New cache device block interval " printk(KERN_WARNING "New cache device block interval "
"doesn't line up with the previous one.\n"); "doesn't line up with the previous one.\n");

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies * Copyright(c) 2024-2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -40,7 +40,6 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/blk-mq.h> #include <linux/blk-mq.h>
#include <linux/ktime.h> #include <linux/ktime.h>
#include "exp_obj.h"
#include "generated_defines.h" #include "generated_defines.h"

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies Co., Ltd. * Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -63,13 +63,14 @@ static void blkdev_set_discard_properties(ocf_cache_t cache,
CAS_SET_DISCARD_ZEROES_DATA(exp_q->limits, 0); CAS_SET_DISCARD_ZEROES_DATA(exp_q->limits, 0);
if (core_q && cas_has_discard_support(core_bd)) { if (core_q && cas_has_discard_support(core_bd)) {
blk_queue_max_discard_sectors(exp_q, core_q->limits.max_discard_sectors); cas_queue_max_discard_sectors(exp_q,
core_q->limits.max_discard_sectors);
exp_q->limits.discard_alignment = exp_q->limits.discard_alignment =
bdev_discard_alignment(core_bd); bdev_discard_alignment(core_bd);
exp_q->limits.discard_granularity = exp_q->limits.discard_granularity =
core_q->limits.discard_granularity; core_q->limits.discard_granularity;
} else { } else {
blk_queue_max_discard_sectors(exp_q, cas_queue_max_discard_sectors(exp_q,
min((uint64_t)core_sectors, (uint64_t)UINT_MAX)); min((uint64_t)core_sectors, (uint64_t)UINT_MAX));
exp_q->limits.discard_granularity = ocf_cache_get_line_size(cache); exp_q->limits.discard_granularity = ocf_cache_get_line_size(cache);
exp_q->limits.discard_alignment = 0; exp_q->limits.discard_alignment = 0;
@ -129,7 +130,37 @@ static int blkdev_core_set_geometry(struct cas_disk *dsk, void *private)
blkdev_set_discard_properties(cache, exp_q, core_bd, sectors); blkdev_set_discard_properties(cache, exp_q, core_bd, sectors);
exp_q->queue_flags |= (1 << QUEUE_FLAG_NONROT); cas_queue_set_nonrot(exp_q);
return 0;
}
static int blkdev_core_set_queue_limits(struct cas_disk *dsk, void *private,
cas_queue_limits_t *lim)
{
ocf_core_t core = private;
ocf_cache_t cache = ocf_core_get_cache(core);
ocf_volume_t core_vol = ocf_core_get_volume(core);
struct bd_object *bd_core_vol;
struct request_queue *core_q;
bool flush, fua;
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
bd_core_vol = bd_object(core_vol);
core_q = cas_disk_get_queue(bd_core_vol->dsk);
flush = (CAS_CHECK_QUEUE_FLUSH(core_q) ||
cache_priv->device_properties.flush);
fua = (CAS_CHECK_QUEUE_FUA(core_q) ||
cache_priv->device_properties.fua);
memset(lim, 0, sizeof(cas_queue_limits_t));
if (flush)
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_WRITE_CACHE);
if (fua)
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_FUA);
return 0; return 0;
} }
@ -428,6 +459,7 @@ static void blkdev_core_submit_bio(struct cas_disk *dsk,
static struct cas_exp_obj_ops kcas_core_exp_obj_ops = { static struct cas_exp_obj_ops kcas_core_exp_obj_ops = {
.set_geometry = blkdev_core_set_geometry, .set_geometry = blkdev_core_set_geometry,
.set_queue_limits = blkdev_core_set_queue_limits,
.submit_bio = blkdev_core_submit_bio, .submit_bio = blkdev_core_submit_bio,
}; };
@ -470,6 +502,37 @@ static int blkdev_cache_set_geometry(struct cas_disk *dsk, void *private)
return 0; return 0;
} }
static int blkdev_cache_set_queue_limits(struct cas_disk *dsk, void *private,
cas_queue_limits_t *lim)
{
ocf_cache_t cache;
ocf_volume_t volume;
struct bd_object *bvol;
struct request_queue *cache_q;
struct block_device *bd;
BUG_ON(!private);
cache = private;
volume = ocf_cache_get_volume(cache);
bvol = bd_object(volume);
bd = cas_disk_get_blkdev(bvol->dsk);
BUG_ON(!bd);
cache_q = bd->bd_disk->queue;
memset(lim, 0, sizeof(cas_queue_limits_t));
if (CAS_CHECK_QUEUE_FLUSH(cache_q))
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_WRITE_CACHE);
if (CAS_CHECK_QUEUE_FUA(cache_q))
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_FUA);
return 0;
}
static void blkdev_cache_submit_bio(struct cas_disk *dsk, static void blkdev_cache_submit_bio(struct cas_disk *dsk,
struct bio *bio, void *private) struct bio *bio, void *private)
{ {
@ -485,6 +548,7 @@ static void blkdev_cache_submit_bio(struct cas_disk *dsk,
static struct cas_exp_obj_ops kcas_cache_exp_obj_ops = { static struct cas_exp_obj_ops kcas_cache_exp_obj_ops = {
.set_geometry = blkdev_cache_set_geometry, .set_geometry = blkdev_cache_set_geometry,
.set_queue_limits = blkdev_cache_set_queue_limits,
.submit_bio = blkdev_cache_submit_bio, .submit_bio = blkdev_cache_submit_bio,
}; };