fix(vhd-lib/VhdDirectory/mergeBlock): write BAT on block creation (#6300)

This commit is contained in:
Florent BEAUCHAMP
2022-08-31 15:35:10 +02:00
committed by GitHub
parent 2cb5169b6d
commit 7883d38622
3 changed files with 9 additions and 0 deletions

View File

@@ -30,6 +30,7 @@
<!--packages-start-->
- @xen-orchestra/fs minor
- vhd-lib patch
- xo-server minor
- xo-web minor

View File

@@ -6,6 +6,7 @@ const { fuFooter, fuHeader, checksumStruct } = require('../_structs')
const { test, set: setBitmap } = require('../_bitmap')
const { VhdAbstract } = require('./VhdAbstract')
const assert = require('assert')
const { synchronized } = require('decorator-synchronized')
const promisify = require('promise-toolbox/promisify')
const zlib = require('zlib')
@@ -131,6 +132,7 @@ exports.VhdDirectory = class VhdDirectory extends VhdAbstract {
this._path = path
this._opts = opts
this.#compressor = getCompressor(opts?.compression)
this.writeBlockAllocationTable = synchronized()(this.writeBlockAllocationTable)
}
async readBlockAllocationTable() {
@@ -259,7 +261,12 @@ exports.VhdDirectory = class VhdDirectory extends VhdAbstract {
return super.mergeBlock(child, blockId)
}
try {
const blockExists = this.containsBlock(blockId)
await this._handler.rename(childBlockPath, this._getFullBlockPath(blockId))
if (!blockExists) {
setBitmap(this.#blockTable, blockId)
await this.writeBlockAllocationTable()
}
} catch (error) {
if (error.code === 'ENOENT' && isResumingMerge === true) {
// when resuming, the blocks moved since the last merge state write are

View File

@@ -21,6 +21,7 @@
"@xen-orchestra/fs": "^3.0.0",
"@xen-orchestra/log": "^0.3.0",
"async-iterator-to-stream": "^1.0.2",
"decorator-synchronized": "^0.6.0",
"fs-extra": "^10.0.0",
"limit-concurrency-decorator": "^0.5.0",
"lodash": "^4.17.4",