Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on kdave/for-next] [also build test ERROR on v5.5 next-20200205] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/David-Sterba/btrfs-print-message-wh... base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next config: s390-randconfig-a001-20200206 (attached as .config) compiler: s390-linux-gcc (GCC) 7.5.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=7.5.0 make.cross ARCH=s390
If you fix the issue, kindly add following tag Reported-by: kbuild test robot lkp@intel.com
All errors (new ones prefixed by >>):
fs/btrfs/disk-io.c: In function 'open_ctree':
fs/btrfs/disk-io.c:3167:37: error: macro "btrfs_info" requires 3 arguments, but only 1 given
btrfs_info("start tree-log replay"); ^
fs/btrfs/disk-io.c:3167:3: error: 'btrfs_info' undeclared (first use in this function); did you mean 'btrfs_ino'?
btrfs_info("start tree-log replay"); ^~~~~~~~~~ btrfs_ino fs/btrfs/disk-io.c:3167:3: note: each undeclared identifier is reported only once for each function it appears in
vim +/btrfs_info +3167 fs/btrfs/disk-io.c
2626 2627 int __cold open_ctree(struct super_block *sb, 2628 struct btrfs_fs_devices *fs_devices, 2629 char *options) 2630 { 2631 u32 sectorsize; 2632 u32 nodesize; 2633 u32 stripesize; 2634 u64 generation; 2635 u64 features; 2636 u16 csum_type; 2637 struct btrfs_key location; 2638 struct buffer_head *bh; 2639 struct btrfs_super_block *disk_super; 2640 struct btrfs_fs_info *fs_info = btrfs_sb(sb); 2641 struct btrfs_root *tree_root; 2642 struct btrfs_root *chunk_root; 2643 int ret; 2644 int err = -EINVAL; 2645 int clear_free_space_tree = 0; 2646 int level; 2647 2648 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL); 2649 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info, GFP_KERNEL); 2650 if (!tree_root || !chunk_root) { 2651 err = -ENOMEM; 2652 goto fail; 2653 } 2654 2655 ret = init_srcu_struct(&fs_info->subvol_srcu); 2656 if (ret) { 2657 err = ret; 2658 goto fail; 2659 } 2660 2661 ret = percpu_counter_init(&fs_info->dio_bytes, 0, GFP_KERNEL); 2662 if (ret) { 2663 err = ret; 2664 goto fail_srcu; 2665 } 2666 2667 ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL); 2668 if (ret) { 2669 err = ret; 2670 goto fail_dio_bytes; 2671 } 2672 fs_info->dirty_metadata_batch = PAGE_SIZE * 2673 (1 + ilog2(nr_cpu_ids)); 2674 2675 ret = percpu_counter_init(&fs_info->delalloc_bytes, 0, GFP_KERNEL); 2676 if (ret) { 2677 err = ret; 2678 goto fail_dirty_metadata_bytes; 2679 } 2680 2681 ret = percpu_counter_init(&fs_info->dev_replace.bio_counter, 0, 2682 GFP_KERNEL); 2683 if (ret) { 2684 err = ret; 2685 goto fail_delalloc_bytes; 2686 } 2687 2688 INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); 2689 INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC); 2690 INIT_LIST_HEAD(&fs_info->trans_list); 2691 INIT_LIST_HEAD(&fs_info->dead_roots); 2692 INIT_LIST_HEAD(&fs_info->delayed_iputs); 2693 INIT_LIST_HEAD(&fs_info->delalloc_roots); 2694 INIT_LIST_HEAD(&fs_info->caching_block_groups); 2695 spin_lock_init(&fs_info->delalloc_root_lock); 2696 spin_lock_init(&fs_info->trans_lock); 2697 spin_lock_init(&fs_info->fs_roots_radix_lock); 2698 spin_lock_init(&fs_info->delayed_iput_lock); 2699 spin_lock_init(&fs_info->defrag_inodes_lock); 2700 spin_lock_init(&fs_info->super_lock); 2701 spin_lock_init(&fs_info->buffer_lock); 2702 spin_lock_init(&fs_info->unused_bgs_lock); 2703 rwlock_init(&fs_info->tree_mod_log_lock); 2704 mutex_init(&fs_info->unused_bg_unpin_mutex); 2705 mutex_init(&fs_info->delete_unused_bgs_mutex); 2706 mutex_init(&fs_info->reloc_mutex); 2707 mutex_init(&fs_info->delalloc_root_mutex); 2708 seqlock_init(&fs_info->profiles_lock); 2709 2710 INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots); 2711 INIT_LIST_HEAD(&fs_info->space_info); 2712 INIT_LIST_HEAD(&fs_info->tree_mod_seq_list); 2713 INIT_LIST_HEAD(&fs_info->unused_bgs); 2714 extent_map_tree_init(&fs_info->mapping_tree); 2715 btrfs_init_block_rsv(&fs_info->global_block_rsv, 2716 BTRFS_BLOCK_RSV_GLOBAL); 2717 btrfs_init_block_rsv(&fs_info->trans_block_rsv, BTRFS_BLOCK_RSV_TRANS); 2718 btrfs_init_block_rsv(&fs_info->chunk_block_rsv, BTRFS_BLOCK_RSV_CHUNK); 2719 btrfs_init_block_rsv(&fs_info->empty_block_rsv, BTRFS_BLOCK_RSV_EMPTY); 2720 btrfs_init_block_rsv(&fs_info->delayed_block_rsv, 2721 BTRFS_BLOCK_RSV_DELOPS); 2722 btrfs_init_block_rsv(&fs_info->delayed_refs_rsv, 2723 BTRFS_BLOCK_RSV_DELREFS); 2724 2725 atomic_set(&fs_info->async_delalloc_pages, 0); 2726 atomic_set(&fs_info->defrag_running, 0); 2727 atomic_set(&fs_info->reada_works_cnt, 0); 2728 atomic_set(&fs_info->nr_delayed_iputs, 0); 2729 atomic64_set(&fs_info->tree_mod_seq, 0); 2730 fs_info->sb = sb; 2731 fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE; 2732 fs_info->metadata_ratio = 0; 2733 fs_info->defrag_inodes = RB_ROOT; 2734 atomic64_set(&fs_info->free_chunk_space, 0); 2735 fs_info->tree_mod_log = RB_ROOT; 2736 fs_info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; 2737 fs_info->avg_delayed_ref_runtime = NSEC_PER_SEC >> 6; /* div by 64 */ 2738 /* readahead state */ 2739 INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); 2740 spin_lock_init(&fs_info->reada_lock); 2741 btrfs_init_ref_verify(fs_info); 2742 2743 fs_info->thread_pool_size = min_t(unsigned long, 2744 num_online_cpus() + 2, 8); 2745 2746 INIT_LIST_HEAD(&fs_info->ordered_roots); 2747 spin_lock_init(&fs_info->ordered_root_lock); 2748 2749 fs_info->btree_inode = new_inode(sb); 2750 if (!fs_info->btree_inode) { 2751 err = -ENOMEM; 2752 goto fail_bio_counter; 2753 } 2754 mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS); 2755 2756 fs_info->delayed_root = kmalloc(sizeof(struct btrfs_delayed_root), 2757 GFP_KERNEL); 2758 if (!fs_info->delayed_root) { 2759 err = -ENOMEM; 2760 goto fail_iput; 2761 } 2762 btrfs_init_delayed_root(fs_info->delayed_root); 2763 2764 btrfs_init_scrub(fs_info); 2765 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 2766 fs_info->check_integrity_print_mask = 0; 2767 #endif 2768 btrfs_init_balance(fs_info); 2769 btrfs_init_async_reclaim_work(&fs_info->async_reclaim_work); 2770 2771 sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE; 2772 sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE); 2773 2774 btrfs_init_btree_inode(fs_info); 2775 2776 spin_lock_init(&fs_info->block_group_cache_lock); 2777 fs_info->block_group_cache_tree = RB_ROOT; 2778 fs_info->first_logical_byte = (u64)-1; 2779 2780 extent_io_tree_init(fs_info, &fs_info->freed_extents[0], 2781 IO_TREE_FS_INFO_FREED_EXTENTS0, NULL); 2782 extent_io_tree_init(fs_info, &fs_info->freed_extents[1], 2783 IO_TREE_FS_INFO_FREED_EXTENTS1, NULL); 2784 fs_info->pinned_extents = &fs_info->freed_extents[0]; 2785 set_bit(BTRFS_FS_BARRIER, &fs_info->flags); 2786 2787 mutex_init(&fs_info->ordered_operations_mutex); 2788 mutex_init(&fs_info->tree_log_mutex); 2789 mutex_init(&fs_info->chunk_mutex); 2790 mutex_init(&fs_info->transaction_kthread_mutex); 2791 mutex_init(&fs_info->cleaner_mutex); 2792 mutex_init(&fs_info->ro_block_group_mutex); 2793 init_rwsem(&fs_info->commit_root_sem); 2794 init_rwsem(&fs_info->cleanup_work_sem); 2795 init_rwsem(&fs_info->subvol_sem); 2796 sema_init(&fs_info->uuid_tree_rescan_sem, 1); 2797 2798 btrfs_init_dev_replace_locks(fs_info); 2799 btrfs_init_qgroup(fs_info); 2800 btrfs_discard_init(fs_info); 2801 2802 btrfs_init_free_cluster(&fs_info->meta_alloc_cluster); 2803 btrfs_init_free_cluster(&fs_info->data_alloc_cluster); 2804 2805 init_waitqueue_head(&fs_info->transaction_throttle); 2806 init_waitqueue_head(&fs_info->transaction_wait); 2807 init_waitqueue_head(&fs_info->transaction_blocked_wait); 2808 init_waitqueue_head(&fs_info->async_submit_wait); 2809 init_waitqueue_head(&fs_info->delayed_iputs_wait); 2810 2811 /* Usable values until the real ones are cached from the superblock */ 2812 fs_info->nodesize = 4096; 2813 fs_info->sectorsize = 4096; 2814 fs_info->stripesize = 4096; 2815 2816 spin_lock_init(&fs_info->swapfile_pins_lock); 2817 fs_info->swapfile_pins = RB_ROOT; 2818 2819 fs_info->send_in_progress = 0; 2820 2821 ret = btrfs_alloc_stripe_hash_table(fs_info); 2822 if (ret) { 2823 err = ret; 2824 goto fail_alloc; 2825 } 2826 2827 __setup_root(tree_root, fs_info, BTRFS_ROOT_TREE_OBJECTID); 2828 2829 invalidate_bdev(fs_devices->latest_bdev); 2830 2831 /* 2832 * Read super block and check the signature bytes only 2833 */ 2834 bh = btrfs_read_dev_super(fs_devices->latest_bdev); 2835 if (IS_ERR(bh)) { 2836 err = PTR_ERR(bh); 2837 goto fail_alloc; 2838 } 2839 2840 /* 2841 * Verify the type first, if that or the the checksum value are 2842 * corrupted, we'll find out 2843 */ 2844 csum_type = btrfs_super_csum_type((struct btrfs_super_block *)bh->b_data); 2845 if (!btrfs_supported_super_csum(csum_type)) { 2846 btrfs_err(fs_info, "unsupported checksum algorithm: %u", 2847 csum_type); 2848 err = -EINVAL; 2849 brelse(bh); 2850 goto fail_alloc; 2851 } 2852 2853 ret = btrfs_init_csum_hash(fs_info, csum_type); 2854 if (ret) { 2855 err = ret; 2856 goto fail_alloc; 2857 } 2858 2859 /* 2860 * We want to check superblock checksum, the type is stored inside. 2861 * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). 2862 */ 2863 if (btrfs_check_super_csum(fs_info, bh->b_data)) { 2864 btrfs_err(fs_info, "superblock checksum mismatch"); 2865 err = -EINVAL; 2866 brelse(bh); 2867 goto fail_csum; 2868 } 2869 2870 /* 2871 * super_copy is zeroed at allocation time and we never touch the 2872 * following bytes up to INFO_SIZE, the checksum is calculated from 2873 * the whole block of INFO_SIZE 2874 */ 2875 memcpy(fs_info->super_copy, bh->b_data, sizeof(*fs_info->super_copy)); 2876 brelse(bh); 2877 2878 disk_super = fs_info->super_copy; 2879 2880 ASSERT(!memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, 2881 BTRFS_FSID_SIZE)); 2882 2883 if (btrfs_fs_incompat(fs_info, METADATA_UUID)) { 2884 ASSERT(!memcmp(fs_info->fs_devices->metadata_uuid, 2885 fs_info->super_copy->metadata_uuid, 2886 BTRFS_FSID_SIZE)); 2887 } 2888 2889 features = btrfs_super_flags(disk_super); 2890 if (features & BTRFS_SUPER_FLAG_CHANGING_FSID_V2) { 2891 features &= ~BTRFS_SUPER_FLAG_CHANGING_FSID_V2; 2892 btrfs_set_super_flags(disk_super, features); 2893 btrfs_info(fs_info, 2894 "found metadata UUID change in progress flag, clearing"); 2895 } 2896 2897 memcpy(fs_info->super_for_commit, fs_info->super_copy, 2898 sizeof(*fs_info->super_for_commit)); 2899 2900 ret = btrfs_validate_mount_super(fs_info); 2901 if (ret) { 2902 btrfs_err(fs_info, "superblock contains fatal errors"); 2903 err = -EINVAL; 2904 goto fail_csum; 2905 } 2906 2907 if (!btrfs_super_root(disk_super)) 2908 goto fail_csum; 2909 2910 /* check FS state, whether FS is broken. */ 2911 if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_ERROR) 2912 set_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state); 2913 2914 /* 2915 * In the long term, we'll store the compression type in the super 2916 * block, and it'll be used for per file compression control. 2917 */ 2918 fs_info->compress_type = BTRFS_COMPRESS_ZLIB; 2919 2920 ret = btrfs_parse_options(fs_info, options, sb->s_flags); 2921 if (ret) { 2922 err = ret; 2923 goto fail_csum; 2924 } 2925 2926 features = btrfs_super_incompat_flags(disk_super) & 2927 ~BTRFS_FEATURE_INCOMPAT_SUPP; 2928 if (features) { 2929 btrfs_err(fs_info, 2930 "cannot mount because of unsupported optional features (%llx)", 2931 features); 2932 err = -EINVAL; 2933 goto fail_csum; 2934 } 2935 2936 features = btrfs_super_incompat_flags(disk_super); 2937 features |= BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF; 2938 if (fs_info->compress_type == BTRFS_COMPRESS_LZO) 2939 features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO; 2940 else if (fs_info->compress_type == BTRFS_COMPRESS_ZSTD) 2941 features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD; 2942 2943 if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) 2944 btrfs_info(fs_info, "has skinny extents"); 2945 2946 /* 2947 * flag our filesystem as having big metadata blocks if 2948 * they are bigger than the page size 2949 */ 2950 if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { 2951 if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) 2952 btrfs_info(fs_info, 2953 "flagging fs with big metadata feature"); 2954 features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; 2955 } 2956 2957 nodesize = btrfs_super_nodesize(disk_super); 2958 sectorsize = btrfs_super_sectorsize(disk_super); 2959 stripesize = sectorsize; 2960 fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); 2961 fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); 2962 2963 /* Cache block sizes */ 2964 fs_info->nodesize = nodesize; 2965 fs_info->sectorsize = sectorsize; 2966 fs_info->stripesize = stripesize; 2967 2968 /* 2969 * mixed block groups end up with duplicate but slightly offset 2970 * extent buffers for the same range. It leads to corruptions 2971 */ 2972 if ((features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) && 2973 (sectorsize != nodesize)) { 2974 btrfs_err(fs_info, 2975 "unequal nodesize/sectorsize (%u != %u) are not allowed for mixed block groups", 2976 nodesize, sectorsize); 2977 goto fail_csum; 2978 } 2979 2980 /* 2981 * Needn't use the lock because there is no other task which will 2982 * update the flag. 2983 */ 2984 btrfs_set_super_incompat_flags(disk_super, features); 2985 2986 features = btrfs_super_compat_ro_flags(disk_super) & 2987 ~BTRFS_FEATURE_COMPAT_RO_SUPP; 2988 if (!sb_rdonly(sb) && features) { 2989 btrfs_err(fs_info, 2990 "cannot mount read-write because of unsupported optional features (%llx)", 2991 features); 2992 err = -EINVAL; 2993 goto fail_csum; 2994 } 2995 2996 ret = btrfs_init_workqueues(fs_info, fs_devices); 2997 if (ret) { 2998 err = ret; 2999 goto fail_sb_buffer; 3000 } 3001 3002 sb->s_bdi->congested_fn = btrfs_congested_fn; 3003 sb->s_bdi->congested_data = fs_info; 3004 sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK; 3005 sb->s_bdi->ra_pages = VM_READAHEAD_PAGES; 3006 sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super); 3007 sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE); 3008 3009 sb->s_blocksize = sectorsize; 3010 sb->s_blocksize_bits = blksize_bits(sectorsize); 3011 memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE); 3012 3013 mutex_lock(&fs_info->chunk_mutex); 3014 ret = btrfs_read_sys_array(fs_info); 3015 mutex_unlock(&fs_info->chunk_mutex); 3016 if (ret) { 3017 btrfs_err(fs_info, "failed to read the system array: %d", ret); 3018 goto fail_sb_buffer; 3019 } 3020 3021 generation = btrfs_super_chunk_root_generation(disk_super); 3022 level = btrfs_super_chunk_root_level(disk_super); 3023 3024 __setup_root(chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID); 3025 3026 chunk_root->node = read_tree_block(fs_info, 3027 btrfs_super_chunk_root(disk_super), 3028 generation, level, NULL); 3029 if (IS_ERR(chunk_root->node) || 3030 !extent_buffer_uptodate(chunk_root->node)) { 3031 btrfs_err(fs_info, "failed to read chunk root"); 3032 if (!IS_ERR(chunk_root->node)) 3033 free_extent_buffer(chunk_root->node); 3034 chunk_root->node = NULL; 3035 goto fail_tree_roots; 3036 } 3037 btrfs_set_root_node(&chunk_root->root_item, chunk_root->node); 3038 chunk_root->commit_root = btrfs_root_node(chunk_root); 3039 3040 read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid, 3041 btrfs_header_chunk_tree_uuid(chunk_root->node), BTRFS_UUID_SIZE); 3042 3043 ret = btrfs_read_chunk_tree(fs_info); 3044 if (ret) { 3045 btrfs_err(fs_info, "failed to read chunk tree: %d", ret); 3046 goto fail_tree_roots; 3047 } 3048 3049 /* 3050 * Keep the devid that is marked to be the target device for the 3051 * device replace procedure 3052 */ 3053 btrfs_free_extra_devids(fs_devices, 0); 3054 3055 if (!fs_devices->latest_bdev) { 3056 btrfs_err(fs_info, "failed to read devices"); 3057 goto fail_tree_roots; 3058 } 3059 3060 ret = init_tree_roots(fs_info); 3061 if (ret) 3062 goto fail_tree_roots; 3063 3064 ret = btrfs_verify_dev_extents(fs_info); 3065 if (ret) { 3066 btrfs_err(fs_info, 3067 "failed to verify dev extents against chunks: %d", 3068 ret); 3069 goto fail_block_groups; 3070 } 3071 ret = btrfs_recover_balance(fs_info); 3072 if (ret) { 3073 btrfs_err(fs_info, "failed to recover balance: %d", ret); 3074 goto fail_block_groups; 3075 } 3076 3077 ret = btrfs_init_dev_stats(fs_info); 3078 if (ret) { 3079 btrfs_err(fs_info, "failed to init dev_stats: %d", ret); 3080 goto fail_block_groups; 3081 } 3082 3083 ret = btrfs_init_dev_replace(fs_info); 3084 if (ret) { 3085 btrfs_err(fs_info, "failed to init dev_replace: %d", ret); 3086 goto fail_block_groups; 3087 } 3088 3089 btrfs_free_extra_devids(fs_devices, 1); 3090 3091 ret = btrfs_sysfs_add_fsid(fs_devices); 3092 if (ret) { 3093 btrfs_err(fs_info, "failed to init sysfs fsid interface: %d", 3094 ret); 3095 goto fail_block_groups; 3096 } 3097 3098 ret = btrfs_sysfs_add_mounted(fs_info); 3099 if (ret) { 3100 btrfs_err(fs_info, "failed to init sysfs interface: %d", ret); 3101 goto fail_fsdev_sysfs; 3102 } 3103 3104 ret = btrfs_init_space_info(fs_info); 3105 if (ret) { 3106 btrfs_err(fs_info, "failed to initialize space info: %d", ret); 3107 goto fail_sysfs; 3108 } 3109 3110 ret = btrfs_read_block_groups(fs_info); 3111 if (ret) { 3112 btrfs_err(fs_info, "failed to read block groups: %d", ret); 3113 goto fail_sysfs; 3114 } 3115 3116 if (!sb_rdonly(sb) && !btrfs_check_rw_degradable(fs_info, NULL)) { 3117 btrfs_warn(fs_info, 3118 "writable mount is not allowed due to too many missing devices"); 3119 goto fail_sysfs; 3120 } 3121 3122 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, 3123 "btrfs-cleaner"); 3124 if (IS_ERR(fs_info->cleaner_kthread)) 3125 goto fail_sysfs; 3126 3127 fs_info->transaction_kthread = kthread_run(transaction_kthread, 3128 tree_root, 3129 "btrfs-transaction"); 3130 if (IS_ERR(fs_info->transaction_kthread)) 3131 goto fail_cleaner; 3132 3133 if (!btrfs_test_opt(fs_info, NOSSD) && 3134 !fs_info->fs_devices->rotating) { 3135 btrfs_set_and_info(fs_info, SSD, "enabling ssd optimizations"); 3136 } 3137 3138 /* 3139 * Mount does not set all options immediately, we can do it now and do 3140 * not have to wait for transaction commit 3141 */ 3142 btrfs_apply_pending_changes(fs_info); 3143 3144 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 3145 if (btrfs_test_opt(fs_info, CHECK_INTEGRITY)) { 3146 ret = btrfsic_mount(fs_info, fs_devices, 3147 btrfs_test_opt(fs_info, 3148 CHECK_INTEGRITY_INCLUDING_EXTENT_DATA) ? 3149 1 : 0, 3150 fs_info->check_integrity_print_mask); 3151 if (ret) 3152 btrfs_warn(fs_info, 3153 "failed to initialize integrity check module: %d", 3154 ret); 3155 } 3156 #endif 3157 ret = btrfs_read_qgroup_config(fs_info); 3158 if (ret) 3159 goto fail_trans_kthread; 3160 3161 if (btrfs_build_ref_tree(fs_info)) 3162 btrfs_err(fs_info, "couldn't build ref tree"); 3163 3164 /* do not make disk changes in broken FS or nologreplay is given */ 3165 if (btrfs_super_log_root(disk_super) != 0 && 3166 !btrfs_test_opt(fs_info, NOLOGREPLAY)) {
3167 btrfs_info("start tree-log replay");
3168 ret = btrfs_replay_log(fs_info, fs_devices); 3169 if (ret) { 3170 err = ret; 3171 goto fail_qgroup; 3172 } 3173 } 3174 3175 ret = btrfs_find_orphan_roots(fs_info); 3176 if (ret) 3177 goto fail_qgroup; 3178 3179 if (!sb_rdonly(sb)) { 3180 ret = btrfs_cleanup_fs_roots(fs_info); 3181 if (ret) 3182 goto fail_qgroup; 3183 3184 mutex_lock(&fs_info->cleaner_mutex); 3185 ret = btrfs_recover_relocation(tree_root); 3186 mutex_unlock(&fs_info->cleaner_mutex); 3187 if (ret < 0) { 3188 btrfs_warn(fs_info, "failed to recover relocation: %d", 3189 ret); 3190 err = -EINVAL; 3191 goto fail_qgroup; 3192 } 3193 } 3194 3195 location.objectid = BTRFS_FS_TREE_OBJECTID; 3196 location.type = BTRFS_ROOT_ITEM_KEY; 3197 location.offset = 0; 3198 3199 fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location); 3200 if (IS_ERR(fs_info->fs_root)) { 3201 err = PTR_ERR(fs_info->fs_root); 3202 btrfs_warn(fs_info, "failed to read fs tree: %d", err); 3203 goto fail_qgroup; 3204 } 3205 3206 if (sb_rdonly(sb)) 3207 return 0; 3208 3209 if (btrfs_test_opt(fs_info, CLEAR_CACHE) && 3210 btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { 3211 clear_free_space_tree = 1; 3212 } else if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) && 3213 !btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID)) { 3214 btrfs_warn(fs_info, "free space tree is invalid"); 3215 clear_free_space_tree = 1; 3216 } 3217 3218 if (clear_free_space_tree) { 3219 btrfs_info(fs_info, "clearing free space tree"); 3220 ret = btrfs_clear_free_space_tree(fs_info); 3221 if (ret) { 3222 btrfs_warn(fs_info, 3223 "failed to clear free space tree: %d", ret); 3224 close_ctree(fs_info); 3225 return ret; 3226 } 3227 } 3228 3229 if (btrfs_test_opt(fs_info, FREE_SPACE_TREE) && 3230 !btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { 3231 btrfs_info(fs_info, "creating free space tree"); 3232 ret = btrfs_create_free_space_tree(fs_info); 3233 if (ret) { 3234 btrfs_warn(fs_info, 3235 "failed to create free space tree: %d", ret); 3236 close_ctree(fs_info); 3237 return ret; 3238 } 3239 } 3240 3241 down_read(&fs_info->cleanup_work_sem); 3242 if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) || 3243 (ret = btrfs_orphan_cleanup(fs_info->tree_root))) { 3244 up_read(&fs_info->cleanup_work_sem); 3245 close_ctree(fs_info); 3246 return ret; 3247 } 3248 up_read(&fs_info->cleanup_work_sem); 3249 3250 ret = btrfs_resume_balance_async(fs_info); 3251 if (ret) { 3252 btrfs_warn(fs_info, "failed to resume balance: %d", ret); 3253 close_ctree(fs_info); 3254 return ret; 3255 } 3256 3257 ret = btrfs_resume_dev_replace_async(fs_info); 3258 if (ret) { 3259 btrfs_warn(fs_info, "failed to resume device replace: %d", ret); 3260 close_ctree(fs_info); 3261 return ret; 3262 } 3263 3264 btrfs_qgroup_rescan_resume(fs_info); 3265 btrfs_discard_resume(fs_info); 3266 3267 if (!fs_info->uuid_root) { 3268 btrfs_info(fs_info, "creating UUID tree"); 3269 ret = btrfs_create_uuid_tree(fs_info); 3270 if (ret) { 3271 btrfs_warn(fs_info, 3272 "failed to create the UUID tree: %d", ret); 3273 close_ctree(fs_info); 3274 return ret; 3275 } 3276 } else if (btrfs_test_opt(fs_info, RESCAN_UUID_TREE) || 3277 fs_info->generation != 3278 btrfs_super_uuid_tree_generation(disk_super)) { 3279 btrfs_info(fs_info, "checking UUID tree"); 3280 ret = btrfs_check_uuid_tree(fs_info); 3281 if (ret) { 3282 btrfs_warn(fs_info, 3283 "failed to check the UUID tree: %d", ret); 3284 close_ctree(fs_info); 3285 return ret; 3286 } 3287 } else { 3288 set_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags); 3289 } 3290 set_bit(BTRFS_FS_OPEN, &fs_info->flags); 3291 3292 /* 3293 * backuproot only affect mount behavior, and if open_ctree succeeded, 3294 * no need to keep the flag 3295 */ 3296 btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT); 3297 3298 return 0; 3299 3300 fail_qgroup: 3301 btrfs_free_qgroup_config(fs_info); 3302 fail_trans_kthread: 3303 kthread_stop(fs_info->transaction_kthread); 3304 btrfs_cleanup_transaction(fs_info); 3305 btrfs_free_fs_roots(fs_info); 3306 fail_cleaner: 3307 kthread_stop(fs_info->cleaner_kthread); 3308 3309 /* 3310 * make sure we're done with the btree inode before we stop our 3311 * kthreads 3312 */ 3313 filemap_write_and_wait(fs_info->btree_inode->i_mapping); 3314 3315 fail_sysfs: 3316 btrfs_sysfs_remove_mounted(fs_info); 3317 3318 fail_fsdev_sysfs: 3319 btrfs_sysfs_remove_fsid(fs_info->fs_devices); 3320 3321 fail_block_groups: 3322 btrfs_put_block_group_cache(fs_info); 3323 3324 fail_tree_roots: 3325 free_root_pointers(fs_info, true); 3326 invalidate_inode_pages2(fs_info->btree_inode->i_mapping); 3327 3328 fail_sb_buffer: 3329 btrfs_stop_all_workers(fs_info); 3330 btrfs_free_block_groups(fs_info); 3331 fail_csum: 3332 btrfs_free_csum_hash(fs_info); 3333 fail_alloc: 3334 fail_iput: 3335 btrfs_mapping_tree_free(&fs_info->mapping_tree); 3336 3337 iput(fs_info->btree_inode); 3338 fail_bio_counter: 3339 percpu_counter_destroy(&fs_info->dev_replace.bio_counter); 3340 fail_delalloc_bytes: 3341 percpu_counter_destroy(&fs_info->delalloc_bytes); 3342 fail_dirty_metadata_bytes: 3343 percpu_counter_destroy(&fs_info->dirty_metadata_bytes); 3344 fail_dio_bytes: 3345 percpu_counter_destroy(&fs_info->dio_bytes); 3346 fail_srcu: 3347 cleanup_srcu_struct(&fs_info->subvol_srcu); 3348 fail: 3349 btrfs_free_stripe_hash_table(fs_info); 3350 btrfs_close_devices(fs_info->fs_devices); 3351 return err; 3352 } 3353 ALLOW_ERROR_INJECTION(open_ctree, ERRNO); 3354
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org