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

Pull btrfs fixes from Chris Mason:
"Eric's rcu barrier patch fixes a long standing problem with our
unmount code hanging on to devices in workqueue helpers. Liu Bo
nailed down a difficult assertion for in-memory extent mappings."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: fix warning of free_extent_map
Btrfs: fix warning when creating snapshots
Btrfs: return as soon as possible when edquot happens
Btrfs: return EIO if we have extent tree corruption
btrfs: use rcu_barrier() to wait for bdev puts at unmount
Btrfs: remove btrfs_try_spin_lock
Btrfs: get better concurrency for snapshot-aware defrag work

+4 -1
fs/btrfs/extent-tree.c
··· 1467 1467 if (ret && !insert) { 1468 1468 err = -ENOENT; 1469 1469 goto out; 1470 + } else if (ret) { 1471 + err = -EIO; 1472 + WARN_ON(1); 1473 + goto out; 1470 1474 } 1471 - BUG_ON(ret); /* Corruption */ 1472 1475 1473 1476 leaf = path->nodes[0]; 1474 1477 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
+1
fs/btrfs/file.c
··· 591 591 } 592 592 compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags); 593 593 clear_bit(EXTENT_FLAG_PINNED, &em->flags); 594 + clear_bit(EXTENT_FLAG_LOGGING, &flags); 594 595 remove_extent_mapping(em_tree, em); 595 596 if (no_splits) 596 597 goto next;
+3
fs/btrfs/inode.c
··· 2312 2312 key.type = BTRFS_EXTENT_DATA_KEY; 2313 2313 key.offset = start; 2314 2314 2315 + path->leave_spinning = 1; 2315 2316 if (merge) { 2316 2317 struct btrfs_file_extent_item *fi; 2317 2318 u64 extent_len; ··· 2369 2368 2370 2369 btrfs_mark_buffer_dirty(leaf); 2371 2370 inode_add_bytes(inode, len); 2371 + btrfs_release_path(path); 2372 2372 2373 2373 ret = btrfs_inc_extent_ref(trans, root, new->bytenr, 2374 2374 new->disk_len, 0, ··· 2383 2381 ret = 1; 2384 2382 out_free_path: 2385 2383 btrfs_release_path(path); 2384 + path->leave_spinning = 0; 2386 2385 btrfs_end_transaction(trans, root); 2387 2386 out_unlock: 2388 2387 unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start, lock_end,
-1
fs/btrfs/locking.h
··· 26 26 27 27 void btrfs_tree_lock(struct extent_buffer *eb); 28 28 void btrfs_tree_unlock(struct extent_buffer *eb); 29 - int btrfs_try_spin_lock(struct extent_buffer *eb); 30 29 31 30 void btrfs_tree_read_lock(struct extent_buffer *eb); 32 31 void btrfs_tree_read_unlock(struct extent_buffer *eb);
+6 -4
fs/btrfs/qgroup.c
··· 1525 1525 1526 1526 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && 1527 1527 qg->reserved + qg->rfer + num_bytes > 1528 - qg->max_rfer) 1528 + qg->max_rfer) { 1529 1529 ret = -EDQUOT; 1530 + goto out; 1531 + } 1530 1532 1531 1533 if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) && 1532 1534 qg->reserved + qg->excl + num_bytes > 1533 - qg->max_excl) 1535 + qg->max_excl) { 1534 1536 ret = -EDQUOT; 1537 + goto out; 1538 + } 1535 1539 1536 1540 list_for_each_entry(glist, &qg->groups, next_group) { 1537 1541 ulist_add(ulist, glist->group->qgroupid, 1538 1542 (uintptr_t)glist->group, GFP_ATOMIC); 1539 1543 } 1540 1544 } 1541 - if (ret) 1542 - goto out; 1543 1545 1544 1546 /* 1545 1547 * no limits exceeded, now record the reservation into all qgroups
+5 -6
fs/btrfs/transaction.c
··· 625 625 626 626 btrfs_trans_release_metadata(trans, root); 627 627 trans->block_rsv = NULL; 628 - /* 629 - * the same root has to be passed to start_transaction and 630 - * end_transaction. Subvolume quota depends on this. 631 - */ 632 - WARN_ON(trans->root != root); 633 628 634 629 if (trans->qgroup_reserved) { 635 - btrfs_qgroup_free(root, trans->qgroup_reserved); 630 + /* 631 + * the same root has to be passed here between start_transaction 632 + * and end_transaction. Subvolume quota depends on this. 633 + */ 634 + btrfs_qgroup_free(trans->root, trans->qgroup_reserved); 636 635 trans->qgroup_reserved = 0; 637 636 } 638 637
+6
fs/btrfs/volumes.c
··· 684 684 __btrfs_close_devices(fs_devices); 685 685 free_fs_devices(fs_devices); 686 686 } 687 + /* 688 + * Wait for rcu kworkers under __btrfs_close_devices 689 + * to finish all blkdev_puts so device is really 690 + * free when umount is done. 691 + */ 692 + rcu_barrier(); 687 693 return ret; 688 694 } 689 695