[Devel] [PATCH rh7 24/38] ploop: zero blocks on reuse
Andrey Smetanin
asmetanin at virtuozzo.com
Fri May 15 09:48:25 PDT 2015
There is a check_zero feature allowing to skip zero writes if image-block
is not allocated yet for given preq->req_cluster. But this means that inner-fs
will hope to read zero from that range afterwards. Hence, while allocating
the image-block we *must* zero it. We always do so in submit_alloc, but the
implementation of free-block-reuse ended up in submit, not submit_alloc.
https://jira.sw.ru/browse/PSBM-25391
Signed-off-by: Maxim Patlasov <MPatlasov at parallels.com>
---
drivers/block/ploop/dev.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 2e6302f..9aaab4a 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2335,9 +2335,36 @@ restart:
preq->eng_state = PLOOP_E_DATA_WBI;
top_delta = ploop_top_delta(plo);
plo->st.bio_out++;
- top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
- &preq->bl, preq->iblock,
- preq->req_size);
+ if (whole_block(plo, preq)) {
+ top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
+ &preq->bl, preq->iblock,
+ preq->req_size);
+ } else {
+ struct bio_list sbl;
+ struct bio * b;
+ int i;
+
+ if (!preq->aux_bio)
+ preq->aux_bio = bio_alloc(GFP_NOFS, block_vecs(plo));
+
+ if (!preq->aux_bio ||
+ fill_bio(plo, preq->aux_bio, preq->req_cluster)) {
+ ploop_fail_immediate(preq, -ENOMEM);
+ break;
+ }
+
+ for (i = 0; i < preq->aux_bio->bi_vcnt; i++)
+ memset(page_address(preq->aux_bio->bi_io_vec[i].bv_page),
+ 0, PAGE_SIZE);
+
+ bio_list_for_each(b, &preq->bl) {
+ bio_bcopy(preq->aux_bio, b, plo);
+ }
+
+ 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);
+ }
break;
}
case PLOOP_E_DELTA_ZERO_INDEX:
--
1.9.3
More information about the Devel
mailing list