sys/vfs/hammer: Try to fix hammer_ioc_pfs_iterate() [1/2]
- The ioctl HAMMERIOC_PFS_ITERATE added in commit
29d31c2d has
several design issues. This commit and the next one try to fix
them. Since it's been exposed to userspace, some of them are
left as it is with comments.
- The name hammer_ioc_pfs_iterate::pos (pi->pos) is misleading.
It should have been 'pfs_id'. Users will have no idea what
the 'pos' is supposed to be.
- pi->pos is unsigned.
- Don't shift pi->pos (Don't ip localize pi->pos). Copy it to a
local variable and then shift that.
- cursor.key_end fields are necessary only when iterating btree.
This function has 'iterate' in its name but all it does is
a single btree lookup.
- Don't |= HAMMER_PFSD_DELETED with pi->head.flags. pi->head.flags
is for HAMMER_IOC_XXX macros, but not for ondisk pfs status
(it was lucky PFSD_DELETED does not conflict with those values).
Users get pfs status from cursor.data->pfsd.mirror_flags copied
to userspace. libhammer code that is based on this wrong flag
checking is fixed accordingly.
- Check if pi->ondisk is allocated.
- Copy ondisk pfs data regardless of ondisk pfs delete flag bit.
The delete flag doesn't mean the data is gone.