[Devel] [PATCH] ploop: Enable native discard support for kaio engine
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Apr 26 16:46:48 MSK 2019
This enabled native discard support for kaio engine
in the way we have for direct engine.
Since io->prealloced_size is never initialized,
here small workaround to handle this case.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/fmt_ploop1.c | 3 ---
drivers/block/ploop/io_kaio.c | 17 +++++++++++++++--
include/linux/ploop/ploop.h | 2 +-
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 32437175dadb..2ae22179c9c5 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -271,9 +271,6 @@ ploop1_open(struct ploop_delta * delta)
((u64)ph->bd_size + ph->l1_off) << 9)
delta->flags |= PLOOP_FMT_PREALLOCATED;
- if (delta->io.ops->id != PLOOP_IO_DIRECT)
- set_bit(PLOOP_S_NO_FALLOC_DISCARD, &delta->plo->state);
-
return 0;
out_err:
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 5b97ed73611e..2bd5b6e176f5 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -552,7 +552,8 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
{
int log = preq->plo->cluster_log + 9;
loff_t clu_siz = 1 << log;
- loff_t end_pos = (loff_t)io->alloc_head << log;
+ loff_t end_pos = (loff_t)(iblk + 1) << log;
+ loff_t isize;
if (unlikely(preq->req_rw & REQ_FLUSH)) {
spin_lock_irq(&io->plo->lock);
@@ -565,6 +566,18 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
BUG_ON(preq->prealloc_size);
if (unlikely(io->prealloced_size < end_pos + clu_siz)) {
+ isize = i_size_read(io->files.inode);
+ /*
+ * FIXME: We never initialize io->prealloced_size,
+ * and it can be 0 here. The below actualizes it.
+ * This should be reworked in more natural way.
+ */
+ if (unlikely(io->prealloced_size < isize)) {
+ io->prealloced_size = isize;
+ if (io->prealloced_size >= end_pos + clu_siz)
+ goto submit;
+ }
+
if (!io->prealloc_preq) {
loff_t pos = (((loff_t)(iblk + 1) << log) |
(KAIO_PREALLOC - 1)) + 1;
@@ -584,7 +597,7 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
return 0;
}
}
-
+submit:
preq->iblock = iblk;
preq->eng_state = PLOOP_E_DATA_WBI;
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 230c51ecba87..ea6df68634a5 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -52,7 +52,7 @@ enum {
PLOOP_S_ENOSPC_EVENT, /* ENOSPC event happened but but was not
* consumed by userspace yet */
PLOOP_S_CONGESTED, /* Too many bios submitted to us */
- PLOOP_S_NO_FALLOC_DISCARD, /* Unable to handle discard requests by fallocate */
+ PLOOP_S_NO_FALLOC_DISCARD, /* FIXME: Remove this: Unable to handle discard requests by fallocate */
PLOOP_S_DISCARD, /* ploop is ready to handle discard request */
PLOOP_S_DISCARD_LOADED, /* A discard request was handled and
free blocks loaded */
More information about the Devel
mailing list