[Devel] [PATCH RHEL7 COMMIT] ploop: Add cluster_log local variable
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 6 14:22:48 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 45e82c5a14480e190a54e9103722b89ec0dc7a76
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Wed Mar 6 14:22:45 2019 +0300
ploop: Add cluster_log local variable
This refactoring adds local variable in functions,
where the construction "plo->cluster_log" is used
more then once.
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 | 23 +++++++++++++----------
drivers/block/ploop/fmt_raw.c | 7 ++++---
drivers/block/ploop/io_kaio.c | 2 +-
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 42b8a1b7af99..df35c4d011ec 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -661,9 +661,10 @@ static struct ploop_delta *
ploop_fast_lookup(struct ploop_device * plo, sector_t sec,
unsigned long rw, sector_t * isec)
{
+ unsigned int cluster_log = plo->cluster_log;
struct ploop_delta * top_delta, * delta;
int level;
- cluster_t bio_cluster = sec >> plo->cluster_log;
+ cluster_t bio_cluster = sec >> cluster_log;
iblock_t iblk;
level = ploop_fastmap(&plo->map, bio_cluster, &iblk);
@@ -687,8 +688,8 @@ ploop_fast_lookup(struct ploop_device * plo, sector_t sec,
delta = find_delta(plo, level);
}
if (delta) {
- *isec = ((sector_t)iblk << plo->cluster_log) +
- (sec & ((1 << plo->cluster_log) - 1));
+ *isec = ((sector_t)iblk << cluster_log) +
+ (sec & ((1 << cluster_log) - 1));
}
return delta;
}
@@ -847,6 +848,7 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
{
struct bio * nbio;
struct ploop_device * plo = q->queuedata;
+ unsigned int cluster_log = plo->cluster_log;
unsigned long rw = bio_data_dir(bio);
struct hd_struct *part;
int cpu;
@@ -895,11 +897,11 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
* not depending on any alignment constraints. So be it.
*/
if (!(bio->bi_rw & REQ_DISCARD) && bio->bi_size &&
- (bio->bi_sector >> plo->cluster_log) !=
- ((bio->bi_sector + (bio->bi_size >> 9) - 1) >> plo->cluster_log)) {
+ (bio->bi_sector >> cluster_log) !=
+ ((bio->bi_sector + (bio->bi_size >> 9) - 1) >> cluster_log)) {
struct bio_pair *bp;
- unsigned int first_sectors = (1<<plo->cluster_log)
- - (bio->bi_sector & ((1<<plo->cluster_log) - 1));
+ unsigned int first_sectors = (1<<cluster_log)
+ - (bio->bi_sector & ((1<<cluster_log) - 1));
plo->st.bio_splits++;
@@ -981,7 +983,7 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
bio->bi_size) {
struct ploop_request * preq;
struct rb_node * n = req_entry_tree(plo, bio->bi_rw)->rb_node;
- u32 bio_cluster = bio->bi_sector >> plo->cluster_log;
+ u32 bio_cluster = bio->bi_sector >> cluster_log;
while (n) {
preq = rb_entry(n, struct ploop_request, lockout_link);
@@ -1103,6 +1105,7 @@ ploop_merge_bvec(struct request_queue *q, struct bvec_merge_data *bm_data,
struct bio_vec *bvec)
{
struct ploop_device *plo = q->queuedata;
+ unsigned int cluster_log = plo->cluster_log;
struct ploop_delta * delta;
sector_t sec;
sector_t isector;
@@ -1122,8 +1125,8 @@ ploop_merge_bvec(struct request_queue *q, struct bvec_merge_data *bm_data,
len >>= 9;
- if ((sec >> plo->cluster_log) !=
- ((sec + len - 1) >> plo->cluster_log)) {
+ if ((sec >> cluster_log) !=
+ ((sec + len - 1) >> cluster_log)) {
plo->st.merge_neg_cluster++;
return 0;
}
diff --git a/drivers/block/ploop/fmt_raw.c b/drivers/block/ploop/fmt_raw.c
index f7efa86a80ce..529ea625e917 100644
--- a/drivers/block/ploop/fmt_raw.c
+++ b/drivers/block/ploop/fmt_raw.c
@@ -74,6 +74,7 @@ raw_open(struct ploop_delta * delta)
static int
raw_refresh(struct ploop_delta * delta)
{
+ unsigned int cluster_log = delta->plo->cluster_log;
loff_t pos;
pos = delta->io.ops->i_size_read(&delta->io);
@@ -81,15 +82,15 @@ raw_refresh(struct ploop_delta * delta)
printk("raw delta is not aligned (%llu bytes)\n", pos);
return -EINVAL;
}
- if ((pos >> (delta->plo->cluster_log + 9)) < delta->io.alloc_head) {
+ if ((pos >> (cluster_log + 9)) < delta->io.alloc_head) {
printk("raw delta was corrupted "
"(old_size=%u new_size=%llu iblocks)\n",
delta->io.alloc_head,
- pos >> (delta->plo->cluster_log + 9));
+ pos >> (cluster_log + 9));
return -EINVAL;
}
- delta->io.alloc_head = pos >> (delta->plo->cluster_log + 9);
+ delta->io.alloc_head = pos >> (cluster_log + 9);
return 0;
}
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index df55533458a3..f5d9936d4cd4 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -554,7 +554,7 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
iblock_t iblk;
int log = preq->plo->cluster_log + 9;
loff_t clu_siz = 1 << log;
- loff_t end_pos = (loff_t)io->alloc_head << (io->plo->cluster_log + 9);
+ loff_t end_pos = (loff_t)io->alloc_head << log;
if (delta->flags & PLOOP_FMT_RDONLY) {
PLOOP_FAIL_REQUEST(preq, -EBADF);
More information about the Devel
mailing list