Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull btrfs fixes from Chris Mason:
"The most user visible change here is a fix for our recent superblock
validation checks that were causing problems on non-4k pagesized
systems"

* 'for-linus-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: btrfs_check_super_valid: Allow 4096 as stripesize
btrfs: remove build fixup for qgroup_account_snapshot
btrfs: use new error message helper in qgroup_account_snapshot
btrfs: avoid blocking open_ctree from cleaner_kthread
Btrfs: don't BUG_ON() in btrfs_orphan_add
btrfs: account for non-CoW'd blocks in btrfs_abort_transaction
Btrfs: check if extent buffer is aligned to sectorsize
btrfs: Use correct format specifier

+61 -43
+1 -1
fs/btrfs/check-integrity.c
··· 2645 2645 * This algorithm is recursive because the amount of used stack space 2646 2646 * is very small and the max recursion depth is limited. 2647 2647 */ 2648 - indent_add = sprintf(buf, "%c-%llu(%s/%llu/%d)", 2648 + indent_add = sprintf(buf, "%c-%llu(%s/%llu/%u)", 2649 2649 btrfsic_get_block_type(state, block), 2650 2650 block->logical_bytenr, block->dev_state->name, 2651 2651 block->dev_bytenr, block->mirror_num);
+6 -1
fs/btrfs/ctree.c
··· 1554 1554 trans->transid, root->fs_info->generation); 1555 1555 1556 1556 if (!should_cow_block(trans, root, buf)) { 1557 + trans->dirty = true; 1557 1558 *cow_ret = buf; 1558 1559 return 0; 1559 1560 } ··· 2513 2512 if (!btrfs_buffer_uptodate(tmp, 0, 0)) 2514 2513 ret = -EIO; 2515 2514 free_extent_buffer(tmp); 2515 + } else { 2516 + ret = PTR_ERR(tmp); 2516 2517 } 2517 2518 return ret; 2518 2519 } ··· 2778 2775 * then we don't want to set the path blocking, 2779 2776 * so we test it here 2780 2777 */ 2781 - if (!should_cow_block(trans, root, b)) 2778 + if (!should_cow_block(trans, root, b)) { 2779 + trans->dirty = true; 2782 2780 goto cow_done; 2781 + } 2783 2782 2784 2783 /* 2785 2784 * must have write locks on this node and the
+16 -20
fs/btrfs/disk-io.c
··· 1098 1098 struct inode *btree_inode = root->fs_info->btree_inode; 1099 1099 1100 1100 buf = btrfs_find_create_tree_block(root, bytenr); 1101 - if (!buf) 1101 + if (IS_ERR(buf)) 1102 1102 return; 1103 1103 read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, 1104 1104 buf, 0, WAIT_NONE, btree_get_extent, 0); ··· 1114 1114 int ret; 1115 1115 1116 1116 buf = btrfs_find_create_tree_block(root, bytenr); 1117 - if (!buf) 1117 + if (IS_ERR(buf)) 1118 1118 return 0; 1119 1119 1120 1120 set_bit(EXTENT_BUFFER_READAHEAD, &buf->bflags); ··· 1172 1172 int ret; 1173 1173 1174 1174 buf = btrfs_find_create_tree_block(root, bytenr); 1175 - if (!buf) 1176 - return ERR_PTR(-ENOMEM); 1175 + if (IS_ERR(buf)) 1176 + return buf; 1177 1177 1178 1178 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); 1179 1179 if (ret) { ··· 1804 1804 1805 1805 /* Make the cleaner go to sleep early. */ 1806 1806 if (btrfs_need_cleaner_sleep(root)) 1807 + goto sleep; 1808 + 1809 + /* 1810 + * Do not do anything if we might cause open_ctree() to block 1811 + * before we have finished mounting the filesystem. 1812 + */ 1813 + if (!root->fs_info->open) 1807 1814 goto sleep; 1808 1815 1809 1816 if (!mutex_trylock(&root->fs_info->cleaner_mutex)) ··· 2527 2520 int num_backups_tried = 0; 2528 2521 int backup_index = 0; 2529 2522 int max_active; 2530 - bool cleaner_mutex_locked = false; 2531 2523 2532 2524 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL); 2533 2525 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info, GFP_KERNEL); ··· 3005 2999 goto fail_sysfs; 3006 3000 } 3007 3001 3008 - /* 3009 - * Hold the cleaner_mutex thread here so that we don't block 3010 - * for a long time on btrfs_recover_relocation. cleaner_kthread 3011 - * will wait for us to finish mounting the filesystem. 3012 - */ 3013 - mutex_lock(&fs_info->cleaner_mutex); 3014 - cleaner_mutex_locked = true; 3015 3002 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, 3016 3003 "btrfs-cleaner"); 3017 3004 if (IS_ERR(fs_info->cleaner_kthread)) ··· 3064 3065 ret = btrfs_cleanup_fs_roots(fs_info); 3065 3066 if (ret) 3066 3067 goto fail_qgroup; 3067 - /* We locked cleaner_mutex before creating cleaner_kthread. */ 3068 + 3069 + mutex_lock(&fs_info->cleaner_mutex); 3068 3070 ret = btrfs_recover_relocation(tree_root); 3071 + mutex_unlock(&fs_info->cleaner_mutex); 3069 3072 if (ret < 0) { 3070 3073 btrfs_warn(fs_info, "failed to recover relocation: %d", 3071 3074 ret); ··· 3075 3074 goto fail_qgroup; 3076 3075 } 3077 3076 } 3078 - mutex_unlock(&fs_info->cleaner_mutex); 3079 - cleaner_mutex_locked = false; 3080 3077 3081 3078 location.objectid = BTRFS_FS_TREE_OBJECTID; 3082 3079 location.type = BTRFS_ROOT_ITEM_KEY; ··· 3188 3189 filemap_write_and_wait(fs_info->btree_inode->i_mapping); 3189 3190 3190 3191 fail_sysfs: 3191 - if (cleaner_mutex_locked) { 3192 - mutex_unlock(&fs_info->cleaner_mutex); 3193 - cleaner_mutex_locked = false; 3194 - } 3195 3192 btrfs_sysfs_remove_mounted(fs_info); 3196 3193 3197 3194 fail_fsdev_sysfs: ··· 4134 4139 ret = -EINVAL; 4135 4140 } 4136 4141 if (!is_power_of_2(btrfs_super_stripesize(sb)) || 4137 - btrfs_super_stripesize(sb) != sectorsize) { 4142 + ((btrfs_super_stripesize(sb) != sectorsize) && 4143 + (btrfs_super_stripesize(sb) != 4096))) { 4138 4144 btrfs_err(fs_info, "invalid stripesize %u", 4139 4145 btrfs_super_stripesize(sb)); 4140 4146 ret = -EINVAL;
+7 -5
fs/btrfs/extent-tree.c
··· 8016 8016 struct extent_buffer *buf; 8017 8017 8018 8018 buf = btrfs_find_create_tree_block(root, bytenr); 8019 - if (!buf) 8020 - return ERR_PTR(-ENOMEM); 8019 + if (IS_ERR(buf)) 8020 + return buf; 8021 + 8021 8022 btrfs_set_header_generation(buf, trans->transid); 8022 8023 btrfs_set_buffer_lockdep_class(root->root_key.objectid, buf, level); 8023 8024 btrfs_tree_lock(buf); ··· 8045 8044 set_extent_dirty(&trans->transaction->dirty_pages, buf->start, 8046 8045 buf->start + buf->len - 1, GFP_NOFS); 8047 8046 } 8048 - trans->blocks_used++; 8047 + trans->dirty = true; 8049 8048 /* this returns a buffer locked for blocking */ 8050 8049 return buf; 8051 8050 } ··· 8660 8659 next = btrfs_find_tree_block(root->fs_info, bytenr); 8661 8660 if (!next) { 8662 8661 next = btrfs_find_create_tree_block(root, bytenr); 8663 - if (!next) 8664 - return -ENOMEM; 8662 + if (IS_ERR(next)) 8663 + return PTR_ERR(next); 8664 + 8665 8665 btrfs_set_buffer_lockdep_class(root->root_key.objectid, next, 8666 8666 level - 1); 8667 8667 reada = 1;
+12 -3
fs/btrfs/extent_io.c
··· 4892 4892 int uptodate = 1; 4893 4893 int ret; 4894 4894 4895 + if (!IS_ALIGNED(start, fs_info->tree_root->sectorsize)) { 4896 + btrfs_err(fs_info, "bad tree block start %llu", start); 4897 + return ERR_PTR(-EINVAL); 4898 + } 4899 + 4895 4900 eb = find_extent_buffer(fs_info, start); 4896 4901 if (eb) 4897 4902 return eb; 4898 4903 4899 4904 eb = __alloc_extent_buffer(fs_info, start, len); 4900 4905 if (!eb) 4901 - return NULL; 4906 + return ERR_PTR(-ENOMEM); 4902 4907 4903 4908 for (i = 0; i < num_pages; i++, index++) { 4904 4909 p = find_or_create_page(mapping, index, GFP_NOFS|__GFP_NOFAIL); 4905 - if (!p) 4910 + if (!p) { 4911 + exists = ERR_PTR(-ENOMEM); 4906 4912 goto free_eb; 4913 + } 4907 4914 4908 4915 spin_lock(&mapping->private_lock); 4909 4916 if (PagePrivate(p)) { ··· 4955 4948 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); 4956 4949 again: 4957 4950 ret = radix_tree_preload(GFP_NOFS); 4958 - if (ret) 4951 + if (ret) { 4952 + exists = ERR_PTR(ret); 4959 4953 goto free_eb; 4954 + } 4960 4955 4961 4956 spin_lock(&fs_info->buffer_lock); 4962 4957 ret = radix_tree_insert(&fs_info->buffer_radix,
+10 -1
fs/btrfs/inode.c
··· 3271 3271 /* grab metadata reservation from transaction handle */ 3272 3272 if (reserve) { 3273 3273 ret = btrfs_orphan_reserve_metadata(trans, inode); 3274 - BUG_ON(ret); /* -ENOSPC in reservation; Logic error? JDM */ 3274 + ASSERT(!ret); 3275 + if (ret) { 3276 + atomic_dec(&root->orphan_inodes); 3277 + clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, 3278 + &BTRFS_I(inode)->runtime_flags); 3279 + if (insert) 3280 + clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, 3281 + &BTRFS_I(inode)->runtime_flags); 3282 + return ret; 3283 + } 3275 3284 } 3276 3285 3277 3286 /* insert an orphan item to track this unlinked/truncated file */
+3 -1
fs/btrfs/super.c
··· 235 235 trans->aborted = errno; 236 236 /* Nothing used. The other threads that have joined this 237 237 * transaction may be able to continue. */ 238 - if (!trans->blocks_used && list_empty(&trans->new_bgs)) { 238 + if (!trans->dirty && list_empty(&trans->new_bgs)) { 239 239 const char *errstr; 240 240 241 241 errstr = btrfs_decode_error(errno); ··· 1807 1807 } 1808 1808 } 1809 1809 sb->s_flags &= ~MS_RDONLY; 1810 + 1811 + fs_info->open = 1; 1810 1812 } 1811 1813 out: 1812 1814 wake_up_process(fs_info->transaction_kthread);
+1 -6
fs/btrfs/transaction.c
··· 1311 1311 return ret; 1312 1312 } 1313 1313 1314 - /* Bisesctability fixup, remove in 4.8 */ 1315 - #ifndef btrfs_std_error 1316 - #define btrfs_std_error btrfs_handle_fs_error 1317 - #endif 1318 - 1319 1314 /* 1320 1315 * Do all special snapshot related qgroup dirty hack. 1321 1316 * ··· 1380 1385 switch_commit_roots(trans->transaction, fs_info); 1381 1386 ret = btrfs_write_and_wait_transaction(trans, src); 1382 1387 if (ret) 1383 - btrfs_std_error(fs_info, ret, 1388 + btrfs_handle_fs_error(fs_info, ret, 1384 1389 "Error while writing out transaction for qgroup"); 1385 1390 1386 1391 out:
+1 -1
fs/btrfs/transaction.h
··· 110 110 u64 chunk_bytes_reserved; 111 111 unsigned long use_count; 112 112 unsigned long blocks_reserved; 113 - unsigned long blocks_used; 114 113 unsigned long delayed_ref_updates; 115 114 struct btrfs_transaction *transaction; 116 115 struct btrfs_block_rsv *block_rsv; ··· 120 121 bool can_flush_pending_bgs; 121 122 bool reloc_reserved; 122 123 bool sync; 124 + bool dirty; 123 125 unsigned int type; 124 126 /* 125 127 * this root is only needed to validate that the root passed to
+2 -2
fs/btrfs/tree-log.c
··· 2422 2422 root_owner = btrfs_header_owner(parent); 2423 2423 2424 2424 next = btrfs_find_create_tree_block(root, bytenr); 2425 - if (!next) 2426 - return -ENOMEM; 2425 + if (IS_ERR(next)) 2426 + return PTR_ERR(next); 2427 2427 2428 2428 if (*level == 1) { 2429 2429 ret = wc->process_func(root, next, wc, ptr_gen);
+2 -2
fs/btrfs/volumes.c
··· 6607 6607 * overallocate but we can keep it as-is, only the first page is used. 6608 6608 */ 6609 6609 sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET); 6610 - if (!sb) 6611 - return -ENOMEM; 6610 + if (IS_ERR(sb)) 6611 + return PTR_ERR(sb); 6612 6612 set_extent_buffer_uptodate(sb); 6613 6613 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); 6614 6614 /*