From patchwork Mon Nov 9 15:43:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gan Qixin X-Patchwork-Id: 11893335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98955697 for ; Tue, 10 Nov 2020 06:18:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4767920731 for ; Tue, 10 Nov 2020 06:18:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4767920731 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcMzJ-0007ok-1i for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Nov 2020 01:18:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxs-0005dY-Do; Tue, 10 Nov 2020 01:17:12 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2136) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxp-0003YE-1v; Tue, 10 Nov 2020 01:17:12 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CVd1F2G8Vz74xv; Tue, 10 Nov 2020 14:16:49 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 14:16:48 +0800 From: Gan Qixin To: , Subject: [PATCH 1/4] block/accounting.c: Use lock guard macros Date: Mon, 9 Nov 2020 23:43:24 +0800 Message-ID: <20201109154327.325675-2-ganqixin@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201109154327.325675-1-ganqixin@huawei.com> References: <20201109154327.325675-1-ganqixin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=ganqixin@huawei.com; helo=szxga07-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 01:02:06 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Gan Qixin , zhang.zhanghailiang@huawei.com, mreitz@redhat.com, dnbrdsky@gmail.com, stefanha@redhat.com, kuhn.chenqun@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/accounting.c. Signed-off-by: Gan Qixin --- block/accounting.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/block/accounting.c b/block/accounting.c index 8d41c8a83a..2030851d79 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -199,29 +199,27 @@ static void block_account_one_io(BlockAcctStats *stats, BlockAcctCookie *cookie, return; } - qemu_mutex_lock(&stats->lock); - - if (failed) { - stats->failed_ops[cookie->type]++; - } else { - stats->nr_bytes[cookie->type] += cookie->bytes; - stats->nr_ops[cookie->type]++; - } + WITH_QEMU_LOCK_GUARD(&stats->lock) { + if (failed) { + stats->failed_ops[cookie->type]++; + } else { + stats->nr_bytes[cookie->type] += cookie->bytes; + stats->nr_ops[cookie->type]++; + } - block_latency_histogram_account(&stats->latency_histogram[cookie->type], - latency_ns); + block_latency_histogram_account(&stats->latency_histogram[cookie->type], + latency_ns); - if (!failed || stats->account_failed) { - stats->total_time_ns[cookie->type] += latency_ns; - stats->last_access_time_ns = time_ns; + if (!failed || stats->account_failed) { + stats->total_time_ns[cookie->type] += latency_ns; + stats->last_access_time_ns = time_ns; - QSLIST_FOREACH(s, &stats->intervals, entries) { - timed_average_account(&s->latency[cookie->type], latency_ns); + QSLIST_FOREACH(s, &stats->intervals, entries) { + timed_average_account(&s->latency[cookie->type], latency_ns); + } } } - qemu_mutex_unlock(&stats->lock); - cookie->type = BLOCK_ACCT_NONE; } From patchwork Mon Nov 9 15:43:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gan Qixin X-Patchwork-Id: 11893337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9477E1391 for ; Tue, 10 Nov 2020 06:19:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D84120731 for ; Tue, 10 Nov 2020 06:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D84120731 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcN0M-0000wq-Bv for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Nov 2020 01:19:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxt-0005dj-21; Tue, 10 Nov 2020 01:17:13 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxp-0003ZJ-6U; Tue, 10 Nov 2020 01:17:12 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CVd1L0yKtzhjjM; Tue, 10 Nov 2020 14:16:54 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 14:16:50 +0800 From: Gan Qixin To: , Subject: [PATCH 2/4] block/curl.c: Use lock guard macros Date: Mon, 9 Nov 2020 23:43:25 +0800 Message-ID: <20201109154327.325675-3-ganqixin@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201109154327.325675-1-ganqixin@huawei.com> References: <20201109154327.325675-1-ganqixin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.191; envelope-from=ganqixin@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 01:17:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Gan Qixin , zhang.zhanghailiang@huawei.com, mreitz@redhat.com, dnbrdsky@gmail.com, stefanha@redhat.com, kuhn.chenqun@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/curl.c. Signed-off-by: Gan Qixin --- block/curl.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/block/curl.c b/block/curl.c index 4f907c47be..d24a4c5897 100644 --- a/block/curl.c +++ b/block/curl.c @@ -564,23 +564,23 @@ static void curl_detach_aio_context(BlockDriverState *bs) BDRVCURLState *s = bs->opaque; int i; - qemu_mutex_lock(&s->mutex); - for (i = 0; i < CURL_NUM_STATES; i++) { - if (s->states[i].in_use) { - curl_clean_state(&s->states[i]); + WITH_QEMU_LOCK_GUARD(&s->mutex) { + for (i = 0; i < CURL_NUM_STATES; i++) { + if (s->states[i].in_use) { + curl_clean_state(&s->states[i]); + } + if (s->states[i].curl) { + curl_easy_cleanup(s->states[i].curl); + s->states[i].curl = NULL; + } + g_free(s->states[i].orig_buf); + s->states[i].orig_buf = NULL; } - if (s->states[i].curl) { - curl_easy_cleanup(s->states[i].curl); - s->states[i].curl = NULL; + if (s->multi) { + curl_multi_cleanup(s->multi); + s->multi = NULL; } - g_free(s->states[i].orig_buf); - s->states[i].orig_buf = NULL; - } - if (s->multi) { - curl_multi_cleanup(s->multi); - s->multi = NULL; } - qemu_mutex_unlock(&s->mutex); timer_del(&s->timer); } From patchwork Mon Nov 9 15:43:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gan Qixin X-Patchwork-Id: 11893343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95EC51391 for ; Tue, 10 Nov 2020 06:21:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FEC820665 for ; Tue, 10 Nov 2020 06:21:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FEC820665 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcN1s-0001y9-49 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Nov 2020 01:21:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxu-0005e2-3L; Tue, 10 Nov 2020 01:17:14 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxr-0003Zh-38; Tue, 10 Nov 2020 01:17:13 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CVd1L18nvzhjjP; Tue, 10 Nov 2020 14:16:54 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 14:16:52 +0800 From: Gan Qixin To: , Subject: [PATCH 3/4] block/throttle-groups.c: Use lock guard macros Date: Mon, 9 Nov 2020 23:43:26 +0800 Message-ID: <20201109154327.325675-4-ganqixin@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201109154327.325675-1-ganqixin@huawei.com> References: <20201109154327.325675-1-ganqixin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.191; envelope-from=ganqixin@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 01:17:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Gan Qixin , zhang.zhanghailiang@huawei.com, mreitz@redhat.com, dnbrdsky@gmail.com, stefanha@redhat.com, kuhn.chenqun@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/throttle-groups.c. Signed-off-by: Gan Qixin --- block/throttle-groups.c | 48 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index e2f2813c0f..badb93a3be 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -546,7 +546,7 @@ void throttle_group_register_tgm(ThrottleGroupMember *tgm, tgm->aio_context = ctx; qatomic_set(&tgm->restart_pending, 0); - qemu_mutex_lock(&tg->lock); + QEMU_LOCK_GUARD(&tg->lock); /* If the ThrottleGroup is new set this ThrottleGroupMember as the token */ for (i = 0; i < 2; i++) { if (!tg->tokens[i]) { @@ -565,8 +565,6 @@ void throttle_group_register_tgm(ThrottleGroupMember *tgm, qemu_co_mutex_init(&tgm->throttled_reqs_lock); qemu_co_queue_init(&tgm->throttled_reqs[0]); qemu_co_queue_init(&tgm->throttled_reqs[1]); - - qemu_mutex_unlock(&tg->lock); } /* Unregister a ThrottleGroupMember from its group, removing it from the list, @@ -594,25 +592,25 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *tgm) /* Wait for throttle_group_restart_queue_entry() coroutines to finish */ AIO_WAIT_WHILE(tgm->aio_context, qatomic_read(&tgm->restart_pending) > 0); - qemu_mutex_lock(&tg->lock); - for (i = 0; i < 2; i++) { - assert(tgm->pending_reqs[i] == 0); - assert(qemu_co_queue_empty(&tgm->throttled_reqs[i])); - assert(!timer_pending(tgm->throttle_timers.timers[i])); - if (tg->tokens[i] == tgm) { - token = throttle_group_next_tgm(tgm); - /* Take care of the case where this is the last tgm in the group */ - if (token == tgm) { - token = NULL; + WITH_QEMU_LOCK_GUARD(&tg->lock) { + for (i = 0; i < 2; i++) { + assert(tgm->pending_reqs[i] == 0); + assert(qemu_co_queue_empty(&tgm->throttled_reqs[i])); + assert(!timer_pending(tgm->throttle_timers.timers[i])); + if (tg->tokens[i] == tgm) { + token = throttle_group_next_tgm(tgm); + /* Take care of the case where this is the last tgm in the group */ + if (token == tgm) { + token = NULL; + } + tg->tokens[i] = token; } - tg->tokens[i] = token; } - } - /* remove the current tgm from the list */ - QLIST_REMOVE(tgm, round_robin); - throttle_timers_destroy(&tgm->throttle_timers); - qemu_mutex_unlock(&tg->lock); + /* remove the current tgm from the list */ + QLIST_REMOVE(tgm, round_robin); + throttle_timers_destroy(&tgm->throttle_timers); + } throttle_group_unref(&tg->ts); tgm->throttle_state = NULL; @@ -638,14 +636,14 @@ void throttle_group_detach_aio_context(ThrottleGroupMember *tgm) assert(qemu_co_queue_empty(&tgm->throttled_reqs[1])); /* Kick off next ThrottleGroupMember, if necessary */ - qemu_mutex_lock(&tg->lock); - for (i = 0; i < 2; i++) { - if (timer_pending(tt->timers[i])) { - tg->any_timer_armed[i] = false; - schedule_next_request(tgm, i); + WITH_QEMU_LOCK_GUARD(&tg->lock) { + for (i = 0; i < 2; i++) { + if (timer_pending(tt->timers[i])) { + tg->any_timer_armed[i] = false; + schedule_next_request(tgm, i); + } } } - qemu_mutex_unlock(&tg->lock); throttle_timers_detach_aio_context(tt); tgm->aio_context = NULL; From patchwork Mon Nov 9 15:43:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gan Qixin X-Patchwork-Id: 11893333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE5771391 for ; Tue, 10 Nov 2020 06:18:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6937820731 for ; Tue, 10 Nov 2020 06:18:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6937820731 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcMzH-0007kn-A5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Nov 2020 01:18:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxt-0005dv-QO; Tue, 10 Nov 2020 01:17:13 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcMxr-0003ZN-3G; Tue, 10 Nov 2020 01:17:13 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CVd1L0jyxzhjg7; Tue, 10 Nov 2020 14:16:54 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 14:16:54 +0800 From: Gan Qixin To: , Subject: [PATCH 4/4] block/iscsi.c: Use lock guard macros Date: Mon, 9 Nov 2020 23:43:27 +0800 Message-ID: <20201109154327.325675-5-ganqixin@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201109154327.325675-1-ganqixin@huawei.com> References: <20201109154327.325675-1-ganqixin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.191; envelope-from=ganqixin@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 01:17:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Gan Qixin , zhang.zhanghailiang@huawei.com, mreitz@redhat.com, dnbrdsky@gmail.com, stefanha@redhat.com, kuhn.chenqun@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/iscsi.c. Signed-off-by: Gan Qixin --- block/iscsi.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index e30a7e3606..f5f657b582 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -322,7 +322,7 @@ iscsi_aio_cancel(BlockAIOCB *blockacb) IscsiAIOCB *acb = (IscsiAIOCB *)blockacb; IscsiLun *iscsilun = acb->iscsilun; - qemu_mutex_lock(&iscsilun->mutex); + QEMU_LOCK_GUARD(&iscsilun->mutex); /* If it was cancelled or completed already, our work is done here */ if (acb->cancelled || acb->status != -EINPROGRESS) { @@ -339,8 +339,6 @@ iscsi_aio_cancel(BlockAIOCB *blockacb) iscsi_abort_task_cb, acb) < 0) { qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */ } - - qemu_mutex_unlock(&iscsilun->mutex); } static const AIOCBInfo iscsi_aiocb_info = { @@ -375,22 +373,22 @@ static void iscsi_timed_check_events(void *opaque) { IscsiLun *iscsilun = opaque; - qemu_mutex_lock(&iscsilun->mutex); + WITH_QEMU_LOCK_GUARD(&iscsilun->mutex) { + /* check for timed out requests */ + iscsi_service(iscsilun->iscsi, 0); - /* check for timed out requests */ - iscsi_service(iscsilun->iscsi, 0); + if (iscsilun->request_timed_out) { + iscsilun->request_timed_out = false; + iscsi_reconnect(iscsilun->iscsi); + } - if (iscsilun->request_timed_out) { - iscsilun->request_timed_out = false; - iscsi_reconnect(iscsilun->iscsi); + /* + * newer versions of libiscsi may return zero events. Ensure we are + * able to return to service once this situation changes. + */ + iscsi_set_events(iscsilun); } - /* newer versions of libiscsi may return zero events. Ensure we are able - * to return to service once this situation changes. */ - iscsi_set_events(iscsilun); - - qemu_mutex_unlock(&iscsilun->mutex); - timer_mod(iscsilun->event_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL); }