diff --git a/utils/src/format.h b/utils/src/format.h index c88462eb..611cd7a2 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -113,7 +113,7 @@ struct scoutfs_key { #define SCOUTFS_DIRENT_KEY 5 #define SCOUTFS_LINK_BACKREF_KEY 6 #define SCOUTFS_SYMLINK_KEY 7 -#define SCOUTFS_BMAP_KEY 8 +#define SCOUTFS_EXTENT_KEY 8 #define SCOUTFS_ORPHAN_KEY 9 #define SCOUTFS_MAX_ITEM_LEN 512 @@ -259,11 +259,8 @@ struct scoutfs_dirent { #define SCOUTFS_NAME_LEN 255 -/* - * Just to keep sloppy (int) apps from being confused. 2^31 is good - * enough for everybody. - */ -#define SCOUTFS_LINK_MAX (1 << 31) +/* S32_MAX avoids the (int) sign bit and might avoid sloppy bugs */ +#define SCOUTFS_LINK_MAX S32_MAX /* * We only use 31 bits for readdir positions so that we don't confuse @@ -296,23 +293,13 @@ 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_file_extent { + __le64 blkno; + __le64 len; + __u8 flags; +} __packed; -struct scoutfs_block_map { - __le64 blkno[SCOUTFS_BLOCK_MAP_COUNT]; - __le64 seq[SCOUTFS_BLOCK_MAP_COUNT]; -}; +#define SCOUTFS_EXTENT_FLAG_OFFLINE (1 << 0) /* * link backrefs give us a way to find all the hard links that refer diff --git a/utils/src/print.c b/utils/src/print.c index 66f64fea..91655582 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -122,16 +122,16 @@ static void print_symlink(char *str, unsigned int val_len) printf(" symlink: %.*s\n", val_len, str); } -static void print_block_map(struct scoutfs_block_map *map) -{ - int i; +#define EXT_FLAG(f, flags, str) \ + (flags & f) ? str : "", (flags & (f - 1)) ? "|" : "" - printf(" bmap:"); - for (i = 0; i < SCOUTFS_BLOCK_MAP_COUNT; i++) - printf(" [%u] %llu:%llu", - i, le64_to_cpu(map->blkno[i]), - le64_to_cpu(map->seq[i])); - printf("\n"); +static void print_extent(struct scoutfs_key *key, + struct scoutfs_file_extent *ext) +{ + printf(" extent: (offest %llu) blkno %llu, len %llu flags %s%s\n", + le64_to_cpu(key->offset), le64_to_cpu(ext->blkno), + le64_to_cpu(ext->len), + EXT_FLAG(SCOUTFS_EXTENT_FLAG_OFFLINE, ext->flags, "OFF")); } static void print_block_ref(struct scoutfs_block_ref *ref) @@ -168,8 +168,8 @@ static void print_btree_val(struct scoutfs_btree_item *item, u8 level) case SCOUTFS_SYMLINK_KEY: print_symlink((void *)item->val, le16_to_cpu(item->val_len)); break; - case SCOUTFS_BMAP_KEY: - print_block_map((void *)item->val); + case SCOUTFS_EXTENT_KEY: + print_extent(&item->key, (void *)item->val); break; } }