sys/vfs/hammer: Use MIN/MAX macros for B-Tree node's elm base
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 11 Oct 2016 14:40:45 +0000 (23:40 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 12 Oct 2016 13:56:41 +0000 (22:56 +0900)
Leave obj_type with 0 instead of using HAMMER_OBJTYPE_UNKNOWN,
since it's not intended to be unknown, but literally intended
to be a value of 0.

sbin/hammer/cmd_show.c
sbin/hammer/misc.c
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_object.c
sys/vfs/hammer/hammer_vfsops.c
sys/vfs/hammer/hammer_vnops.c

index 9629377..6a52226 100644 (file)
@@ -319,11 +319,11 @@ is_root_btree_beg(uint8_t type, int i, hammer_btree_elm_t elm)
        return (type == HAMMER_BTREE_TYPE_INTERNAL &&
                i == 0 &&
                elm->base.localization == 0 &&
-               elm->base.obj_id == (int64_t)-0x8000000000000000LL &&
-               elm->base.key == (int64_t)-0x8000000000000000LL &&
+               elm->base.obj_id == (int64_t)HAMMER_MIN_OBJID &&
+               elm->base.key == (int64_t)HAMMER_MIN_KEY &&
                elm->base.create_tid == 1 &&
                elm->base.delete_tid == 1 &&
-               elm->base.rec_type == 0 &&
+               elm->base.rec_type == HAMMER_MIN_RECTYPE &&
                elm->base.obj_type == 0 &&
                elm->base.btype != HAMMER_BTREE_TYPE_NONE);
 }
@@ -335,11 +335,11 @@ is_root_btree_end(uint8_t type, int i, hammer_btree_elm_t elm)
        return (type == HAMMER_BTREE_TYPE_INTERNAL &&
                i != 0 &&
                elm->base.localization == 0xFFFFFFFFU &&
-               elm->base.obj_id == 0x7FFFFFFFFFFFFFFFLL &&
-               elm->base.key == 0x7FFFFFFFFFFFFFFFLL &&
-               elm->base.create_tid == 0xFFFFFFFFFFFFFFFFULL &&
+               elm->base.obj_id == HAMMER_MAX_OBJID &&
+               elm->base.key == HAMMER_MAX_KEY &&
+               elm->base.create_tid == HAMMER_MAX_TID &&
                elm->base.delete_tid == 0 &&
-               elm->base.rec_type == 0xFFFFU &&
+               elm->base.rec_type == HAMMER_MAX_RECTYPE &&
                elm->base.obj_type == 0 &&
                elm->base.btype == HAMMER_BTREE_TYPE_NONE);
 }
index 47980c9..df664cb 100644 (file)
@@ -46,6 +46,7 @@ hammer_key_beg_init(hammer_base_elm_t base)
        base->key = HAMMER_MIN_KEY;
        base->create_tid = 1;
        base->rec_type = HAMMER_MIN_RECTYPE;
+       base->obj_type = 0;
 }
 
 void
@@ -58,6 +59,7 @@ hammer_key_end_init(hammer_base_elm_t base)
        base->key = HAMMER_MAX_KEY;
        base->create_tid = HAMMER_MAX_TID;
        base->rec_type = HAMMER_MAX_RECTYPE;
+       base->obj_type = 0;
 }
 
 int
index 220fbc6..e7c565e 100644 (file)
@@ -3013,7 +3013,7 @@ hammer_sync_inode(hammer_transaction_t trans, hammer_inode_t ip)
                 */
                error = hammer_ip_delete_range(&cursor, ip,
                                                aligned_trunc_off,
-                                               0x7FFFFFFFFFFFFFFFLL, 2);
+                                               HAMMER_MAX_KEY, 2);
                if (error == EWOULDBLOCK) {
                        ip->flags |= HAMMER_INODE_WOULDBLOCK;
                        error = 0;
index cc7d05d..a81abeb 100644 (file)
@@ -1988,7 +1988,7 @@ retry:
        } else {
                tmp64 = ran_end + MAXPHYS + 1;  /* work around GCC-4 bug */
                if (tmp64 < ran_end)
-                       cursor->key_end.key = 0x7FFFFFFFFFFFFFFFLL;
+                       cursor->key_end.key = HAMMER_MAX_KEY;
                else
                        cursor->key_end.key = ran_end + MAXPHYS + 1;
        }
index 90e081a..8c01e01 100644 (file)
@@ -453,20 +453,20 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data,
                kmalloc_raise_limit(hmp->m_inodes, 0);  /* unlimited */
 
                hmp->root_btree_beg.localization = 0x00000000U;
-               hmp->root_btree_beg.obj_id = -0x8000000000000000LL;
-               hmp->root_btree_beg.key = -0x8000000000000000LL;
+               hmp->root_btree_beg.obj_id = HAMMER_MIN_OBJID;
+               hmp->root_btree_beg.key = HAMMER_MIN_KEY;
                hmp->root_btree_beg.create_tid = 1;
                hmp->root_btree_beg.delete_tid = 1;
-               hmp->root_btree_beg.rec_type = 0;
+               hmp->root_btree_beg.rec_type = HAMMER_MIN_RECTYPE;
                hmp->root_btree_beg.obj_type = 0;
                hmp->root_btree_beg.btype = HAMMER_BTREE_TYPE_NONE;
 
                hmp->root_btree_end.localization = 0xFFFFFFFFU;
-               hmp->root_btree_end.obj_id = 0x7FFFFFFFFFFFFFFFLL;
-               hmp->root_btree_end.key = 0x7FFFFFFFFFFFFFFFLL;
-               hmp->root_btree_end.create_tid = 0xFFFFFFFFFFFFFFFFULL;
+               hmp->root_btree_end.obj_id = HAMMER_MAX_OBJID;
+               hmp->root_btree_end.key = HAMMER_MAX_KEY;
+               hmp->root_btree_end.create_tid = HAMMER_MAX_TID;
                hmp->root_btree_end.delete_tid = 0;   /* special case */
-               hmp->root_btree_end.rec_type = 0xFFFFU;
+               hmp->root_btree_end.rec_type = HAMMER_MAX_RECTYPE;
                hmp->root_btree_end.obj_type = 0;
                hmp->root_btree_end.btype = HAMMER_BTREE_TYPE_NONE;
 
index 4e6d03b..5a6696f 100644 (file)
@@ -2724,7 +2724,7 @@ hammer_vop_strategy_read(struct vop_strategy_args *ap)
        if (ip->ino_data.obj_type == HAMMER_OBJTYPE_DBFILE) {
                cursor.key_beg.rec_type = HAMMER_RECTYPE_DB;
                cursor.key_end.rec_type = HAMMER_RECTYPE_DB;
-               cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
+               cursor.key_end.key = HAMMER_MAX_KEY;
        } else
 #endif
        {
@@ -2733,7 +2733,7 @@ hammer_vop_strategy_read(struct vop_strategy_args *ap)
                cursor.key_end.rec_type = HAMMER_RECTYPE_DATA;
                tmp64 = ran_end + MAXPHYS + 1;  /* work-around GCC-4 bug */
                if (tmp64 < ran_end)
-                       cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
+                       cursor.key_end.key = HAMMER_MAX_KEY;
                else
                        cursor.key_end.key = ran_end + MAXPHYS + 1;
        }
@@ -3045,7 +3045,7 @@ hammer_vop_bmap(struct vop_bmap_args *ap)
        cursor.key_end.rec_type = HAMMER_RECTYPE_DATA;
        tmp64 = ran_end + MAXPHYS + 1;  /* work-around GCC-4 bug */
        if (tmp64 < ran_end)
-               cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
+               cursor.key_end.key = HAMMER_MAX_KEY;
        else
                cursor.key_end.key = ran_end + MAXPHYS + 1;