[Devel] [PATCH RHEL8 COMMIT] dm-qcow2: Make target !immutable
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Sep 10 20:19:18 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.11
------>
commit 079863256dd67cc6b692666aab7f7adeca701dd7
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Sep 10 20:19:18 2021 +0300
dm-qcow2: Make target !immutable
After that we can't use per_io_data.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-qcow2-map.c | 11 +++++++----
drivers/md/dm-qcow2-target.c | 3 +--
drivers/md/dm-qcow2.h | 17 -----------------
3 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 73785f2b8a57..5fcfb8bffdcb 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -3409,7 +3409,7 @@ static struct bio_vec *create_bvec_from_rq(struct request *rq)
static void prepare_one_embedded_qio(struct qcow2 *qcow2, struct qio *qio,
struct list_head *deferred_qios)
{
- struct qcow2_rq *qrq = embedded_qio_to_qrq(qio);
+ struct qcow2_rq *qrq = qio->endio_cb_data;
struct request *rq = qrq->rq;
struct bio_vec *bvec = NULL;
LIST_HEAD(list);
@@ -4001,6 +4001,7 @@ static void qrq_endio(struct qcow2_target *tgt, struct qio *unused,
if (qrq->bvec)
kfree(qrq->bvec);
+ kfree(qrq);
dm_complete_request(rq, bi_status);
}
@@ -4012,7 +4013,7 @@ static void init_qrq(struct qcow2_rq *qrq, struct request *rq)
void submit_embedded_qio(struct qcow2_target *tgt, struct qio *qio)
{
- struct qcow2_rq *qrq = embedded_qio_to_qrq(qio);
+ struct qcow2_rq *qrq = qio->endio_cb_data;
struct request *rq = qrq->rq;
u8 queue_list_id, ref_index;
struct work_struct *worker;
@@ -4063,10 +4064,12 @@ int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
struct qcow2_rq *qrq;
struct qio *qio;
- qrq = map_info_to_embedded_qrq(info);
+ qrq = kmalloc(sizeof(*qrq) + sizeof(*qio), GFP_ATOMIC);
+ if (!qrq)
+ return DM_MAPIO_KILL;
init_qrq(qrq, rq);
- qio = map_info_to_embedded_qio(info);
+ qio = (void *)qrq + sizeof(*qrq);
init_qio(qio, req_op(rq), NULL);
qio->endio_cb = qrq_endio;
qio->endio_cb_data = qrq;
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 8c878073ac55..d3a99c26f489 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -758,7 +758,6 @@ static int qcow2_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->num_flush_bios = 1;
ti->discards_supported = true;
ti->num_discard_bios = 1;
- ti->per_io_data_size = qcow2_per_io_data_size();
return 0;
err:
qcow2_tgt_destroy(tgt);
@@ -897,7 +896,7 @@ static void qcow2_resume(struct dm_target *ti)
static struct target_type qcow2_target = {
.name = "qcow2",
.version = {1, 0, 0},
- .features = DM_TARGET_SINGLETON|DM_TARGET_IMMUTABLE,
+ .features = DM_TARGET_SINGLETON,
.module = THIS_MODULE,
.ctr = qcow2_ctr,
.dtr = qcow2_dtr,
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 4fa02eac0e2a..d7d668824b74 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -299,23 +299,6 @@ int qcow2_inflight_ref_switch(struct qcow2_target *tgt);
void flush_deferred_activity(struct qcow2_target *tgt, struct qcow2 *qcow2);
int qcow2_truncate_safe(struct file *file, loff_t new_len);
-static inline ssize_t qcow2_per_io_data_size(void)
-{
- return sizeof(struct qcow2_rq) + sizeof(struct qio);
-}
-static inline struct qcow2_rq *map_info_to_embedded_qrq(union map_info *info)
-{
- return (void *)info->ptr;
-}
-static inline struct qio *map_info_to_embedded_qio(union map_info *info)
-{
- return (void *)info->ptr + sizeof(struct qcow2_rq);
-}
-static inline struct qcow2_rq *embedded_qio_to_qrq(struct qio *qio)
-{
- return (void *)qio - sizeof(struct qcow2_rq);
-}
-
static inline struct qcow2_target *to_qcow2_target(struct dm_target *ti)
{
return ti->private;
More information about the Devel
mailing list