sys/vfs/hammer: Use bitwise OR to generate ondisk localization
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 5 Dec 2015 07:32:38 +0000 (16:32 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 6 Dec 2015 16:41:39 +0000 (01:41 +0900)
Use |= to generate localization field for B-Tree elements and
cursor keys instead of +=, since lower 16 bits are bitfields
(or safer to treat INODE=0x1 and MISC=0x2 as bitfields).

The typical code to generate ondisk localization value is to
do either of the followings.

  ondisk_lo = local_variable          + {INODE or MISC};
  ondisk_lo = ip->obj_localization    + {INODE or MISC};
  ondisk_lo = HAMMER_XXX_LOCALIZATION + {INODE or MISC};
              ^^^^^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^
              (A)32 bits localization   (B)lower 16 bits
                 with usually 0 for
                 lower 16 bits for type

Adding (A) and (B) to synthesize PFS id and localization type
could lead to a potential bug if (A) already has type bits set
to either INODE or MISC. For example if (A) had INODE for type
bits and the code is to += INODE for (B), then type bits turn
into MISC (1+1=2) which is not the intention of the code.

This could potentially occur with the first example of above
three where (A) is a local variable or a function argument.
It is not too obvious from the code whether that local variable
has 0 for the lower 16 bits (which basically should be).
If the code just always uses |= no such thing will happen.

13 files changed:
sbin/newfs_hammer/newfs_hammer.c
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_btree.h
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_mirror.c
sys/vfs/hammer/hammer_object.c
sys/vfs/hammer/hammer_pfs.c
sys/vfs/hammer/hammer_prune.c
sys/vfs/hammer/hammer_rebalance.c
sys/vfs/hammer/hammer_reblock.c
sys/vfs/hammer/hammer_vfsops.c
sys/vfs/hammer/hammer_vnops.c

index 736bb02..5e7f30b 100644 (file)
@@ -628,7 +628,7 @@ format_root(const char *label)
 
        elm = &bnode->elms[0];
        elm->leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION +
+       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION |
                                      HAMMER_LOCALIZE_INODE;
        elm->leaf.base.obj_id = HAMMER_OBJID_ROOT;
        elm->leaf.base.key = 0;
@@ -644,7 +644,7 @@ format_root(const char *label)
 
        elm = &bnode->elms[1];
        elm->leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION +
+       elm->leaf.base.localization = HAMMER_DEF_LOCALIZATION |
                                      HAMMER_LOCALIZE_MISC;
        elm->leaf.base.obj_id = HAMMER_OBJID_ROOT;
        elm->leaf.base.key = 0;
index aeeb54b..ac951d2 100644 (file)
@@ -101,7 +101,7 @@ struct hammer_io;
 typedef struct hammer_inode_info {
        int64_t         obj_id;         /* (key) object identifier */
        hammer_tid_t    obj_asof;       /* (key) snapshot transid or 0 */
-       uint32_t        obj_localization; /* (key) pseudo-fs */
+       uint32_t        obj_localization; /* (key) pseudo-fs id for upper 16 bits */
        union {
                struct hammer_btree_leaf_elm *leaf;
        } u;
@@ -367,7 +367,7 @@ struct hammer_inode {
        struct hammer_record_list target_list;  /* target of dependant recs */
        int64_t                 obj_id;         /* (key) object identifier */
        hammer_tid_t            obj_asof;       /* (key) snapshot or 0 */
-       uint32_t                obj_localization; /* (key) pseudo-fs */
+       uint32_t                obj_localization; /* (key) pseudo-fs id for upper 16 bits */
        struct hammer_mount     *hmp;
        hammer_objid_cache_t    objid_cache;
        int                     flags;
index c589b15..3bdcdbd 100644 (file)
@@ -117,9 +117,14 @@ typedef struct hammer_base_elm *hammer_base_elm_t;
  *
  * Localization can also be used to create pseudo-filesystems within
  * a HAMMER filesystem.  Pseudo-filesystems would be suitable
- * replication targets.  Upper 16 bits of the localization field in
- * struct hammer_base_elm represents pseudo-filesystem id, and lower
- * 16 bits of this field represents its type (inode or misc).
+ * replication targets.
+ *
+ * Upper 16 bits of the localization field in struct hammer_base_elm
+ * represents pseudo-filesystem id ranging from default 0 to 65535,
+ * and lower 16 bits represents its localization type in bitfield
+ * where 0x1 means the element is for inode and 0x2 means the element
+ * is for anything other than inode.  Note that 0x3 (0x1|0x2) is not
+ * a valid type, while 0 and 0xFFFF are valid types for some cases.
  *
  * The root inode (not the PFS root inode but the real root) uses
  * HAMMER_DEF_LOCALIZATION for its incore ip->obj_localization.
index d03ead3..55f398e 100644 (file)
@@ -496,7 +496,7 @@ retry:
                        cachep = &dip->cache[0];
        }
        hammer_init_cursor(trans, &cursor, cachep, NULL);
-       cursor.key_beg.localization = localization + HAMMER_LOCALIZE_INODE;
+       cursor.key_beg.localization = localization | HAMMER_LOCALIZE_INODE;
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.key = 0;
        cursor.key_beg.create_tid = 0;
@@ -821,7 +821,7 @@ hammer_create_inode(hammer_transaction_t trans, struct vattr *vap,
        }
 
        ip->ino_leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       ip->ino_leaf.base.localization = ip->obj_localization +
+       ip->ino_leaf.base.localization = ip->obj_localization |
                                         HAMMER_LOCALIZE_INODE;
        ip->ino_leaf.base.obj_id = ip->obj_id;
        ip->ino_leaf.base.key = 0;
@@ -1008,7 +1008,7 @@ retry:
        pfsm->pfsd.shared_uuid = pfsm->pfsd.unique_uuid;
 
        hammer_init_cursor(trans, &cursor, (ip ? &ip->cache[1] : NULL), ip);
-       cursor.key_beg.localization = HAMMER_DEF_LOCALIZATION +
+       cursor.key_beg.localization = HAMMER_DEF_LOCALIZATION |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = HAMMER_OBJID_ROOT;
        cursor.key_beg.create_tid = 0;
@@ -1071,7 +1071,7 @@ hammer_save_pseudofs(hammer_transaction_t trans, hammer_pseudofs_inmem_t pfsm)
 retry:
        pfsm->fsid_udev = hammer_fsid_to_udev(&pfsm->pfsd.shared_uuid);
        hammer_init_cursor(trans, &cursor, &ip->cache[1], ip);
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = HAMMER_OBJID_ROOT;
        cursor.key_beg.create_tid = 0;
@@ -1107,7 +1107,7 @@ retry:
                record = hammer_alloc_mem_record(ip, sizeof(pfsm->pfsd));
                record->type = HAMMER_MEM_RECORD_GENERAL;
 
-               record->leaf.base.localization = ip->obj_localization +
+               record->leaf.base.localization = ip->obj_localization |
                                                 HAMMER_LOCALIZE_MISC;
                record->leaf.base.rec_type = HAMMER_RECTYPE_PFS;
                record->leaf.base.key = pfsm->localization;
@@ -1245,7 +1245,7 @@ retry:
        if ((ip->flags & (HAMMER_INODE_ONDISK|HAMMER_INODE_DELONDISK)) ==
            HAMMER_INODE_ONDISK) {
                hammer_normalize_cursor(cursor);
-               cursor->key_beg.localization = ip->obj_localization +
+               cursor->key_beg.localization = ip->obj_localization |
                                               HAMMER_LOCALIZE_INODE;
                cursor->key_beg.obj_id = ip->obj_id;
                cursor->key_beg.key = 0;
@@ -1415,7 +1415,7 @@ retry:
        }
 
        hammer_normalize_cursor(cursor);
-       cursor->key_beg.localization = ip->obj_localization +
+       cursor->key_beg.localization = ip->obj_localization |
                                       HAMMER_LOCALIZE_INODE;
        cursor->key_beg.obj_id = ip->obj_id;
        cursor->key_beg.key = 0;
index 5728302..a85fb67 100644 (file)
@@ -312,9 +312,9 @@ hammer_ioc_gethistory(hammer_transaction_t trans, hammer_inode_t ip,
                 */
                cursor.key_beg.key = hist->key;
                cursor.key_end.key = HAMMER_MAX_KEY;
-               cursor.key_beg.localization = ip->obj_localization +
+               cursor.key_beg.localization = ip->obj_localization |
                                              HAMMER_LOCALIZE_MISC;
-               cursor.key_end.localization = ip->obj_localization +
+               cursor.key_end.localization = ip->obj_localization |
                                              HAMMER_LOCALIZE_MISC;
 
                switch(ip->ino_data.obj_type) {
@@ -324,9 +324,9 @@ hammer_ioc_gethistory(hammer_transaction_t trans, hammer_inode_t ip,
                        break;
                case HAMMER_OBJTYPE_DIRECTORY:
                        cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
-                       cursor.key_beg.localization = ip->obj_localization +
+                       cursor.key_beg.localization = ip->obj_localization |
                                                hammer_dir_localization(ip);
-                       cursor.key_end.localization = ip->obj_localization +
+                       cursor.key_end.localization = ip->obj_localization |
                                                hammer_dir_localization(ip);
                        break;
                case HAMMER_OBJTYPE_DBFILE:
@@ -345,9 +345,9 @@ hammer_ioc_gethistory(hammer_transaction_t trans, hammer_inode_t ip,
                cursor.key_end.key = 0;
                cursor.key_beg.rec_type = HAMMER_RECTYPE_INODE;
                cursor.key_end.rec_type = HAMMER_RECTYPE_INODE;
-               cursor.key_beg.localization = ip->obj_localization +
+               cursor.key_beg.localization = ip->obj_localization |
                                              HAMMER_LOCALIZE_INODE;
-               cursor.key_end.localization = ip->obj_localization +
+               cursor.key_end.localization = ip->obj_localization |
                                              HAMMER_LOCALIZE_INODE;
        }
 
@@ -707,7 +707,7 @@ again:
        leaf.base.rec_type = HAMMER_RECTYPE_SNAPSHOT;
        leaf.base.create_tid = hammer_alloc_tid(hmp, 1);
        leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       leaf.base.localization = ip->obj_localization + HAMMER_LOCALIZE_INODE;
+       leaf.base.localization = ip->obj_localization | HAMMER_LOCALIZE_INODE;
        leaf.data_len = sizeof(struct hammer_snapshot_data);
 
        while (snap->index < snap->count) {
@@ -781,7 +781,7 @@ again:
        cursor.key_beg.delete_tid = 0;
        cursor.key_beg.obj_type = 0;
        cursor.key_beg.rec_type = HAMMER_RECTYPE_SNAPSHOT;
-       cursor.key_beg.localization = ip->obj_localization + HAMMER_LOCALIZE_INODE;
+       cursor.key_beg.localization = ip->obj_localization | HAMMER_LOCALIZE_INODE;
        cursor.asof = HAMMER_MAX_TID;
        cursor.flags |= HAMMER_CURSOR_ASOF;
 
@@ -850,7 +850,7 @@ hammer_ioc_get_snapshot(hammer_transaction_t trans, hammer_inode_t ip,
        cursor.key_beg.delete_tid = 0;
        cursor.key_beg.obj_type = 0;
        cursor.key_beg.rec_type = HAMMER_RECTYPE_SNAPSHOT;
-       cursor.key_beg.localization = ip->obj_localization + HAMMER_LOCALIZE_INODE;
+       cursor.key_beg.localization = ip->obj_localization | HAMMER_LOCALIZE_INODE;
        if (snap->count == 0)
                cursor.key_beg.key = HAMMER_MIN_KEY;
        else
@@ -932,7 +932,7 @@ hammer_ioc_get_config(hammer_transaction_t trans, hammer_inode_t ip,
        cursor.key_beg.delete_tid = 0;
        cursor.key_beg.obj_type = 0;
        cursor.key_beg.rec_type = HAMMER_RECTYPE_CONFIG;
-       cursor.key_beg.localization = ip->obj_localization + HAMMER_LOCALIZE_INODE;
+       cursor.key_beg.localization = ip->obj_localization | HAMMER_LOCALIZE_INODE;
        cursor.key_beg.key = 0;         /* config space page 0 */
 
        cursor.asof = HAMMER_MAX_TID;
@@ -979,7 +979,7 @@ again:
        leaf.base.rec_type = HAMMER_RECTYPE_CONFIG;
        leaf.base.create_tid = hammer_alloc_tid(hmp, 1);
        leaf.base.btype = HAMMER_BTREE_TYPE_RECORD;
-       leaf.base.localization = ip->obj_localization + HAMMER_LOCALIZE_INODE;
+       leaf.base.localization = ip->obj_localization | HAMMER_LOCALIZE_INODE;
        leaf.base.key = 0;      /* page 0 */
        leaf.data_len = sizeof(struct hammer_config_data);
 
index 90ad139..3c9eff7 100644 (file)
@@ -98,7 +98,7 @@ hammer_ioc_mirror_read(hammer_transaction_t trans, hammer_inode_t ip,
 
        mirror->key_cur = mirror->key_beg;
        mirror->key_cur.localization &= HAMMER_LOCALIZE_MASK;
-       mirror->key_cur.localization += localization;
+       mirror->key_cur.localization |= localization;
        bzero(&mrec, sizeof(mrec));
        bzero(&cmirror, sizeof(cmirror));
 
@@ -117,7 +117,7 @@ retry:
        cursor.key_beg = mirror->key_cur;
        cursor.key_end = mirror->key_end;
        cursor.key_end.localization &= HAMMER_LOCALIZE_MASK;
-       cursor.key_end.localization += localization;
+       cursor.key_end.localization |= localization;
 
        cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE;
        cursor.flags |= HAMMER_CURSOR_BACKEND;
@@ -353,11 +353,11 @@ hammer_ioc_mirror_write(hammer_transaction_t trans, hammer_inode_t ip,
        if (mirror->size < 0 || mirror->size > 0x70000000)
                return(EINVAL);
        mirror->key_beg.localization &= HAMMER_LOCALIZE_MASK;
-       mirror->key_beg.localization += localization;
+       mirror->key_beg.localization |= localization;
        mirror->key_end.localization &= HAMMER_LOCALIZE_MASK;
-       mirror->key_end.localization += localization;
+       mirror->key_end.localization |= localization;
        mirror->key_cur.localization &= HAMMER_LOCALIZE_MASK;
-       mirror->key_cur.localization += localization;
+       mirror->key_cur.localization |= localization;
 
        /*
         * Set up our tracking cursor for the loop.  The tracking cursor
@@ -524,9 +524,9 @@ hammer_ioc_mirror_write_skip(hammer_cursor_t cursor,
         * Relocalize the skip range
         */
        mrec->skip_beg.localization &= HAMMER_LOCALIZE_MASK;
-       mrec->skip_beg.localization += localization;
+       mrec->skip_beg.localization |= localization;
        mrec->skip_end.localization &= HAMMER_LOCALIZE_MASK;
-       mrec->skip_end.localization += localization;
+       mrec->skip_end.localization |= localization;
 
        /*
         * Iterate from current position to skip_beg, deleting any records
@@ -588,7 +588,7 @@ hammer_ioc_mirror_write_rec(hammer_cursor_t cursor,
         * by hammer_create_at_cursor().
         */
        mrec->leaf.base.localization &= HAMMER_LOCALIZE_MASK;
-       mrec->leaf.base.localization += localization;
+       mrec->leaf.base.localization |= localization;
 
        /*
         * Delete records through until we reach (non-inclusively) the
@@ -669,7 +669,7 @@ hammer_ioc_mirror_write_pass(hammer_cursor_t cursor,
         * by hammer_create_at_cursor().
         */
        mrec->leaf.base.localization &= HAMMER_LOCALIZE_MASK;
-       mrec->leaf.base.localization += localization;
+       mrec->leaf.base.localization |= localization;
 
        /*
         * Delete records through until we reach (non-inclusively) the
index f51e3d3..a1b171e 100644 (file)
@@ -670,7 +670,7 @@ hammer_ip_add_directory(struct hammer_transaction *trans,
        record = hammer_alloc_mem_record(dip, HAMMER_ENTRY_SIZE(bytes));
 
        record->type = HAMMER_MEM_RECORD_ADD;
-       record->leaf.base.localization = dip->obj_localization +
+       record->leaf.base.localization = dip->obj_localization |
                                         hammer_dir_localization(dip);
        record->leaf.base.obj_id = dip->obj_id;
        record->leaf.base.key = hammer_directory_namekey(dip, name, bytes,
@@ -1006,7 +1006,7 @@ nodedup:
        record->leaf.base.obj_type = ip->ino_leaf.base.obj_type;
        record->leaf.base.obj_id = ip->obj_id;
        record->leaf.base.key = file_offset + bytes;
-       record->leaf.base.localization = ip->obj_localization +
+       record->leaf.base.localization = ip->obj_localization |
                                         HAMMER_LOCALIZE_MISC;
        record->leaf.data_len = bytes;
        record->leaf.data_crc = crc;
@@ -1952,7 +1952,7 @@ hammer_ip_delete_range(hammer_cursor_t cursor, hammer_inode_t ip,
        KKASSERT(trans->type == HAMMER_TRANS_FLS);
 retry:
        hammer_normalize_cursor(cursor);
-       cursor->key_beg.localization = ip->obj_localization +
+       cursor->key_beg.localization = ip->obj_localization |
                                       HAMMER_LOCALIZE_MISC;
        cursor->key_beg.obj_id = ip->obj_id;
        cursor->key_beg.create_tid = 0;
@@ -2143,7 +2143,7 @@ hammer_ip_delete_clean(hammer_cursor_t cursor, hammer_inode_t ip, int *countp)
        KKASSERT(trans->type == HAMMER_TRANS_FLS);
 retry:
        hammer_normalize_cursor(cursor);
-       cursor->key_beg.localization = ip->obj_localization +
+       cursor->key_beg.localization = ip->obj_localization |
                                       HAMMER_LOCALIZE_MISC;
        cursor->key_beg.obj_id = ip->obj_id;
        cursor->key_beg.create_tid = 0;
@@ -2632,7 +2632,7 @@ hammer_ip_check_directory_empty(hammer_transaction_t trans, hammer_inode_t ip)
         */
        hammer_init_cursor(trans, &cursor, &ip->cache[1], ip);
 
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      hammer_dir_localization(ip);
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.create_tid = 0;
index 1e4fb73..cd6aa02 100644 (file)
@@ -353,7 +353,7 @@ hammer_ioc_iterate_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
        if (error)
                goto out;
 
-       cursor.key_beg.localization = HAMMER_DEF_LOCALIZATION +
+       cursor.key_beg.localization = HAMMER_DEF_LOCALIZATION |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = HAMMER_OBJID_ROOT;
        cursor.key_beg.create_tid = 0;
@@ -431,7 +431,7 @@ hammer_pfs_rollback(hammer_transaction_t trans,
 
        bzero(&cmirror, sizeof(cmirror));
        bzero(&key_cur, sizeof(key_cur));
-       key_cur.localization = HAMMER_MIN_LOCALIZATION + pfsm->localization;
+       key_cur.localization = HAMMER_MIN_LOCALIZATION | pfsm->localization;
        key_cur.obj_id = HAMMER_MIN_OBJID;
        key_cur.key = HAMMER_MIN_KEY;
        key_cur.create_tid = 1;
@@ -446,7 +446,7 @@ retry:
                goto failed;
        }
        cursor.key_beg = key_cur;
-       cursor.key_end.localization = HAMMER_MAX_LOCALIZATION +
+       cursor.key_end.localization = HAMMER_MAX_LOCALIZATION |
                                      pfsm->localization;
        cursor.key_end.obj_id = HAMMER_MAX_OBJID;
        cursor.key_end.key = HAMMER_MAX_KEY;
index a193965..14f1bda 100644 (file)
@@ -86,11 +86,11 @@ hammer_ioc_prune(hammer_transaction_t trans, hammer_inode_t ip,
         */
        key_beg_localization = prune->key_beg.localization;
        key_beg_localization &= HAMMER_LOCALIZE_MASK;
-       key_beg_localization += ip->obj_localization;
+       key_beg_localization |= ip->obj_localization;
 
        prune->key_cur.localization = prune->key_end.localization;
        prune->key_cur.localization &= HAMMER_LOCALIZE_MASK;
-       prune->key_cur.localization += ip->obj_localization;
+       prune->key_cur.localization |= ip->obj_localization;
 
        prune->key_cur.obj_id = prune->key_end.obj_id;
        prune->key_cur.key = HAMMER_MAX_KEY;
index 5ba7af0..bebec59 100644 (file)
@@ -84,14 +84,14 @@ hammer_ioc_rebalance(hammer_transaction_t trans, hammer_inode_t ip,
        rebal->key_cur = rebal->key_beg;
        rebal->key_cur.localization &= HAMMER_LOCALIZE_MASK;
        if (rebal->allpfs == 0)
-               rebal->key_cur.localization += ip->obj_localization;
+               rebal->key_cur.localization |= ip->obj_localization;
 
        key_end_localization = rebal->key_end.localization;
        key_end_localization &= HAMMER_LOCALIZE_MASK;
        if (rebal->allpfs == 0)
-               key_end_localization += ip->obj_localization;
+               key_end_localization |= ip->obj_localization;
        else
-               key_end_localization += ((HAMMER_MAX_PFS - 1) << 16);
+               key_end_localization |= ((HAMMER_MAX_PFS - 1) << 16);
 
        hammer_btree_lcache_init(trans->hmp, &lcache, 2);
 
index 1c838e2..f0f4915 100644 (file)
@@ -93,14 +93,14 @@ hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
        reblock->key_cur = reblock->key_beg;
        reblock->key_cur.localization &= HAMMER_LOCALIZE_MASK;
        if (reblock->allpfs == 0)
-               reblock->key_cur.localization += ip->obj_localization;
+               reblock->key_cur.localization |= ip->obj_localization;
 
        key_end_localization = reblock->key_end.localization;
        key_end_localization &= HAMMER_LOCALIZE_MASK;
        if (reblock->allpfs == 0)
-               key_end_localization += ip->obj_localization;
+               key_end_localization |= ip->obj_localization;
        else
-               key_end_localization += ((HAMMER_MAX_PFS - 1) << 16);
+               key_end_localization |= ((HAMMER_MAX_PFS - 1) << 16);
 
        checkspace_count = 0;
        seq = trans->hmp->flusher.done;
index e784d07..e022c48 100644 (file)
@@ -995,7 +995,7 @@ hammer_vfs_vget(struct mount *mp, struct vnode *dvp,
         * inodes in the root PFS.
         */
        if (dvp) {
-               localization = HAMMER_DEF_LOCALIZATION +
+               localization = HAMMER_DEF_LOCALIZATION |
                                VTOI(dvp)->obj_localization;
        } else {
                localization = HAMMER_DEF_LOCALIZATION;
index 9ce2674..bc4a75d 100644 (file)
@@ -1205,7 +1205,7 @@ hammer_vop_nresolve(struct vop_nresolve_args *ap)
                                           &max_iterations);
 
        error = hammer_init_cursor(&trans, &cursor, &dip->cache[1], dip);
-       cursor.key_beg.localization = dip->obj_localization +
+       cursor.key_beg.localization = dip->obj_localization |
                                      hammer_dir_localization(dip);
         cursor.key_beg.obj_id = dip->obj_id;
        cursor.key_beg.key = namekey;
@@ -1696,7 +1696,7 @@ hammer_vop_readdir(struct vop_readdir_args *ap)
         * directly translate to a 64 bit 'seek' position.
         */
        hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      hammer_dir_localization(ip);
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.create_tid = 0;
@@ -1855,7 +1855,7 @@ hammer_vop_readlink(struct vop_readlink_args *ap)
         * Key range (begin and end inclusive) to scan.  Directory keys
         * directly translate to a 64 bit 'seek' position.
         */
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.create_tid = 0;
@@ -2001,7 +2001,7 @@ hammer_vop_nrename(struct vop_nrename_args *ap)
                                           &max_iterations);
 retry:
        hammer_init_cursor(&trans, &cursor, &fdip->cache[1], fdip);
-       cursor.key_beg.localization = fdip->obj_localization +
+       cursor.key_beg.localization = fdip->obj_localization |
                                      hammer_dir_localization(fdip);
         cursor.key_beg.obj_id = fdip->obj_id;
        cursor.key_beg.key = namekey;
@@ -2440,7 +2440,7 @@ hammer_vop_nsymlink(struct vop_nsymlink_args *ap)
                        record = hammer_alloc_mem_record(nip, bytes);
                        record->type = HAMMER_MEM_RECORD_GENERAL;
 
-                       record->leaf.base.localization = nip->obj_localization +
+                       record->leaf.base.localization = nip->obj_localization |
                                                         HAMMER_LOCALIZE_MISC;
                        record->leaf.base.key = HAMMER_FIXKEY_SYMLINK;
                        record->leaf.base.rec_type = HAMMER_RECTYPE_FIX;
@@ -2716,7 +2716,7 @@ hammer_vop_strategy_read(struct vop_strategy_args *ap)
         * stored in the actual records represent BASE+LEN, not BASE.  The
         * first record containing bio_offset will have a key > bio_offset.
         */
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.create_tid = 0;
@@ -3032,7 +3032,7 @@ hammer_vop_bmap(struct vop_bmap_args *ap)
         * stored in the actual records represent BASE+LEN, not BASE.  The
         * first record containing bio_offset will have a key > bio_offset.
         */
-       cursor.key_beg.localization = ip->obj_localization +
+       cursor.key_beg.localization = ip->obj_localization |
                                      HAMMER_LOCALIZE_MISC;
        cursor.key_beg.obj_id = ip->obj_id;
        cursor.key_beg.create_tid = 0;
@@ -3349,7 +3349,7 @@ hammer_dounlink(hammer_transaction_t trans, struct nchandle *nch,
                                           &max_iterations);
 retry:
        hammer_init_cursor(trans, &cursor, &dip->cache[1], dip);
-       cursor.key_beg.localization = dip->obj_localization +
+       cursor.key_beg.localization = dip->obj_localization |
                                      hammer_dir_localization(dip);
         cursor.key_beg.obj_id = dip->obj_id;
        cursor.key_beg.key = namekey;