[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a loc
From: |
Eric Blake |
Subject: |
Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock |
Date: |
Fri, 7 May 2021 10:29:18 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 |
On 5/7/21 10:12 AM, Emanuele Giuseppe Esposito wrote:
> Co-developed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> block/blkdebug.c | 32 +++++++++++++++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> @@ -929,11 +956,14 @@ static bool
> blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag)
> BDRVBlkdebugState *s = bs->opaque;
> BlkdebugSuspendedReq *r;
>
> + qemu_mutex_lock(&s->lock);
> QLIST_FOREACH(r, &s->suspended_reqs, next) {
> if (!strcmp(r->tag, tag)) {
> + qemu_mutex_unlock(&s->lock);
> return true;
> }
> }
> + qemu_mutex_unlock(&s->lock);
> return false;
Would code like this be easier to write by using QEMU_LOCK_GUARD from
lockable.h?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH v2 0/5] blkdebug: fix racing condition when iterating on, Emanuele Giuseppe Esposito, 2021/05/07
- [PATCH v2 1/5] blkdebug: refactor removal of a suspended request, Emanuele Giuseppe Esposito, 2021/05/07
- [PATCH v2 2/5] blkdebug: move post-resume handling to resume_req_by_tag, Emanuele Giuseppe Esposito, 2021/05/07
- [PATCH v2 4/5] blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE, Emanuele Giuseppe Esposito, 2021/05/07
- [PATCH v2 3/5] blkdebug: track all actions, Emanuele Giuseppe Esposito, 2021/05/07
- [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock, Emanuele Giuseppe Esposito, 2021/05/07
- Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock,
Eric Blake <=