From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117743077205.87330923450338; Sat, 12 May 2018 02:35:43 -0700 (PDT) Received: from localhost ([::1]:60351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQwF-0005Wu-F5 for importer@patchew.org; Sat, 12 May 2018 05:35:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqi-00069G-PH for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqh-0000nU-PI for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50308 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqe-0000lf-Jo; Sat, 12 May 2018 05:29:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 353357D85E; Sat, 12 May 2018 09:29:52 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id D71F9906B0; Sat, 12 May 2018 09:29:51 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:17 +0100 Message-Id: <20180512092824.13848-2-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/8] blockjob: drop block_job_pause/resume_all() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 8119334918e86f45877cfc139192d54f2449a239 ("block: Don't block_job_pause_all() in bdrv_drain_all()") removed the only callers of block_job_pause/resume_all(). Pausing and resuming now happens in child_job_drained_begin/end() so it's no longer necessary to globally pause/resume jobs. Signed-off-by: Stefan Hajnoczi Reviewed-by: John Snow Reviewed-by: Alberto Garcia Message-id: 20180424085240.5798-1-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- include/block/blockjob_int.h | 14 -------------- blockjob.c | 27 --------------------------- 2 files changed, 41 deletions(-) diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index 642adce68b..d5a515de9b 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -168,20 +168,6 @@ void block_job_sleep_ns(BlockJob *job, int64_t ns); */ void block_job_yield(BlockJob *job); =20 -/** - * block_job_pause_all: - * - * Asynchronously pause all jobs. - */ -void block_job_pause_all(void); - -/** - * block_job_resume_all: - * - * Resume all block jobs. Must be paired with a preceding block_job_pause= _all. - */ -void block_job_resume_all(void); - /** * block_job_early_fail: * @bs: The block device. diff --git a/blockjob.c b/blockjob.c index 27f957e571..dfffad921a 100644 --- a/blockjob.c +++ b/blockjob.c @@ -988,19 +988,6 @@ void *block_job_create(const char *job_id, const Block= JobDriver *driver, return job; } =20 -void block_job_pause_all(void) -{ - BlockJob *job =3D NULL; - while ((job =3D block_job_next(job))) { - AioContext *aio_context =3D blk_get_aio_context(job->blk); - - aio_context_acquire(aio_context); - block_job_ref(job); - block_job_pause(job); - aio_context_release(aio_context); - } -} - void block_job_early_fail(BlockJob *job) { assert(job->status =3D=3D BLOCK_JOB_STATUS_CREATED); @@ -1078,20 +1065,6 @@ void coroutine_fn block_job_pause_point(BlockJob *jo= b) } } =20 -void block_job_resume_all(void) -{ - BlockJob *job, *next; - - QLIST_FOREACH_SAFE(job, &block_jobs, job_list, next) { - AioContext *aio_context =3D blk_get_aio_context(job->blk); - - aio_context_acquire(aio_context); - block_job_resume(job); - block_job_unref(job); - aio_context_release(aio_context); - } -} - /* * Conditionally enter a block_job pending a call to fn() while * under the block_job_lock critical section. --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117570926376.2284481939562; Sat, 12 May 2018 02:32:50 -0700 (PDT) Received: from localhost ([::1]:60207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQtV-0007lE-VX for importer@patchew.org; Sat, 12 May 2018 05:32:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqh-00064Q-K0 for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqg-0000mc-CY for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50306 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqd-0000lK-2J; Sat, 12 May 2018 05:29:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A562B7D85E; Sat, 12 May 2018 09:29:50 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5425C2026E03; Sat, 12 May 2018 09:29:50 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:18 +0100 Message-Id: <20180512092824.13848-3-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:50 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/8] checkpatch: add a --strict check for utf-8 in commit logs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Joe Perches Some find using utf-8 in commit logs inappropriate. Some patch commit logs contain unintended utf-8 characters when doing things like copy/pasting compilation output. Look for the start of any commit log by skipping initial lines that look like email headers and "From: " lines. Stop looking for utf-8 at the first signature line. Signed-off-by: Joe Perches Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Message-id: 20180430124651.10340-2-stefanha@redhat.com Suggested-by: Andrew Morton Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 15662b3e8644905032c2e26808401a487d4e90c1) Signed-off-by: Stefan Hajnoczi Conflicts: QEMU does not have CHK(), use WARN() instead. QEMU WARN() only takes one argument, drop the 'type' value in the first argument. Signed-off-by: Stefan Hajnoczi --- scripts/checkpatch.pl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5b8735defb..c667d085ae 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -224,9 +224,8 @@ our $NonptrType; our $Type; our $Declare; =20 -our $UTF8 =3D qr { - [\x09\x0A\x0D\x20-\x7E] # ASCII - | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte +our $NON_ASCII_UTF8 =3D qr{ + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates @@ -235,6 +234,11 @@ our $UTF8 =3D qr { | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 }x; =20 +our $UTF8 =3D qr{ + [\x09\x0A\x0D\x20-\x7E] # ASCII + | $NON_ASCII_UTF8 +}x; + # There are still some false positives, but this catches most # common cases. our $typeTypedefs =3D qr{(?x: @@ -1179,6 +1183,9 @@ sub process { my $signoff =3D 0; my $is_patch =3D 0; =20 + my $in_header_lines =3D 1; + my $in_commit_log =3D 0; #Scanning lines before patch + our @report =3D (); our $cnt_lines =3D 0; our $cnt_error =3D 0; @@ -1331,7 +1338,6 @@ sub process { if ($line =3D~ /^diff --git.*?(\S+)$/) { $realfile =3D $1; $realfile =3D~ s@^([^/]*)/@@; - } elsif ($line =3D~ /^\+\+\+\s+(\S+)/) { $realfile =3D $1; $realfile =3D~ s@^([^/]*)/@@; @@ -1370,6 +1376,8 @@ sub process { if ($line =3D~ /^\s*signed-off-by:/i) { # This is a signoff, if ugly, so do not double report. $signoff++; + $in_commit_log =3D 0; + if (!($line =3D~ /^\s*Signed-off-by:/)) { ERROR("The correct form is \"Signed-off-by\"\n" . $herecurr); @@ -1398,6 +1406,20 @@ sub process { ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF= -8\n" . $hereptr); } =20 +# Check if it's the start of a commit log +# (not a header line and we haven't seen the patch filename) + if ($in_header_lines && $realfile =3D~ /^$/ && + $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { + $in_header_lines =3D 0; + $in_commit_log =3D 1; + } + +# Still not yet in a patch, check for any UTF-8 + if ($in_commit_log && $realfile =3D~ /^$/ && + $rawline =3D~ /$NON_ASCII_UTF8/) { + WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr); + } + # ignore non-hunk lines and lines being removed next if (!$hunk_line || $line =3D~ /^-/); =20 --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117864679614.3792506754561; Sat, 12 May 2018 02:37:44 -0700 (PDT) Received: from localhost ([::1]:60432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQyA-0006sp-I6 for importer@patchew.org; Sat, 12 May 2018 05:37:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqk-0006F1-Ot for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqj-0000oM-Ou for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:58 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50312 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqh-0000n3-HY; Sat, 12 May 2018 05:29:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BE227D85E; Sat, 12 May 2018 09:29:55 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFD84906B0; Sat, 12 May 2018 09:29:54 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:19 +0100 Message-Id: <20180512092824.13848-4-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:55 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 3/8] checkpatch: check utf-8 content from a commit log when it's missing from charset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pasi Savanainen Check that a commit log doesn't contain UTF-8 when a mail header explicitly defines a different charset, like 'Content-Type: text/plain; charset=3D"us-ascii"' Signed-off-by: Pasi Savanainen Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Message-id: 20180430124651.10340-3-stefanha@redhat.com Cc: Joe Perches Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit fa64205df9dfd7b7662cc64a7e82115c00e428e5) Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi --- scripts/checkpatch.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c667d085ae..25bf43bad0 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1186,6 +1186,8 @@ sub process { my $in_header_lines =3D 1; my $in_commit_log =3D 0; #Scanning lines before patch =20 + my $non_utf8_charset =3D 0; + our @report =3D (); our $cnt_lines =3D 0; our $cnt_error =3D 0; @@ -1414,8 +1416,15 @@ sub process { $in_commit_log =3D 1; } =20 -# Still not yet in a patch, check for any UTF-8 - if ($in_commit_log && $realfile =3D~ /^$/ && +# Check if there is UTF-8 in a commit log when a mail header has explicitly +# declined it, i.e defined some charset where it is missing. + if ($in_header_lines && + $rawline =3D~ /^Content-Type:.+charset=3D"(.+)".*$/ && + $1 !~ /utf-8/i) { + $non_utf8_charset =3D 1; + } + + if ($in_commit_log && $non_utf8_charset && $realfile =3D~ /^$/ && $rawline =3D~ /$NON_ASCII_UTF8/) { WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr); } --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117725144716.3142656899245; Sat, 12 May 2018 02:35:25 -0700 (PDT) Received: from localhost ([::1]:60347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQw0-00047A-BO for importer@patchew.org; Sat, 12 May 2018 05:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqj-0006CR-Le for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqi-0000nr-Pi for qemu-devel@nongnu.org; Sat, 12 May 2018 05:29:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50418 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqg-0000mZ-Hd; Sat, 12 May 2018 05:29:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E84CE4480; Sat, 12 May 2018 09:29:54 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EE6E215CDA7; Sat, 12 May 2018 09:29:53 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:20 +0100 Message-Id: <20180512092824.13848-5-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 12 May 2018 09:29:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 12 May 2018 09:29:54 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/8] checkpatch: ignore email headers better X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Joe Perches There are some patches created by git format-patch that when scanned by checkpatch report errors on lines like To: address.tld This is a checkpatch false positive. Improve the logic a bit to ignore folded email headers to avoid emitting these messages. Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi Message-id: 20180430124651.10340-4-stefanha@redhat.com (cherry picked from commit 29ee1b0c67e0dd7dea8dd718e8326076bce5b6fe) Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi --- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 25bf43bad0..20d5b62586 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1183,7 +1183,7 @@ sub process { my $signoff =3D 0; my $is_patch =3D 0; =20 - my $in_header_lines =3D 1; + my $in_header_lines =3D $file ? 0 : 1; my $in_commit_log =3D 0; #Scanning lines before patch =20 my $non_utf8_charset =3D 0; @@ -1411,7 +1411,8 @@ sub process { # Check if it's the start of a commit log # (not a header line and we haven't seen the patch filename) if ($in_header_lines && $realfile =3D~ /^$/ && - $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { + !($rawline =3D~ /^\s+\S/ || + $rawline =3D~ /^(commit\b|from\b|[\w-]+:).*$/i)) { $in_header_lines =3D 0; $in_commit_log =3D 1; } --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117884382836.3227077269501; Sat, 12 May 2018 02:38:04 -0700 (PDT) Received: from localhost ([::1]:60433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQyM-0007VK-Fl for importer@patchew.org; Sat, 12 May 2018 05:37:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqp-0006M6-0i for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqo-0000qB-5t for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50424 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqj-0000o0-Ap; Sat, 12 May 2018 05:29:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0C23E4480; Sat, 12 May 2018 09:29:56 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9082E10E4CEF; Sat, 12 May 2018 09:29:56 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:21 +0100 Message-Id: <20180512092824.13848-6-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 12 May 2018 09:29:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sat, 12 May 2018 09:29:56 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 5/8] checkpatch: emit a warning on file add/move/delete X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Joe Perches Whenever files are added, moved, or deleted, the MAINTAINERS file patterns can be out of sync or outdated. To try to keep MAINTAINERS more up-to-date, add a one-time warning whenever a patch does any of those. Signed-off-by: Joe Perches Acked-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi Message-id: 20180430124651.10340-5-stefanha@redhat.com (cherry picked from commit 13f1937ef33950b1112049972249e6191b82e6c9) Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Conflicts: QEMU WARN() only takes one argument, drop the 'type' value in the first argument. Signed-off-by: Stefan Hajnoczi --- scripts/checkpatch.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 20d5b62586..84bdf53af7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1185,7 +1185,7 @@ sub process { =20 my $in_header_lines =3D $file ? 0 : 1; my $in_commit_log =3D 0; #Scanning lines before patch - + my $reported_maintainer_file =3D 0; my $non_utf8_charset =3D 0; =20 our @report =3D (); @@ -1390,6 +1390,16 @@ sub process { } } =20 +# Check for added, moved or deleted files + if (!$reported_maintainer_file && !$in_commit_log && + ($line =3D~ /^(?:new|deleted) file mode\s*\d+\s*$/ || + $line =3D~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || + ($line =3D~ /\{\s*([\w\/\.\-]*)\s*\=3D\>\s*([\w\/\.\-]*)\s*\}/ && + (defined($1) || defined($2))))) { + $reported_maintainer_file =3D 1; + WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\= n" . $herecurr); + } + # Check for wrappage within a valid hunk of the file if ($realcnt !=3D 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { ERROR("patch seems to be corrupt (line wrapped?)\n" . --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117567199537.7194490649343; Sat, 12 May 2018 02:32:47 -0700 (PDT) Received: from localhost ([::1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQtS-0007JU-9q for importer@patchew.org; Sat, 12 May 2018 05:32:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqp-0006NL-89 for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqo-0000qQ-Cc for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50316 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqk-0000od-NL; Sat, 12 May 2018 05:29:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56A0F7D85E; Sat, 12 May 2018 09:29:58 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0652410E4CEC; Sat, 12 May 2018 09:29:57 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:22 +0100 Message-Id: <20180512092824.13848-7-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:29:58 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 6/8] checkpatch: reduce MAINTAINERS update message frequency X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Joe Perches When files are being added/moved/deleted and a patch contains an update to the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly and do not emit the "does MAINTAINERS need updating?" message. Reported by many people. Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Reviewed-by: Markus Armbruster Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi Message-id: 20180430124651.10340-6-stefanha@redhat.com (cherry picked from e0d975b1b439c4fef58fbc306c542c94f48bb849) Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Signed-off-by: Stefan Hajnoczi --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 84bdf53af7..5506502cf4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1390,6 +1390,12 @@ sub process { } } =20 +# Check if MAINTAINERS is being updated. If so, there's probably no need = to +# emit the "does MAINTAINERS need updating?" message on file add/move/dele= te + if ($line =3D~ /^\s*MAINTAINERS\s*\|/) { + $reported_maintainer_file =3D 1; + } + # Check for added, moved or deleted files if (!$reported_maintainer_file && !$in_commit_log && ($line =3D~ /^(?:new|deleted) file mode\s*\d+\s*$/ || --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526117577205537.8062990890805; Sat, 12 May 2018 02:32:57 -0700 (PDT) Received: from localhost ([::1]:60208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQtc-0008EY-Al for importer@patchew.org; Sat, 12 May 2018 05:32:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqq-0006Pp-1E for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqo-0000qg-Si for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50320 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqm-0000pL-IY; Sat, 12 May 2018 05:30:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 306AA7D85E; Sat, 12 May 2018 09:30:00 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3D96ADF92; Sat, 12 May 2018 09:29:59 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:23 +0100 Message-Id: <20180512092824.13848-8-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:30:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:30:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 7/8] block/file-posix: implement bdrv_co_invalidate_cache() on Linux X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On Linux posix_fadvise(POSIX_FADV_DONTNEED) invalidates pages*. Use this to drop page cache on the destination host during shared storage migration. This way the destination host will read the latest copy of the data and will not use stale data from the page cache. The flow is as follows: 1. Source host writes out all dirty pages and inactivates drives. 2. QEMU_VM_EOF is sent on migration stream. 3. Destination host invalidates caches before accessing drives. This patch enables live migration even with -drive cache.direct=3Doff. * Terms and conditions may apply, please see patch for details. Signed-off-by: Stefan Hajnoczi Reviewed-by: Fam Zheng Message-id: 20180427162312.18583-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- block/file-posix.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 3794c0007a..3707ea2d1c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2236,6 +2236,49 @@ static int coroutine_fn raw_co_block_status(BlockDri= verState *bs, return ret | BDRV_BLOCK_OFFSET_VALID; } =20 +static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, + Error **errp) +{ + BDRVRawState *s =3D bs->opaque; + int ret; + + ret =3D fd_open(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "The file descriptor is not open"); + return; + } + + if (s->open_flags & O_DIRECT) { + return; /* No host kernel page cache */ + } + +#if defined(__linux__) + /* This sets the scene for the next syscall... */ + ret =3D bdrv_co_flush(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "flush failed"); + return; + } + + /* Linux does not invalidate pages that are dirty, locked, or mmapped = by a + * process. These limitations are okay because we just fsynced the fi= le, + * we don't use mmap, and the file should not be in use by other proce= sses. + */ + ret =3D posix_fadvise(s->fd, 0, 0, POSIX_FADV_DONTNEED); + if (ret !=3D 0) { /* the return value is a positive errno */ + error_setg_errno(errp, ret, "fadvise failed"); + return; + } +#else /* __linux__ */ + /* Do nothing. Live migration to a remote host with cache.direct=3Dof= f is + * unsupported on other host operating systems. Cache consistency iss= ues + * may occur but no error is reported here, partly because that's the + * historical behavior and partly because it's hard to differentiate v= alid + * configurations that should not cause errors. + */ +#endif /* !__linux__ */ +} + static coroutine_fn BlockAIOCB *raw_aio_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, BlockCompletionFunc *cb, void *opaque) @@ -2328,6 +2371,7 @@ BlockDriver bdrv_file =3D { .bdrv_co_create_opts =3D raw_co_create_opts, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_co_block_status =3D raw_co_block_status, + .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, .bdrv_co_pwrite_zeroes =3D raw_co_pwrite_zeroes, =20 .bdrv_co_preadv =3D raw_co_preadv, @@ -2805,6 +2849,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_reopen_abort =3D raw_reopen_abort, .bdrv_co_create_opts =3D hdev_co_create_opts, .create_opts =3D &raw_create_opts, + .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, .bdrv_co_pwrite_zeroes =3D hdev_co_pwrite_zeroes, =20 .bdrv_co_preadv =3D raw_co_preadv, @@ -2927,6 +2972,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_reopen_abort =3D raw_reopen_abort, .bdrv_co_create_opts =3D hdev_co_create_opts, .create_opts =3D &raw_create_opts, + .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, =20 =20 .bdrv_co_preadv =3D raw_co_preadv, --=20 2.17.0 From nobody Thu Dec 18 13:15:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526118000488776.4101869236086; Sat, 12 May 2018 02:40:00 -0700 (PDT) Received: from localhost ([::1]:60582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHR0R-0002X2-NJ for importer@patchew.org; Sat, 12 May 2018 05:39:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHQqs-0006Vl-77 for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHQqq-0000sg-Re for qemu-devel@nongnu.org; Sat, 12 May 2018 05:30:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50326 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fHQqo-0000pu-1c; Sat, 12 May 2018 05:30:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF7DB7D85E; Sat, 12 May 2018 09:30:01 +0000 (UTC) Received: from localhost (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65ECC215CDA7; Sat, 12 May 2018 09:30:01 +0000 (UTC) From: Stefan Hajnoczi To: Date: Sat, 12 May 2018 10:28:24 +0100 Message-Id: <20180512092824.13848-9-stefanha@redhat.com> In-Reply-To: <20180512092824.13848-1-stefanha@redhat.com> References: <20180512092824.13848-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:30:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 12 May 2018 09:30:01 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 8/8] block/file-posix: add x-check-page-cache=on|off option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mincore(2) checks whether pages are resident. Use it to verify that page cache has been dropped. You can trigger a verification failure by mmapping the image file from another process that loads a byte from a page, forcing it to become resident. bdrv_co_invalidate_cache() will fail while that process is alive. Signed-off-by: Stefan Hajnoczi Reviewed-by: Fam Zheng Message-id: 20180427162312.18583-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- qapi/block-core.json | 7 ++- block/file-posix.c | 100 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c50517bff3..21c3470234 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2530,6 +2530,10 @@ # @locking: whether to enable file locking. If set to 'auto', only ena= ble # when Open File Descriptor (OFD) locking API is available # (default: auto, since 2.10) +# @x-check-cache-dropped: whether to check that page cache was dropped on = live +# migration. May cause noticeable delays if the i= mage +# file is large, do not use in production. +# (default: off) (since: 2.13) # # Since: 2.9 ## @@ -2537,7 +2541,8 @@ 'data': { 'filename': 'str', '*pr-manager': 'str', '*locking': 'OnOffAuto', - '*aio': 'BlockdevAioOptions' } } + '*aio': 'BlockdevAioOptions', + '*x-check-cache-dropped': 'bool' } } =20 ## # @BlockdevOptionsNull: diff --git a/block/file-posix.c b/block/file-posix.c index 3707ea2d1c..5a602cfe37 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -161,6 +161,7 @@ typedef struct BDRVRawState { bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; + bool check_cache_dropped; =20 PRManager *pr_mgr; } BDRVRawState; @@ -168,6 +169,7 @@ typedef struct BDRVRawState { typedef struct BDRVRawReopenState { int fd; int open_flags; + bool check_cache_dropped; } BDRVRawReopenState; =20 static int fd_open(BlockDriverState *bs); @@ -415,6 +417,11 @@ static QemuOptsList raw_runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "id of persistent reservation manager object (defaul= t: none)", }, + { + .name =3D "x-check-cache-dropped", + .type =3D QEMU_OPT_BOOL, + .help =3D "check that page cache was dropped on live migration= (default: off)" + }, { /* end of list */ } }, }; @@ -500,6 +507,9 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, } } =20 + s->check_cache_dropped =3D qemu_opt_get_bool(opts, "x-check-cache-drop= ped", + false); + s->open_flags =3D open_flags; raw_parse_flags(bdrv_flags, &s->open_flags); =20 @@ -777,6 +787,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, { BDRVRawState *s; BDRVRawReopenState *rs; + QemuOpts *opts; int ret =3D 0; Error *local_err =3D NULL; =20 @@ -787,6 +798,19 @@ static int raw_reopen_prepare(BDRVReopenState *state, =20 state->opaque =3D g_new0(BDRVRawReopenState, 1); rs =3D state->opaque; + rs->fd =3D -1; + + /* Handle options changes */ + opts =3D qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, state->options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -EINVAL; + goto out; + } + + rs->check_cache_dropped =3D qemu_opt_get_bool(opts, "x-check-cache-dro= pped", + s->check_cache_dropped); =20 if (s->type =3D=3D FTYPE_CD) { rs->open_flags |=3D O_NONBLOCK; @@ -794,8 +818,6 @@ static int raw_reopen_prepare(BDRVReopenState *state, =20 raw_parse_flags(state->flags, &rs->open_flags); =20 - rs->fd =3D -1; - int fcntl_flags =3D O_APPEND | O_NONBLOCK; #ifdef O_NOATIME fcntl_flags |=3D O_NOATIME; @@ -850,6 +872,8 @@ static int raw_reopen_prepare(BDRVReopenState *state, } } =20 +out: + qemu_opts_del(opts); return ret; } =20 @@ -858,6 +882,7 @@ static void raw_reopen_commit(BDRVReopenState *state) BDRVRawReopenState *rs =3D state->opaque; BDRVRawState *s =3D state->bs->opaque; =20 + s->check_cache_dropped =3D rs->check_cache_dropped; s->open_flags =3D rs->open_flags; =20 qemu_close(s->fd); @@ -2236,6 +2261,73 @@ static int coroutine_fn raw_co_block_status(BlockDri= verState *bs, return ret | BDRV_BLOCK_OFFSET_VALID; } =20 +#if defined(__linux__) +/* Verify that the file is not in the page cache */ +static void check_cache_dropped(BlockDriverState *bs, Error **errp) +{ + const size_t window_size =3D 128 * 1024 * 1024; + BDRVRawState *s =3D bs->opaque; + void *window =3D NULL; + size_t length =3D 0; + unsigned char *vec; + size_t page_size; + off_t offset; + off_t end; + + /* mincore(2) page status information requires 1 byte per page */ + page_size =3D sysconf(_SC_PAGESIZE); + vec =3D g_malloc(DIV_ROUND_UP(window_size, page_size)); + + end =3D raw_getlength(bs); + + for (offset =3D 0; offset < end; offset +=3D window_size) { + void *new_window; + size_t new_length; + size_t vec_end; + size_t i; + int ret; + + /* Unmap previous window if size has changed */ + new_length =3D MIN(end - offset, window_size); + if (new_length !=3D length) { + munmap(window, length); + window =3D NULL; + length =3D 0; + } + + new_window =3D mmap(window, new_length, PROT_NONE, MAP_PRIVATE, + s->fd, offset); + if (new_window =3D=3D MAP_FAILED) { + error_setg_errno(errp, errno, "mmap failed"); + break; + } + + window =3D new_window; + length =3D new_length; + + ret =3D mincore(window, length, vec); + if (ret < 0) { + error_setg_errno(errp, errno, "mincore failed"); + break; + } + + vec_end =3D DIV_ROUND_UP(length, page_size); + for (i =3D 0; i < vec_end; i++) { + if (vec[i] & 0x1) { + error_setg(errp, "page cache still in use!"); + break; + } + } + } + + if (window) { + munmap(window, length); + } + + g_free(vec); +} +#endif /* __linux__ */ + static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, Error **errp) { @@ -2269,6 +2361,10 @@ static void coroutine_fn raw_co_invalidate_cache(Blo= ckDriverState *bs, error_setg_errno(errp, ret, "fadvise failed"); return; } + + if (s->check_cache_dropped) { + check_cache_dropped(bs, errp); + } #else /* __linux__ */ /* Do nothing. Live migration to a remote host with cache.direct=3Dof= f is * unsupported on other host operating systems. Cache consistency iss= ues --=20 2.17.0