Commit 4f4274af7009890f0d4724909bf9038193955489
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason: "Filipe is nailing down some problems with our skinny extent variation, and Dave's patch fixes endian problems in the new super block checks" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: Btrfs: fix race that makes btrfs_lookup_extent_info miss skinny extent items Btrfs: properly clean up btrfs_end_io_wq_cache Btrfs: fix invalid leaf slot access in btrfs_lookup_extent() btrfs: use macro accessors in superblock validation checks
Showing 5 changed files Side-by-side Diff
fs/btrfs/ctree.h
... | ... | @@ -3276,7 +3276,7 @@ |
3276 | 3276 | struct btrfs_root *root, unsigned long count); |
3277 | 3277 | int btrfs_async_run_delayed_refs(struct btrfs_root *root, |
3278 | 3278 | unsigned long count, int wait); |
3279 | -int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); | |
3279 | +int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len); | |
3280 | 3280 | int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, |
3281 | 3281 | struct btrfs_root *root, u64 bytenr, |
3282 | 3282 | u64 offset, int metadata, u64 *refs, u64 *flags); |
fs/btrfs/disk-io.c
... | ... | @@ -3817,19 +3817,19 @@ |
3817 | 3817 | struct btrfs_super_block *sb = fs_info->super_copy; |
3818 | 3818 | int ret = 0; |
3819 | 3819 | |
3820 | - if (sb->root_level > BTRFS_MAX_LEVEL) { | |
3821 | - printk(KERN_ERR "BTRFS: tree_root level too big: %d > %d\n", | |
3822 | - sb->root_level, BTRFS_MAX_LEVEL); | |
3820 | + if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) { | |
3821 | + printk(KERN_ERR "BTRFS: tree_root level too big: %d >= %d\n", | |
3822 | + btrfs_super_root_level(sb), BTRFS_MAX_LEVEL); | |
3823 | 3823 | ret = -EINVAL; |
3824 | 3824 | } |
3825 | - if (sb->chunk_root_level > BTRFS_MAX_LEVEL) { | |
3826 | - printk(KERN_ERR "BTRFS: chunk_root level too big: %d > %d\n", | |
3827 | - sb->chunk_root_level, BTRFS_MAX_LEVEL); | |
3825 | + if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) { | |
3826 | + printk(KERN_ERR "BTRFS: chunk_root level too big: %d >= %d\n", | |
3827 | + btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL); | |
3828 | 3828 | ret = -EINVAL; |
3829 | 3829 | } |
3830 | - if (sb->log_root_level > BTRFS_MAX_LEVEL) { | |
3831 | - printk(KERN_ERR "BTRFS: log_root level too big: %d > %d\n", | |
3832 | - sb->log_root_level, BTRFS_MAX_LEVEL); | |
3830 | + if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) { | |
3831 | + printk(KERN_ERR "BTRFS: log_root level too big: %d >= %d\n", | |
3832 | + btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL); | |
3833 | 3833 | ret = -EINVAL; |
3834 | 3834 | } |
3835 | 3835 | |
3836 | 3836 | |
3837 | 3837 | |
3838 | 3838 | |
... | ... | @@ -3837,15 +3837,15 @@ |
3837 | 3837 | * The common minimum, we don't know if we can trust the nodesize/sectorsize |
3838 | 3838 | * items yet, they'll be verified later. Issue just a warning. |
3839 | 3839 | */ |
3840 | - if (!IS_ALIGNED(sb->root, 4096)) | |
3840 | + if (!IS_ALIGNED(btrfs_super_root(sb), 4096)) | |
3841 | 3841 | printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", |
3842 | 3842 | sb->root); |
3843 | - if (!IS_ALIGNED(sb->chunk_root, 4096)) | |
3843 | + if (!IS_ALIGNED(btrfs_super_chunk_root(sb), 4096)) | |
3844 | 3844 | printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", |
3845 | 3845 | sb->chunk_root); |
3846 | - if (!IS_ALIGNED(sb->log_root, 4096)) | |
3846 | + if (!IS_ALIGNED(btrfs_super_log_root(sb), 4096)) | |
3847 | 3847 | printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", |
3848 | - sb->log_root); | |
3848 | + btrfs_super_log_root(sb)); | |
3849 | 3849 | |
3850 | 3850 | if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { |
3851 | 3851 | printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n", |
3852 | 3852 | |
3853 | 3853 | |
3854 | 3854 | |
... | ... | @@ -3857,13 +3857,13 @@ |
3857 | 3857 | * Hint to catch really bogus numbers, bitflips or so, more exact checks are |
3858 | 3858 | * done later |
3859 | 3859 | */ |
3860 | - if (sb->num_devices > (1UL << 31)) | |
3860 | + if (btrfs_super_num_devices(sb) > (1UL << 31)) | |
3861 | 3861 | printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", |
3862 | - sb->num_devices); | |
3862 | + btrfs_super_num_devices(sb)); | |
3863 | 3863 | |
3864 | - if (sb->bytenr != BTRFS_SUPER_INFO_OFFSET) { | |
3864 | + if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) { | |
3865 | 3865 | printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n", |
3866 | - sb->bytenr, BTRFS_SUPER_INFO_OFFSET); | |
3866 | + btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET); | |
3867 | 3867 | ret = -EINVAL; |
3868 | 3868 | } |
3869 | 3869 | |
3870 | 3870 | |
3871 | 3871 | |
... | ... | @@ -3871,14 +3871,15 @@ |
3871 | 3871 | * The generation is a global counter, we'll trust it more than the others |
3872 | 3872 | * but it's still possible that it's the one that's wrong. |
3873 | 3873 | */ |
3874 | - if (sb->generation < sb->chunk_root_generation) | |
3874 | + if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb)) | |
3875 | 3875 | printk(KERN_WARNING |
3876 | 3876 | "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n", |
3877 | - sb->generation, sb->chunk_root_generation); | |
3878 | - if (sb->generation < sb->cache_generation && sb->cache_generation != (u64)-1) | |
3877 | + btrfs_super_generation(sb), btrfs_super_chunk_root_generation(sb)); | |
3878 | + if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb) | |
3879 | + && btrfs_super_cache_generation(sb) != (u64)-1) | |
3879 | 3880 | printk(KERN_WARNING |
3880 | 3881 | "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n", |
3881 | - sb->generation, sb->cache_generation); | |
3882 | + btrfs_super_generation(sb), btrfs_super_cache_generation(sb)); | |
3882 | 3883 | |
3883 | 3884 | return ret; |
3884 | 3885 | } |
fs/btrfs/extent-tree.c
... | ... | @@ -710,8 +710,8 @@ |
710 | 710 | rcu_read_unlock(); |
711 | 711 | } |
712 | 712 | |
713 | -/* simple helper to search for an existing extent at a given offset */ | |
714 | -int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len) | |
713 | +/* simple helper to search for an existing data extent at a given offset */ | |
714 | +int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len) | |
715 | 715 | { |
716 | 716 | int ret; |
717 | 717 | struct btrfs_key key; |
... | ... | @@ -726,12 +726,6 @@ |
726 | 726 | key.type = BTRFS_EXTENT_ITEM_KEY; |
727 | 727 | ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path, |
728 | 728 | 0, 0); |
729 | - if (ret > 0) { | |
730 | - btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); | |
731 | - if (key.objectid == start && | |
732 | - key.type == BTRFS_METADATA_ITEM_KEY) | |
733 | - ret = 0; | |
734 | - } | |
735 | 729 | btrfs_free_path(path); |
736 | 730 | return ret; |
737 | 731 | } |
... | ... | @@ -786,7 +780,6 @@ |
786 | 780 | else |
787 | 781 | key.type = BTRFS_EXTENT_ITEM_KEY; |
788 | 782 | |
789 | -again: | |
790 | 783 | ret = btrfs_search_slot(trans, root->fs_info->extent_root, |
791 | 784 | &key, path, 0, 0); |
792 | 785 | if (ret < 0) |
... | ... | @@ -801,13 +794,6 @@ |
801 | 794 | key.type == BTRFS_EXTENT_ITEM_KEY && |
802 | 795 | key.offset == root->nodesize) |
803 | 796 | ret = 0; |
804 | - } | |
805 | - if (ret) { | |
806 | - key.objectid = bytenr; | |
807 | - key.type = BTRFS_EXTENT_ITEM_KEY; | |
808 | - key.offset = root->nodesize; | |
809 | - btrfs_release_path(path); | |
810 | - goto again; | |
811 | 797 | } |
812 | 798 | } |
813 | 799 |
fs/btrfs/super.c
fs/btrfs/tree-log.c
... | ... | @@ -672,7 +672,7 @@ |
672 | 672 | * is this extent already allocated in the extent |
673 | 673 | * allocation tree? If so, just add a reference |
674 | 674 | */ |
675 | - ret = btrfs_lookup_extent(root, ins.objectid, | |
675 | + ret = btrfs_lookup_data_extent(root, ins.objectid, | |
676 | 676 | ins.offset); |
677 | 677 | if (ret == 0) { |
678 | 678 | ret = btrfs_inc_extent_ref(trans, root, |