From e1c1c50ead2924df294c8db711fbb67184d8116a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 24 Mar 2016 21:09:51 -0700 Subject: [PATCH] Update to multiple dirent hash format Update print to show the inode fields in the newer dirent hashing scheme. mkfs doesn't create directory entries. Signed-off-by: Zach Brown --- utils/src/format.h | 33 +++++++++++++++------------------ utils/src/print.c | 2 ++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/utils/src/format.h b/utils/src/format.h index efdfa6b9..989592e3 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -183,8 +183,8 @@ struct scoutfs_skip_root { } __packed; /* - * An item block follows the bloom filters blocks at the start of a log - * segment chunk. Its skip list root references the item structs which + * An item block follows the bloom filter blocks at the start of a log + * segment. Its skip root references the item structs which then * reference the item values in the rest of the block. The references * are byte offsets from the start of the chunk. */ @@ -225,6 +225,7 @@ struct scoutfs_inode { __le32 mode; __le32 rdev; __le32 salt; + __u8 max_dirent_hash_nr; struct scoutfs_timespec atime; struct scoutfs_timespec ctime; struct scoutfs_timespec mtime; @@ -238,17 +239,17 @@ struct scoutfs_inode { */ struct scoutfs_dirent { __le64 ino; -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u8 type:4, - coll_nr:4; -#else - __u8 coll_nr:4, - type:4; -#endif - __u8 name_len; + __u8 type; __u8 name[0]; } __packed; +/* + * The max number of dirent hash values determines the overhead of + * lookups in very large directories. With 31bit offsets the number + * of entries stored before enospc tends to plateau around 200 million + * entries around 8 functions. That seems OK for now. + */ +#define SCOUTFS_MAX_DENT_HASH_NR 8 #define SCOUTFS_NAME_LEN 255 /* @@ -257,14 +258,10 @@ struct scoutfs_dirent { * network protocols that have limited readir positions. */ -#define SCOUTFS_DIRENT_OFF_BITS 27 -#define SCOUTFS_DIRENT_OFF_MASK ((1 << SCOUTFS_DIRENT_OFF_BITS) - 1) -#define SCOUTFS_DIRENT_COLL_BITS 4 -#define SCOUTFS_DIRENT_COLL_MASK ((1 << SCOUTFS_DIRENT_COLL_BITS) - 1) - -/* getdents returns the *next* pos with each entry. so we can't return ~0 */ -#define SCOUTFS_DIRENT_MAX_POS \ - (((1 << (SCOUTFS_DIRENT_OFF_BITS + SCOUTFS_DIRENT_COLL_BITS)) - 1) - 1) +#define SCOUTFS_DIRENT_OFF_BITS 31 +#define SCOUTFS_DIRENT_OFF_MASK ((1U << SCOUTFS_DIRENT_OFF_BITS) - 1) +/* getdents returns next pos with an entry, no entry at (f_pos)~0 */ +#define SCOUTFS_DIRENT_LAST_POS (INT_MAX - 1) enum { SCOUTFS_DT_FIFO = 0, diff --git a/utils/src/print.c b/utils/src/print.c index 0a174fce..f8dcf49e 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -123,6 +123,7 @@ static void print_inode(struct scoutfs_inode *inode) " mode: 0%o\n" " rdev: 0x%x\n" " salt: 0x%x\n" + " max_dirent_hash_nr: %u\n" " atime: %llu.%08u\n" " ctime: %llu.%08u\n" " mtime: %llu.%08u\n", @@ -130,6 +131,7 @@ static void print_inode(struct scoutfs_inode *inode) le32_to_cpu(inode->nlink), le32_to_cpu(inode->uid), le32_to_cpu(inode->gid), le32_to_cpu(inode->mode), le32_to_cpu(inode->rdev), le32_to_cpu(inode->salt), + inode->max_dirent_hash_nr, le64_to_cpu(inode->atime.sec), le32_to_cpu(inode->atime.nsec), le64_to_cpu(inode->ctime.sec),