Currently push_backup device cannot be stopped if any process in a system is waiting next push block via push_backup_read. This means we have to kill that process or thread to release push_backup device, as it holds pb->ctl_rwsem. Change code so push_backup is marked !alive and all waiters are woken up before acquiring the lock. This is safe to do as pb->alive is only used for determining if we should postpone new I/O and process user push_backup_read/push_backup_write. All operations like releasing I/O or memory will be done with acquired lock as soon as all kicked readers exit syscall.
Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> --- drivers/md/dm-push-backup.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c index 1500d0681cee..bd021560a3e9 100644 --- a/drivers/md/dm-push-backup.c +++ b/drivers/md/dm-push-backup.c @@ -575,6 +575,17 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv, if (argc < 1) goto out; + if (!strcmp(argv[0], "push_backup_stop")) { + if (argc != 1) + goto out; + + if (!pb->map) + return -EBADF; + + pb->alive = false; + wake_up_interruptible(&pb->waitq); /* pb->alive = false */ + } + write = msg_wants_down_write(argv[0]); if (write) ret = down_write_killable(&pb->ctl_rwsem); @@ -593,8 +604,6 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv, goto unlock; ret = push_backup_start(pb, val, (void *)val2); } else if (!strcmp(argv[0], "push_backup_stop")) { - if (argc != 1) - goto unlock; ret = push_backup_stop(pb, result, maxlen); } else if (!strcmp(argv[0], "push_backup_read")) { if (argc != 1) -- 2.31.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel