[Devel] [PATCH RHEL8 COMMIT] ploop: Acquire mutex in ploop_preresume()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Mar 19 19:03:16 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.9
------>
commit 5bd9d4eeabe2a4b0d1584a1fd652cfa964a71e9d
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Mar 19 19:03:16 2021 +0300

    ploop: Acquire mutex in ploop_preresume()
    
    Close race between "set noresume" and resume.
    Also, add READ_ONCE() in ploop_status to underline
    we read unlocked.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-target.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 591f583bc324..5ae0c624c8fb 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -265,7 +265,7 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
 	read_lock_irq(&ploop->bat_rwlock);
 	if (ploop->tracking_bitmap)
 		p += sprintf(p, "t");
-	if (ploop->noresume)
+	if (READ_ONCE(ploop->noresume))
 		p += sprintf(p, "n");
 	if (ploop->pb) {
 		if (ploop->pb->alive)
@@ -286,8 +286,10 @@ static int ploop_preresume(struct dm_target *ti)
 	struct ploop *ploop = ti->private;
 	int ret = 0;
 
-	if (READ_ONCE(ploop->noresume))
+	down_read(&ploop->ctl_rwsem);
+	if (ploop->noresume)
 		ret = -EAGAIN;
+	up_read(&ploop->ctl_rwsem);
 	return ret;
 }
 


More information about the Devel mailing list