[Devel] [PATCH rh7 11/12] ploop: Introduce ploop_can_issue_discard() helper
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Mar 1 18:14:21 MSK 2019
Logical neighbouring blocks usually are not physically
neighbours, so we can issue discard only for a single
block.
This is the basis. Later we may introduce some performance
improvements for corner cases on top of this.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/dev.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index bf508a9b1bc8..518b52e8f0d0 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2525,6 +2525,18 @@ ploop_entry_request(struct ploop_request * preq)
PLOOP_REQ_FAIL_IMMEDIATE(preq, err);
}
+static bool ploop_can_issue_discard(struct ploop_device *plo,
+ struct ploop_request *preq)
+{
+ if (test_bit(PLOOP_REQ_DISCARD, &preq->state))
+ return true;
+
+ if (test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+ return false;
+
+ return whole_block(plo, preq);
+}
+
static void ploop_req_state_process(struct ploop_request * preq)
{
struct ploop_device * plo = preq->plo;
@@ -2604,8 +2616,7 @@ static void ploop_req_state_process(struct ploop_request * preq)
}
if ((preq->req_rw & REQ_DISCARD) &&
- !test_bit(PLOOP_REQ_DISCARD, &preq->state) &&
- test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state)) {
+ !ploop_can_issue_discard(plo, preq)) {
preq->eng_state = PLOOP_E_COMPLETE;
preq->error = -EOPNOTSUPP;
ploop_complete_io_state(preq);
More information about the Devel
mailing list