1 | The following changes since commit 411ad78115ebeb3411cf4b7622784b93dfabe259: | 1 | The following changes since commit 6338c30111d596d955e6bc933a82184a0b910c43: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2017-12-15-1' into staging (2017-12-17 15:27:41 +0000) | 3 | Merge tag 'm68k-for-7.2-pull-request' of https://github.com/vivier/qemu-m68k into staging (2022-09-21 13:12:36 -0400) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/codyprime/qemu-kvm-jtc.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 996922de45299878cdc4c15b72b19edf2bc618a4: | 9 | for you to fetch changes up to f16d15c9276bd8f501f861c39cbd4adc812d0c1d: |
10 | 10 | ||
11 | block/curl: fix minor memory leaks (2017-12-18 15:44:39 -0500) | 11 | virtiofsd: use g_date_time_get_microsecond to get subsecond (2022-09-22 13:13:47 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Blockjob and protocol patches | 14 | Pull request |
15 | |||
15 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
16 | 17 | ||
17 | Jeff Cody (4): | 18 | Yusuke Okada (1): |
18 | block/sheepdog: remove spurious NULL check | 19 | virtiofsd: use g_date_time_get_microsecond to get subsecond |
19 | block/sheepdog: code beautification | ||
20 | block/curl: check error return of curl_global_init() | ||
21 | block/curl: fix minor memory leaks | ||
22 | 20 | ||
23 | John Snow (1): | 21 | tools/virtiofsd/passthrough_ll.c | 7 +++++-- |
24 | blockjob: kick jobs on set-speed | 22 | 1 file changed, 5 insertions(+), 2 deletions(-) |
25 | |||
26 | Vladimir Sementsov-Ogievskiy (5): | ||
27 | hbitmap: add next_zero function | ||
28 | backup: move from done_bitmap to copy_bitmap | ||
29 | backup: init copy_bitmap from sync_bitmap for incremental | ||
30 | backup: simplify non-dirty bits progress processing | ||
31 | backup: use copy_bitmap in incremental backup | ||
32 | |||
33 | block/backup.c | 116 +++++++++++++++++------------- | ||
34 | block/curl.c | 24 +++++-- | ||
35 | block/dirty-bitmap.c | 5 ++ | ||
36 | block/sheepdog.c | 166 +++++++++++++++++++++---------------------- | ||
37 | blockjob.c | 30 +++++++- | ||
38 | include/block/dirty-bitmap.h | 1 + | ||
39 | include/qemu/hbitmap.h | 8 +++ | ||
40 | tests/test-hbitmap.c | 61 ++++++++++++++++ | ||
41 | util/hbitmap.c | 39 ++++++++++ | ||
42 | 9 files changed, 309 insertions(+), 141 deletions(-) | ||
43 | 23 | ||
44 | -- | 24 | -- |
45 | 2.9.5 | 25 | 2.37.3 |
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | The function searches for next zero bit. | ||
4 | Also add interface for BdrvDirtyBitmap and unit test. | ||
5 | |||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Message-id: 20171012135313.227864-2-vsementsov@virtuozzo.com | ||
9 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
10 | --- | ||
11 | block/dirty-bitmap.c | 5 ++++ | ||
12 | include/block/dirty-bitmap.h | 1 + | ||
13 | include/qemu/hbitmap.h | 8 ++++++ | ||
14 | tests/test-hbitmap.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | util/hbitmap.c | 39 ++++++++++++++++++++++++++++ | ||
16 | 5 files changed, 114 insertions(+) | ||
17 | |||
18 | diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/block/dirty-bitmap.c | ||
21 | +++ b/block/dirty-bitmap.c | ||
22 | @@ -XXX,XX +XXX,XX @@ char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp) | ||
23 | { | ||
24 | return hbitmap_sha256(bitmap->bitmap, errp); | ||
25 | } | ||
26 | + | ||
27 | +int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset) | ||
28 | +{ | ||
29 | + return hbitmap_next_zero(bitmap->bitmap, offset); | ||
30 | +} | ||
31 | diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/include/block/dirty-bitmap.h | ||
34 | +++ b/include/block/dirty-bitmap.h | ||
35 | @@ -XXX,XX +XXX,XX @@ bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs); | ||
36 | BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs, | ||
37 | BdrvDirtyBitmap *bitmap); | ||
38 | char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp); | ||
39 | +int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t start); | ||
40 | |||
41 | #endif | ||
42 | diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/qemu/hbitmap.h | ||
45 | +++ b/include/qemu/hbitmap.h | ||
46 | @@ -XXX,XX +XXX,XX @@ void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first); | ||
47 | */ | ||
48 | unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi); | ||
49 | |||
50 | +/* hbitmap_next_zero: | ||
51 | + * @hb: The HBitmap to operate on | ||
52 | + * @start: The bit to start from. | ||
53 | + * | ||
54 | + * Find next not dirty bit. | ||
55 | + */ | ||
56 | +int64_t hbitmap_next_zero(const HBitmap *hb, uint64_t start); | ||
57 | + | ||
58 | /* hbitmap_create_meta: | ||
59 | * Create a "meta" hbitmap to track dirtiness of the bits in this HBitmap. | ||
60 | * The caller owns the created bitmap and must call hbitmap_free_meta(hb) to | ||
61 | diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/tests/test-hbitmap.c | ||
64 | +++ b/tests/test-hbitmap.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void test_hbitmap_iter_and_reset(TestHBitmapData *data, | ||
66 | hbitmap_iter_next(&hbi); | ||
67 | } | ||
68 | |||
69 | +static void test_hbitmap_next_zero_check(TestHBitmapData *data, int64_t start) | ||
70 | +{ | ||
71 | + int64_t ret1 = hbitmap_next_zero(data->hb, start); | ||
72 | + int64_t ret2 = start; | ||
73 | + for ( ; ret2 < data->size && hbitmap_get(data->hb, ret2); ret2++) { | ||
74 | + ; | ||
75 | + } | ||
76 | + if (ret2 == data->size) { | ||
77 | + ret2 = -1; | ||
78 | + } | ||
79 | + | ||
80 | + g_assert_cmpint(ret1, ==, ret2); | ||
81 | +} | ||
82 | + | ||
83 | +static void test_hbitmap_next_zero_do(TestHBitmapData *data, int granularity) | ||
84 | +{ | ||
85 | + hbitmap_test_init(data, L3, granularity); | ||
86 | + test_hbitmap_next_zero_check(data, 0); | ||
87 | + test_hbitmap_next_zero_check(data, L3 - 1); | ||
88 | + | ||
89 | + hbitmap_set(data->hb, L2, 1); | ||
90 | + test_hbitmap_next_zero_check(data, 0); | ||
91 | + test_hbitmap_next_zero_check(data, L2 - 1); | ||
92 | + test_hbitmap_next_zero_check(data, L2); | ||
93 | + test_hbitmap_next_zero_check(data, L2 + 1); | ||
94 | + | ||
95 | + hbitmap_set(data->hb, L2 + 5, L1); | ||
96 | + test_hbitmap_next_zero_check(data, 0); | ||
97 | + test_hbitmap_next_zero_check(data, L2 + 1); | ||
98 | + test_hbitmap_next_zero_check(data, L2 + 2); | ||
99 | + test_hbitmap_next_zero_check(data, L2 + 5); | ||
100 | + test_hbitmap_next_zero_check(data, L2 + L1 - 1); | ||
101 | + test_hbitmap_next_zero_check(data, L2 + L1); | ||
102 | + | ||
103 | + hbitmap_set(data->hb, L2 * 2, L3 - L2 * 2); | ||
104 | + test_hbitmap_next_zero_check(data, L2 * 2 - L1); | ||
105 | + test_hbitmap_next_zero_check(data, L2 * 2 - 2); | ||
106 | + test_hbitmap_next_zero_check(data, L2 * 2 - 1); | ||
107 | + test_hbitmap_next_zero_check(data, L2 * 2); | ||
108 | + test_hbitmap_next_zero_check(data, L3 - 1); | ||
109 | + | ||
110 | + hbitmap_set(data->hb, 0, L3); | ||
111 | + test_hbitmap_next_zero_check(data, 0); | ||
112 | +} | ||
113 | + | ||
114 | +static void test_hbitmap_next_zero_0(TestHBitmapData *data, const void *unused) | ||
115 | +{ | ||
116 | + test_hbitmap_next_zero_do(data, 0); | ||
117 | +} | ||
118 | + | ||
119 | +static void test_hbitmap_next_zero_4(TestHBitmapData *data, const void *unused) | ||
120 | +{ | ||
121 | + test_hbitmap_next_zero_do(data, 4); | ||
122 | +} | ||
123 | + | ||
124 | int main(int argc, char **argv) | ||
125 | { | ||
126 | g_test_init(&argc, &argv, NULL); | ||
127 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
128 | |||
129 | hbitmap_test_add("/hbitmap/iter/iter_and_reset", | ||
130 | test_hbitmap_iter_and_reset); | ||
131 | + | ||
132 | + hbitmap_test_add("/hbitmap/next_zero/next_zero_0", | ||
133 | + test_hbitmap_next_zero_0); | ||
134 | + hbitmap_test_add("/hbitmap/next_zero/next_zero_4", | ||
135 | + test_hbitmap_next_zero_4); | ||
136 | + | ||
137 | g_test_run(); | ||
138 | |||
139 | return 0; | ||
140 | diff --git a/util/hbitmap.c b/util/hbitmap.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/util/hbitmap.c | ||
143 | +++ b/util/hbitmap.c | ||
144 | @@ -XXX,XX +XXX,XX @@ void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first) | ||
145 | } | ||
146 | } | ||
147 | |||
148 | +int64_t hbitmap_next_zero(const HBitmap *hb, uint64_t start) | ||
149 | +{ | ||
150 | + size_t pos = (start >> hb->granularity) >> BITS_PER_LEVEL; | ||
151 | + unsigned long *last_lev = hb->levels[HBITMAP_LEVELS - 1]; | ||
152 | + uint64_t sz = hb->sizes[HBITMAP_LEVELS - 1]; | ||
153 | + unsigned long cur = last_lev[pos]; | ||
154 | + unsigned start_bit_offset = | ||
155 | + (start >> hb->granularity) & (BITS_PER_LONG - 1); | ||
156 | + int64_t res; | ||
157 | + | ||
158 | + cur |= (1UL << start_bit_offset) - 1; | ||
159 | + assert((start >> hb->granularity) < hb->size); | ||
160 | + | ||
161 | + if (cur == (unsigned long)-1) { | ||
162 | + do { | ||
163 | + pos++; | ||
164 | + } while (pos < sz && last_lev[pos] == (unsigned long)-1); | ||
165 | + | ||
166 | + if (pos >= sz) { | ||
167 | + return -1; | ||
168 | + } | ||
169 | + | ||
170 | + cur = last_lev[pos]; | ||
171 | + } | ||
172 | + | ||
173 | + res = (pos << BITS_PER_LEVEL) + ctol(cur); | ||
174 | + if (res >= hb->size) { | ||
175 | + return -1; | ||
176 | + } | ||
177 | + | ||
178 | + res = res << hb->granularity; | ||
179 | + if (res < start) { | ||
180 | + assert(((start - res) >> hb->granularity) == 0); | ||
181 | + return start; | ||
182 | + } | ||
183 | + | ||
184 | + return res; | ||
185 | +} | ||
186 | + | ||
187 | bool hbitmap_empty(const HBitmap *hb) | ||
188 | { | ||
189 | return hb->count == 0; | ||
190 | -- | ||
191 | 2.9.5 | ||
192 | |||
193 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | Use HBitmap copy_bitmap instead of done_bitmap. This is needed to | ||
4 | improve incremental backup in following patches and to unify backup | ||
5 | loop for full/incremental modes in future patches. | ||
6 | |||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
11 | Message-id: 20171012135313.227864-3-vsementsov@virtuozzo.com | ||
12 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
13 | --- | ||
14 | block/backup.c | 23 ++++++++++++++--------- | ||
15 | 1 file changed, 14 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/block/backup.c b/block/backup.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/backup.c | ||
20 | +++ b/block/backup.c | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct BackupBlockJob { | ||
22 | BlockdevOnError on_target_error; | ||
23 | CoRwlock flush_rwlock; | ||
24 | uint64_t bytes_read; | ||
25 | - unsigned long *done_bitmap; | ||
26 | int64_t cluster_size; | ||
27 | bool compress; | ||
28 | NotifierWithReturn before_write; | ||
29 | QLIST_HEAD(, CowRequest) inflight_reqs; | ||
30 | + | ||
31 | + HBitmap *copy_bitmap; | ||
32 | } BackupBlockJob; | ||
33 | |||
34 | /* See if in-flight requests overlap and wait for them to complete */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job, | ||
36 | cow_request_begin(&cow_request, job, start, end); | ||
37 | |||
38 | for (; start < end; start += job->cluster_size) { | ||
39 | - if (test_bit(start / job->cluster_size, job->done_bitmap)) { | ||
40 | + if (!hbitmap_get(job->copy_bitmap, start / job->cluster_size)) { | ||
41 | trace_backup_do_cow_skip(job, start); | ||
42 | continue; /* already copied */ | ||
43 | } | ||
44 | + hbitmap_reset(job->copy_bitmap, start / job->cluster_size, 1); | ||
45 | |||
46 | trace_backup_do_cow_process(job, start); | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job, | ||
49 | if (error_is_read) { | ||
50 | *error_is_read = true; | ||
51 | } | ||
52 | + hbitmap_set(job->copy_bitmap, start / job->cluster_size, 1); | ||
53 | goto out; | ||
54 | } | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job, | ||
57 | if (error_is_read) { | ||
58 | *error_is_read = false; | ||
59 | } | ||
60 | + hbitmap_set(job->copy_bitmap, start / job->cluster_size, 1); | ||
61 | goto out; | ||
62 | } | ||
63 | |||
64 | - set_bit(start / job->cluster_size, job->done_bitmap); | ||
65 | - | ||
66 | /* Publish progress, guest I/O counts as progress too. Note that the | ||
67 | * offset field is an opaque progress value, it is not a disk offset. | ||
68 | */ | ||
69 | @@ -XXX,XX +XXX,XX @@ void backup_do_checkpoint(BlockJob *job, Error **errp) | ||
70 | } | ||
71 | |||
72 | len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size); | ||
73 | - bitmap_zero(backup_job->done_bitmap, len); | ||
74 | + hbitmap_set(backup_job->copy_bitmap, 0, len); | ||
75 | } | ||
76 | |||
77 | void backup_wait_for_overlapping_requests(BlockJob *job, int64_t offset, | ||
78 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_run(void *opaque) | ||
79 | BackupBlockJob *job = opaque; | ||
80 | BackupCompleteData *data; | ||
81 | BlockDriverState *bs = blk_bs(job->common.blk); | ||
82 | - int64_t offset; | ||
83 | + int64_t offset, nb_clusters; | ||
84 | int ret = 0; | ||
85 | |||
86 | QLIST_INIT(&job->inflight_reqs); | ||
87 | qemu_co_rwlock_init(&job->flush_rwlock); | ||
88 | |||
89 | - job->done_bitmap = bitmap_new(DIV_ROUND_UP(job->common.len, | ||
90 | - job->cluster_size)); | ||
91 | + nb_clusters = DIV_ROUND_UP(job->common.len, job->cluster_size); | ||
92 | + job->copy_bitmap = hbitmap_alloc(nb_clusters, 0); | ||
93 | + hbitmap_set(job->copy_bitmap, 0, nb_clusters); | ||
94 | |||
95 | job->before_write.notify = backup_before_write_notify; | ||
96 | bdrv_add_before_write_notifier(bs, &job->before_write); | ||
97 | |||
98 | if (job->sync_mode == MIRROR_SYNC_MODE_NONE) { | ||
99 | + /* All bits are set in copy_bitmap to allow any cluster to be copied. | ||
100 | + * This does not actually require them to be copied. */ | ||
101 | while (!block_job_is_cancelled(&job->common)) { | ||
102 | /* Yield until the job is cancelled. We just let our before_write | ||
103 | * notify callback service CoW requests. */ | ||
104 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_run(void *opaque) | ||
105 | /* wait until pending backup_do_cow() calls have completed */ | ||
106 | qemu_co_rwlock_wrlock(&job->flush_rwlock); | ||
107 | qemu_co_rwlock_unlock(&job->flush_rwlock); | ||
108 | - g_free(job->done_bitmap); | ||
109 | + hbitmap_free(job->copy_bitmap); | ||
110 | |||
111 | data = g_malloc(sizeof(*data)); | ||
112 | data->ret = ret; | ||
113 | -- | ||
114 | 2.9.5 | ||
115 | |||
116 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | We should not copy non-dirty clusters in write notifiers. So, | ||
4 | initialize copy_bitmap from sync_bitmap. | ||
5 | |||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Message-id: 20171012135313.227864-4-vsementsov@virtuozzo.com | ||
11 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
12 | --- | ||
13 | block/backup.c | 44 +++++++++++++++++++++++++++++++++++++++++++- | ||
14 | 1 file changed, 43 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/block/backup.c b/block/backup.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/backup.c | ||
19 | +++ b/block/backup.c | ||
20 | @@ -XXX,XX +XXX,XX @@ out: | ||
21 | return ret; | ||
22 | } | ||
23 | |||
24 | +/* init copy_bitmap from sync_bitmap */ | ||
25 | +static void backup_incremental_init_copy_bitmap(BackupBlockJob *job) | ||
26 | +{ | ||
27 | + BdrvDirtyBitmapIter *dbi; | ||
28 | + int64_t offset; | ||
29 | + int64_t end = DIV_ROUND_UP(bdrv_dirty_bitmap_size(job->sync_bitmap), | ||
30 | + job->cluster_size); | ||
31 | + | ||
32 | + dbi = bdrv_dirty_iter_new(job->sync_bitmap); | ||
33 | + while ((offset = bdrv_dirty_iter_next(dbi)) != -1) { | ||
34 | + int64_t cluster = offset / job->cluster_size; | ||
35 | + int64_t next_cluster; | ||
36 | + | ||
37 | + offset += bdrv_dirty_bitmap_granularity(job->sync_bitmap); | ||
38 | + if (offset >= bdrv_dirty_bitmap_size(job->sync_bitmap)) { | ||
39 | + hbitmap_set(job->copy_bitmap, cluster, end - cluster); | ||
40 | + break; | ||
41 | + } | ||
42 | + | ||
43 | + offset = bdrv_dirty_bitmap_next_zero(job->sync_bitmap, offset); | ||
44 | + if (offset == -1) { | ||
45 | + hbitmap_set(job->copy_bitmap, cluster, end - cluster); | ||
46 | + break; | ||
47 | + } | ||
48 | + | ||
49 | + next_cluster = DIV_ROUND_UP(offset, job->cluster_size); | ||
50 | + hbitmap_set(job->copy_bitmap, cluster, next_cluster - cluster); | ||
51 | + if (next_cluster >= end) { | ||
52 | + break; | ||
53 | + } | ||
54 | + | ||
55 | + bdrv_set_dirty_iter(dbi, next_cluster * job->cluster_size); | ||
56 | + } | ||
57 | + | ||
58 | + bdrv_dirty_iter_free(dbi); | ||
59 | +} | ||
60 | + | ||
61 | static void coroutine_fn backup_run(void *opaque) | ||
62 | { | ||
63 | BackupBlockJob *job = opaque; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_run(void *opaque) | ||
65 | |||
66 | nb_clusters = DIV_ROUND_UP(job->common.len, job->cluster_size); | ||
67 | job->copy_bitmap = hbitmap_alloc(nb_clusters, 0); | ||
68 | - hbitmap_set(job->copy_bitmap, 0, nb_clusters); | ||
69 | + if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { | ||
70 | + backup_incremental_init_copy_bitmap(job); | ||
71 | + } else { | ||
72 | + hbitmap_set(job->copy_bitmap, 0, nb_clusters); | ||
73 | + } | ||
74 | + | ||
75 | |||
76 | job->before_write.notify = backup_before_write_notify; | ||
77 | bdrv_add_before_write_notifier(bs, &job->before_write); | ||
78 | -- | ||
79 | 2.9.5 | ||
80 | |||
81 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | Set fake progress for non-dirty clusters in copy_bitmap initialization, | ||
4 | to. It simplifies code and allows further refactoring. | ||
5 | |||
6 | This patch changes user's view of backup progress, but formally it | ||
7 | doesn't changed: progress hops are just moved to the beginning. | ||
8 | |||
9 | Actually it's just a point of view: when do we actually skip clusters? | ||
10 | We can say in the very beginning, that we skip these clusters and do | ||
11 | not think about them later. | ||
12 | |||
13 | Of course, if go through disk sequentially, it's logical to say, that | ||
14 | we skip clusters between copied portions to the left and to the right | ||
15 | of them. But even now copying progress is not sequential because of | ||
16 | write notifiers. Future patches will introduce new backup architecture | ||
17 | which will do copying in several coroutines in parallel, so it will | ||
18 | make no sense to publish fake progress by parts in parallel with | ||
19 | other copying requests. | ||
20 | |||
21 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
22 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
23 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
24 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
25 | Message-id: 20171012135313.227864-5-vsementsov@virtuozzo.com | ||
26 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
27 | --- | ||
28 | block/backup.c | 18 +++--------------- | ||
29 | 1 file changed, 3 insertions(+), 15 deletions(-) | ||
30 | |||
31 | diff --git a/block/backup.c b/block/backup.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/block/backup.c | ||
34 | +++ b/block/backup.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) | ||
36 | int64_t offset; | ||
37 | int64_t cluster; | ||
38 | int64_t end; | ||
39 | - int64_t last_cluster = -1; | ||
40 | BdrvDirtyBitmapIter *dbi; | ||
41 | |||
42 | granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap); | ||
43 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) | ||
44 | while ((offset = bdrv_dirty_iter_next(dbi)) >= 0) { | ||
45 | cluster = offset / job->cluster_size; | ||
46 | |||
47 | - /* Fake progress updates for any clusters we skipped */ | ||
48 | - if (cluster != last_cluster + 1) { | ||
49 | - job->common.offset += ((cluster - last_cluster - 1) * | ||
50 | - job->cluster_size); | ||
51 | - } | ||
52 | - | ||
53 | for (end = cluster + clusters_per_iter; cluster < end; cluster++) { | ||
54 | do { | ||
55 | if (yield_and_check(job)) { | ||
56 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) | ||
57 | if (granularity < job->cluster_size) { | ||
58 | bdrv_set_dirty_iter(dbi, cluster * job->cluster_size); | ||
59 | } | ||
60 | - | ||
61 | - last_cluster = cluster - 1; | ||
62 | - } | ||
63 | - | ||
64 | - /* Play some final catchup with the progress meter */ | ||
65 | - end = DIV_ROUND_UP(job->common.len, job->cluster_size); | ||
66 | - if (last_cluster + 1 < end) { | ||
67 | - job->common.offset += ((end - last_cluster - 1) * job->cluster_size); | ||
68 | } | ||
69 | |||
70 | out: | ||
71 | @@ -XXX,XX +XXX,XX @@ static void backup_incremental_init_copy_bitmap(BackupBlockJob *job) | ||
72 | bdrv_set_dirty_iter(dbi, next_cluster * job->cluster_size); | ||
73 | } | ||
74 | |||
75 | + job->common.offset = job->common.len - | ||
76 | + hbitmap_count(job->copy_bitmap) * job->cluster_size; | ||
77 | + | ||
78 | bdrv_dirty_iter_free(dbi); | ||
79 | } | ||
80 | |||
81 | -- | ||
82 | 2.9.5 | ||
83 | |||
84 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | We can use copy_bitmap instead of sync_bitmap. copy_bitmap is | ||
4 | initialized from sync_bitmap and it is more informative: we will not try | ||
5 | to process data, that is already in progress (by write notifier). | ||
6 | |||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
10 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
11 | Message-id: 20171012135313.227864-6-vsementsov@virtuozzo.com | ||
12 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
13 | --- | ||
14 | block/backup.c | 55 +++++++++++++++++-------------------------------------- | ||
15 | 1 file changed, 17 insertions(+), 38 deletions(-) | ||
16 | |||
17 | diff --git a/block/backup.c b/block/backup.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/backup.c | ||
20 | +++ b/block/backup.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool coroutine_fn yield_and_check(BackupBlockJob *job) | ||
22 | |||
23 | static int coroutine_fn backup_run_incremental(BackupBlockJob *job) | ||
24 | { | ||
25 | + int ret; | ||
26 | bool error_is_read; | ||
27 | - int ret = 0; | ||
28 | - int clusters_per_iter; | ||
29 | - uint32_t granularity; | ||
30 | - int64_t offset; | ||
31 | int64_t cluster; | ||
32 | - int64_t end; | ||
33 | - BdrvDirtyBitmapIter *dbi; | ||
34 | + HBitmapIter hbi; | ||
35 | |||
36 | - granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap); | ||
37 | - clusters_per_iter = MAX((granularity / job->cluster_size), 1); | ||
38 | - dbi = bdrv_dirty_iter_new(job->sync_bitmap); | ||
39 | - | ||
40 | - /* Find the next dirty sector(s) */ | ||
41 | - while ((offset = bdrv_dirty_iter_next(dbi)) >= 0) { | ||
42 | - cluster = offset / job->cluster_size; | ||
43 | - | ||
44 | - for (end = cluster + clusters_per_iter; cluster < end; cluster++) { | ||
45 | - do { | ||
46 | - if (yield_and_check(job)) { | ||
47 | - goto out; | ||
48 | - } | ||
49 | - ret = backup_do_cow(job, cluster * job->cluster_size, | ||
50 | - job->cluster_size, &error_is_read, | ||
51 | - false); | ||
52 | - if ((ret < 0) && | ||
53 | - backup_error_action(job, error_is_read, -ret) == | ||
54 | - BLOCK_ERROR_ACTION_REPORT) { | ||
55 | - goto out; | ||
56 | - } | ||
57 | - } while (ret < 0); | ||
58 | - } | ||
59 | - | ||
60 | - /* If the bitmap granularity is smaller than the backup granularity, | ||
61 | - * we need to advance the iterator pointer to the next cluster. */ | ||
62 | - if (granularity < job->cluster_size) { | ||
63 | - bdrv_set_dirty_iter(dbi, cluster * job->cluster_size); | ||
64 | - } | ||
65 | + hbitmap_iter_init(&hbi, job->copy_bitmap, 0); | ||
66 | + while ((cluster = hbitmap_iter_next(&hbi)) != -1) { | ||
67 | + do { | ||
68 | + if (yield_and_check(job)) { | ||
69 | + return 0; | ||
70 | + } | ||
71 | + ret = backup_do_cow(job, cluster * job->cluster_size, | ||
72 | + job->cluster_size, &error_is_read, false); | ||
73 | + if (ret < 0 && backup_error_action(job, error_is_read, -ret) == | ||
74 | + BLOCK_ERROR_ACTION_REPORT) | ||
75 | + { | ||
76 | + return ret; | ||
77 | + } | ||
78 | + } while (ret < 0); | ||
79 | } | ||
80 | |||
81 | -out: | ||
82 | - bdrv_dirty_iter_free(dbi); | ||
83 | - return ret; | ||
84 | + return 0; | ||
85 | } | ||
86 | |||
87 | /* init copy_bitmap from sync_bitmap */ | ||
88 | -- | ||
89 | 2.9.5 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: John Snow <jsnow@redhat.com> | ||
2 | 1 | ||
3 | If users set an unreasonably low speed (like one byte per second), the | ||
4 | calculated delay may exceed many hours. While we like to punish users | ||
5 | for asking for stupid things, we do also like to allow users to correct | ||
6 | their wicked ways. | ||
7 | |||
8 | When a user provides a new speed, kick the job to allow it to recalculate | ||
9 | its delay. | ||
10 | |||
11 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Message-id: 20171213204611.26276-1-jsnow@redhat.com | ||
14 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
15 | --- | ||
16 | blockjob.c | 30 +++++++++++++++++++++++++++++- | ||
17 | 1 file changed, 29 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/blockjob.c b/blockjob.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/blockjob.c | ||
22 | +++ b/blockjob.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void __attribute__((__constructor__)) block_job_init(void) | ||
24 | |||
25 | static void block_job_event_cancelled(BlockJob *job); | ||
26 | static void block_job_event_completed(BlockJob *job, const char *msg); | ||
27 | +static void block_job_enter_cond(BlockJob *job, bool(*fn)(BlockJob *job)); | ||
28 | |||
29 | /* Transactional group of block jobs */ | ||
30 | struct BlockJobTxn { | ||
31 | @@ -XXX,XX +XXX,XX @@ static void block_job_completed_txn_success(BlockJob *job) | ||
32 | } | ||
33 | } | ||
34 | |||
35 | +/* Assumes the block_job_mutex is held */ | ||
36 | +static bool block_job_timer_pending(BlockJob *job) | ||
37 | +{ | ||
38 | + return timer_pending(&job->sleep_timer); | ||
39 | +} | ||
40 | + | ||
41 | void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) | ||
42 | { | ||
43 | Error *local_err = NULL; | ||
44 | + int64_t old_speed = job->speed; | ||
45 | |||
46 | if (!job->driver->set_speed) { | ||
47 | error_setg(errp, QERR_UNSUPPORTED); | ||
48 | @@ -XXX,XX +XXX,XX @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) | ||
49 | } | ||
50 | |||
51 | job->speed = speed; | ||
52 | + if (speed <= old_speed) { | ||
53 | + return; | ||
54 | + } | ||
55 | + | ||
56 | + /* kick only if a timer is pending */ | ||
57 | + block_job_enter_cond(job, block_job_timer_pending); | ||
58 | } | ||
59 | |||
60 | void block_job_complete(BlockJob *job, Error **errp) | ||
61 | @@ -XXX,XX +XXX,XX @@ void block_job_resume_all(void) | ||
62 | } | ||
63 | } | ||
64 | |||
65 | -void block_job_enter(BlockJob *job) | ||
66 | +/* | ||
67 | + * Conditionally enter a block_job pending a call to fn() while | ||
68 | + * under the block_job_lock critical section. | ||
69 | + */ | ||
70 | +static void block_job_enter_cond(BlockJob *job, bool(*fn)(BlockJob *job)) | ||
71 | { | ||
72 | if (!block_job_started(job)) { | ||
73 | return; | ||
74 | @@ -XXX,XX +XXX,XX @@ void block_job_enter(BlockJob *job) | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | + if (fn && !fn(job)) { | ||
79 | + block_job_unlock(); | ||
80 | + return; | ||
81 | + } | ||
82 | + | ||
83 | assert(!job->deferred_to_main_loop); | ||
84 | timer_del(&job->sleep_timer); | ||
85 | job->busy = true; | ||
86 | @@ -XXX,XX +XXX,XX @@ void block_job_enter(BlockJob *job) | ||
87 | aio_co_wake(job->co); | ||
88 | } | ||
89 | |||
90 | +void block_job_enter(BlockJob *job) | ||
91 | +{ | ||
92 | + block_job_enter_cond(job, NULL); | ||
93 | +} | ||
94 | + | ||
95 | bool block_job_is_cancelled(BlockJob *job) | ||
96 | { | ||
97 | return job->cancelled; | ||
98 | -- | ||
99 | 2.9.5 | ||
100 | |||
101 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | 'tag' is already checked in the lines immediately preceding this check, | ||
2 | and set to non-NULL if NULL. No need to check again, it hasn't changed. | ||
3 | 1 | ||
4 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
6 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
7 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
8 | --- | ||
9 | block/sheepdog.c | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/block/sheepdog.c b/block/sheepdog.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/block/sheepdog.c | ||
15 | +++ b/block/sheepdog.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, | ||
17 | if (!tag) { | ||
18 | tag = ""; | ||
19 | } | ||
20 | - if (tag && strlen(tag) >= SD_MAX_VDI_TAG_LEN) { | ||
21 | + if (strlen(tag) >= SD_MAX_VDI_TAG_LEN) { | ||
22 | error_setg(errp, "value of parameter 'tag' is too long"); | ||
23 | ret = -EINVAL; | ||
24 | goto err_no_fd; | ||
25 | -- | ||
26 | 2.9.5 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | No functional changes, just whitespace manipulation. | ||
2 | 1 | ||
3 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
4 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
5 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
6 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
7 | --- | ||
8 | block/sheepdog.c | 164 +++++++++++++++++++++++++++---------------------------- | ||
9 | 1 file changed, 82 insertions(+), 82 deletions(-) | ||
10 | |||
11 | diff --git a/block/sheepdog.c b/block/sheepdog.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/block/sheepdog.c | ||
14 | +++ b/block/sheepdog.c | ||
15 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVSheepdogReopenState { | ||
16 | int cache_flags; | ||
17 | } BDRVSheepdogReopenState; | ||
18 | |||
19 | -static const char * sd_strerror(int err) | ||
20 | +static const char *sd_strerror(int err) | ||
21 | { | ||
22 | int i; | ||
23 | |||
24 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList sd_create_opts = { | ||
25 | }; | ||
26 | |||
27 | static BlockDriver bdrv_sheepdog = { | ||
28 | - .format_name = "sheepdog", | ||
29 | - .protocol_name = "sheepdog", | ||
30 | - .instance_size = sizeof(BDRVSheepdogState), | ||
31 | - .bdrv_parse_filename = sd_parse_filename, | ||
32 | - .bdrv_file_open = sd_open, | ||
33 | - .bdrv_reopen_prepare = sd_reopen_prepare, | ||
34 | - .bdrv_reopen_commit = sd_reopen_commit, | ||
35 | - .bdrv_reopen_abort = sd_reopen_abort, | ||
36 | - .bdrv_close = sd_close, | ||
37 | - .bdrv_create = sd_create, | ||
38 | - .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
39 | - .bdrv_getlength = sd_getlength, | ||
40 | + .format_name = "sheepdog", | ||
41 | + .protocol_name = "sheepdog", | ||
42 | + .instance_size = sizeof(BDRVSheepdogState), | ||
43 | + .bdrv_parse_filename = sd_parse_filename, | ||
44 | + .bdrv_file_open = sd_open, | ||
45 | + .bdrv_reopen_prepare = sd_reopen_prepare, | ||
46 | + .bdrv_reopen_commit = sd_reopen_commit, | ||
47 | + .bdrv_reopen_abort = sd_reopen_abort, | ||
48 | + .bdrv_close = sd_close, | ||
49 | + .bdrv_create = sd_create, | ||
50 | + .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
51 | + .bdrv_getlength = sd_getlength, | ||
52 | .bdrv_get_allocated_file_size = sd_get_allocated_file_size, | ||
53 | - .bdrv_truncate = sd_truncate, | ||
54 | + .bdrv_truncate = sd_truncate, | ||
55 | |||
56 | - .bdrv_co_readv = sd_co_readv, | ||
57 | - .bdrv_co_writev = sd_co_writev, | ||
58 | - .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
59 | - .bdrv_co_pdiscard = sd_co_pdiscard, | ||
60 | - .bdrv_co_get_block_status = sd_co_get_block_status, | ||
61 | + .bdrv_co_readv = sd_co_readv, | ||
62 | + .bdrv_co_writev = sd_co_writev, | ||
63 | + .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
64 | + .bdrv_co_pdiscard = sd_co_pdiscard, | ||
65 | + .bdrv_co_get_block_status = sd_co_get_block_status, | ||
66 | |||
67 | - .bdrv_snapshot_create = sd_snapshot_create, | ||
68 | - .bdrv_snapshot_goto = sd_snapshot_goto, | ||
69 | - .bdrv_snapshot_delete = sd_snapshot_delete, | ||
70 | - .bdrv_snapshot_list = sd_snapshot_list, | ||
71 | + .bdrv_snapshot_create = sd_snapshot_create, | ||
72 | + .bdrv_snapshot_goto = sd_snapshot_goto, | ||
73 | + .bdrv_snapshot_delete = sd_snapshot_delete, | ||
74 | + .bdrv_snapshot_list = sd_snapshot_list, | ||
75 | |||
76 | - .bdrv_save_vmstate = sd_save_vmstate, | ||
77 | - .bdrv_load_vmstate = sd_load_vmstate, | ||
78 | + .bdrv_save_vmstate = sd_save_vmstate, | ||
79 | + .bdrv_load_vmstate = sd_load_vmstate, | ||
80 | |||
81 | - .bdrv_detach_aio_context = sd_detach_aio_context, | ||
82 | - .bdrv_attach_aio_context = sd_attach_aio_context, | ||
83 | + .bdrv_detach_aio_context = sd_detach_aio_context, | ||
84 | + .bdrv_attach_aio_context = sd_attach_aio_context, | ||
85 | |||
86 | - .create_opts = &sd_create_opts, | ||
87 | + .create_opts = &sd_create_opts, | ||
88 | }; | ||
89 | |||
90 | static BlockDriver bdrv_sheepdog_tcp = { | ||
91 | - .format_name = "sheepdog", | ||
92 | - .protocol_name = "sheepdog+tcp", | ||
93 | - .instance_size = sizeof(BDRVSheepdogState), | ||
94 | - .bdrv_parse_filename = sd_parse_filename, | ||
95 | - .bdrv_file_open = sd_open, | ||
96 | - .bdrv_reopen_prepare = sd_reopen_prepare, | ||
97 | - .bdrv_reopen_commit = sd_reopen_commit, | ||
98 | - .bdrv_reopen_abort = sd_reopen_abort, | ||
99 | - .bdrv_close = sd_close, | ||
100 | - .bdrv_create = sd_create, | ||
101 | - .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
102 | - .bdrv_getlength = sd_getlength, | ||
103 | + .format_name = "sheepdog", | ||
104 | + .protocol_name = "sheepdog+tcp", | ||
105 | + .instance_size = sizeof(BDRVSheepdogState), | ||
106 | + .bdrv_parse_filename = sd_parse_filename, | ||
107 | + .bdrv_file_open = sd_open, | ||
108 | + .bdrv_reopen_prepare = sd_reopen_prepare, | ||
109 | + .bdrv_reopen_commit = sd_reopen_commit, | ||
110 | + .bdrv_reopen_abort = sd_reopen_abort, | ||
111 | + .bdrv_close = sd_close, | ||
112 | + .bdrv_create = sd_create, | ||
113 | + .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
114 | + .bdrv_getlength = sd_getlength, | ||
115 | .bdrv_get_allocated_file_size = sd_get_allocated_file_size, | ||
116 | - .bdrv_truncate = sd_truncate, | ||
117 | + .bdrv_truncate = sd_truncate, | ||
118 | |||
119 | - .bdrv_co_readv = sd_co_readv, | ||
120 | - .bdrv_co_writev = sd_co_writev, | ||
121 | - .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
122 | - .bdrv_co_pdiscard = sd_co_pdiscard, | ||
123 | - .bdrv_co_get_block_status = sd_co_get_block_status, | ||
124 | + .bdrv_co_readv = sd_co_readv, | ||
125 | + .bdrv_co_writev = sd_co_writev, | ||
126 | + .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
127 | + .bdrv_co_pdiscard = sd_co_pdiscard, | ||
128 | + .bdrv_co_get_block_status = sd_co_get_block_status, | ||
129 | |||
130 | - .bdrv_snapshot_create = sd_snapshot_create, | ||
131 | - .bdrv_snapshot_goto = sd_snapshot_goto, | ||
132 | - .bdrv_snapshot_delete = sd_snapshot_delete, | ||
133 | - .bdrv_snapshot_list = sd_snapshot_list, | ||
134 | + .bdrv_snapshot_create = sd_snapshot_create, | ||
135 | + .bdrv_snapshot_goto = sd_snapshot_goto, | ||
136 | + .bdrv_snapshot_delete = sd_snapshot_delete, | ||
137 | + .bdrv_snapshot_list = sd_snapshot_list, | ||
138 | |||
139 | - .bdrv_save_vmstate = sd_save_vmstate, | ||
140 | - .bdrv_load_vmstate = sd_load_vmstate, | ||
141 | + .bdrv_save_vmstate = sd_save_vmstate, | ||
142 | + .bdrv_load_vmstate = sd_load_vmstate, | ||
143 | |||
144 | - .bdrv_detach_aio_context = sd_detach_aio_context, | ||
145 | - .bdrv_attach_aio_context = sd_attach_aio_context, | ||
146 | + .bdrv_detach_aio_context = sd_detach_aio_context, | ||
147 | + .bdrv_attach_aio_context = sd_attach_aio_context, | ||
148 | |||
149 | - .create_opts = &sd_create_opts, | ||
150 | + .create_opts = &sd_create_opts, | ||
151 | }; | ||
152 | |||
153 | static BlockDriver bdrv_sheepdog_unix = { | ||
154 | - .format_name = "sheepdog", | ||
155 | - .protocol_name = "sheepdog+unix", | ||
156 | - .instance_size = sizeof(BDRVSheepdogState), | ||
157 | - .bdrv_parse_filename = sd_parse_filename, | ||
158 | - .bdrv_file_open = sd_open, | ||
159 | - .bdrv_reopen_prepare = sd_reopen_prepare, | ||
160 | - .bdrv_reopen_commit = sd_reopen_commit, | ||
161 | - .bdrv_reopen_abort = sd_reopen_abort, | ||
162 | - .bdrv_close = sd_close, | ||
163 | - .bdrv_create = sd_create, | ||
164 | - .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
165 | - .bdrv_getlength = sd_getlength, | ||
166 | + .format_name = "sheepdog", | ||
167 | + .protocol_name = "sheepdog+unix", | ||
168 | + .instance_size = sizeof(BDRVSheepdogState), | ||
169 | + .bdrv_parse_filename = sd_parse_filename, | ||
170 | + .bdrv_file_open = sd_open, | ||
171 | + .bdrv_reopen_prepare = sd_reopen_prepare, | ||
172 | + .bdrv_reopen_commit = sd_reopen_commit, | ||
173 | + .bdrv_reopen_abort = sd_reopen_abort, | ||
174 | + .bdrv_close = sd_close, | ||
175 | + .bdrv_create = sd_create, | ||
176 | + .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
177 | + .bdrv_getlength = sd_getlength, | ||
178 | .bdrv_get_allocated_file_size = sd_get_allocated_file_size, | ||
179 | - .bdrv_truncate = sd_truncate, | ||
180 | + .bdrv_truncate = sd_truncate, | ||
181 | |||
182 | - .bdrv_co_readv = sd_co_readv, | ||
183 | - .bdrv_co_writev = sd_co_writev, | ||
184 | - .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
185 | - .bdrv_co_pdiscard = sd_co_pdiscard, | ||
186 | - .bdrv_co_get_block_status = sd_co_get_block_status, | ||
187 | + .bdrv_co_readv = sd_co_readv, | ||
188 | + .bdrv_co_writev = sd_co_writev, | ||
189 | + .bdrv_co_flush_to_disk = sd_co_flush_to_disk, | ||
190 | + .bdrv_co_pdiscard = sd_co_pdiscard, | ||
191 | + .bdrv_co_get_block_status = sd_co_get_block_status, | ||
192 | |||
193 | - .bdrv_snapshot_create = sd_snapshot_create, | ||
194 | - .bdrv_snapshot_goto = sd_snapshot_goto, | ||
195 | - .bdrv_snapshot_delete = sd_snapshot_delete, | ||
196 | - .bdrv_snapshot_list = sd_snapshot_list, | ||
197 | + .bdrv_snapshot_create = sd_snapshot_create, | ||
198 | + .bdrv_snapshot_goto = sd_snapshot_goto, | ||
199 | + .bdrv_snapshot_delete = sd_snapshot_delete, | ||
200 | + .bdrv_snapshot_list = sd_snapshot_list, | ||
201 | |||
202 | - .bdrv_save_vmstate = sd_save_vmstate, | ||
203 | - .bdrv_load_vmstate = sd_load_vmstate, | ||
204 | + .bdrv_save_vmstate = sd_save_vmstate, | ||
205 | + .bdrv_load_vmstate = sd_load_vmstate, | ||
206 | |||
207 | - .bdrv_detach_aio_context = sd_detach_aio_context, | ||
208 | - .bdrv_attach_aio_context = sd_attach_aio_context, | ||
209 | + .bdrv_detach_aio_context = sd_detach_aio_context, | ||
210 | + .bdrv_attach_aio_context = sd_attach_aio_context, | ||
211 | |||
212 | - .create_opts = &sd_create_opts, | ||
213 | + .create_opts = &sd_create_opts, | ||
214 | }; | ||
215 | |||
216 | static void bdrv_sheepdog_init(void) | ||
217 | -- | ||
218 | 2.9.5 | ||
219 | |||
220 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If curl_global_init() fails, per the documentation no other curl | ||
2 | functions may be called, so make sure to check the return value. | ||
3 | 1 | ||
4 | Also, some minor changes to the initialization latch variable 'inited': | ||
5 | |||
6 | - Make it static in the file, for clarity | ||
7 | - Change the name for clarity | ||
8 | - Make it a bool | ||
9 | |||
10 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
11 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
12 | Reviewed-by: Richard W.M. Jones <rjones@redhat.com> | ||
13 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
14 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
15 | --- | ||
16 | block/curl.c | 18 ++++++++++++------ | ||
17 | 1 file changed, 12 insertions(+), 6 deletions(-) | ||
18 | |||
19 | diff --git a/block/curl.c b/block/curl.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/curl.c | ||
22 | +++ b/block/curl.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle, | ||
24 | |||
25 | struct BDRVCURLState; | ||
26 | |||
27 | +static bool libcurl_initialized; | ||
28 | + | ||
29 | typedef struct CURLAIOCB { | ||
30 | Coroutine *co; | ||
31 | QEMUIOVector *qiov; | ||
32 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | ||
33 | double d; | ||
34 | const char *secretid; | ||
35 | const char *protocol_delimiter; | ||
36 | + int ret; | ||
37 | |||
38 | - static int inited = 0; | ||
39 | |||
40 | if (flags & BDRV_O_RDWR) { | ||
41 | error_setg(errp, "curl block device does not support writes"); | ||
42 | return -EROFS; | ||
43 | } | ||
44 | |||
45 | + if (!libcurl_initialized) { | ||
46 | + ret = curl_global_init(CURL_GLOBAL_ALL); | ||
47 | + if (ret) { | ||
48 | + error_setg(errp, "libcurl initialization failed with %d", ret); | ||
49 | + return -EIO; | ||
50 | + } | ||
51 | + libcurl_initialized = true; | ||
52 | + } | ||
53 | + | ||
54 | qemu_mutex_init(&s->mutex); | ||
55 | opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); | ||
56 | qemu_opts_absorb_qdict(opts, options, &local_err); | ||
57 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | ||
58 | } | ||
59 | } | ||
60 | |||
61 | - if (!inited) { | ||
62 | - curl_global_init(CURL_GLOBAL_ALL); | ||
63 | - inited = 1; | ||
64 | - } | ||
65 | - | ||
66 | DPRINTF("CURL: Opening %s\n", file); | ||
67 | QSIMPLEQ_INIT(&s->free_state_waitq); | ||
68 | s->aio_context = bdrv_get_aio_context(bs); | ||
69 | -- | ||
70 | 2.9.5 | ||
71 | |||
72 | diff view generated by jsdifflib |
1 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 1 | From: Yusuke Okada <okada.yusuke@jp.fujitsu.com> |
---|---|---|---|
2 | Reviewed-by: Richard W.M. Jones <rjones@redhat.com> | 2 | |
3 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 3 | The "%f" specifier in g_date_time_format() is only available in glib |
4 | 2.65.2 or later. If combined with older glib, the function returns null | ||
5 | and the timestamp displayed as "(null)". | ||
6 | |||
7 | For backward compatibility, g_date_time_get_microsecond should be used | ||
8 | to retrieve subsecond. | ||
9 | |||
10 | In this patch the g_date_time_format() leaves subsecond field as "%06d" | ||
11 | and let next snprintf to format with g_date_time_get_microsecond. | ||
12 | |||
13 | Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com> | ||
14 | Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> | ||
15 | Message-id: 20220818184618.2205172-1-yokada.996@gmail.com | ||
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
4 | --- | 17 | --- |
5 | block/curl.c | 6 ++++++ | 18 | tools/virtiofsd/passthrough_ll.c | 7 +++++-- |
6 | 1 file changed, 6 insertions(+) | 19 | 1 file changed, 5 insertions(+), 2 deletions(-) |
7 | 20 | ||
8 | diff --git a/block/curl.c b/block/curl.c | 21 | diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c |
9 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
10 | --- a/block/curl.c | 23 | --- a/tools/virtiofsd/passthrough_ll.c |
11 | +++ b/block/curl.c | 24 | +++ b/tools/virtiofsd/passthrough_ll.c |
12 | @@ -XXX,XX +XXX,XX @@ out_noclean: | 25 | @@ -XXX,XX +XXX,XX @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile) |
13 | qemu_mutex_destroy(&s->mutex); | 26 | static void log_func(enum fuse_log_level level, const char *fmt, va_list ap) |
14 | g_free(s->cookie); | 27 | { |
15 | g_free(s->url); | 28 | g_autofree char *localfmt = NULL; |
16 | + g_free(s->username); | 29 | + char buf[64]; |
17 | + g_free(s->proxyusername); | 30 | |
18 | + g_free(s->proxypassword); | 31 | if (current_log_level < level) { |
19 | qemu_opts_del(opts); | 32 | return; |
20 | return -EINVAL; | 33 | @@ -XXX,XX +XXX,XX @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap) |
21 | } | 34 | fmt); |
22 | @@ -XXX,XX +XXX,XX @@ static void curl_close(BlockDriverState *bs) | 35 | } else { |
23 | 36 | g_autoptr(GDateTime) now = g_date_time_new_now_utc(); | |
24 | g_free(s->cookie); | 37 | - g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z"); |
25 | g_free(s->url); | 38 | + g_autofree char *nowstr = g_date_time_format(now, |
26 | + g_free(s->username); | 39 | + "%Y-%m-%d %H:%M:%S.%%06d%z"); |
27 | + g_free(s->proxyusername); | 40 | + snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now)); |
28 | + g_free(s->proxypassword); | 41 | localfmt = g_strdup_printf("[%s] [ID: %08ld] %s", |
29 | } | 42 | - nowstr, syscall(__NR_gettid), fmt); |
30 | 43 | + buf, syscall(__NR_gettid), fmt); | |
31 | static int64_t curl_getlength(BlockDriverState *bs) | 44 | } |
45 | fmt = localfmt; | ||
46 | } | ||
32 | -- | 47 | -- |
33 | 2.9.5 | 48 | 2.37.3 |
34 | |||
35 | diff view generated by jsdifflib |