sbin/newfs_hammer: Properly set ondisk localization value
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 26 Feb 2015 11:36:42 +0000 (20:36 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 26 Feb 2015 17:38:10 +0000 (02:38 +0900)
- Make hammer_newfs properly set ondisk localization for the first
  two elements (for root inode and PFS) of the root node.

- HAMMER does cursor lookup using sum of onmemory ip(inode) localization
  and localization type, so in this case hammer_newfs needs to write
  ondisk bits using (HAMMER_DEF_LOCALIZATION + type) instead of just
  a type (see hammer_get_inode() and hammer_load_pseudofs() for details).

- It makes no binary difference since HAMMER_DEF_LOCALIZATION is 0,
  however it should be fixed for the consistency (e.g. if the macro
  happens to be defined differently, although it is not likely as it
  forces ondisk layout change).

sbin/newfs_hammer/newfs_hammer.c

index f0a3920..6065baf 100644 (file)
@@ -655,7 +655,8 @@ format_root(const char *label)
 
        elm = &bnode->elms[0];
        elm->leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       elm->leaf.base.localization = HAMMER_LOCALIZE_INODE;
+       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION +
+                                     HAMMER_LOCALIZE_INODE;
        elm->leaf.base.obj_id = HAMMER_OBJID_ROOT;
        elm->leaf.base.key = 0;
        elm->leaf.base.create_tid = create_tid;
@@ -670,7 +671,8 @@ format_root(const char *label)
 
        elm = &bnode->elms[1];
        elm->leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       elm->leaf.base.localization = HAMMER_LOCALIZE_MISC;
+       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION +
+                                     HAMMER_LOCALIZE_MISC;
        elm->leaf.base.obj_id = HAMMER_OBJID_ROOT;
        elm->leaf.base.key = 0;
        elm->leaf.base.create_tid = create_tid;