Submit #2771 ยป 0002-sys-vfs-hammer-make-hammer_blockmap_lookup-lightweig.patch
sys/vfs/hammer/hammer.h | ||
---|---|---|
hammer_off_t zone_offset, int bytes);
|
||
int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t zone_offset,
|
||
int *curp, int *errorp);
|
||
hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t zone_offset,
|
||
int *errorp);
|
||
hammer_off_t hammer_blockmap_lookup_verify(hammer_mount_t hmp,
|
||
hammer_off_t zone_offset, int *errorp);
|
||
hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t zone3_off,
|
||
int *errorp);
|
||
int64_t hammer_undo_used(hammer_transaction_t trans);
|
||
... | ... | |
}
|
||
hammer_modify_buffer_done(node->buffer);
|
||
}
|
||
/*
|
||
* Translate a zone address to zone-2 address.
|
||
*/
|
||
#define hammer_xlate_to_zone2(offset) \
|
||
((offset & ~HAMMER_OFF_ZONE_MASK) | HAMMER_ZONE_RAW_BUFFER)
|
||
/*
|
||
* Lookup a blockmap offset.
|
||
*/
|
||
static __inline hammer_off_t
|
||
hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t zone_offset,
|
||
int *errorp)
|
||
{
|
||
int zone = HAMMER_ZONE_DECODE(zone_offset);
|
||
KKASSERT(zone >= HAMMER_ZONE_BTREE_INDEX && zone < HAMMER_MAX_ZONES);
|
||
/*
|
||
* We can actually skip blockmap verify by default,
|
||
* as normal blockmaps are now direct-mapped onto the freemap
|
||
* and so represent zone-2 addresses.
|
||
*/
|
||
if (hammer_verify_zone == 0) {
|
||
*errorp = 0;
|
||
return hammer_xlate_to_zone2(zone_offset);
|
||
}
|
||
return hammer_blockmap_lookup_verify(hmp, zone_offset, errorp);
|
||
}
|
||
#endif
|
||
#define hammer_modify_volume_field(trans, vol, field) \
|
sys/vfs/hammer/hammer_blockmap.c | ||
---|---|---|
/*
|
||
* Lookup a blockmap offset.
|
||
* Lookup a blockmap offset and verify blockmap layers.
|
||
*/
|
||
hammer_off_t
|
||
hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t zone_offset,
|
||
int *errorp)
|
||
hammer_blockmap_lookup_verify(hammer_mount_t hmp, hammer_off_t zone_offset,
|
||
int *errorp)
|
||
{
|
||
hammer_volume_t root_volume;
|
||
hammer_blockmap_t freemap;
|
||
... | ... | |
* Calculate the zone-2 offset.
|
||
*/
|
||
zone = HAMMER_ZONE_DECODE(zone_offset);
|
||
KKASSERT(zone >= HAMMER_ZONE_BTREE_INDEX && zone < HAMMER_MAX_ZONES);
|
||
result_offset = (zone_offset & ~HAMMER_OFF_ZONE_MASK) |
|
||
HAMMER_ZONE_RAW_BUFFER;
|
||
/*
|
||
* We can actually stop here, normal blockmaps are now direct-mapped
|
||
* onto the freemap and so represent zone-2 addresses.
|
||
*/
|
||
if (hammer_verify_zone == 0) {
|
||
*errorp = 0;
|
||
return(result_offset);
|
||
}
|
||
result_offset = hammer_xlate_to_zone2(zone_offset);
|
||
/*
|
||
* Validate the allocation zone
|
||
... | ... | |
KKASSERT(resv && resv->zone == zone);
|
||
} else if (layer2->zone != zone) {
|
||
panic("hammer_blockmap_lookup: bad zone %d/%d",
|
||
panic("hammer_blockmap_lookup_verify: bad zone %d/%d",
|
||
layer2->zone, zone);
|
||
}
|
||
if (layer2->entry_crc != crc32(layer2, HAMMER_LAYER2_CRCSIZE)) {
|
||
... | ... | |
hammer_rel_buffer(buffer, 0);
|
||
hammer_rel_volume(root_volume, 0);
|
||
if (hammer_debug_general & 0x0800) {
|
||
kprintf("hammer_blockmap_lookup: %016llx -> %016llx\n",
|
||
kprintf("hammer_blockmap_lookup_verify: %016llx -> %016llx\n",
|
||
(long long)zone_offset, (long long)result_offset);
|
||
}
|
||
return(result_offset);
|