[Devel] [PATCH RHEL7 COMMIT] ploop: Add cluster_size_in_bytes() 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 08c1031a62de98ec9be681635429e9c98c91b59e
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed Mar 6 14:22:42 2019 +0300

    ploop: Add cluster_size_in_bytes() 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       | 4 ++--
 drivers/block/ploop/fmt_raw.c   | 2 +-
 drivers/block/ploop/io_direct.c | 4 ++--
 include/linux/ploop/ploop.h     | 5 +++++
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 94fe835169e5..820eb4f96df8 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1538,7 +1538,7 @@ static int fill_bio(struct ploop_device *plo, struct bio * bio, cluster_t blk)
 		bio->bi_io_vec[bio->bi_vcnt].bv_len = PAGE_SIZE;
 	}
 	bio->bi_sector = blk << plo->cluster_log;
-	bio->bi_size = (1 << (plo->cluster_log + 9));
+	bio->bi_size = cluster_size_in_bytes(plo);
 	return 0;
 }
 
@@ -1997,7 +1997,7 @@ static void fill_zero_bio(struct ploop_device *plo, struct bio * bio)
 		bio->bi_io_vec[bio->bi_vcnt].bv_len = PAGE_SIZE;
 	}
 	bio->bi_sector = 0;
-	bio->bi_size = (1 << (plo->cluster_log + 9));
+	bio->bi_size = cluster_size_in_bytes(plo);
 }
 
 /*
diff --git a/drivers/block/ploop/fmt_raw.c b/drivers/block/ploop/fmt_raw.c
index ce4d93d03fe2..f7efa86a80ce 100644
--- a/drivers/block/ploop/fmt_raw.c
+++ b/drivers/block/ploop/fmt_raw.c
@@ -77,7 +77,7 @@ raw_refresh(struct ploop_delta * delta)
 	loff_t pos;
 
 	pos = delta->io.ops->i_size_read(&delta->io);
-	if (pos & ((1 << (delta->plo->cluster_log + 9)) - 1)) {
+	if (pos & (cluster_size_in_bytes(delta->plo) - 1)) {
 		printk("raw delta is not aligned (%llu bytes)\n", pos);
 		return -EINVAL;
 	}
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index f257a2770bcc..64e45d87524f 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -356,7 +356,7 @@ cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
 	struct ploop_device * plo = preq->plo;
 	int err = 0;
 	loff_t pos, end_pos, start, end;
-	loff_t clu_siz = 1 << (plo->cluster_log + 9);
+	loff_t clu_siz = cluster_size_in_bytes(plo);
 	struct bio_iter biter;
 	loff_t new_size;
 	loff_t used_pos;
@@ -498,7 +498,7 @@ dio_post_submit(struct ploop_io *io, struct ploop_request * preq)
 {
 	struct ploop_device *plo = preq->plo;
 	sector_t sec = (sector_t)preq->iblock << preq->plo->cluster_log;
-	loff_t clu_siz = 1 << (preq->plo->cluster_log + 9);
+	loff_t clu_siz = cluster_size_in_bytes(preq->plo);
 	int force_sync = preq->req_rw & REQ_FUA;
 	int err;
 
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index c1a92b08b5fb..bdf960f0c58f 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -633,6 +633,11 @@ static inline struct ploop_delta * map_top_delta(struct ploop_map * map)
 	return list_first_entry(&map->delta_list, struct ploop_delta, list);
 }
 
+static inline unsigned int cluster_size_in_bytes(struct ploop_device *plo)
+{
+	return 1 << (plo->cluster_log + 9);
+}
+
 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);



More information about the Devel mailing list