ploop: Add lockout on discard requests

Submitted by Kirill Tkhai on May 24, 2019, 11:15 a.m.

Details

Message ID 155869648918.7902.16777370453510047874.stgit@localhost.localdomain
State New
Series "ploop: Add lockout on discard requests"
Headers show

Commit Message

Kirill Tkhai May 24, 2019, 11:15 a.m.
In case of ext4 sends discard, it prohibits to reuse
the discarded block in its internals. But in case of
direct using of the device, there is no such protection.
This patch implements it.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 36df41450c4d..fa87bfdd84bb 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2459,7 +2459,8 @@  ploop_entry_request(struct ploop_request * preq)
 			if (delta == top_delta) {
 				/* Block exists in top delta. Good. */
 				if (plo->maintenance_type == PLOOP_MNTN_GROW ||
-				    plo->maintenance_type == PLOOP_MNTN_RELOC) {
+				    plo->maintenance_type == PLOOP_MNTN_RELOC ||
+				    preq->req_rw & REQ_DISCARD) {
 					spin_lock_irq(&plo->lock);
 					ploop_add_lockout(preq, 0);
 					spin_unlock_irq(&plo->lock);