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 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable

* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
Btrfs: Fix oops and use after free during space balancing
Btrfs: set device->total_disk_bytes when adding new device

+49 -3
+48 -3
fs/btrfs/extent-tree.c
··· 2622 2622 search_start); 2623 2623 if (block_group && block_group_bits(block_group, data)) { 2624 2624 down_read(&space_info->groups_sem); 2625 - goto have_block_group; 2625 + if (list_empty(&block_group->list) || 2626 + block_group->ro) { 2627 + /* 2628 + * someone is removing this block group, 2629 + * we can't jump into the have_block_group 2630 + * target because our list pointers are not 2631 + * valid 2632 + */ 2633 + btrfs_put_block_group(block_group); 2634 + up_read(&space_info->groups_sem); 2635 + } else 2636 + goto have_block_group; 2626 2637 } else if (block_group) { 2627 2638 btrfs_put_block_group(block_group); 2628 2639 } ··· 2667 2656 * people trying to start a new cluster 2668 2657 */ 2669 2658 spin_lock(&last_ptr->refill_lock); 2659 + if (last_ptr->block_group && 2660 + (last_ptr->block_group->ro || 2661 + !block_group_bits(last_ptr->block_group, data))) { 2662 + offset = 0; 2663 + goto refill_cluster; 2664 + } 2665 + 2670 2666 offset = btrfs_alloc_from_cluster(block_group, last_ptr, 2671 2667 num_bytes, search_start); 2672 2668 if (offset) { ··· 2699 2681 2700 2682 last_ptr_loop = 1; 2701 2683 search_start = block_group->key.objectid; 2684 + /* 2685 + * we know this block group is properly 2686 + * in the list because 2687 + * btrfs_remove_block_group, drops the 2688 + * cluster before it removes the block 2689 + * group from the list 2690 + */ 2702 2691 goto have_block_group; 2703 2692 } 2704 2693 spin_unlock(&last_ptr->lock); 2705 - 2694 + refill_cluster: 2706 2695 /* 2707 2696 * this cluster didn't work out, free it and 2708 2697 * start over ··· 5993 5968 { 5994 5969 struct btrfs_path *path; 5995 5970 struct btrfs_block_group_cache *block_group; 5971 + struct btrfs_free_cluster *cluster; 5996 5972 struct btrfs_key key; 5997 5973 int ret; 5998 5974 ··· 6005 5979 6006 5980 memcpy(&key, &block_group->key, sizeof(key)); 6007 5981 5982 + /* make sure this block group isn't part of an allocation cluster */ 5983 + cluster = &root->fs_info->data_alloc_cluster; 5984 + spin_lock(&cluster->refill_lock); 5985 + btrfs_return_cluster_to_free_space(block_group, cluster); 5986 + spin_unlock(&cluster->refill_lock); 5987 + 5988 + /* 5989 + * make sure this block group isn't part of a metadata 5990 + * allocation cluster 5991 + */ 5992 + cluster = &root->fs_info->meta_alloc_cluster; 5993 + spin_lock(&cluster->refill_lock); 5994 + btrfs_return_cluster_to_free_space(block_group, cluster); 5995 + spin_unlock(&cluster->refill_lock); 5996 + 6008 5997 path = btrfs_alloc_path(); 6009 5998 BUG_ON(!path); 6010 5999 ··· 6029 5988 spin_unlock(&root->fs_info->block_group_cache_lock); 6030 5989 btrfs_remove_free_space_cache(block_group); 6031 5990 down_write(&block_group->space_info->groups_sem); 6032 - list_del(&block_group->list); 5991 + /* 5992 + * we must use list_del_init so people can check to see if they 5993 + * are still on the list after taking the semaphore 5994 + */ 5995 + list_del_init(&block_group->list); 6033 5996 up_write(&block_group->space_info->groups_sem); 6034 5997 6035 5998 spin_lock(&block_group->space_info->lock);
+1
fs/btrfs/volumes.c
··· 1440 1440 device->io_align = root->sectorsize; 1441 1441 device->sector_size = root->sectorsize; 1442 1442 device->total_bytes = i_size_read(bdev->bd_inode); 1443 + device->disk_total_bytes = device->total_bytes; 1443 1444 device->dev_root = root->fs_info->dev_root; 1444 1445 device->bdev = bdev; 1445 1446 device->in_fs_metadata = 1;