aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorAl Viro <viro@www.linux.org.uk>2005-05-01 11:59:19 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 11:59:19 -0400
commit6b9f5829e6e3af44f20c681e26524c637d4f82ff (patch)
tree2694220606477b9afc5a98d73f6980e334048c1f /include/linux
parentb8cc936f6295bba23513a49d858ea82f64982faf (diff)
[PATCH] reiserfs endianness: comp_short_keys() cleanup
comp_short_keys() massaged into sane form, which kills the last place where pointer to in_core_key (or any object containing such) would be cast to or from something else. At that point we are free to change layout of in_core_key - nothing depends on it anymore. So we drop the mess with union in there and simply use (unconditional) __u64 k_offset and __u8 k_type instead; places using in_core_key switched to those. That gives _far_ better code than current mess - on all platforms. Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk> Cc: <reiserfs-dev@namesys.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/reiserfs_fs.h49
1 files changed, 8 insertions, 41 deletions
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 2f7a34d636dd..d445b682ce00 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -433,23 +433,6 @@ static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset )
433# define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val)) 433# define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val))
434#endif 434#endif
435 435
436struct in_core_offset_v1 {
437 __u32 k_offset;
438 __u32 k_uniqueness;
439} __attribute__ ((__packed__));
440
441struct in_core_offset_v2 {
442#ifdef __LITTLE_ENDIAN
443 /* little endian version */
444 __u64 k_offset:60;
445 __u64 k_type: 4;
446#else
447 /* big endian version */
448 __u64 k_type: 4;
449 __u64 k_offset:60;
450#endif
451} __attribute__ ((__packed__));
452
453/* Key of an item determines its location in the S+tree, and 436/* Key of an item determines its location in the S+tree, and
454 is composed of 4 components */ 437 is composed of 4 components */
455struct reiserfs_key { 438struct reiserfs_key {
@@ -466,11 +449,9 @@ struct in_core_key {
466 __u32 k_dir_id; /* packing locality: by default parent 449 __u32 k_dir_id; /* packing locality: by default parent
467 directory object id */ 450 directory object id */
468 __u32 k_objectid; /* object identifier */ 451 __u32 k_objectid; /* object identifier */
469 union { 452 __u64 k_offset;
470 struct in_core_offset_v1 k_offset_v1; 453 __u8 k_type;
471 struct in_core_offset_v2 k_offset_v2; 454};
472 } __attribute__ ((__packed__)) u;
473} __attribute__ ((__packed__));
474 455
475struct cpu_key { 456struct cpu_key {
476 struct in_core_key on_disk_key; 457 struct in_core_key on_disk_key;
@@ -696,43 +677,29 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type)
696// 677//
697static inline loff_t cpu_key_k_offset (const struct cpu_key * key) 678static inline loff_t cpu_key_k_offset (const struct cpu_key * key)
698{ 679{
699 return (key->version == KEY_FORMAT_3_5) ? 680 return key->on_disk_key.k_offset;
700 key->on_disk_key.u.k_offset_v1.k_offset :
701 key->on_disk_key.u.k_offset_v2.k_offset;
702} 681}
703 682
704static inline loff_t cpu_key_k_type (const struct cpu_key * key) 683static inline loff_t cpu_key_k_type (const struct cpu_key * key)
705{ 684{
706 return (key->version == KEY_FORMAT_3_5) ? 685 return key->on_disk_key.k_type;
707 uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) :
708 key->on_disk_key.u.k_offset_v2.k_type;
709} 686}
710 687
711static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset) 688static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset)
712{ 689{
713 (key->version == KEY_FORMAT_3_5) ? 690 key->on_disk_key.k_offset = offset;
714 (key->on_disk_key.u.k_offset_v1.k_offset = offset) :
715 (key->on_disk_key.u.k_offset_v2.k_offset = offset);
716} 691}
717 692
718
719static inline void set_cpu_key_k_type (struct cpu_key * key, int type) 693static inline void set_cpu_key_k_type (struct cpu_key * key, int type)
720{ 694{
721 (key->version == KEY_FORMAT_3_5) ? 695 key->on_disk_key.k_type = type;
722 (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)):
723 (key->on_disk_key.u.k_offset_v2.k_type = type);
724} 696}
725 697
726
727static inline void cpu_key_k_offset_dec (struct cpu_key * key) 698static inline void cpu_key_k_offset_dec (struct cpu_key * key)
728{ 699{
729 if (key->version == KEY_FORMAT_3_5) 700 key->on_disk_key.k_offset --;
730 key->on_disk_key.u.k_offset_v1.k_offset --;
731 else
732 key->on_disk_key.u.k_offset_v2.k_offset --;
733} 701}
734 702
735
736#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY) 703#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
737#define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT) 704#define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT)
738#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT) 705#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)