[Devel] [PATCH RH8 1/2] ploop: Acquire mutex in ploop_preresume()
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Mar 19 18:50:48 MSK 2021
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