158
158
h.id_str_size = cpu_to_be16(id_str_size);
159
159
h.name_size = cpu_to_be16(name_size);
160
160
offset = align_offset(offset, 8);
161
if (bdrv_pwrite(s->hd, offset, &h, sizeof(h)) != sizeof(h))
161
if (bdrv_pwrite_sync(s->hd, offset, &h, sizeof(h)) < 0)
163
163
offset += sizeof(h);
164
if (bdrv_pwrite(s->hd, offset, sn->id_str, id_str_size) != id_str_size)
164
if (bdrv_pwrite_sync(s->hd, offset, sn->id_str, id_str_size) < 0)
166
166
offset += id_str_size;
167
if (bdrv_pwrite(s->hd, offset, sn->name, name_size) != name_size)
167
if (bdrv_pwrite_sync(s->hd, offset, sn->name, name_size) < 0)
169
169
offset += name_size;
172
172
/* update the various header fields */
173
173
data64 = cpu_to_be64(snapshots_offset);
174
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, snapshots_offset),
175
&data64, sizeof(data64)) != sizeof(data64))
174
if (bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, snapshots_offset),
175
&data64, sizeof(data64)) < 0)
177
177
data32 = cpu_to_be32(s->nb_snapshots);
178
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, nb_snapshots),
179
&data32, sizeof(data32)) != sizeof(data32))
178
if (bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, nb_snapshots),
179
&data32, sizeof(data32)) < 0)
182
182
/* free the old snapshot table */
284
284
for(i = 0; i < s->l1_size; i++) {
285
285
l1_table[i] = cpu_to_be64(s->l1_table[i]);
287
if (bdrv_pwrite(s->hd, sn->l1_table_offset,
288
l1_table, s->l1_size * sizeof(uint64_t)) !=
289
(s->l1_size * sizeof(uint64_t)))
287
if (bdrv_pwrite_sync(s->hd, sn->l1_table_offset,
288
l1_table, s->l1_size * sizeof(uint64_t)) < 0)
291
290
qemu_free(l1_table);
335
334
if (bdrv_pread(s->hd, sn->l1_table_offset,
336
335
s->l1_table, l1_size2) != l1_size2)
338
if (bdrv_pwrite(s->hd, s->l1_table_offset,
339
s->l1_table, l1_size2) != l1_size2)
337
if (bdrv_pwrite_sync(s->hd, s->l1_table_offset,
338
s->l1_table, l1_size2) < 0)
341
340
for(i = 0;i < s->l1_size; i++) {
342
341
be64_to_cpus(&s->l1_table[i]);