diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-18 16:15:28 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-18 16:15:28 -0400 |
commit | a429e51371eee3c989160c003ee40bc3947c6a76 (patch) | |
tree | 863b55de8823be579264260a51407cd90aac103d /fs/btrfs/ctree.h | |
parent | 70b2befd0c8a4064715d8b340270650cc9d15af8 (diff) |
Btrfs: working file_write, reorganized key flags
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d75a4d5bc010..8a329d3901a2 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -282,11 +282,12 @@ struct btrfs_root { | |||
282 | 282 | ||
283 | /* the lower bits in the key flags defines the item type */ | 283 | /* the lower bits in the key flags defines the item type */ |
284 | #define BTRFS_KEY_TYPE_MAX 256 | 284 | #define BTRFS_KEY_TYPE_MAX 256 |
285 | #define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1) | 285 | #define BTRFS_KEY_TYPE_SHIFT 24 |
286 | #define BTRFS_KEY_TYPE_MASK (((u32)BTRFS_KEY_TYPE_MAX - 1) << \ | ||
287 | BTRFS_KEY_TYPE_SHIFT) | ||
286 | 288 | ||
287 | #define BTRFS_KEY_OVERFLOW_MAX 128 | 289 | #define BTRFS_KEY_OVERFLOW_MAX 128 |
288 | #define BTRFS_KEY_OVERFLOW_SHIFT 8 | 290 | #define BTRFS_KEY_OVERFLOW_MASK ((u32)BTRFS_KEY_OVERFLOW_MAX - 1) |
289 | #define BTRFS_KEY_OVERFLOW_MASK (0x7FULL << BTRFS_KEY_OVERFLOW_SHIFT) | ||
290 | 291 | ||
291 | /* | 292 | /* |
292 | * inode items have the data typically returned from stat and store other | 293 | * inode items have the data typically returned from stat and store other |
@@ -586,56 +587,55 @@ static inline void btrfs_set_disk_key_flags(struct btrfs_disk_key *disk, | |||
586 | disk->flags = cpu_to_le32(val); | 587 | disk->flags = cpu_to_le32(val); |
587 | } | 588 | } |
588 | 589 | ||
589 | static inline u32 btrfs_key_overflow(struct btrfs_key *key) | 590 | static inline u32 btrfs_disk_key_type(struct btrfs_disk_key *key) |
590 | { | 591 | { |
591 | u32 over = key->flags & BTRFS_KEY_OVERFLOW_MASK; | 592 | return le32_to_cpu(key->flags) >> BTRFS_KEY_TYPE_SHIFT; |
592 | return over >> BTRFS_KEY_OVERFLOW_SHIFT; | ||
593 | } | 593 | } |
594 | 594 | ||
595 | static inline void btrfs_set_key_overflow(struct btrfs_key *key, u32 over) | 595 | static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, |
596 | u32 val) | ||
596 | { | 597 | { |
597 | BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX); | 598 | u32 flags = btrfs_disk_key_flags(key); |
598 | over = over << BTRFS_KEY_OVERFLOW_SHIFT; | 599 | BUG_ON(val >= BTRFS_KEY_TYPE_MAX); |
599 | key->flags = (key->flags & ~((u64)BTRFS_KEY_OVERFLOW_MASK)) | over; | 600 | val = val << BTRFS_KEY_TYPE_SHIFT; |
601 | flags = (flags & ~BTRFS_KEY_TYPE_MASK) | val; | ||
602 | btrfs_set_disk_key_flags(key, flags); | ||
600 | } | 603 | } |
601 | 604 | ||
602 | static inline u32 btrfs_key_type(struct btrfs_key *key) | 605 | static inline u32 btrfs_key_type(struct btrfs_key *key) |
603 | { | 606 | { |
604 | return key->flags & BTRFS_KEY_TYPE_MASK; | 607 | return key->flags >> BTRFS_KEY_TYPE_SHIFT; |
605 | } | 608 | } |
606 | 609 | ||
607 | static inline u32 btrfs_disk_key_type(struct btrfs_disk_key *key) | 610 | static inline void btrfs_set_key_type(struct btrfs_key *key, u32 val) |
608 | { | 611 | { |
609 | return le32_to_cpu(key->flags) & BTRFS_KEY_TYPE_MASK; | 612 | BUG_ON(val >= BTRFS_KEY_TYPE_MAX); |
613 | val = val << BTRFS_KEY_TYPE_SHIFT; | ||
614 | key->flags = (key->flags & ~(BTRFS_KEY_TYPE_MASK)) | val; | ||
610 | } | 615 | } |
611 | 616 | ||
612 | static inline void btrfs_set_key_type(struct btrfs_key *key, u32 type) | 617 | static inline u32 btrfs_key_overflow(struct btrfs_key *key) |
613 | { | 618 | { |
614 | BUG_ON(type >= BTRFS_KEY_TYPE_MAX); | 619 | return key->flags & BTRFS_KEY_OVERFLOW_MASK; |
615 | key->flags = (key->flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type; | ||
616 | } | 620 | } |
617 | 621 | ||
618 | static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u32 type) | 622 | static inline void btrfs_set_key_overflow(struct btrfs_key *key, u32 over) |
619 | { | 623 | { |
620 | u32 flags = btrfs_disk_key_flags(key); | 624 | BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX); |
621 | BUG_ON(type >= BTRFS_KEY_TYPE_MAX); | 625 | key->flags = (key->flags & ~BTRFS_KEY_OVERFLOW_MASK) | over; |
622 | flags = (flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type; | ||
623 | btrfs_set_disk_key_flags(key, flags); | ||
624 | } | 626 | } |
625 | 627 | ||
626 | static inline u32 btrfs_disk_key_overflow(struct btrfs_disk_key *key) | 628 | static inline u32 btrfs_disk_key_overflow(struct btrfs_disk_key *key) |
627 | { | 629 | { |
628 | u32 over = le32_to_cpu(key->flags) & BTRFS_KEY_OVERFLOW_MASK; | 630 | return le32_to_cpu(key->flags) & BTRFS_KEY_OVERFLOW_MASK; |
629 | return over >> BTRFS_KEY_OVERFLOW_SHIFT; | ||
630 | } | 631 | } |
631 | 632 | ||
632 | static inline void btrfs_set_disK_key_overflow(struct btrfs_disk_key *key, | 633 | static inline void btrfs_set_disk_key_overflow(struct btrfs_disk_key *key, |
633 | u32 over) | 634 | u32 over) |
634 | { | 635 | { |
635 | u32 flags = btrfs_disk_key_flags(key); | 636 | u32 flags = btrfs_disk_key_flags(key); |
636 | BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX); | 637 | BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX); |
637 | over = over << BTRFS_KEY_OVERFLOW_SHIFT; | 638 | flags = (flags & ~BTRFS_KEY_OVERFLOW_MASK) | over; |
638 | flags = (flags & ~((u64)BTRFS_KEY_OVERFLOW_MASK)) | over; | ||
639 | btrfs_set_disk_key_flags(key, flags); | 639 | btrfs_set_disk_key_flags(key, flags); |
640 | } | 640 | } |
641 | 641 | ||