mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-09 05:13:18 +00:00
Add support for printing block map items
Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -100,7 +100,7 @@ struct scoutfs_key {
|
||||
#define SCOUTFS_INODE_KEY 1
|
||||
#define SCOUTFS_XATTR_KEY 2
|
||||
#define SCOUTFS_DIRENT_KEY 3
|
||||
#define SCOUTFS_DATA_KEY 4
|
||||
#define SCOUTFS_BMAP_KEY 4
|
||||
|
||||
#define SCOUTFS_MAX_ITEM_LEN 512
|
||||
|
||||
@@ -244,4 +244,22 @@ struct scoutfs_xattr {
|
||||
__u8 name[0];
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* We use simple block map items to map a aligned fixed group of logical
|
||||
* block offsets to physical blocks. We make them a decent size to
|
||||
* reduce the item storage overhead per block referenced, but we don't
|
||||
* want them so large that they start to take up an extraordinary amount
|
||||
* of space for small files. 8 block items ranges from around 3% to .3%
|
||||
* overhead for files that use only one or all of the blocks in the
|
||||
* mapping item.
|
||||
*/
|
||||
#define SCOUTFS_BLOCK_MAP_SHIFT 3
|
||||
#define SCOUTFS_BLOCK_MAP_COUNT (1 << SCOUTFS_BLOCK_MAP_SHIFT)
|
||||
#define SCOUTFS_BLOCK_MAP_MASK (SCOUTFS_BLOCK_MAP_COUNT - 1)
|
||||
|
||||
struct scoutfs_block_map {
|
||||
__le32 crc[SCOUTFS_BLOCK_MAP_COUNT];
|
||||
__le64 blkno[SCOUTFS_BLOCK_MAP_COUNT];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -89,6 +89,17 @@ static void print_dirent(struct scoutfs_dirent *dent, unsigned int val_len)
|
||||
le64_to_cpu(dent->ino), dent->type, i, name);
|
||||
}
|
||||
|
||||
static void print_block_map(struct scoutfs_block_map *map)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf(" bmap:");
|
||||
for (i = 0; i < SCOUTFS_BLOCK_MAP_COUNT; i++)
|
||||
printf(" [%u] %llu",
|
||||
i, le64_to_cpu(map->blkno[i]));
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void print_block_ref(struct scoutfs_block_ref *ref)
|
||||
{
|
||||
printf(" ref: blkno %llu seq %llu\n",
|
||||
@@ -110,6 +121,9 @@ static void print_btree_val(struct scoutfs_btree_item *item, u8 level)
|
||||
case SCOUTFS_DIRENT_KEY:
|
||||
print_dirent((void *)item->val, le16_to_cpu(item->val_len));
|
||||
break;
|
||||
case SCOUTFS_BMAP_KEY:
|
||||
print_block_map((void *)item->val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user