[Devel] [PATCH vz7 v3] ploop: Only perform standby check when enabled on the target.
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Thu Oct 27 18:41:37 MSK 2022
Add static key enabled via module parameter when running on
mixed mode systems and standby enable flag on the request queue.
Using the flags perform the check only if required by
the target device. Avoid unwanted side effects and performance impact.
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/block/ploop/dev.c | 10 +++++++---
drivers/block/ploop/io_kaio.c | 11 ++++++++---
include/linux/blkdev.h | 2 ++
kernel/ve/ve.c | 4 ++++
4 files changed, 21 insertions(+), 6 deletions(-)
[LIU]: OK, then move the key in core, I'll modify SCST code to enable it, though not in scst_vstor_pr_init().
Moved to core. I will wait for the scst patch, so i can make a live patch.
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 06b72542633b..32f4a394e4b8 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -76,6 +76,8 @@ static DEFINE_MUTEX(ploop_devices_mutex);
static LIST_HEAD(ploop_formats);
static DEFINE_MUTEX(ploop_formats_mutex);
+extern struct static_key ploop_standby_check;
+
int ploop_register_format(struct ploop_delta_ops * ops)
{
mutex_lock(&ploop_formats_mutex);
@@ -985,9 +987,11 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
hd_struct_put(part);
part_stat_unlock();
- if (blk_queue_standby(plo->queue)) {
- BIO_ENDIO(q, bio, -EIO);
- return;
+ if (static_key_false(&ploop_standby_check)) {
+ if (blk_queue_standby(plo->queue)) {
+ BIO_ENDIO(q, bio, -EIO);
+ return;
+ }
}
if (unlikely(bio->bi_size == 0)) {
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index e24952703549..a0c28379eb7d 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -23,6 +23,7 @@
#define KAIO_MAX_PAGES_PER_REQ 32 /* 128 KB */
+extern struct static_key ploop_standby_check;
/* This will be used as flag "ploop_kaio_open() succeeded" */
static struct extent_map_tree
{
@@ -116,6 +117,9 @@ static void check_standby_mode(long res, struct ploop_device *plo) {
struct request_queue *q = plo->queue;
int prev;
+ if (!blk_queue_standby_en(q))
+ return;
+
/* move to standby if delta lease was stolen or mount is gone */
if (res != -EBUSY && res != -ENOTCONN && res != -EIO) {
return;
@@ -146,8 +150,8 @@ static void kaio_rw_aio_complete(u64 data, long res)
bio_list_for_each(b, &preq->bl)
printk(" bio=%p: bi_sector=%ld bi_size=%d\n",
b, b->bi_sector, b->bi_size);
-
- check_standby_mode(res, preq->plo);
+ if (static_key_false(&ploop_standby_check))
+ check_standby_mode(res, preq->plo);
PLOOP_REQ_SET_ERROR(preq, res);
}
@@ -560,7 +564,8 @@ static int kaio_fsync_thread(void * data)
"on ploop%d)\n",
err, io->files.inode->i_ino,
io2level(io), plo->index);
- check_standby_mode(err, plo);
+ if (static_key_false(&ploop_standby_check))
+ check_standby_mode(err, plo);
PLOOP_REQ_SET_ERROR(preq, -EIO);
} else if (preq->req_rw & REQ_FLUSH) {
BUG_ON(!preq->req_size);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4e2970ff97b2..fb6daf0eef7a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -643,6 +643,7 @@ struct request_queue {
#define QUEUE_FLAG_SCSI_PASSTHROUGH 30 /* queue supports SCSI commands */
#define QUEUE_FLAG_STANDBY 31 /* unable to handle read/write requests */
+#define QUEUE_FLAG_STANDBY_EN 32 /* enable standby queue flag */
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_STACKABLE) | \
@@ -739,6 +740,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
#define blk_queue_scsi_passthrough(q) \
test_bit(QUEUE_FLAG_SCSI_PASSTHROUGH, &(q)->queue_flags)
#define blk_queue_standby(q) test_bit(QUEUE_FLAG_STANDBY, &(q)->queue_flags)
+#define blk_queue_standby_en(q) test_bit(QUEUE_FLAG_STANDBY_EN, &(q)->queue_flags)
extern int blk_set_preempt_only(struct request_queue *q);
extern void blk_clear_preempt_only(struct request_queue *q);
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 68c3e91d60c1..67d48b9680e2 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -76,6 +76,10 @@ MODULE_PARM_DESC(ve_allow_ioctl_fitrim,
"Allow ioctl(FITRIM) from inside VE. Only ext4 is supported now");
EXPORT_SYMBOL(ve_allow_ioctl_fitrim);
+/* to avoid creating inter module dependancies */
+struct static_key ploop_standby_check = STATIC_KEY_INIT_FALSE;
+EXPORT_SYMBOL(ploop_standby_check);
+
static DEFINE_PER_CPU(struct kstat_lat_pcpu_snap_struct, ve0_lat_stats);
struct ve_struct ve0 = {
base-commit: 726ab1f1d5f51619964a0626187f8aee970d6920
--
2.31.1
More information about the Devel
mailing list