1
The following changes since commit e5cd695266c5709308aa95b1baae499e4b5d4544:
1
The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b:
2
2
3
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-05-08 17:05:58 +0100)
3
Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700)
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 d45c83328feab2e4083991693160f0a417cfd9b0:
10
10
11
block/file-posix: add x-check-page-cache=on|off option (2018-05-11 16:43:05 +0100)
11
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option (2022-04-21 12:05:15 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block pull request
14
Pull request
15
15
16
* Support -drive cache.direct=off live migration for POSIX files
16
Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd
17
improvements.
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
20
20
Joe Perches (4):
21
Liu Yiding (1):
21
checkpatch: add a --strict check for utf-8 in commit logs
22
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option
22
checkpatch: ignore email headers better
23
checkpatch: emit a warning on file add/move/delete
24
checkpatch: reduce MAINTAINERS update message frequency
25
23
26
Pasi Savanainen (1):
24
Sakshi Kaushik (1):
27
checkpatch: check utf-8 content from a commit log when it's missing
25
Implements Backend Program conventions for vhost-user-scsi
28
from charset
29
26
30
Stefan Hajnoczi (3):
27
Stefan Hajnoczi (1):
31
blockjob: drop block_job_pause/resume_all()
28
contrib/vhost-user-blk: add missing GOptionEntry NULL terminator
32
block/file-posix: implement bdrv_co_invalidate_cache() on Linux
33
block/file-posix: add x-check-page-cache=on|off option
34
29
35
qapi/block-core.json | 7 +-
30
docs/tools/virtiofsd.rst | 5 ++
36
include/block/blockjob_int.h | 14 ----
31
contrib/vhost-user-blk/vhost-user-blk.c | 3 +-
37
block/file-posix.c | 146 ++++++++++++++++++++++++++++++++++-
32
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
38
blockjob.c | 27 -------
33
tools/virtiofsd/helper.c | 3 +
39
scripts/checkpatch.pl | 56 +++++++++++++-
34
4 files changed, 62 insertions(+), 26 deletions(-)
40
5 files changed, 202 insertions(+), 48 deletions(-)
41
35
42
--
36
--
43
2.17.0
37
2.35.1
44
45
diff view generated by jsdifflib
Deleted patch
1
Commit 8119334918e86f45877cfc139192d54f2449a239 ("block: Don't
2
block_job_pause_all() in bdrv_drain_all()") removed the only callers of
3
block_job_pause/resume_all().
4
1
5
Pausing and resuming now happens in child_job_drained_begin/end() so
6
it's no longer necessary to globally pause/resume jobs.
7
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Reviewed-by: Alberto Garcia <berto@igalia.com>
11
Message-id: 20180424085240.5798-1-stefanha@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
14
include/block/blockjob_int.h | 14 --------------
15
blockjob.c | 27 ---------------------------
16
2 files changed, 41 deletions(-)
17
18
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/block/blockjob_int.h
21
+++ b/include/block/blockjob_int.h
22
@@ -XXX,XX +XXX,XX @@ void block_job_sleep_ns(BlockJob *job, int64_t ns);
23
*/
24
void block_job_yield(BlockJob *job);
25
26
-/**
27
- * block_job_pause_all:
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
/**
41
* block_job_early_fail:
42
* @bs: The block device.
43
diff --git a/blockjob.c b/blockjob.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/blockjob.c
46
+++ b/blockjob.c
47
@@ -XXX,XX +XXX,XX @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
48
return job;
49
}
50
51
-void block_job_pause_all(void)
52
-{
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
{
66
assert(job->status == BLOCK_JOB_STATUS_CREATED);
67
@@ -XXX,XX +XXX,XX @@ void coroutine_fn block_job_pause_point(BlockJob *job)
68
}
69
}
70
71
-void block_job_resume_all(void)
72
-{
73
- BlockJob *job, *next;
74
-
75
- QLIST_FOREACH_SAFE(job, &block_jobs, job_list, next) {
76
- AioContext *aio_context = blk_get_aio_context(job->blk);
77
-
78
- aio_context_acquire(aio_context);
79
- block_job_resume(job);
80
- block_job_unref(job);
81
- aio_context_release(aio_context);
82
- }
83
-}
84
-
85
/*
86
* Conditionally enter a block_job pending a call to fn() while
87
* under the block_job_lock critical section.
88
--
89
2.17.0
90
91
diff view generated by jsdifflib
1
mincore(2) checks whether pages are resident. Use it to verify that
1
From: Sakshi Kaushik <sakshikaushik717@gmail.com>
2
page cache has been dropped.
3
2
4
You can trigger a verification failure by mmapping the image file from
3
Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com>
5
another process that loads a byte from a page, forcing it to become
4
Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com
6
resident. bdrv_co_invalidate_cache() will fail while that process is
5
7
alive.
6
[Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for
7
consistency, fix --fd which was rejected due to an outdated
8
--socket-path check, and add missing entries[] terminator.
9
--Stefan]
8
10
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Reviewed-by: Fam Zheng <famz@redhat.com>
11
Message-id: 20180427162312.18583-3-stefanha@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
12
---
14
qapi/block-core.json | 7 ++-
13
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
15
block/file-posix.c | 100 ++++++++++++++++++++++++++++++++++++++++++-
14
1 file changed, 52 insertions(+), 25 deletions(-)
16
2 files changed, 104 insertions(+), 3 deletions(-)
17
15
18
diff --git a/qapi/block-core.json b/qapi/block-core.json
16
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/qapi/block-core.json
18
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
21
+++ b/qapi/block-core.json
19
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
22
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ fail:
23
# @locking: whether to enable file locking. If set to 'auto', only enable
21
24
# when Open File Descriptor (OFD) locking API is available
22
/** vhost-user-scsi **/
25
# (default: auto, since 2.10)
23
26
+# @x-check-cache-dropped: whether to check that page cache was dropped on live
24
+static int opt_fdnum = -1;
27
+# migration. May cause noticeable delays if the image
25
+static char *opt_socket_path;
28
+# file is large, do not use in production.
26
+static gboolean opt_print_caps;
29
+# (default: off) (since: 2.13)
27
+static char *iscsi_uri;
30
#
31
# Since: 2.9
32
##
33
@@ -XXX,XX +XXX,XX @@
34
'data': { 'filename': 'str',
35
'*pr-manager': 'str',
36
'*locking': 'OnOffAuto',
37
- '*aio': 'BlockdevAioOptions' } }
38
+ '*aio': 'BlockdevAioOptions',
39
+ '*x-check-cache-dropped': 'bool' } }
40
41
##
42
# @BlockdevOptionsNull:
43
diff --git a/block/file-posix.c b/block/file-posix.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/file-posix.c
46
+++ b/block/file-posix.c
47
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState {
48
bool page_cache_inconsistent:1;
49
bool has_fallocate;
50
bool needs_alignment;
51
+ bool check_cache_dropped;
52
53
PRManager *pr_mgr;
54
} BDRVRawState;
55
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState {
56
typedef struct BDRVRawReopenState {
57
int fd;
58
int open_flags;
59
+ bool check_cache_dropped;
60
} BDRVRawReopenState;
61
62
static int fd_open(BlockDriverState *bs);
63
@@ -XXX,XX +XXX,XX @@ static QemuOptsList raw_runtime_opts = {
64
.type = QEMU_OPT_STRING,
65
.help = "id of persistent reservation manager object (default: none)",
66
},
67
+ {
68
+ .name = "x-check-cache-dropped",
69
+ .type = QEMU_OPT_BOOL,
70
+ .help = "check that page cache was dropped on live migration (default: off)"
71
+ },
72
{ /* end of list */ }
73
},
74
};
75
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
76
}
77
}
78
79
+ s->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
80
+ false);
81
+
28
+
82
s->open_flags = open_flags;
29
+static GOptionEntry entries[] = {
83
raw_parse_flags(bdrv_flags, &s->open_flags);
30
+ { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps,
84
31
+ "Print capabilities", NULL },
85
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
32
+ { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum,
33
+ "Use inherited fd socket", "FDNUM" },
34
+ { "iscsi-uri", 'i', 0, G_OPTION_ARG_FILENAME, &iscsi_uri,
35
+ "iSCSI URI to connect to", "FDNUM" },
36
+ { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path,
37
+ "Use UNIX socket path", "PATH" },
38
+ { NULL, }
39
+};
40
+
41
int main(int argc, char **argv)
86
{
42
{
87
BDRVRawState *s;
43
VusDev *vdev_scsi = NULL;
88
BDRVRawReopenState *rs;
44
- char *unix_fn = NULL;
89
+ QemuOpts *opts;
45
- char *iscsi_uri = NULL;
90
int ret = 0;
46
- int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS;
91
Error *local_err = NULL;
47
+ int lsock = -1, csock = -1, err = EXIT_SUCCESS;
92
48
93
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
49
- while ((opt = getopt(argc, argv, "u:i:")) != -1) {
94
50
- switch (opt) {
95
state->opaque = g_new0(BDRVRawReopenState, 1);
51
- case 'h':
96
rs = state->opaque;
52
- goto help;
97
+ rs->fd = -1;
53
- case 'u':
54
- unix_fn = g_strdup(optarg);
55
- break;
56
- case 'i':
57
- iscsi_uri = g_strdup(optarg);
58
- break;
59
- default:
60
- goto help;
61
- }
62
+ GError *error = NULL;
63
+ GOptionContext *context;
98
+
64
+
99
+ /* Handle options changes */
65
+ context = g_option_context_new(NULL);
100
+ opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
66
+ g_option_context_add_main_entries(context, entries, NULL);
101
+ qemu_opts_absorb_qdict(opts, state->options, &local_err);
67
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
102
+ if (local_err) {
68
+ g_printerr("Option parsing failed: %s\n", error->message);
103
+ error_propagate(errp, local_err);
69
+ exit(EXIT_FAILURE);
104
+ ret = -EINVAL;
105
+ goto out;
106
+ }
70
+ }
107
+
71
+
108
+ rs->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
72
+ if (opt_print_caps) {
109
+ s->check_cache_dropped);
73
+ g_print("{\n");
110
74
+ g_print(" \"type\": \"scsi\"\n");
111
if (s->type == FTYPE_CD) {
75
+ g_print("}\n");
112
rs->open_flags |= O_NONBLOCK;
76
+ goto out;
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
}
124
}
77
}
125
78
- if (!unix_fn || !iscsi_uri) {
126
+out:
127
+ qemu_opts_del(opts);
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
+
79
+
156
+ /* mincore(2) page status information requires 1 byte per page */
80
+ if (!iscsi_uri) {
157
+ page_size = sysconf(_SC_PAGESIZE);
81
goto help;
158
+ vec = g_malloc(DIV_ROUND_UP(window_size, page_size));
82
}
159
+
83
160
+ end = raw_getlength(bs);
84
- lsock = unix_sock_new(unix_fn);
161
+
85
- if (lsock < 0) {
162
+ for (offset = 0; offset < end; offset += window_size) {
86
- goto err;
163
+ void *new_window;
87
+ if (opt_socket_path) {
164
+ size_t new_length;
88
+ lsock = unix_sock_new(opt_socket_path);
165
+ size_t vec_end;
89
+ if (lsock < 0) {
166
+ size_t i;
90
+ exit(EXIT_FAILURE);
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
+ }
91
+ }
176
+
92
+ } else if (opt_fdnum < 0) {
177
+ new_window = mmap(window, new_length, PROT_NONE, MAP_PRIVATE,
93
+ g_print("%s\n", g_option_context_get_help(context, true, NULL));
178
+ s->fd, offset);
94
+ exit(EXIT_FAILURE);
179
+ if (new_window == MAP_FAILED) {
95
+ } else {
180
+ error_setg_errno(errp, errno, "mmap failed");
96
+ lsock = opt_fdnum;
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
+ }
199
+ }
200
+ }
201
+
202
+ if (window) {
203
+ munmap(window, length);
204
+ }
205
+
206
+ g_free(vec);
207
+}
208
+#endif /* __linux__ */
209
+
210
static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
211
Error **errp)
212
{
213
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
214
error_setg_errno(errp, ret, "fadvise failed");
215
return;
216
}
97
}
217
+
98
218
+ if (s->check_cache_dropped) {
99
csock = accept(lsock, NULL, NULL);
219
+ check_cache_dropped(bs, errp);
100
@@ -XXX,XX +XXX,XX @@ out:
220
+ }
101
if (vdev_scsi) {
221
#else /* __linux__ */
102
g_main_loop_unref(vdev_scsi->loop);
222
/* Do nothing. Live migration to a remote host with cache.direct=off is
103
g_free(vdev_scsi);
223
* unsupported on other host operating systems. Cache consistency issues
104
- unlink(unix_fn);
105
+ unlink(opt_socket_path);
106
}
107
if (csock >= 0) {
108
close(csock);
109
@@ -XXX,XX +XXX,XX @@ out:
110
if (lsock >= 0) {
111
close(lsock);
112
}
113
- g_free(unix_fn);
114
+ g_free(opt_socket_path);
115
g_free(iscsi_uri);
116
117
return err;
118
@@ -XXX,XX +XXX,XX @@ err:
119
goto out;
120
121
help:
122
- fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n",
123
+ fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n",
124
argv[0]);
125
- fprintf(stderr, " -u path to unix socket\n");
126
- fprintf(stderr, " -i iscsi uri for lun 0\n");
127
+ fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n");
128
+ fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n");
129
+ fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n");
130
+ fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n");
131
fprintf(stderr, " -h print help and quit\n");
132
133
goto err;
224
--
134
--
225
2.17.0
135
2.35.1
226
227
diff view generated by jsdifflib
1
On Linux posix_fadvise(POSIX_FADV_DONTNEED) invalidates pages*. Use
1
The GLib documentation says "a NULL-terminated array of GOptionEntrys"
2
this to drop page cache on the destination host during shared storage
2
so we'd better make sure there is a terminator that lets
3
migration. This way the destination host will read the latest copy of
3
g_option_context_add_main_entries() know when the end of the array has
4
the data and will not use stale data from the page cache.
4
been reached.
5
6
The flow is as follows:
7
8
1. Source host writes out all dirty pages and inactivates drives.
9
2. QEMU_VM_EOF is sent on migration stream.
10
3. Destination host invalidates caches before accessing drives.
11
12
This patch enables live migration even with -drive cache.direct=off.
13
14
* Terms and conditions may apply, please see patch for details.
15
5
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Reviewed-by: Fam Zheng <famz@redhat.com>
7
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
18
Message-id: 20180427162312.18583-2-stefanha@redhat.com
8
Message-id: 20220411150057.3009667-1-stefanha@redhat.com
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
20
---
10
---
21
block/file-posix.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
11
contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
22
1 file changed, 46 insertions(+)
12
1 file changed, 2 insertions(+), 1 deletion(-)
23
13
24
diff --git a/block/file-posix.c b/block/file-posix.c
14
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/block/file-posix.c
16
--- a/contrib/vhost-user-blk/vhost-user-blk.c
27
+++ b/block/file-posix.c
17
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
28
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
18
@@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = {
29
return ret | BDRV_BLOCK_OFFSET_VALID;
19
{"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file,
30
}
20
"block device or file path", "PATH"},
31
21
{ "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only,
32
+static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
22
- "Enable read-only", NULL }
33
+ Error **errp)
23
+ "Enable read-only", NULL },
34
+{
24
+ { NULL, },
35
+ BDRVRawState *s = bs->opaque;
25
};
36
+ int ret;
26
37
+
27
int main(int argc, char **argv)
38
+ ret = fd_open(bs);
39
+ if (ret < 0) {
40
+ error_setg_errno(errp, -ret, "The file descriptor is not open");
41
+ return;
42
+ }
43
+
44
+ if (s->open_flags & O_DIRECT) {
45
+ return; /* No host kernel page cache */
46
+ }
47
+
48
+#if defined(__linux__)
49
+ /* This sets the scene for the next syscall... */
50
+ ret = bdrv_co_flush(bs);
51
+ if (ret < 0) {
52
+ error_setg_errno(errp, -ret, "flush failed");
53
+ return;
54
+ }
55
+
56
+ /* Linux does not invalidate pages that are dirty, locked, or mmapped by a
57
+ * process. These limitations are okay because we just fsynced the file,
58
+ * we don't use mmap, and the file should not be in use by other processes.
59
+ */
60
+ ret = posix_fadvise(s->fd, 0, 0, POSIX_FADV_DONTNEED);
61
+ if (ret != 0) { /* the return value is a positive errno */
62
+ error_setg_errno(errp, ret, "fadvise failed");
63
+ return;
64
+ }
65
+#else /* __linux__ */
66
+ /* Do nothing. Live migration to a remote host with cache.direct=off is
67
+ * unsupported on other host operating systems. Cache consistency issues
68
+ * may occur but no error is reported here, partly because that's the
69
+ * historical behavior and partly because it's hard to differentiate valid
70
+ * configurations that should not cause errors.
71
+ */
72
+#endif /* !__linux__ */
73
+}
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
--
28
--
103
2.17.0
29
2.35.1
104
105
diff view generated by jsdifflib
1
From: Joe Perches <joe@perches.com>
1
From: Liu Yiding <liuyd.fnst@fujitsu.com>
2
2
3
Some find using utf-8 in commit logs inappropriate.
3
virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add
4
description of it to docs/helper.
4
5
5
Some patch commit logs contain unintended utf-8 characters when doing
6
Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
6
things like copy/pasting compilation output.
7
Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com>
7
8
8
Look for the start of any commit log by skipping initial lines that look
9
[Small documentation fixes: s/as client supports/as the client supports/
9
like email headers and "From: " lines.
10
and s/. /. /.
10
11
--Stefan]
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
12
33
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34
---
14
---
35
scripts/checkpatch.pl | 30 ++++++++++++++++++++++++++----
15
docs/tools/virtiofsd.rst | 5 +++++
36
1 file changed, 26 insertions(+), 4 deletions(-)
16
tools/virtiofsd/helper.c | 3 +++
17
2 files changed, 8 insertions(+)
37
18
38
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
19
diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst
39
index XXXXXXX..XXXXXXX 100755
20
index XXXXXXX..XXXXXXX 100644
40
--- a/scripts/checkpatch.pl
21
--- a/docs/tools/virtiofsd.rst
41
+++ b/scripts/checkpatch.pl
22
+++ b/docs/tools/virtiofsd.rst
42
@@ -XXX,XX +XXX,XX @@ our $NonptrType;
23
@@ -XXX,XX +XXX,XX @@ Options
43
our $Type;
24
label. Server will try to set that label on newly created file
44
our $Declare;
25
atomically wherever possible.
45
26
46
-our $UTF8    = qr {
27
+ * killpriv_v2|no_killpriv_v2 -
47
-    [\x09\x0A\x0D\x20-\x7E] # ASCII
28
+ Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled
48
-    | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
29
+ by default as long as the client supports it. Enabling this option helps
49
+our $NON_ASCII_UTF8    = qr{
30
+ with performance in write path.
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
+
31
+
63
# There are still some false positives, but this catches most
32
.. option:: --socket-path=PATH
64
# common cases.
33
65
our $typeTypedefs = qr{(?x:
34
Listen on vhost-user UNIX domain socket at PATH.
66
@@ -XXX,XX +XXX,XX @@ sub process {
35
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
67
    my $signoff = 0;
36
index XXXXXXX..XXXXXXX 100644
68
    my $is_patch = 0;
37
--- a/tools/virtiofsd/helper.c
69
38
+++ b/tools/virtiofsd/helper.c
70
+    my $in_header_lines = 1;
39
@@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void)
71
+    my $in_commit_log = 0;        #Scanning lines before patch
40
" -o announce_submounts Announce sub-mount points to the guest\n"
72
+
41
" -o posix_acl/no_posix_acl Enable/Disable posix_acl. (default: disabled)\n"
73
    our @report = ();
42
" -o security_label/no_security_label Enable/Disable security label. (default: disabled)\n"
74
    our $cnt_lines = 0;
43
+ " -o killpriv_v2/no_killpriv_v2\n"
75
    our $cnt_error = 0;
44
+ " Enable/Disable FUSE_HANDLE_KILLPRIV_V2.\n"
76
@@ -XXX,XX +XXX,XX @@ sub process {
45
+ " (default: enabled as long as client supports it)\n"
77
        if ($line =~ /^diff --git.*?(\S+)$/) {
46
);
78
            $realfile = $1;
47
}
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
48
114
--
49
--
115
2.17.0
50
2.35.1
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
Deleted patch
1
From: Joe Perches <joe@perches.com>
2
1
3
Whenever files are added, moved, or deleted, the MAINTAINERS file
4
patterns can be out of sync or outdated.
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>
25
---
26
scripts/checkpatch.pl | 12 +++++++++++-
27
1 file changed, 11 insertions(+), 1 deletion(-)
28
29
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
30
index XXXXXXX..XXXXXXX 100755
31
--- a/scripts/checkpatch.pl
32
+++ b/scripts/checkpatch.pl
33
@@ -XXX,XX +XXX,XX @@ sub process {
34
35
    my $in_header_lines = $file ? 0 : 1;
36
    my $in_commit_log = 0;        #Scanning lines before patch
37
-
38
+    my $reported_maintainer_file = 0;
39
    my $non_utf8_charset = 0;
40
41
    our @report = ();
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
--
60
2.17.0
61
62
diff view generated by jsdifflib
Deleted patch
1
From: Joe Perches <joe@perches.com>
2
1
3
When files are being added/moved/deleted and a patch contains an update to
4
the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly
5
and do not emit the "does MAINTAINERS need updating?" message.
6
7
Reported by many people.
8
9
Signed-off-by: Joe Perches <joe@perches.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>
15
Message-id: 20180430124651.10340-6-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
---
21
scripts/checkpatch.pl | 6 ++++++
22
1 file changed, 6 insertions(+)
23
24
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
25
index XXXXXXX..XXXXXXX 100755
26
--- a/scripts/checkpatch.pl
27
+++ b/scripts/checkpatch.pl
28
@@ -XXX,XX +XXX,XX @@ sub process {
29
            }
30
        }
31
32
+# Check if MAINTAINERS is being updated. If so, there's probably no need to
33
+# emit the "does MAINTAINERS need updating?" message on file add/move/delete
34
+        if ($line =~ /^\s*MAINTAINERS\s*\|/) {
35
+            $reported_maintainer_file = 1;
36
+        }
37
+
38
# Check for added, moved or deleted files
39
        if (!$reported_maintainer_file && !$in_commit_log &&
40
         ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
41
--
42
2.17.0
43
44
diff view generated by jsdifflib