1
The following changes since commit e5cd695266c5709308aa95b1baae499e4b5d4544:
1
The following changes since commit 711c0418c8c1ce3a24346f058b001c4c5a2f0f81:
2
2
3
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-05-08 17:05:58 +0100)
3
Merge remote-tracking branch 'remotes/philmd/tags/mips-20210702' into staging (2021-07-04 14:04:12 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 31be8a2a97ecba7d31a82932286489cac318e9e9:
9
for you to fetch changes up to 9f460c64e13897117f35ffb61f6f5e0102cabc70:
10
10
11
block/file-posix: add x-check-page-cache=on|off option (2018-05-11 16:43:05 +0100)
11
block/io: Merge discard request alignments (2021-07-06 14:28:55 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block pull request
14
Pull request
15
16
* Support -drive cache.direct=off live migration for POSIX files
17
15
18
----------------------------------------------------------------
16
----------------------------------------------------------------
19
17
20
Joe Perches (4):
18
Akihiko Odaki (3):
21
checkpatch: add a --strict check for utf-8 in commit logs
19
block/file-posix: Optimize for macOS
22
checkpatch: ignore email headers better
20
block: Add backend_defaults property
23
checkpatch: emit a warning on file add/move/delete
21
block/io: Merge discard request alignments
24
checkpatch: reduce MAINTAINERS update message frequency
25
22
26
Pasi Savanainen (1):
23
Stefan Hajnoczi (2):
27
checkpatch: check utf-8 content from a commit log when it's missing
24
util/async: add a human-readable name to BHs for debugging
28
from charset
25
util/async: print leaked BH name when AioContext finalizes
29
26
30
Stefan Hajnoczi (3):
27
include/block/aio.h | 31 ++++++++++++++++++++++---
31
blockjob: drop block_job_pause/resume_all()
28
include/hw/block/block.h | 3 +++
32
block/file-posix: implement bdrv_co_invalidate_cache() on Linux
29
include/qemu/main-loop.h | 4 +++-
33
block/file-posix: add x-check-page-cache=on|off option
30
block/file-posix.c | 27 ++++++++++++++++++++--
34
31
block/io.c | 2 ++
35
qapi/block-core.json | 7 +-
32
hw/block/block.c | 42 ++++++++++++++++++++++++++++++----
36
include/block/blockjob_int.h | 14 ----
33
tests/unit/ptimer-test-stubs.c | 2 +-
37
block/file-posix.c | 146 ++++++++++++++++++++++++++++++++++-
34
util/async.c | 25 ++++++++++++++++----
38
blockjob.c | 27 -------
35
util/main-loop.c | 4 ++--
39
scripts/checkpatch.pl | 56 +++++++++++++-
36
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++
40
5 files changed, 202 insertions(+), 48 deletions(-)
37
10 files changed, 161 insertions(+), 17 deletions(-)
41
38
42
--
39
--
43
2.17.0
40
2.31.1
44
41
45
diff view generated by jsdifflib
1
Commit 8119334918e86f45877cfc139192d54f2449a239 ("block: Don't
1
It can be difficult to debug issues with BHs in production environments.
2
block_job_pause_all() in bdrv_drain_all()") removed the only callers of
2
Although BHs can usually be identified by looking up their ->cb()
3
block_job_pause/resume_all().
3
function pointer, this requires debug information for the program. It is
4
also not possible to print human-readable diagnostics about BHs because
5
they have no identifier.
4
6
5
Pausing and resuming now happens in child_job_drained_begin/end() so
7
This patch adds a name to each BH. The name is not unique per instance
6
it's no longer necessary to globally pause/resume jobs.
8
but differentiates between cb() functions, which is usually enough. It's
9
done by changing aio_bh_new() and friends to macros that stringify cb.
10
11
The next patch will use the name field when reporting leaked BHs.
7
12
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Reviewed-by: Alberto Garcia <berto@igalia.com>
15
Message-Id: <20210414200247.917496-2-stefanha@redhat.com>
11
Message-id: 20180424085240.5798-1-stefanha@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
16
---
14
include/block/blockjob_int.h | 14 --------------
17
include/block/aio.h | 31 ++++++++++++++++++++++++++++---
15
blockjob.c | 27 ---------------------------
18
include/qemu/main-loop.h | 4 +++-
16
2 files changed, 41 deletions(-)
19
tests/unit/ptimer-test-stubs.c | 2 +-
20
util/async.c | 9 +++++++--
21
util/main-loop.c | 4 ++--
22
5 files changed, 41 insertions(+), 9 deletions(-)
17
23
18
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
24
diff --git a/include/block/aio.h b/include/block/aio.h
19
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
20
--- a/include/block/blockjob_int.h
26
--- a/include/block/aio.h
21
+++ b/include/block/blockjob_int.h
27
+++ b/include/block/aio.h
22
@@ -XXX,XX +XXX,XX @@ void block_job_sleep_ns(BlockJob *job, int64_t ns);
28
@@ -XXX,XX +XXX,XX @@ void aio_context_acquire(AioContext *ctx);
29
/* Relinquish ownership of the AioContext. */
30
void aio_context_release(AioContext *ctx);
31
32
+/**
33
+ * aio_bh_schedule_oneshot_full: Allocate a new bottom half structure that will
34
+ * run only once and as soon as possible.
35
+ *
36
+ * @name: A human-readable identifier for debugging purposes.
37
+ */
38
+void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
39
+ const char *name);
40
+
41
/**
42
* aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run
43
* only once and as soon as possible.
44
+ *
45
+ * A convenience wrapper for aio_bh_schedule_oneshot_full() that uses cb as the
46
+ * name string.
23
*/
47
*/
24
void block_job_yield(BlockJob *job);
48
-void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
25
49
+#define aio_bh_schedule_oneshot(ctx, cb, opaque) \
26
-/**
50
+ aio_bh_schedule_oneshot_full((ctx), (cb), (opaque), (stringify(cb)))
27
- * block_job_pause_all:
51
28
- *
29
- * Asynchronously pause all jobs.
30
- */
31
-void block_job_pause_all(void);
32
-
33
-/**
34
- * block_job_resume_all:
35
- *
36
- * Resume all block jobs. Must be paired with a preceding block_job_pause_all.
37
- */
38
-void block_job_resume_all(void);
39
-
40
/**
52
/**
41
* block_job_early_fail:
53
- * aio_bh_new: Allocate a new bottom half structure.
42
* @bs: The block device.
54
+ * aio_bh_new_full: Allocate a new bottom half structure.
43
diff --git a/blockjob.c b/blockjob.c
55
*
56
* Bottom halves are lightweight callbacks whose invocation is guaranteed
57
* to be wait-free, thread-safe and signal-safe. The #QEMUBH structure
58
* is opaque and must be allocated prior to its use.
59
+ *
60
+ * @name: A human-readable identifier for debugging purposes.
61
*/
62
-QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque);
63
+QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
64
+ const char *name);
65
+
66
+/**
67
+ * aio_bh_new: Allocate a new bottom half structure
68
+ *
69
+ * A convenience wrapper for aio_bh_new_full() that uses the cb as the name
70
+ * string.
71
+ */
72
+#define aio_bh_new(ctx, cb, opaque) \
73
+ aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)))
74
75
/**
76
* aio_notify: Force processing of pending events.
77
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
44
index XXXXXXX..XXXXXXX 100644
78
index XXXXXXX..XXXXXXX 100644
45
--- a/blockjob.c
79
--- a/include/qemu/main-loop.h
46
+++ b/blockjob.c
80
+++ b/include/qemu/main-loop.h
47
@@ -XXX,XX +XXX,XX @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
81
@@ -XXX,XX +XXX,XX @@ void qemu_cond_timedwait_iothread(QemuCond *cond, int ms);
48
return job;
82
83
void qemu_fd_register(int fd);
84
85
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
86
+#define qemu_bh_new(cb, opaque) \
87
+ qemu_bh_new_full((cb), (opaque), (stringify(cb)))
88
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name);
89
void qemu_bh_schedule_idle(QEMUBH *bh);
90
91
enum {
92
diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/tests/unit/ptimer-test-stubs.c
95
+++ b/tests/unit/ptimer-test-stubs.c
96
@@ -XXX,XX +XXX,XX @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask)
97
return deadline;
49
}
98
}
50
99
51
-void block_job_pause_all(void)
100
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
52
-{
101
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name)
53
- BlockJob *job = NULL;
54
- while ((job = block_job_next(job))) {
55
- AioContext *aio_context = blk_get_aio_context(job->blk);
56
-
57
- aio_context_acquire(aio_context);
58
- block_job_ref(job);
59
- block_job_pause(job);
60
- aio_context_release(aio_context);
61
- }
62
-}
63
-
64
void block_job_early_fail(BlockJob *job)
65
{
102
{
66
assert(job->status == BLOCK_JOB_STATUS_CREATED);
103
QEMUBH *bh = g_new(QEMUBH, 1);
67
@@ -XXX,XX +XXX,XX @@ void coroutine_fn block_job_pause_point(BlockJob *job)
104
68
}
105
diff --git a/util/async.c b/util/async.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/util/async.c
108
+++ b/util/async.c
109
@@ -XXX,XX +XXX,XX @@ enum {
110
111
struct QEMUBH {
112
AioContext *ctx;
113
+ const char *name;
114
QEMUBHFunc *cb;
115
void *opaque;
116
QSLIST_ENTRY(QEMUBH) next;
117
@@ -XXX,XX +XXX,XX @@ static QEMUBH *aio_bh_dequeue(BHList *head, unsigned *flags)
118
return bh;
69
}
119
}
70
120
71
-void block_job_resume_all(void)
121
-void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
72
-{
122
+void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb,
73
- BlockJob *job, *next;
123
+ void *opaque, const char *name)
74
-
124
{
75
- QLIST_FOREACH_SAFE(job, &block_jobs, job_list, next) {
125
QEMUBH *bh;
76
- AioContext *aio_context = blk_get_aio_context(job->blk);
126
bh = g_new(QEMUBH, 1);
77
-
127
@@ -XXX,XX +XXX,XX @@ void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
78
- aio_context_acquire(aio_context);
128
.ctx = ctx,
79
- block_job_resume(job);
129
.cb = cb,
80
- block_job_unref(job);
130
.opaque = opaque,
81
- aio_context_release(aio_context);
131
+ .name = name,
82
- }
132
};
83
-}
133
aio_bh_enqueue(bh, BH_SCHEDULED | BH_ONESHOT);
84
-
134
}
135
136
-QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
137
+QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
138
+ const char *name)
139
{
140
QEMUBH *bh;
141
bh = g_new(QEMUBH, 1);
142
@@ -XXX,XX +XXX,XX @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
143
.ctx = ctx,
144
.cb = cb,
145
.opaque = opaque,
146
+ .name = name,
147
};
148
return bh;
149
}
150
diff --git a/util/main-loop.c b/util/main-loop.c
151
index XXXXXXX..XXXXXXX 100644
152
--- a/util/main-loop.c
153
+++ b/util/main-loop.c
154
@@ -XXX,XX +XXX,XX @@ void main_loop_wait(int nonblocking)
155
156
/* Functions to operate on the main QEMU AioContext. */
157
158
-QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
159
+QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name)
160
{
161
- return aio_bh_new(qemu_aio_context, cb, opaque);
162
+ return aio_bh_new_full(qemu_aio_context, cb, opaque, name);
163
}
164
85
/*
165
/*
86
* Conditionally enter a block_job pending a call to fn() while
87
* under the block_job_lock critical section.
88
--
166
--
89
2.17.0
167
2.31.1
90
168
91
diff view generated by jsdifflib
Deleted patch
1
From: Joe Perches <joe@perches.com>
2
1
3
Some find using utf-8 in commit logs inappropriate.
4
5
Some patch commit logs contain unintended utf-8 characters when doing
6
things like copy/pasting compilation output.
7
8
Look for the start of any commit log by skipping initial lines that look
9
like email headers and "From: " lines.
10
11
Stop looking for utf-8 at the first signature line.
12
13
Signed-off-by: Joe Perches <joe@perches.com>
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
15
Reviewed-by: Thomas Huth <thuth@redhat.com>
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
18
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
19
Message-id: 20180430124651.10340-2-stefanha@redhat.com
20
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
21
Cc: Andy Whitcroft <apw@shadowen.org>
22
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
23
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
24
(cherry picked from commit 15662b3e8644905032c2e26808401a487d4e90c1)
25
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
27
Conflicts:
28
QEMU does not have CHK(), use WARN() instead.
29
30
QEMU WARN() only takes one argument, drop the 'type' value in the
31
first argument.
32
33
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34
---
35
scripts/checkpatch.pl | 30 ++++++++++++++++++++++++++----
36
1 file changed, 26 insertions(+), 4 deletions(-)
37
38
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
39
index XXXXXXX..XXXXXXX 100755
40
--- a/scripts/checkpatch.pl
41
+++ b/scripts/checkpatch.pl
42
@@ -XXX,XX +XXX,XX @@ our $NonptrType;
43
our $Type;
44
our $Declare;
45
46
-our $UTF8    = qr {
47
-    [\x09\x0A\x0D\x20-\x7E] # ASCII
48
-    | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
49
+our $NON_ASCII_UTF8    = qr{
50
+    [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
51
    | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
52
    | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
53
    | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
54
@@ -XXX,XX +XXX,XX @@ our $UTF8    = qr {
55
    | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
56
}x;
57
58
+our $UTF8    = qr{
59
+    [\x09\x0A\x0D\x20-\x7E] # ASCII
60
+    | $NON_ASCII_UTF8
61
+}x;
62
+
63
# There are still some false positives, but this catches most
64
# common cases.
65
our $typeTypedefs = qr{(?x:
66
@@ -XXX,XX +XXX,XX @@ sub process {
67
    my $signoff = 0;
68
    my $is_patch = 0;
69
70
+    my $in_header_lines = 1;
71
+    my $in_commit_log = 0;        #Scanning lines before patch
72
+
73
    our @report = ();
74
    our $cnt_lines = 0;
75
    our $cnt_error = 0;
76
@@ -XXX,XX +XXX,XX @@ sub process {
77
        if ($line =~ /^diff --git.*?(\S+)$/) {
78
            $realfile = $1;
79
            $realfile =~ s@^([^/]*)/@@;
80
-
81
        } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
82
            $realfile = $1;
83
            $realfile =~ s@^([^/]*)/@@;
84
@@ -XXX,XX +XXX,XX @@ sub process {
85
        if ($line =~ /^\s*signed-off-by:/i) {
86
            # This is a signoff, if ugly, so do not double report.
87
            $signoff++;
88
+            $in_commit_log = 0;
89
+
90
            if (!($line =~ /^\s*Signed-off-by:/)) {
91
                ERROR("The correct form is \"Signed-off-by\"\n" .
92
                    $herecurr);
93
@@ -XXX,XX +XXX,XX @@ sub process {
94
            ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
95
        }
96
97
+# Check if it's the start of a commit log
98
+# (not a header line and we haven't seen the patch filename)
99
+        if ($in_header_lines && $realfile =~ /^$/ &&
100
+         $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
101
+            $in_header_lines = 0;
102
+            $in_commit_log = 1;
103
+        }
104
+
105
+# Still not yet in a patch, check for any UTF-8
106
+        if ($in_commit_log && $realfile =~ /^$/ &&
107
+         $rawline =~ /$NON_ASCII_UTF8/) {
108
+            WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);
109
+        }
110
+
111
# ignore non-hunk lines and lines being removed
112
        next if (!$hunk_line || $line =~ /^-/);
113
114
--
115
2.17.0
116
117
diff view generated by jsdifflib
Deleted patch
1
From: Pasi Savanainen <pasi.savanainen@nixu.com>
2
1
3
Check that a commit log doesn't contain UTF-8 when a mail header
4
explicitly defines a different charset, like
5
6
'Content-Type: text/plain; charset="us-ascii"'
7
8
Signed-off-by: Pasi Savanainen <pasi.savanainen@nixu.com>
9
Reviewed-by: Markus Armbruster <armbru@redhat.com>
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
13
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
14
Message-id: 20180430124651.10340-3-stefanha@redhat.com
15
Cc: Joe Perches <joe@perches.com>
16
Cc: Andy Whitcroft <apw@canonical.com>
17
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
18
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
19
(cherry picked from commit fa64205df9dfd7b7662cc64a7e82115c00e428e5)
20
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
21
Reviewed-by: Thomas Huth <thuth@redhat.com>
22
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
23
---
24
scripts/checkpatch.pl | 13 +++++++++++--
25
1 file changed, 11 insertions(+), 2 deletions(-)
26
27
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
28
index XXXXXXX..XXXXXXX 100755
29
--- a/scripts/checkpatch.pl
30
+++ b/scripts/checkpatch.pl
31
@@ -XXX,XX +XXX,XX @@ sub process {
32
    my $in_header_lines = 1;
33
    my $in_commit_log = 0;        #Scanning lines before patch
34
35
+    my $non_utf8_charset = 0;
36
+
37
    our @report = ();
38
    our $cnt_lines = 0;
39
    our $cnt_error = 0;
40
@@ -XXX,XX +XXX,XX @@ sub process {
41
            $in_commit_log = 1;
42
        }
43
44
-# Still not yet in a patch, check for any UTF-8
45
-        if ($in_commit_log && $realfile =~ /^$/ &&
46
+# Check if there is UTF-8 in a commit log when a mail header has explicitly
47
+# declined it, i.e defined some charset where it is missing.
48
+        if ($in_header_lines &&
49
+         $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
50
+         $1 !~ /utf-8/i) {
51
+            $non_utf8_charset = 1;
52
+        }
53
+
54
+        if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
55
         $rawline =~ /$NON_ASCII_UTF8/) {
56
            WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);
57
        }
58
--
59
2.17.0
60
61
diff view generated by jsdifflib
Deleted patch
1
From: Joe Perches <joe@perches.com>
2
1
3
There are some patches created by git format-patch that when scanned by
4
checkpatch report errors on lines like
5
6
To:    address.tld
7
8
This is a checkpatch false positive.
9
10
Improve the logic a bit to ignore folded email headers to avoid emitting
11
these messages.
12
13
Signed-off-by: Joe Perches <joe@perches.com>
14
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
15
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
16
Reviewed-by: Markus Armbruster <armbru@redhat.com>
17
Reviewed-by: Thomas Huth <thuth@redhat.com>
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
Message-id: 20180430124651.10340-4-stefanha@redhat.com
20
(cherry picked from commit 29ee1b0c67e0dd7dea8dd718e8326076bce5b6fe)
21
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22
Reviewed-by: Thomas Huth <thuth@redhat.com>
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
---
25
scripts/checkpatch.pl | 5 +++--
26
1 file changed, 3 insertions(+), 2 deletions(-)
27
28
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
29
index XXXXXXX..XXXXXXX 100755
30
--- a/scripts/checkpatch.pl
31
+++ b/scripts/checkpatch.pl
32
@@ -XXX,XX +XXX,XX @@ sub process {
33
    my $signoff = 0;
34
    my $is_patch = 0;
35
36
-    my $in_header_lines = 1;
37
+    my $in_header_lines = $file ? 0 : 1;
38
    my $in_commit_log = 0;        #Scanning lines before patch
39
40
    my $non_utf8_charset = 0;
41
@@ -XXX,XX +XXX,XX @@ sub process {
42
# Check if it's the start of a commit log
43
# (not a header line and we haven't seen the patch filename)
44
        if ($in_header_lines && $realfile =~ /^$/ &&
45
-         $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
46
+         !($rawline =~ /^\s+\S/ ||
47
+         $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
48
            $in_header_lines = 0;
49
            $in_commit_log = 1;
50
        }
51
--
52
2.17.0
53
54
diff view generated by jsdifflib
1
From: Joe Perches <joe@perches.com>
1
BHs must be deleted before the AioContext is finalized. If not, it's a
2
bug and probably indicates that some part of the program still expects
3
the BH to run in the future. That can lead to memory leaks, inconsistent
4
state, or just hangs.
2
5
3
When files are being added/moved/deleted and a patch contains an update to
6
Unfortunately the assert(flags & BH_DELETED) call in aio_ctx_finalize()
4
the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly
7
is difficult to debug because the assertion failure contains no
5
and do not emit the "does MAINTAINERS need updating?" message.
8
information about the BH!
6
9
7
Reported by many people.
10
Use the QEMUBH name field added in the previous patch to show a useful
11
error when a leaked BH is detected.
8
12
9
Signed-off-by: Joe Perches <joe@perches.com>
13
Suggested-by: Eric Ernst <eric.g.ernst@gmail.com>
10
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
11
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13
Reviewed-by: Thomas Huth <thuth@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Message-id: 20180430124651.10340-6-stefanha@redhat.com
15
Message-Id: <20210414200247.917496-3-stefanha@redhat.com>
16
(cherry picked from e0d975b1b439c4fef58fbc306c542c94f48bb849)
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Reviewed-by: Thomas Huth <thuth@redhat.com>
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
20
---
16
---
21
scripts/checkpatch.pl | 6 ++++++
17
util/async.c | 16 ++++++++++++++--
22
1 file changed, 6 insertions(+)
18
1 file changed, 14 insertions(+), 2 deletions(-)
23
19
24
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
20
diff --git a/util/async.c b/util/async.c
25
index XXXXXXX..XXXXXXX 100755
21
index XXXXXXX..XXXXXXX 100644
26
--- a/scripts/checkpatch.pl
22
--- a/util/async.c
27
+++ b/scripts/checkpatch.pl
23
+++ b/util/async.c
28
@@ -XXX,XX +XXX,XX @@ sub process {
24
@@ -XXX,XX +XXX,XX @@ aio_ctx_finalize(GSource *source)
29
            }
25
assert(QSIMPLEQ_EMPTY(&ctx->bh_slice_list));
30
        }
26
31
27
while ((bh = aio_bh_dequeue(&ctx->bh_list, &flags))) {
32
+# Check if MAINTAINERS is being updated. If so, there's probably no need to
28
- /* qemu_bh_delete() must have been called on BHs in this AioContext */
33
+# emit the "does MAINTAINERS need updating?" message on file add/move/delete
29
- assert(flags & BH_DELETED);
34
+        if ($line =~ /^\s*MAINTAINERS\s*\|/) {
30
+ /*
35
+            $reported_maintainer_file = 1;
31
+ * qemu_bh_delete() must have been called on BHs in this AioContext. In
36
+        }
32
+ * many cases memory leaks, hangs, or inconsistent state occur when a
37
+
33
+ * BH is leaked because something still expects it to run.
38
# Check for added, moved or deleted files
34
+ *
39
        if (!$reported_maintainer_file && !$in_commit_log &&
35
+ * If you hit this, fix the lifecycle of the BH so that
40
         ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
36
+ * qemu_bh_delete() and any associated cleanup is called before the
37
+ * AioContext is finalized.
38
+ */
39
+ if (unlikely(!(flags & BH_DELETED))) {
40
+ fprintf(stderr, "%s: BH '%s' leaked, aborting...\n",
41
+ __func__, bh->name);
42
+ abort();
43
+ }
44
45
g_free(bh);
46
}
41
--
47
--
42
2.17.0
48
2.31.1
43
49
44
diff view generated by jsdifflib
1
On Linux posix_fadvise(POSIX_FADV_DONTNEED) invalidates pages*. Use
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
this to drop page cache on the destination host during shared storage
3
migration. This way the destination host will read the latest copy of
4
the data and will not use stale data from the page cache.
5
2
6
The flow is as follows:
3
This commit introduces "punch hole" operation and optimizes transfer
4
block size for macOS.
7
5
8
1. Source host writes out all dirty pages and inactivates drives.
6
Thanks to Konstantin Nazarov for detailed analysis of a flaw in an
9
2. QEMU_VM_EOF is sent on migration stream.
7
old version of this change:
10
3. Destination host invalidates caches before accessing drives.
8
https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667
11
9
12
This patch enables live migration even with -drive cache.direct=off.
10
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
13
11
Message-id: 20210705130458.97642-1-akihiko.odaki@gmail.com
14
* Terms and conditions may apply, please see patch for details.
15
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Reviewed-by: Fam Zheng <famz@redhat.com>
18
Message-id: 20180427162312.18583-2-stefanha@redhat.com
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
20
---
13
---
21
block/file-posix.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
14
block/file-posix.c | 27 +++++++++++++++++++++++++--
22
1 file changed, 46 insertions(+)
15
1 file changed, 25 insertions(+), 2 deletions(-)
23
16
24
diff --git a/block/file-posix.c b/block/file-posix.c
17
diff --git a/block/file-posix.c b/block/file-posix.c
25
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
26
--- a/block/file-posix.c
19
--- a/block/file-posix.c
27
+++ b/block/file-posix.c
20
+++ b/block/file-posix.c
28
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
21
@@ -XXX,XX +XXX,XX @@
29
return ret | BDRV_BLOCK_OFFSET_VALID;
22
#if defined(HAVE_HOST_BLOCK_DEVICE)
23
#include <paths.h>
24
#include <sys/param.h>
25
+#include <sys/mount.h>
26
#include <IOKit/IOKitLib.h>
27
#include <IOKit/IOBSD.h>
28
#include <IOKit/storage/IOMediaBSDClient.h>
29
@@ -XXX,XX +XXX,XX @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
30
return;
31
}
32
33
+#if defined(__APPLE__) && (__MACH__)
34
+ struct statfs buf;
35
+
36
+ if (!fstatfs(s->fd, &buf)) {
37
+ bs->bl.opt_transfer = buf.f_iosize;
38
+ bs->bl.pdiscard_alignment = buf.f_bsize;
39
+ }
40
+#endif
41
+
42
if (bs->sg || S_ISBLK(st.st_mode)) {
43
int ret = hdev_get_max_hw_transfer(s->fd, &st);
44
45
@@ -XXX,XX +XXX,XX @@ out:
46
}
30
}
47
}
31
48
32
+static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
49
+#if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) || defined(BLKDISCARD)
33
+ Error **errp)
50
static int translate_err(int err)
34
+{
51
{
35
+ BDRVRawState *s = bs->opaque;
52
if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP ||
36
+ int ret;
53
@@ -XXX,XX +XXX,XX @@ static int translate_err(int err)
37
+
54
}
38
+ ret = fd_open(bs);
55
return err;
39
+ if (ret < 0) {
56
}
40
+ error_setg_errno(errp, -ret, "The file descriptor is not open");
57
+#endif
41
+ return;
58
42
+ }
59
#ifdef CONFIG_FALLOCATE
43
+
60
static int do_fallocate(int fd, int mode, off_t offset, off_t len)
44
+ if (s->open_flags & O_DIRECT) {
61
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
45
+ return; /* No host kernel page cache */
62
}
46
+ }
63
} while (errno == EINTR);
47
+
64
48
+#if defined(__linux__)
65
- ret = -errno;
49
+ /* This sets the scene for the next syscall... */
66
+ ret = translate_err(-errno);
50
+ ret = bdrv_co_flush(bs);
67
#endif
51
+ if (ret < 0) {
68
} else {
52
+ error_setg_errno(errp, -ret, "flush failed");
69
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
53
+ return;
70
ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
54
+ }
71
aiocb->aio_offset, aiocb->aio_nbytes);
55
+
72
+ ret = translate_err(-errno);
56
+ /* Linux does not invalidate pages that are dirty, locked, or mmapped by a
73
+#elif defined(__APPLE__) && (__MACH__)
57
+ * process. These limitations are okay because we just fsynced the file,
74
+ fpunchhole_t fpunchhole;
58
+ * we don't use mmap, and the file should not be in use by other processes.
75
+ fpunchhole.fp_flags = 0;
59
+ */
76
+ fpunchhole.reserved = 0;
60
+ ret = posix_fadvise(s->fd, 0, 0, POSIX_FADV_DONTNEED);
77
+ fpunchhole.fp_offset = aiocb->aio_offset;
61
+ if (ret != 0) { /* the return value is a positive errno */
78
+ fpunchhole.fp_length = aiocb->aio_nbytes;
62
+ error_setg_errno(errp, ret, "fadvise failed");
79
+ if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) {
63
+ return;
80
+ ret = errno == ENODEV ? -ENOTSUP : -errno;
64
+ }
81
+ } else {
65
+#else /* __linux__ */
82
+ ret = 0;
66
+ /* Do nothing. Live migration to a remote host with cache.direct=off is
83
+ }
67
+ * unsupported on other host operating systems. Cache consistency issues
84
#endif
68
+ * may occur but no error is reported here, partly because that's the
85
}
69
+ * historical behavior and partly because it's hard to differentiate valid
86
70
+ * configurations that should not cause errors.
87
- ret = translate_err(ret);
71
+ */
88
if (ret == -ENOTSUP) {
72
+#endif /* !__linux__ */
89
s->has_discard = false;
73
+}
90
}
74
+
75
static coroutine_fn BlockAIOCB *raw_aio_pdiscard(BlockDriverState *bs,
76
int64_t offset, int bytes,
77
BlockCompletionFunc *cb, void *opaque)
78
@@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_file = {
79
.bdrv_co_create_opts = raw_co_create_opts,
80
.bdrv_has_zero_init = bdrv_has_zero_init_1,
81
.bdrv_co_block_status = raw_co_block_status,
82
+ .bdrv_co_invalidate_cache = raw_co_invalidate_cache,
83
.bdrv_co_pwrite_zeroes = raw_co_pwrite_zeroes,
84
85
.bdrv_co_preadv = raw_co_preadv,
86
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_host_device = {
87
.bdrv_reopen_abort = raw_reopen_abort,
88
.bdrv_co_create_opts = hdev_co_create_opts,
89
.create_opts = &raw_create_opts,
90
+ .bdrv_co_invalidate_cache = raw_co_invalidate_cache,
91
.bdrv_co_pwrite_zeroes = hdev_co_pwrite_zeroes,
92
93
.bdrv_co_preadv = raw_co_preadv,
94
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_host_cdrom = {
95
.bdrv_reopen_abort = raw_reopen_abort,
96
.bdrv_co_create_opts = hdev_co_create_opts,
97
.create_opts = &raw_create_opts,
98
+ .bdrv_co_invalidate_cache = raw_co_invalidate_cache,
99
100
101
.bdrv_co_preadv = raw_co_preadv,
102
--
91
--
103
2.17.0
92
2.31.1
104
93
105
diff view generated by jsdifflib
1
mincore(2) checks whether pages are resident. Use it to verify that
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
page cache has been dropped.
2
3
3
backend_defaults property allow users to control if default block
4
You can trigger a verification failure by mmapping the image file from
4
properties should be decided with backend information.
5
another process that loads a byte from a page, forcing it to become
5
6
resident. bdrv_co_invalidate_cache() will fail while that process is
6
If it is off, any backend information will be discarded, which is
7
alive.
7
suitable if you plan to perform live migration to a different disk backend.
8
8
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
If it is on, a block device may utilize backend information more
10
Reviewed-by: Fam Zheng <famz@redhat.com>
10
aggressively.
11
Message-id: 20180427162312.18583-3-stefanha@redhat.com
11
12
By default, it is auto, which uses backend information for block
13
sizes and ignores the others, which is consistent with the older
14
versions.
15
16
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
17
Message-id: 20210705130458.97642-2-akihiko.odaki@gmail.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
19
---
14
qapi/block-core.json | 7 ++-
20
include/hw/block/block.h | 3 +++
15
block/file-posix.c | 100 ++++++++++++++++++++++++++++++++++++++++++-
21
hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++----
16
2 files changed, 104 insertions(+), 3 deletions(-)
22
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++++++
17
23
3 files changed, 79 insertions(+), 4 deletions(-)
18
diff --git a/qapi/block-core.json b/qapi/block-core.json
24
25
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
19
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
20
--- a/qapi/block-core.json
27
--- a/include/hw/block/block.h
21
+++ b/qapi/block-core.json
28
+++ b/include/hw/block/block.h
22
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
23
# @locking: whether to enable file locking. If set to 'auto', only enable
30
24
# when Open File Descriptor (OFD) locking API is available
31
typedef struct BlockConf {
25
# (default: auto, since 2.10)
32
BlockBackend *blk;
26
+# @x-check-cache-dropped: whether to check that page cache was dropped on live
33
+ OnOffAuto backend_defaults;
27
+# migration. May cause noticeable delays if the image
34
uint32_t physical_block_size;
28
+# file is large, do not use in production.
35
uint32_t logical_block_size;
29
+# (default: off) (since: 2.13)
36
uint32_t min_io_size;
30
#
37
@@ -XXX,XX +XXX,XX @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
31
# Since: 2.9
38
}
32
##
39
33
@@ -XXX,XX +XXX,XX @@
40
#define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \
34
'data': { 'filename': 'str',
41
+ DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \
35
'*pr-manager': 'str',
42
+ _conf.backend_defaults, ON_OFF_AUTO_AUTO), \
36
'*locking': 'OnOffAuto',
43
DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \
37
- '*aio': 'BlockdevAioOptions' } }
44
_conf.logical_block_size), \
38
+ '*aio': 'BlockdevAioOptions',
45
DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \
39
+ '*x-check-cache-dropped': 'bool' } }
46
diff --git a/hw/block/block.c b/hw/block/block.c
40
41
##
42
# @BlockdevOptionsNull:
43
diff --git a/block/file-posix.c b/block/file-posix.c
44
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
45
--- a/block/file-posix.c
48
--- a/hw/block/block.c
46
+++ b/block/file-posix.c
49
+++ b/hw/block/block.c
47
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState {
50
@@ -XXX,XX +XXX,XX @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp)
48
bool page_cache_inconsistent:1;
51
{
49
bool has_fallocate;
52
BlockBackend *blk = conf->blk;
50
bool needs_alignment;
53
BlockSizes blocksizes;
51
+ bool check_cache_dropped;
54
- int backend_ret;
52
55
+ BlockDriverState *bs;
53
PRManager *pr_mgr;
56
+ bool use_blocksizes;
54
} BDRVRawState;
57
+ bool use_bs;
55
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState {
58
+
56
typedef struct BDRVRawReopenState {
59
+ switch (conf->backend_defaults) {
57
int fd;
60
+ case ON_OFF_AUTO_AUTO:
58
int open_flags;
61
+ use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes);
59
+ bool check_cache_dropped;
62
+ use_bs = false;
60
} BDRVRawReopenState;
63
+ break;
61
64
+
62
static int fd_open(BlockDriverState *bs);
65
+ case ON_OFF_AUTO_ON:
63
@@ -XXX,XX +XXX,XX @@ static QemuOptsList raw_runtime_opts = {
66
+ use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes);
64
.type = QEMU_OPT_STRING,
67
+ bs = blk_bs(blk);
65
.help = "id of persistent reservation manager object (default: none)",
68
+ use_bs = bs;
66
},
69
+ break;
67
+ {
70
+
68
+ .name = "x-check-cache-dropped",
71
+ case ON_OFF_AUTO_OFF:
69
+ .type = QEMU_OPT_BOOL,
72
+ use_blocksizes = false;
70
+ .help = "check that page cache was dropped on live migration (default: off)"
73
+ use_bs = false;
71
+ },
74
+ break;
72
{ /* end of list */ }
75
+
73
},
76
+ default:
74
};
77
+ abort();
75
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
78
+ }
79
80
- backend_ret = blk_probe_blocksizes(blk, &blocksizes);
81
/* fill in detected values if they are not defined via qemu command line */
82
if (!conf->physical_block_size) {
83
- if (!backend_ret) {
84
+ if (use_blocksizes) {
85
conf->physical_block_size = blocksizes.phys;
86
} else {
87
conf->physical_block_size = BDRV_SECTOR_SIZE;
76
}
88
}
77
}
89
}
78
90
if (!conf->logical_block_size) {
79
+ s->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
91
- if (!backend_ret) {
80
+ false);
92
+ if (use_blocksizes) {
81
+
93
conf->logical_block_size = blocksizes.log;
82
s->open_flags = open_flags;
94
} else {
83
raw_parse_flags(bdrv_flags, &s->open_flags);
95
conf->logical_block_size = BDRV_SECTOR_SIZE;
84
85
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
86
{
87
BDRVRawState *s;
88
BDRVRawReopenState *rs;
89
+ QemuOpts *opts;
90
int ret = 0;
91
Error *local_err = NULL;
92
93
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
94
95
state->opaque = g_new0(BDRVRawReopenState, 1);
96
rs = state->opaque;
97
+ rs->fd = -1;
98
+
99
+ /* Handle options changes */
100
+ opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
101
+ qemu_opts_absorb_qdict(opts, state->options, &local_err);
102
+ if (local_err) {
103
+ error_propagate(errp, local_err);
104
+ ret = -EINVAL;
105
+ goto out;
106
+ }
107
+
108
+ rs->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
109
+ s->check_cache_dropped);
110
111
if (s->type == FTYPE_CD) {
112
rs->open_flags |= O_NONBLOCK;
113
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
114
115
raw_parse_flags(state->flags, &rs->open_flags);
116
117
- rs->fd = -1;
118
-
119
int fcntl_flags = O_APPEND | O_NONBLOCK;
120
#ifdef O_NOATIME
121
fcntl_flags |= O_NOATIME;
122
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
123
}
96
}
124
}
97
}
125
98
+ if (use_bs) {
126
+out:
99
+ if (!conf->opt_io_size) {
127
+ qemu_opts_del(opts);
100
+ conf->opt_io_size = bs->bl.opt_transfer;
128
return ret;
129
}
130
131
@@ -XXX,XX +XXX,XX @@ static void raw_reopen_commit(BDRVReopenState *state)
132
BDRVRawReopenState *rs = state->opaque;
133
BDRVRawState *s = state->bs->opaque;
134
135
+ s->check_cache_dropped = rs->check_cache_dropped;
136
s->open_flags = rs->open_flags;
137
138
qemu_close(s->fd);
139
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
140
return ret | BDRV_BLOCK_OFFSET_VALID;
141
}
142
143
+#if defined(__linux__)
144
+/* Verify that the file is not in the page cache */
145
+static void check_cache_dropped(BlockDriverState *bs, Error **errp)
146
+{
147
+ const size_t window_size = 128 * 1024 * 1024;
148
+ BDRVRawState *s = bs->opaque;
149
+ void *window = NULL;
150
+ size_t length = 0;
151
+ unsigned char *vec;
152
+ size_t page_size;
153
+ off_t offset;
154
+ off_t end;
155
+
156
+ /* mincore(2) page status information requires 1 byte per page */
157
+ page_size = sysconf(_SC_PAGESIZE);
158
+ vec = g_malloc(DIV_ROUND_UP(window_size, page_size));
159
+
160
+ end = raw_getlength(bs);
161
+
162
+ for (offset = 0; offset < end; offset += window_size) {
163
+ void *new_window;
164
+ size_t new_length;
165
+ size_t vec_end;
166
+ size_t i;
167
+ int ret;
168
+
169
+ /* Unmap previous window if size has changed */
170
+ new_length = MIN(end - offset, window_size);
171
+ if (new_length != length) {
172
+ munmap(window, length);
173
+ window = NULL;
174
+ length = 0;
175
+ }
101
+ }
176
+
102
+ if (conf->discard_granularity == -1) {
177
+ new_window = mmap(window, new_length, PROT_NONE, MAP_PRIVATE,
103
+ if (bs->bl.pdiscard_alignment) {
178
+ s->fd, offset);
104
+ conf->discard_granularity = bs->bl.pdiscard_alignment;
179
+ if (new_window == MAP_FAILED) {
105
+ } else if (bs->bl.request_alignment != 1) {
180
+ error_setg_errno(errp, errno, "mmap failed");
106
+ conf->discard_granularity = bs->bl.request_alignment;
181
+ break;
182
+ }
183
+
184
+ window = new_window;
185
+ length = new_length;
186
+
187
+ ret = mincore(window, length, vec);
188
+ if (ret < 0) {
189
+ error_setg_errno(errp, errno, "mincore failed");
190
+ break;
191
+ }
192
+
193
+ vec_end = DIV_ROUND_UP(length, page_size);
194
+ for (i = 0; i < vec_end; i++) {
195
+ if (vec[i] & 0x1) {
196
+ error_setg(errp, "page cache still in use!");
197
+ break;
198
+ }
107
+ }
199
+ }
108
+ }
200
+ }
109
+ }
201
+
110
202
+ if (window) {
111
if (conf->logical_block_size > conf->physical_block_size) {
203
+ munmap(window, length);
112
error_setg(errp,
204
+ }
113
diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out
205
+
114
index XXXXXXX..XXXXXXX 100644
206
+ g_free(vec);
115
--- a/tests/qemu-iotests/172.out
207
+}
116
+++ b/tests/qemu-iotests/172.out
208
+#endif /* __linux__ */
117
@@ -XXX,XX +XXX,XX @@ Testing:
209
+
118
dev: floppy, id ""
210
static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
119
unit = 0 (0x0)
211
Error **errp)
120
drive = "floppy0"
212
{
121
+ backend_defaults = "auto"
213
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
122
logical_block_size = 512 (512 B)
214
error_setg_errno(errp, ret, "fadvise failed");
123
physical_block_size = 512 (512 B)
215
return;
124
min_io_size = 0 (0 B)
216
}
125
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2
217
+
126
dev: floppy, id ""
218
+ if (s->check_cache_dropped) {
127
unit = 0 (0x0)
219
+ check_cache_dropped(bs, errp);
128
drive = "floppy0"
220
+ }
129
+ backend_defaults = "auto"
221
#else /* __linux__ */
130
logical_block_size = 512 (512 B)
222
/* Do nothing. Live migration to a remote host with cache.direct=off is
131
physical_block_size = 512 (512 B)
223
* unsupported on other host operating systems. Cache consistency issues
132
min_io_size = 0 (0 B)
133
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2
134
dev: floppy, id ""
135
unit = 1 (0x1)
136
drive = "floppy1"
137
+ backend_defaults = "auto"
138
logical_block_size = 512 (512 B)
139
physical_block_size = 512 (512 B)
140
min_io_size = 0 (0 B)
141
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2
142
dev: floppy, id ""
143
unit = 0 (0x0)
144
drive = "floppy0"
145
+ backend_defaults = "auto"
146
logical_block_size = 512 (512 B)
147
physical_block_size = 512 (512 B)
148
min_io_size = 0 (0 B)
149
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2
150
dev: floppy, id ""
151
unit = 1 (0x1)
152
drive = "floppy1"
153
+ backend_defaults = "auto"
154
logical_block_size = 512 (512 B)
155
physical_block_size = 512 (512 B)
156
min_io_size = 0 (0 B)
157
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2
158
dev: floppy, id ""
159
unit = 0 (0x0)
160
drive = "floppy0"
161
+ backend_defaults = "auto"
162
logical_block_size = 512 (512 B)
163
physical_block_size = 512 (512 B)
164
min_io_size = 0 (0 B)
165
@@ -XXX,XX +XXX,XX @@ Testing: -fdb
166
dev: floppy, id ""
167
unit = 1 (0x1)
168
drive = "floppy1"
169
+ backend_defaults = "auto"
170
logical_block_size = 512 (512 B)
171
physical_block_size = 512 (512 B)
172
min_io_size = 0 (0 B)
173
@@ -XXX,XX +XXX,XX @@ Testing: -fdb
174
dev: floppy, id ""
175
unit = 0 (0x0)
176
drive = "floppy0"
177
+ backend_defaults = "auto"
178
logical_block_size = 512 (512 B)
179
physical_block_size = 512 (512 B)
180
min_io_size = 0 (0 B)
181
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2
182
dev: floppy, id ""
183
unit = 0 (0x0)
184
drive = "floppy0"
185
+ backend_defaults = "auto"
186
logical_block_size = 512 (512 B)
187
physical_block_size = 512 (512 B)
188
min_io_size = 0 (0 B)
189
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1
190
dev: floppy, id ""
191
unit = 1 (0x1)
192
drive = "floppy1"
193
+ backend_defaults = "auto"
194
logical_block_size = 512 (512 B)
195
physical_block_size = 512 (512 B)
196
min_io_size = 0 (0 B)
197
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1
198
dev: floppy, id ""
199
unit = 0 (0x0)
200
drive = "floppy0"
201
+ backend_defaults = "auto"
202
logical_block_size = 512 (512 B)
203
physical_block_size = 512 (512 B)
204
min_io_size = 0 (0 B)
205
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t
206
dev: floppy, id ""
207
unit = 1 (0x1)
208
drive = "floppy1"
209
+ backend_defaults = "auto"
210
logical_block_size = 512 (512 B)
211
physical_block_size = 512 (512 B)
212
min_io_size = 0 (0 B)
213
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t
214
dev: floppy, id ""
215
unit = 0 (0x0)
216
drive = "floppy0"
217
+ backend_defaults = "auto"
218
logical_block_size = 512 (512 B)
219
physical_block_size = 512 (512 B)
220
min_io_size = 0 (0 B)
221
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0
222
dev: floppy, id ""
223
unit = 0 (0x0)
224
drive = "none0"
225
+ backend_defaults = "auto"
226
logical_block_size = 512 (512 B)
227
physical_block_size = 512 (512 B)
228
min_io_size = 0 (0 B)
229
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,unit=1
230
dev: floppy, id ""
231
unit = 1 (0x1)
232
drive = "none0"
233
+ backend_defaults = "auto"
234
logical_block_size = 512 (512 B)
235
physical_block_size = 512 (512 B)
236
min_io_size = 0 (0 B)
237
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
238
dev: floppy, id ""
239
unit = 1 (0x1)
240
drive = "none1"
241
+ backend_defaults = "auto"
242
logical_block_size = 512 (512 B)
243
physical_block_size = 512 (512 B)
244
min_io_size = 0 (0 B)
245
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
246
dev: floppy, id ""
247
unit = 0 (0x0)
248
drive = "none0"
249
+ backend_defaults = "auto"
250
logical_block_size = 512 (512 B)
251
physical_block_size = 512 (512 B)
252
min_io_size = 0 (0 B)
253
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
254
dev: floppy, id ""
255
unit = 1 (0x1)
256
drive = "none0"
257
+ backend_defaults = "auto"
258
logical_block_size = 512 (512 B)
259
physical_block_size = 512 (512 B)
260
min_io_size = 0 (0 B)
261
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
262
dev: floppy, id ""
263
unit = 0 (0x0)
264
drive = "floppy0"
265
+ backend_defaults = "auto"
266
logical_block_size = 512 (512 B)
267
physical_block_size = 512 (512 B)
268
min_io_size = 0 (0 B)
269
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
270
dev: floppy, id ""
271
unit = 1 (0x1)
272
drive = "none0"
273
+ backend_defaults = "auto"
274
logical_block_size = 512 (512 B)
275
physical_block_size = 512 (512 B)
276
min_io_size = 0 (0 B)
277
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
278
dev: floppy, id ""
279
unit = 0 (0x0)
280
drive = "floppy0"
281
+ backend_defaults = "auto"
282
logical_block_size = 512 (512 B)
283
physical_block_size = 512 (512 B)
284
min_io_size = 0 (0 B)
285
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
286
dev: floppy, id ""
287
unit = 0 (0x0)
288
drive = "none0"
289
+ backend_defaults = "auto"
290
logical_block_size = 512 (512 B)
291
physical_block_size = 512 (512 B)
292
min_io_size = 0 (0 B)
293
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
294
dev: floppy, id ""
295
unit = 1 (0x1)
296
drive = "floppy1"
297
+ backend_defaults = "auto"
298
logical_block_size = 512 (512 B)
299
physical_block_size = 512 (512 B)
300
min_io_size = 0 (0 B)
301
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
302
dev: floppy, id ""
303
unit = 0 (0x0)
304
drive = "none0"
305
+ backend_defaults = "auto"
306
logical_block_size = 512 (512 B)
307
physical_block_size = 512 (512 B)
308
min_io_size = 0 (0 B)
309
@@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
310
dev: floppy, id ""
311
unit = 1 (0x1)
312
drive = "floppy1"
313
+ backend_defaults = "auto"
314
logical_block_size = 512 (512 B)
315
physical_block_size = 512 (512 B)
316
min_io_size = 0 (0 B)
317
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
318
dev: floppy, id ""
319
unit = 1 (0x1)
320
drive = "none0"
321
+ backend_defaults = "auto"
322
logical_block_size = 512 (512 B)
323
physical_block_size = 512 (512 B)
324
min_io_size = 0 (0 B)
325
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
326
dev: floppy, id ""
327
unit = 0 (0x0)
328
drive = "floppy0"
329
+ backend_defaults = "auto"
330
logical_block_size = 512 (512 B)
331
physical_block_size = 512 (512 B)
332
min_io_size = 0 (0 B)
333
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
334
dev: floppy, id ""
335
unit = 1 (0x1)
336
drive = "none0"
337
+ backend_defaults = "auto"
338
logical_block_size = 512 (512 B)
339
physical_block_size = 512 (512 B)
340
min_io_size = 0 (0 B)
341
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
342
dev: floppy, id ""
343
unit = 0 (0x0)
344
drive = "floppy0"
345
+ backend_defaults = "auto"
346
logical_block_size = 512 (512 B)
347
physical_block_size = 512 (512 B)
348
min_io_size = 0 (0 B)
349
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -global floppy.drive=none0 -device
350
dev: floppy, id ""
351
unit = 0 (0x0)
352
drive = "none0"
353
+ backend_defaults = "auto"
354
logical_block_size = 512 (512 B)
355
physical_block_size = 512 (512 B)
356
min_io_size = 0 (0 B)
357
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy
358
dev: floppy, id ""
359
unit = 0 (0x0)
360
drive = ""
361
+ backend_defaults = "auto"
362
logical_block_size = 512 (512 B)
363
physical_block_size = 512 (512 B)
364
min_io_size = 0 (0 B)
365
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=120
366
dev: floppy, id ""
367
unit = 0 (0x0)
368
drive = ""
369
+ backend_defaults = "auto"
370
logical_block_size = 512 (512 B)
371
physical_block_size = 512 (512 B)
372
min_io_size = 0 (0 B)
373
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=144
374
dev: floppy, id ""
375
unit = 0 (0x0)
376
drive = ""
377
+ backend_defaults = "auto"
378
logical_block_size = 512 (512 B)
379
physical_block_size = 512 (512 B)
380
min_io_size = 0 (0 B)
381
@@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=288
382
dev: floppy, id ""
383
unit = 0 (0x0)
384
drive = ""
385
+ backend_defaults = "auto"
386
logical_block_size = 512 (512 B)
387
physical_block_size = 512 (512 B)
388
min_io_size = 0 (0 B)
389
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
390
dev: floppy, id ""
391
unit = 0 (0x0)
392
drive = "none0"
393
+ backend_defaults = "auto"
394
logical_block_size = 512 (512 B)
395
physical_block_size = 512 (512 B)
396
min_io_size = 0 (0 B)
397
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
398
dev: floppy, id ""
399
unit = 0 (0x0)
400
drive = "none0"
401
+ backend_defaults = "auto"
402
logical_block_size = 512 (512 B)
403
physical_block_size = 512 (512 B)
404
min_io_size = 0 (0 B)
405
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical
406
dev: floppy, id ""
407
unit = 0 (0x0)
408
drive = "none0"
409
+ backend_defaults = "auto"
410
logical_block_size = 512 (512 B)
411
physical_block_size = 512 (512 B)
412
min_io_size = 0 (0 B)
413
@@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica
414
dev: floppy, id ""
415
unit = 0 (0x0)
416
drive = "none0"
417
+ backend_defaults = "auto"
418
logical_block_size = 512 (512 B)
419
physical_block_size = 512 (512 B)
420
min_io_size = 0 (0 B)
224
--
421
--
225
2.17.0
422
2.31.1
226
423
227
diff view generated by jsdifflib
1
From: Joe Perches <joe@perches.com>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
Whenever files are added, moved, or deleted, the MAINTAINERS file
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
4
patterns can be out of sync or outdated.
4
Message-id: 20210705130458.97642-3-akihiko.odaki@gmail.com
5
6
To try to keep MAINTAINERS more up-to-date, add a one-time warning
7
whenever a patch does any of those.
8
9
Signed-off-by: Joe Perches <joe@perches.com>
10
Acked-by: Andy Whitcroft <apw@canonical.com>
11
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
12
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13
Reviewed-by: Markus Armbruster <armbru@redhat.com>
14
Reviewed-by: Thomas Huth <thuth@redhat.com>
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16
Message-id: 20180430124651.10340-5-stefanha@redhat.com
17
(cherry picked from commit 13f1937ef33950b1112049972249e6191b82e6c9)
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
Reviewed-by: Thomas Huth <thuth@redhat.com>
20
21
Conflicts:
22
QEMU WARN() only takes one argument, drop the 'type' value in the
23
first argument.
24
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
25
---
6
---
26
scripts/checkpatch.pl | 12 +++++++++++-
7
block/io.c | 2 ++
27
1 file changed, 11 insertions(+), 1 deletion(-)
8
1 file changed, 2 insertions(+)
28
9
29
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
10
diff --git a/block/io.c b/block/io.c
30
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
31
--- a/scripts/checkpatch.pl
12
--- a/block/io.c
32
+++ b/scripts/checkpatch.pl
13
+++ b/block/io.c
33
@@ -XXX,XX +XXX,XX @@ sub process {
14
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
34
15
35
    my $in_header_lines = $file ? 0 : 1;
16
static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
36
    my $in_commit_log = 0;        #Scanning lines before patch
17
{
37
-
18
+ dst->pdiscard_alignment = MAX(dst->pdiscard_alignment,
38
+    my $reported_maintainer_file = 0;
19
+ src->pdiscard_alignment);
39
    my $non_utf8_charset = 0;
20
dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer);
40
21
dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer);
41
    our @report = ();
22
dst->max_hw_transfer = MIN_NON_ZERO(dst->max_hw_transfer,
42
@@ -XXX,XX +XXX,XX @@ sub process {
43
            }
44
        }
45
46
+# Check for added, moved or deleted files
47
+        if (!$reported_maintainer_file && !$in_commit_log &&
48
+         ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
49
+         $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
50
+         ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
51
+         (defined($1) || defined($2))))) {
52
+            $reported_maintainer_file = 1;
53
+            WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
54
+        }
55
+
56
# Check for wrappage within a valid hunk of the file
57
        if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
58
            ERROR("patch seems to be corrupt (line wrapped?)\n" .
59
--
23
--
60
2.17.0
24
2.31.1
61
25
62
diff view generated by jsdifflib