sys/vfs/hammer: Try to fix hammer_ioc_pfs_iterate() [1/2]
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 15 Apr 2015 14:21:38 +0000 (23:21 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 18 Apr 2015 11:26:57 +0000 (20:26 +0900)
commitd8c56f70efa21a3b3ee7e17377a6cf0f7e040134
tree37c1cfd2b8b6f492dd5e6fcb66baab4d6a2e2170
parent764d0c8c7a2e13ccf8e3819cee3ee1db4c81acd6
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.
lib/libhammer/info.c
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_ioctl.h