[Devel] [PATCH RHEL7 COMMIT] ploop: Disable discard on ioctl(PLOOP_IOC_FREEZE)
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jun 5 18:43:39 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.10.1.vz7.162.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.10.1.vz7.162.1
------>
commit d7b00695468faa7e4e1a5b40e0f972c0f6c7ccaf
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Jun 5 18:43:38 2020 +0300
ploop: Disable discard on ioctl(PLOOP_IOC_FREEZE)
freeze_bdev() does not affect on discard sent from FITRIM.
Prohibit it too.
In scope of https://jira.sw.ru/browse/PSBM-104462
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/dev.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 201315e973b70..6ee315b54fc9b 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -5283,6 +5283,7 @@ static int ploop_push_backup_stop(struct ploop_device *plo, unsigned long arg)
static int ploop_freeze(struct ploop_device *plo, struct block_device *bdev)
{
struct super_block *sb;
+ int ret;
if (!test_bit(PLOOP_S_RUNNING, &plo->state))
return -EINVAL;
@@ -5293,6 +5294,14 @@ static int ploop_freeze(struct ploop_device *plo, struct block_device *bdev)
if (plo->freeze_state == PLOOP_F_THAWING)
return -EBUSY;
+ /*
+ * Disable discard, since below freeze_bdev()
+ * does not affect FITRIM.
+ */
+ ret = disable_and_wait_discard(plo);
+ if (ret)
+ return ret;
+
if (plo->dm_crypt_bdev)
bdev = plo->dm_crypt_bdev;
@@ -5300,6 +5309,7 @@ static int ploop_freeze(struct ploop_device *plo, struct block_device *bdev)
sb = freeze_bdev(bdev);
if (sb && IS_ERR(sb)) {
bdput(bdev);
+ enable_discard(plo);
return PTR_ERR(sb);
}
@@ -5337,10 +5347,12 @@ static int ploop_thaw(struct ploop_device *plo)
BUG_ON(plo->freeze_state != PLOOP_F_THAWING);
- if (!err)
+ if (!err) {
+ enable_discard(plo);
plo->freeze_state = PLOOP_F_NORMAL;
- else
+ } else {
plo->freeze_state = PLOOP_F_FROZEN;
+ }
return err;
}
More information about the Devel
mailing list