Skip to content

Commit 7ee78ac

Browse files
author
Rafal Stefanowski
committed
Kernel 6.13: Add setting queue limits of exported object
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com> Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
1 parent dbaeb21 commit 7ee78ac

File tree

5 files changed

+93
-12
lines changed

5 files changed

+93
-12
lines changed

configure.d/2_alloc_disk.conf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# Copyright(c) 2012-2022 Intel Corporation
4-
# Copyright(c) 2024 Huawei Technologies
4+
# Copyright(c) 2024-2025 Huawei Technologies
55
# SPDX-License-Identifier: BSD-3-Clause
66
#
77

@@ -28,11 +28,12 @@ check() {
2828
apply() {
2929
case "$1" in
3030
"1")
31+
add_typedef "struct queue_limits cas_queue_limits_t;"
3132
add_function "
3233
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
33-
struct blk_mq_tag_set *tag_set)
34+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
3435
{
35-
*gd = blk_mq_alloc_disk(tag_set, NULL, NULL);
36+
*gd = blk_mq_alloc_disk(tag_set, lim, NULL);
3637
if (IS_ERR(*gd))
3738
return PTR_ERR(*gd);
3839
@@ -48,9 +49,10 @@ apply() {
4849
;;
4950

5051
"2")
52+
add_typedef "void* cas_queue_limits_t;"
5153
add_function "
5254
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
53-
struct blk_mq_tag_set *tag_set)
55+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
5456
{
5557
*gd = blk_mq_alloc_disk(tag_set, NULL);
5658
if (IS_ERR(*gd))
@@ -68,10 +70,10 @@ apply() {
6870
;;
6971

7072
"3")
71-
73+
add_typedef "void* cas_queue_limits_t;"
7274
add_function "
7375
static inline int cas_alloc_mq_disk(struct gendisk **gd, struct request_queue **queue,
74-
struct blk_mq_tag_set *tag_set)
76+
struct blk_mq_tag_set *tag_set, cas_queue_limits_t *lim)
7577
{
7678
*gd = alloc_disk(1);
7779
if (!(*gd))

modules/cas_cache/exp_obj.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3-
* Copyright(c) 2024 Huawei Technologies
3+
* Copyright(c) 2024-2025 Huawei Technologies
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66
#include <linux/module.h>
@@ -417,6 +417,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
417417
struct cas_exp_obj *exp_obj;
418418
struct request_queue *queue;
419419
struct gendisk *gd;
420+
cas_queue_limits_t queue_limits;
420421
int result = 0;
421422

422423
BUG_ON(!owner);
@@ -465,7 +466,15 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
465466
goto error_init_tag_set;
466467
}
467468

468-
result = cas_alloc_mq_disk(&gd, &queue, &exp_obj->tag_set);
469+
if (exp_obj->ops->set_queue_limits) {
470+
result = exp_obj->ops->set_queue_limits(dsk, priv,
471+
&queue_limits);
472+
if (result)
473+
goto error_set_queue_limits;
474+
}
475+
476+
result = cas_alloc_mq_disk(&gd, &queue, &exp_obj->tag_set,
477+
&queue_limits);
469478
if (result) {
470479
goto error_alloc_mq_disk;
471480
}
@@ -521,6 +530,7 @@ int cas_exp_obj_create(struct cas_disk *dsk, const char *dev_name,
521530
cas_cleanup_mq_disk(gd);
522531
exp_obj->gd = NULL;
523532
error_alloc_mq_disk:
533+
error_set_queue_limits:
524534
blk_mq_free_tag_set(&exp_obj->tag_set);
525535
error_init_tag_set:
526536
module_put(owner);

modules/cas_cache/exp_obj.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3-
* Copyright(c) 2024 Huawei Technologies
3+
* Copyright(c) 2024-2025 Huawei Technologies
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66
#ifndef __CASDISK_EXP_OBJ_H__
77
#define __CASDISK_EXP_OBJ_H__
88

9+
#include "linux_kernel_version.h"
910
#include <linux/fs.h>
1011

1112
struct cas_disk;
@@ -17,6 +18,12 @@ struct cas_exp_obj_ops {
1718
*/
1819
int (*set_geometry)(struct cas_disk *dsk, void *private);
1920

21+
/**
22+
* @brief Set queue limits of exported object (top) block device.
23+
*/
24+
int (*set_queue_limits)(struct cas_disk *dsk, void *private,
25+
cas_queue_limits_t *lim);
26+
2027
/**
2128
* @brief submit_bio of exported object (top) block device.
2229
*

modules/cas_cache/linux_kernel_version.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3-
* Copyright(c) 2024 Huawei Technologies
3+
* Copyright(c) 2024-2025 Huawei Technologies
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66

@@ -40,7 +40,6 @@
4040
#include <linux/mm.h>
4141
#include <linux/blk-mq.h>
4242
#include <linux/ktime.h>
43-
#include "exp_obj.h"
4443

4544
#include "generated_defines.h"
4645

modules/cas_cache/volume/vol_block_dev_top.c

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright(c) 2012-2022 Intel Corporation
3-
* Copyright(c) 2024 Huawei Technologies Co., Ltd.
3+
* Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
66

@@ -135,6 +135,36 @@ static int blkdev_core_set_geometry(struct cas_disk *dsk, void *private)
135135
return 0;
136136
}
137137

138+
static int blkdev_core_set_queue_limits(struct cas_disk *dsk, void *private,
139+
cas_queue_limits_t *lim)
140+
{
141+
ocf_core_t core = private;
142+
ocf_cache_t cache = ocf_core_get_cache(core);
143+
ocf_volume_t core_vol = ocf_core_get_volume(core);
144+
struct bd_object *bd_core_vol;
145+
struct request_queue *core_q;
146+
bool flush, fua;
147+
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
148+
149+
bd_core_vol = bd_object(core_vol);
150+
core_q = cas_disk_get_queue(bd_core_vol->dsk);
151+
152+
flush = (CAS_CHECK_QUEUE_FLUSH(core_q) ||
153+
cache_priv->device_properties.flush);
154+
fua = (CAS_CHECK_QUEUE_FUA(core_q) ||
155+
cache_priv->device_properties.fua);
156+
157+
memset(lim, 0, sizeof(cas_queue_limits_t));
158+
159+
if (flush)
160+
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_WRITE_CACHE);
161+
162+
if (fua)
163+
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_FUA);
164+
165+
return 0;
166+
}
167+
138168
struct defer_bio_context {
139169
struct work_struct io_work;
140170
void (*cb)(struct bd_object *bvol, struct bio *bio);
@@ -429,6 +459,7 @@ static void blkdev_core_submit_bio(struct cas_disk *dsk,
429459

430460
static struct cas_exp_obj_ops kcas_core_exp_obj_ops = {
431461
.set_geometry = blkdev_core_set_geometry,
462+
.set_queue_limits = blkdev_core_set_queue_limits,
432463
.submit_bio = blkdev_core_submit_bio,
433464
};
434465

@@ -471,6 +502,37 @@ static int blkdev_cache_set_geometry(struct cas_disk *dsk, void *private)
471502
return 0;
472503
}
473504

505+
static int blkdev_cache_set_queue_limits(struct cas_disk *dsk, void *private,
506+
cas_queue_limits_t *lim)
507+
{
508+
ocf_cache_t cache;
509+
ocf_volume_t volume;
510+
struct bd_object *bvol;
511+
struct request_queue *cache_q;
512+
struct block_device *bd;
513+
514+
BUG_ON(!private);
515+
cache = private;
516+
volume = ocf_cache_get_volume(cache);
517+
518+
bvol = bd_object(volume);
519+
520+
bd = cas_disk_get_blkdev(bvol->dsk);
521+
BUG_ON(!bd);
522+
523+
cache_q = bd->bd_disk->queue;
524+
525+
memset(lim, 0, sizeof(cas_queue_limits_t));
526+
527+
if (CAS_CHECK_QUEUE_FLUSH(cache_q))
528+
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_WRITE_CACHE);
529+
530+
if (CAS_CHECK_QUEUE_FUA(cache_q))
531+
CAS_SET_QUEUE_LIMIT(lim, CAS_BLK_FEAT_FUA);
532+
533+
return 0;
534+
}
535+
474536
static void blkdev_cache_submit_bio(struct cas_disk *dsk,
475537
struct bio *bio, void *private)
476538
{
@@ -486,6 +548,7 @@ static void blkdev_cache_submit_bio(struct cas_disk *dsk,
486548

487549
static struct cas_exp_obj_ops kcas_cache_exp_obj_ops = {
488550
.set_geometry = blkdev_cache_set_geometry,
551+
.set_queue_limits = blkdev_cache_set_queue_limits,
489552
.submit_bio = blkdev_cache_submit_bio,
490553
};
491554

0 commit comments

Comments
 (0)