[Devel] [PATCH rh7 03/12] ploop: Add cluster_size_in_bytes() helper
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Mar 1 18:13:36 MSK 2019
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
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