[Devel] [PATCH RHEL7 COMMIT] ploop: Add cluster_size_in_sec() helper
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 6 14:22:45 MSK 2019
The commit is pushed to "branch-rh7-3.10.0-957.1.3.vz7.93.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.1.3.vz7.83.17
------>
commit d732d03f52eff91754e1cd389191893a868b0540
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Wed Mar 6 14:22:43 2019 +0300
ploop: Add cluster_size_in_sec() helper
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
ploop: Add online discard support for dio engine
The first part of patchset is preparations to make code
a bit readable.
The second part adds online discard support for dio engine.
DIO engine tracks entents, so discard code will use that
for its needs.
https://pmc.acronis.com/browse/VSTOR-19972
Kirill Tkhai (12):
ploop: introduce dio_may_fallocate() helper
ploop: Export whole_block()
ploop: Add cluster_size_in_bytes() helper
ploop: Add cluster_size_in_sec() helper
ploop: Add local variable into dio_submit()
ploop: Add cluster_log local variable
ploop: Add trim_extent_mappings_tail() helper
ploop: Introduce local variable in ploop_start()
ploop: Never merge discard requests
ploop: Set up discard limits
ploop: Introduce ploop_can_issue_discard() helper
ploop: Online discard support for dio engine
---
drivers/block/ploop/dev.c | 27 ++++++++++++++-------------
drivers/block/ploop/io_direct.c | 4 ++--
drivers/block/ploop/io_kaio.c | 2 +-
drivers/block/ploop/sysfs.c | 2 +-
include/linux/ploop/ploop.h | 9 +++++++--
5 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 820eb4f96df8..42b8a1b7af99 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -531,7 +531,7 @@ ploop_bio_queue(struct ploop_device * plo, struct bio * bio,
if (test_bit(PLOOP_S_DISCARD, &plo->state) &&
unlikely(bio->bi_rw & REQ_DISCARD)) {
- int clu_size = 1 << plo->cluster_log;
+ int clu_size = cluster_size_in_sec(plo);
int i = (clu_size - 1) & bio->bi_sector;
int err = 0;
@@ -1736,7 +1736,7 @@ ploop_reloc_sched_read(struct ploop_request *preq, iblock_t iblk)
preq->eng_state = PLOOP_E_RELOC_DATA_READ;
sbl.head = sbl.tail = preq->aux_bio;
delta->io.ops->submit(&delta->io, preq, READ_SYNC,
- &sbl, iblk, 1<<plo->cluster_log);
+ &sbl, iblk, cluster_size_in_sec(plo));
}
/*
@@ -1793,7 +1793,7 @@ ploop_reuse_free_block(struct ploop_request *preq)
sbl.head = sbl.tail = preq->aux_bio;
top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
- &sbl, preq->iblock, 1<<plo->cluster_log);
+ &sbl, preq->iblock, cluster_size_in_sec(plo));
}
return 0;
@@ -2040,7 +2040,7 @@ ploop_entry_nullify_req(struct ploop_request *preq)
}
top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
- &sbl, preq->iblock, 1<<plo->cluster_log);
+ &sbl, preq->iblock, cluster_size_in_sec(plo));
return 0;
}
@@ -2371,7 +2371,7 @@ ploop_entry_request(struct ploop_request * preq)
preq->eng_state = PLOOP_E_TRANS_DELTA_READ;
sbl.head = sbl.tail = preq->aux_bio;
delta->io.ops->submit(&delta->io, preq, READ_SYNC,
- &sbl, iblk, 1<<plo->cluster_log);
+ &sbl, iblk, cluster_size_in_sec(plo));
plo->st.bio_trans_copy++;
return;
}
@@ -2478,7 +2478,7 @@ ploop_entry_request(struct ploop_request * preq)
preq->eng_state = PLOOP_E_DELTA_READ;
sbl.head = sbl.tail = preq->aux_bio;
delta->io.ops->submit(&delta->io, preq, READ_SYNC,
- &sbl, iblk, 1<<plo->cluster_log);
+ &sbl, iblk, cluster_size_in_sec(plo));
}
} else {
if (!whole_block(plo, preq) && map_index_fault(preq) == 0) {
@@ -2705,7 +2705,7 @@ static void ploop_req_state_process(struct ploop_request * preq)
sbl.head = sbl.tail = preq->aux_bio;
top_delta = ploop_top_delta(plo);
top_delta->ops->allocate(top_delta, preq,
- &sbl, 1<<plo->cluster_log);
+ &sbl, cluster_size_in_sec(plo));
}
break;
}
@@ -2742,7 +2742,7 @@ static void ploop_req_state_process(struct ploop_request * preq)
sbl.head = sbl.tail = preq->aux_bio;
top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
- &sbl, preq->iblock, 1<<plo->cluster_log);
+ &sbl, preq->iblock, cluster_size_in_sec(plo));
}
break;
}
@@ -2758,7 +2758,7 @@ static void ploop_req_state_process(struct ploop_request * preq)
plo->st.bio_out++;
top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
&sbl, preq->iblock,
- 1<<plo->cluster_log);
+ cluster_size_in_sec(plo));
break;
}
case PLOOP_E_RELOC_DATA_READ:
@@ -2786,10 +2786,10 @@ static void ploop_req_state_process(struct ploop_request * preq)
top_delta->io.ops->submit(&top_delta->io, preq,
preq->req_rw, &sbl,
preq->iblock,
- 1<<plo->cluster_log);
+ cluster_size_in_sec(plo));
} else {
top_delta->ops->allocate(top_delta, preq, &sbl,
- 1<<plo->cluster_log);
+ cluster_size_in_sec(plo));
}
break;
}
@@ -2843,13 +2843,14 @@ static void ploop_req_state_process(struct ploop_request * preq)
* we can be here only if merge is in progress and
* merge can't happen concurrently with ballooning
*/
- top_delta->ops->allocate(top_delta, preq, &sbl, 1<<plo->cluster_log);
+ top_delta->ops->allocate(top_delta, preq, &sbl,
+ cluster_size_in_sec(plo));
plo->st.bio_trans_alloc++;
} else {
preq->eng_state = PLOOP_E_COMPLETE;
preq->iblock = iblk;
top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
- &sbl, iblk, 1<<plo->cluster_log);
+ &sbl, iblk, cluster_size_in_sec(plo));
}
break;
}
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 64e45d87524f..775ab7f64c03 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -398,7 +398,7 @@ cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
if (may_fallocate) {
sector_t sec = (sector_t)iblk << preq->plo->cluster_log;
- sector_t len = 1 << preq->plo->cluster_log;
+ sector_t len = cluster_size_in_sec(preq->plo);
struct extent_map * em = extent_lookup_create(io, sec, len);
if (unlikely(IS_ERR(em))) {
@@ -551,7 +551,7 @@ dio_submit_pad(struct ploop_io *io, struct ploop_request * preq,
/* sec..end_sec is the range which we are going to write */
sec = (sector_t)preq->iblock << preq->plo->cluster_log;
- end_sec = sec + (1 << preq->plo->cluster_log);
+ end_sec = sec + cluster_size_in_sec(preq->plo);
/* start..end is data that we have. The rest must be zero padded. */
start = sec + (sbl->head->bi_sector & ((1<<preq->plo->cluster_log) - 1));
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 81b42fd254a0..df55533458a3 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -445,7 +445,7 @@ static int kaio_resubmit(struct ploop_request * preq)
struct bio_list tbl;
tbl.head = tbl.tail = preq->aux_bio;
kaio_submit(&delta->io, preq, preq->req_rw, &tbl,
- preq->iblock, 1<<preq->plo->cluster_log);
+ preq->iblock, cluster_size_in_sec(preq->plo));
} else {
kaio_submit(&delta->io, preq, preq->req_rw, &preq->bl,
preq->iblock, preq->req_size);
diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index 48998373ae04..11326613d75c 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -272,7 +272,7 @@ static ssize_t pstat_store(struct kobject * kobj, struct attribute * attr,
static u32 show_block_size(struct ploop_device * plo)
{
- return 1 << plo->cluster_log;
+ return cluster_size_in_sec(plo);
}
static u32 show_fmt_version(struct ploop_device * plo)
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index bdf960f0c58f..58154219d7cb 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -638,6 +638,11 @@ static inline unsigned int cluster_size_in_bytes(struct ploop_device *plo)
return 1 << (plo->cluster_log + 9);
}
+static inline unsigned int cluster_size_in_sec(struct ploop_device *plo)
+{
+ return 1 << (plo->cluster_log);
+}
+
void ploop_complete_io_state(struct ploop_request * preq);
void ploop_fail_request(struct ploop_request * preq, int err);
void ploop_preq_drop(struct ploop_device * plo, struct list_head *drop_list);
@@ -843,9 +848,9 @@ static inline int ploop_map_log(struct ploop_device *plo)
static inline bool whole_block(struct ploop_device * plo, struct ploop_request *preq)
{
- if (preq->req_size != (1<<plo->cluster_log))
+ if (preq->req_size != cluster_size_in_sec(plo))
return 0;
- return !(preq->req_sector & ((1<<plo->cluster_log) - 1));
+ return !(preq->req_sector & (cluster_size_in_sec(plo) - 1));
}
struct map_node;
More information about the Devel
mailing list