[Devel] [vzlin-dev] [PATCH rh7 1/2] ploop: replace BLOCK_UNINIT
Dmitry Monakhov
dmonakhov at openvz.org
Wed Mar 16 05:47:39 PDT 2016
Maxim Patlasov <mpatlasov at virtuozzo.com> writes:
> Next patch will need em->block_start even for unwritten extents. Instead of
> using em->block_start == ~0, let's introduce new explicit field of 'em'.
>
> https://jira.sw.ru/browse/PSBM-22381
Ack-by:Dmitry Monakhov <dmonakhov at parallels.com>
>
> Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
> ---
> drivers/block/ploop/io_direct.c | 10 +++++-----
> drivers/block/ploop/io_direct_map.c | 6 +++---
> drivers/block/ploop/io_direct_map.h | 4 ++--
> 3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
> index 3678d5b..514af4b 100644
> --- a/drivers/block/ploop/io_direct.c
> +++ b/drivers/block/ploop/io_direct.c
> @@ -135,7 +135,7 @@ dio_submit(struct ploop_io *io, struct ploop_request * preq,
> if (IS_ERR(em))
> goto out_em_err;
>
> - if (write && em->block_start == BLOCK_UNINIT) {
> + if (write && em->uninit) {
> sector_t end = (sector_t)(iblk + 1) << preq->plo->cluster_log;
> sec = (sector_t)iblk << preq->plo->cluster_log;
>
> @@ -147,7 +147,7 @@ dio_submit(struct ploop_io *io, struct ploop_request * preq,
> em = extent_lookup_create(io, sec, end - sec);
> if (IS_ERR(em))
> goto out_em_err;
> - if (em->block_start != BLOCK_UNINIT)
> + if (!em->uninit)
> goto write_unint_fail;
>
> sec = em->end;
> @@ -191,13 +191,13 @@ dio_submit(struct ploop_io *io, struct ploop_request * preq,
> em = extent_lookup_create(io, sec, size);
> if (IS_ERR(em))
> goto out_em_err;
> - if (write && em->block_start == BLOCK_UNINIT)
> + if (write && em->uninit)
> goto write_unint_fail;
> }
>
> nsec = dio_isec_to_phys(em, sec);
>
> - if (em->block_start != BLOCK_UNINIT &&
> + if (!em->uninit &&
> (bio == NULL ||
> bio->bi_sector + (bio->bi_size>>9) != nsec)) {
>
> @@ -214,7 +214,7 @@ flush_bio:
> if (copy > ((em->end - sec) << 9))
> copy = (em->end - sec) << 9;
>
> - if (em->block_start == BLOCK_UNINIT) {
> + if (em->uninit) {
> void *kaddr = kmap_atomic(bv->bv_page);
> memset(kaddr + bv->bv_offset + bw.bv_off, 0, copy);
> kunmap_atomic(kaddr);
> diff --git a/drivers/block/ploop/io_direct_map.c b/drivers/block/ploop/io_direct_map.c
> index 1146133..3f9a1ae 100644
> --- a/drivers/block/ploop/io_direct_map.c
> +++ b/drivers/block/ploop/io_direct_map.c
> @@ -257,6 +257,7 @@ struct extent_map *ploop_alloc_extent_map(gfp_t mask)
> atomic_set(&em->refs, 1);
> INIT_LIST_HEAD(&em->lru_link);
> atomic_inc(&ploop_extent_maps_count);
> + em->uninit = false;
> }
> return em;
> }
> @@ -720,12 +721,11 @@ again:
>
> em->start = fi_extent.fe_logical >> 9;
> em->end = (fi_extent.fe_logical + fi_extent.fe_length) >> 9;
> + em->block_start = fi_extent.fe_physical >> 9;
>
> if (fi_extent.fe_flags & FIEMAP_EXTENT_UNWRITTEN) {
> - em->block_start = BLOCK_UNINIT;
> + em->uninit = true;
> } else {
> - em->block_start = fi_extent.fe_physical >> 9;
> -
> ret = add_extent_mapping(tree, em);
> if (ret == -EEXIST) {
> ploop_extent_put(em);
> diff --git a/drivers/block/ploop/io_direct_map.h b/drivers/block/ploop/io_direct_map.h
> index 4be1c5c..a83d1b3 100644
> --- a/drivers/block/ploop/io_direct_map.h
> +++ b/drivers/block/ploop/io_direct_map.h
> @@ -3,8 +3,6 @@
>
> #include <linux/rbtree.h>
>
> -#define BLOCK_UNINIT ~((sector_t) 0)
> -
> struct extent_map_tree
> {
> struct rb_root map;
> @@ -28,6 +26,8 @@ struct extent_map
> sector_t block_start;
>
> atomic_t refs;
> +
> + bool uninit;
> };
>
> extern int max_extent_map_pages;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20160316/0cc37b09/attachment-0001.sig>
More information about the Devel
mailing list