Update format for readdir_pos

We now track each parent dir's next readdir pos and the readdir pos of
each dirent.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-01-25 11:17:30 -08:00
parent 38c8a4901f
commit 52291b2c75
3 changed files with 10 additions and 4 deletions

View File

@@ -380,6 +380,7 @@ struct scoutfs_inode {
__le64 blocks;
__le64 link_counter;
__le64 data_version;
__le64 next_readdir_pos;
__le32 nlink;
__le32 uid;
__le32 gid;
@@ -403,6 +404,7 @@ struct scoutfs_inode {
struct scoutfs_dirent {
__le64 ino;
__le64 counter;
__le64 readdir_pos;
__u8 type;
__u8 name[0];
} __packed;
@@ -435,6 +437,7 @@ struct scoutfs_dirent {
#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_FIRST_POS 2
#define SCOUTFS_DIRENT_LAST_POS (INT_MAX - 1)
enum {

View File

@@ -180,7 +180,8 @@ static int write_new_fs(char *path, int fd)
*ikey = root_ikey;
inode->nlink = cpu_to_le32(2);
inode->next_readdir_pos = cpu_to_le64(2);
inode->nlink = cpu_to_le32(SCOUTFS_DIRENT_FIRST_POS);
inode->mode = cpu_to_le32(0755 | 0040000);
inode->atime.sec = cpu_to_le64(tv.tv_sec);
inode->atime.nsec = cpu_to_le32(tv.tv_usec * 1000);

View File

@@ -85,7 +85,7 @@ static void print_inode(void *key, int key_len, void *val, int val_len)
printf(" inode: ino %llu size %llu blocks %llu lctr %llu nlink %u\n"
" uid %u gid %u mode 0%o rdev 0x%x\n"
" salt 0x%x data_version %llu\n"
" salt 0x%x next_readdir_pos %llu data_version %llu\n"
" atime %llu.%08u ctime %llu.%08u\n"
" mtime %llu.%08u\n",
be64_to_cpu(ikey->ino),
@@ -94,6 +94,7 @@ static void print_inode(void *key, int key_len, void *val, int val_len)
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),
le64_to_cpu(inode->next_readdir_pos),
le64_to_cpu(inode->data_version),
le64_to_cpu(inode->atime.sec),
le32_to_cpu(inode->atime.nsec),
@@ -149,9 +150,10 @@ static void print_dirent(void *key, int key_len, void *val, int val_len)
unsigned int name_len = key_len - sizeof(*dkey);
u8 *name = global_printable_name(dkey->name, name_len);
printf(" dirent: dir ino %llu type %u targ ino %llu\n"
printf(" dirent: dir ino %llu type %u rdpos %llu targ ino %llu\n"
" name %s\n",
be64_to_cpu(dkey->ino), dent->type, le64_to_cpu(dent->ino),
be64_to_cpu(dkey->ino), dent->type,
le64_to_cpu(dent->readdir_pos), le64_to_cpu(dent->ino),
name);
}