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

Pull btrfs fixes from Chris Mason:
"We've queued up a few fixes in my for-linus branch"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: fix crash when starting transaction
Btrfs: fix btrfs_print_leaf for skinny metadata
Btrfs: fix race of using total_bytes_pinned
btrfs: use E2BIG instead of EIO if compression does not help
btrfs: remove stale comment from btrfs_flush_all_pending_stuffs
Btrfs: fix use-after-free when cloning a trailing file hole
btrfs: fix null pointer dereference in btrfs_show_devname when name is null
btrfs: fix null pointer dereference in clone_fs_devices when name is null
btrfs: fix nossd and ssd_spread mount option regression
Btrfs: fix race between balance recovery and root deletion
Btrfs: atomically set inode->i_flags in btrfs_update_iflags
btrfs: only unlock block in verify_parent_transid if we locked it
Btrfs: assert send doesn't attempt to start transactions
btrfs compression: reuse recently used workspace
Btrfs: fix crash when mounting raid5 btrfs with missing disks
btrfs: create sprout should rename fsid on the sysfs as well
btrfs: dev replace should replace the sysfs entry
btrfs: dev add should add its sysfs entry
btrfs: dev delete should remove sysfs entry
btrfs: rename add_device_membership to btrfs_kobj_add_device

+109 -47
+1 -1
fs/btrfs/compression.c
··· 821 821 822 822 spin_lock(workspace_lock); 823 823 if (*num_workspace < num_online_cpus()) { 824 - list_add_tail(workspace, idle_workspace); 824 + list_add(workspace, idle_workspace); 825 825 (*num_workspace)++; 826 826 spin_unlock(workspace_lock); 827 827 goto wake;
+5
fs/btrfs/dev-replace.c
··· 36 36 #include "check-integrity.h" 37 37 #include "rcu-string.h" 38 38 #include "dev-replace.h" 39 + #include "sysfs.h" 39 40 40 41 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, 41 42 int scrub_ret); ··· 562 561 if (fs_info->fs_devices->latest_bdev == src_device->bdev) 563 562 fs_info->fs_devices->latest_bdev = tgt_device->bdev; 564 563 list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); 564 + 565 + /* replace the sysfs entry */ 566 + btrfs_kobj_rm_device(fs_info, src_device); 567 + btrfs_kobj_add_device(fs_info, tgt_device); 565 568 566 569 btrfs_rm_dev_replace_blocked(fs_info); 567 570
+4 -1
fs/btrfs/disk-io.c
··· 369 369 out: 370 370 unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1, 371 371 &cached_state, GFP_NOFS); 372 - btrfs_tree_read_unlock_blocking(eb); 372 + if (need_lock) 373 + btrfs_tree_read_unlock_blocking(eb); 373 374 return ret; 374 375 } 375 376 ··· 2905 2904 if (ret) 2906 2905 goto fail_qgroup; 2907 2906 2907 + mutex_lock(&fs_info->cleaner_mutex); 2908 2908 ret = btrfs_recover_relocation(tree_root); 2909 + mutex_unlock(&fs_info->cleaner_mutex); 2909 2910 if (ret < 0) { 2910 2911 printk(KERN_WARNING 2911 2912 "BTRFS: failed to recover relocation\n");
+1 -4
fs/btrfs/extent-tree.c
··· 5678 5678 struct btrfs_caching_control *next; 5679 5679 struct btrfs_caching_control *caching_ctl; 5680 5680 struct btrfs_block_group_cache *cache; 5681 - struct btrfs_space_info *space_info; 5682 5681 5683 5682 down_write(&fs_info->commit_root_sem); 5684 5683 ··· 5699 5700 fs_info->pinned_extents = &fs_info->freed_extents[0]; 5700 5701 5701 5702 up_write(&fs_info->commit_root_sem); 5702 - 5703 - list_for_each_entry_rcu(space_info, &fs_info->space_info, list) 5704 - percpu_counter_set(&space_info->total_bytes_pinned, 0); 5705 5703 5706 5704 update_global_block_rsv(fs_info); 5707 5705 } ··· 5737 5741 spin_lock(&cache->lock); 5738 5742 cache->pinned -= len; 5739 5743 space_info->bytes_pinned -= len; 5744 + percpu_counter_add(&space_info->total_bytes_pinned, -len); 5740 5745 if (cache->ro) { 5741 5746 space_info->bytes_readonly += len; 5742 5747 readonly = true;
+19 -18
fs/btrfs/ioctl.c
··· 136 136 void btrfs_update_iflags(struct inode *inode) 137 137 { 138 138 struct btrfs_inode *ip = BTRFS_I(inode); 139 - 140 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); 139 + unsigned int new_fl = 0; 141 140 142 141 if (ip->flags & BTRFS_INODE_SYNC) 143 - inode->i_flags |= S_SYNC; 142 + new_fl |= S_SYNC; 144 143 if (ip->flags & BTRFS_INODE_IMMUTABLE) 145 - inode->i_flags |= S_IMMUTABLE; 144 + new_fl |= S_IMMUTABLE; 146 145 if (ip->flags & BTRFS_INODE_APPEND) 147 - inode->i_flags |= S_APPEND; 146 + new_fl |= S_APPEND; 148 147 if (ip->flags & BTRFS_INODE_NOATIME) 149 - inode->i_flags |= S_NOATIME; 148 + new_fl |= S_NOATIME; 150 149 if (ip->flags & BTRFS_INODE_DIRSYNC) 151 - inode->i_flags |= S_DIRSYNC; 150 + new_fl |= S_DIRSYNC; 151 + 152 + set_mask_bits(&inode->i_flags, 153 + S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC, 154 + new_fl); 152 155 } 153 156 154 157 /* ··· 3142 3139 static void clone_update_extent_map(struct inode *inode, 3143 3140 const struct btrfs_trans_handle *trans, 3144 3141 const struct btrfs_path *path, 3145 - struct btrfs_file_extent_item *fi, 3146 3142 const u64 hole_offset, 3147 3143 const u64 hole_len) 3148 3144 { ··· 3156 3154 return; 3157 3155 } 3158 3156 3159 - if (fi) { 3157 + if (path) { 3158 + struct btrfs_file_extent_item *fi; 3159 + 3160 + fi = btrfs_item_ptr(path->nodes[0], path->slots[0], 3161 + struct btrfs_file_extent_item); 3160 3162 btrfs_extent_item_to_extent_map(inode, path, fi, false, em); 3161 3163 em->generation = -1; 3162 3164 if (btrfs_file_extent_type(path->nodes[0], fi) == ··· 3514 3508 btrfs_item_ptr_offset(leaf, slot), 3515 3509 size); 3516 3510 inode_add_bytes(inode, datal); 3517 - extent = btrfs_item_ptr(leaf, slot, 3518 - struct btrfs_file_extent_item); 3519 3511 } 3520 3512 3521 3513 /* If we have an implicit hole (NO_HOLES feature). */ 3522 3514 if (drop_start < new_key.offset) 3523 3515 clone_update_extent_map(inode, trans, 3524 - path, NULL, drop_start, 3516 + NULL, drop_start, 3525 3517 new_key.offset - drop_start); 3526 3518 3527 - clone_update_extent_map(inode, trans, path, 3528 - extent, 0, 0); 3519 + clone_update_extent_map(inode, trans, path, 0, 0); 3529 3520 3530 3521 btrfs_mark_buffer_dirty(leaf); 3531 3522 btrfs_release_path(path); ··· 3565 3562 btrfs_end_transaction(trans, root); 3566 3563 goto out; 3567 3564 } 3565 + clone_update_extent_map(inode, trans, NULL, last_dest_end, 3566 + destoff + len - last_dest_end); 3568 3567 ret = clone_finish_inode_update(trans, inode, destoff + len, 3569 3568 destoff, olen); 3570 - if (ret) 3571 - goto out; 3572 - clone_update_extent_map(inode, trans, path, NULL, last_dest_end, 3573 - destoff + len - last_dest_end); 3574 3569 } 3575 3570 3576 3571 out:
+5 -4
fs/btrfs/print-tree.c
··· 54 54 btrfs_extent_data_ref_count(eb, ref)); 55 55 } 56 56 57 - static void print_extent_item(struct extent_buffer *eb, int slot) 57 + static void print_extent_item(struct extent_buffer *eb, int slot, int type) 58 58 { 59 59 struct btrfs_extent_item *ei; 60 60 struct btrfs_extent_inline_ref *iref; ··· 63 63 struct btrfs_disk_key key; 64 64 unsigned long end; 65 65 unsigned long ptr; 66 - int type; 67 66 u32 item_size = btrfs_item_size_nr(eb, slot); 68 67 u64 flags; 69 68 u64 offset; ··· 87 88 btrfs_extent_refs(eb, ei), btrfs_extent_generation(eb, ei), 88 89 flags); 89 90 90 - if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) { 91 + if ((type == BTRFS_EXTENT_ITEM_KEY) && 92 + flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) { 91 93 struct btrfs_tree_block_info *info; 92 94 info = (struct btrfs_tree_block_info *)(ei + 1); 93 95 btrfs_tree_block_key(eb, info, &key); ··· 223 223 btrfs_disk_root_refs(l, ri)); 224 224 break; 225 225 case BTRFS_EXTENT_ITEM_KEY: 226 - print_extent_item(l, i); 226 + case BTRFS_METADATA_ITEM_KEY: 227 + print_extent_item(l, i, type); 227 228 break; 228 229 case BTRFS_TREE_BLOCK_REF_KEY: 229 230 printk(KERN_INFO "\t\ttree block backref\n");
+3 -2
fs/btrfs/raid56.c
··· 1956 1956 * pages are going to be uptodate. 1957 1957 */ 1958 1958 for (stripe = 0; stripe < bbio->num_stripes; stripe++) { 1959 - if (rbio->faila == stripe || 1960 - rbio->failb == stripe) 1959 + if (rbio->faila == stripe || rbio->failb == stripe) { 1960 + atomic_inc(&rbio->bbio->error); 1961 1961 continue; 1962 + } 1962 1963 1963 1964 for (pagenr = 0; pagenr < nr_pages; pagenr++) { 1964 1965 struct page *p;
+6 -1
fs/btrfs/super.c
··· 522 522 case Opt_ssd_spread: 523 523 btrfs_set_and_info(root, SSD_SPREAD, 524 524 "use spread ssd allocation scheme"); 525 + btrfs_set_opt(info->mount_opt, SSD); 525 526 break; 526 527 case Opt_nossd: 527 - btrfs_clear_and_info(root, NOSSD, 528 + btrfs_set_and_info(root, NOSSD, 528 529 "not using ssd allocation scheme"); 529 530 btrfs_clear_opt(info->mount_opt, SSD); 530 531 break; ··· 1468 1467 goto restore; 1469 1468 1470 1469 /* recover relocation */ 1470 + mutex_lock(&fs_info->cleaner_mutex); 1471 1471 ret = btrfs_recover_relocation(root); 1472 + mutex_unlock(&fs_info->cleaner_mutex); 1472 1473 if (ret) 1473 1474 goto restore; 1474 1475 ··· 1810 1807 head = &cur_devices->devices; 1811 1808 list_for_each_entry(dev, head, dev_list) { 1812 1809 if (dev->missing) 1810 + continue; 1811 + if (!dev->name) 1813 1812 continue; 1814 1813 if (!first_dev || dev->devid < first_dev->devid) 1815 1814 first_dev = dev;
+29 -3
fs/btrfs/sysfs.c
··· 605 605 } 606 606 } 607 607 608 - static int add_device_membership(struct btrfs_fs_info *fs_info) 608 + int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info, 609 + struct btrfs_device *one_device) 610 + { 611 + struct hd_struct *disk; 612 + struct kobject *disk_kobj; 613 + 614 + if (!fs_info->device_dir_kobj) 615 + return -EINVAL; 616 + 617 + if (one_device) { 618 + disk = one_device->bdev->bd_part; 619 + disk_kobj = &part_to_dev(disk)->kobj; 620 + 621 + sysfs_remove_link(fs_info->device_dir_kobj, 622 + disk_kobj->name); 623 + } 624 + 625 + return 0; 626 + } 627 + 628 + int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info, 629 + struct btrfs_device *one_device) 609 630 { 610 631 int error = 0; 611 632 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; 612 633 struct btrfs_device *dev; 613 634 614 - fs_info->device_dir_kobj = kobject_create_and_add("devices", 635 + if (!fs_info->device_dir_kobj) 636 + fs_info->device_dir_kobj = kobject_create_and_add("devices", 615 637 &fs_info->super_kobj); 638 + 616 639 if (!fs_info->device_dir_kobj) 617 640 return -ENOMEM; 618 641 ··· 644 621 struct kobject *disk_kobj; 645 622 646 623 if (!dev->bdev) 624 + continue; 625 + 626 + if (one_device && one_device != dev) 647 627 continue; 648 628 649 629 disk = dev->bdev->bd_part; ··· 692 666 if (error) 693 667 goto failure; 694 668 695 - error = add_device_membership(fs_info); 669 + error = btrfs_kobj_add_device(fs_info, NULL); 696 670 if (error) 697 671 goto failure; 698 672
+4
fs/btrfs/sysfs.h
··· 66 66 extern const char * const btrfs_feature_set_names[3]; 67 67 extern struct kobj_type space_info_ktype; 68 68 extern struct kobj_type btrfs_raid_ktype; 69 + int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info, 70 + struct btrfs_device *one_device); 71 + int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info, 72 + struct btrfs_device *one_device); 69 73 #endif /* _BTRFS_SYSFS_H_ */
+5 -7
fs/btrfs/transaction.c
··· 386 386 bool reloc_reserved = false; 387 387 int ret; 388 388 389 + /* Send isn't supposed to start transactions. */ 390 + ASSERT(current->journal_info != (void *)BTRFS_SEND_TRANS_STUB); 391 + 389 392 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) 390 393 return ERR_PTR(-EROFS); 391 394 392 - if (current->journal_info && 393 - current->journal_info != (void *)BTRFS_SEND_TRANS_STUB) { 395 + if (current->journal_info) { 394 396 WARN_ON(type & TRANS_EXTWRITERS); 395 397 h = current->journal_info; 396 398 h->use_count++; ··· 493 491 smp_mb(); 494 492 if (cur_trans->state >= TRANS_STATE_BLOCKED && 495 493 may_wait_transaction(root, type)) { 494 + current->journal_info = h; 496 495 btrfs_commit_transaction(h, root); 497 496 goto again; 498 497 } ··· 1618 1615 int ret; 1619 1616 1620 1617 ret = btrfs_run_delayed_items(trans, root); 1621 - /* 1622 - * running the delayed items may have added new refs. account 1623 - * them now so that they hinder processing of more delayed refs 1624 - * as little as possible. 1625 - */ 1626 1618 if (ret) 1627 1619 return ret; 1628 1620
+25 -5
fs/btrfs/volumes.c
··· 40 40 #include "rcu-string.h" 41 41 #include "math.h" 42 42 #include "dev-replace.h" 43 + #include "sysfs.h" 43 44 44 45 static int init_first_rw_device(struct btrfs_trans_handle *trans, 45 46 struct btrfs_root *root, ··· 555 554 * This is ok to do without rcu read locked because we hold the 556 555 * uuid mutex so nothing we touch in here is going to disappear. 557 556 */ 558 - name = rcu_string_strdup(orig_dev->name->str, GFP_NOFS); 559 - if (!name) { 560 - kfree(device); 561 - goto error; 557 + if (orig_dev->name) { 558 + name = rcu_string_strdup(orig_dev->name->str, GFP_NOFS); 559 + if (!name) { 560 + kfree(device); 561 + goto error; 562 + } 563 + rcu_assign_pointer(device->name, name); 562 564 } 563 - rcu_assign_pointer(device->name, name); 564 565 565 566 list_add(&device->dev_list, &fs_devices->devices); 566 567 device->fs_devices = fs_devices; ··· 1683 1680 if (device->bdev) 1684 1681 device->fs_devices->open_devices--; 1685 1682 1683 + /* remove sysfs entry */ 1684 + btrfs_kobj_rm_device(root->fs_info, device); 1685 + 1686 1686 call_rcu(&device->rcu, free_device); 1687 1687 1688 1688 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; ··· 2149 2143 total_bytes = btrfs_super_num_devices(root->fs_info->super_copy); 2150 2144 btrfs_set_super_num_devices(root->fs_info->super_copy, 2151 2145 total_bytes + 1); 2146 + 2147 + /* add sysfs device entry */ 2148 + btrfs_kobj_add_device(root->fs_info, device); 2149 + 2152 2150 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); 2153 2151 2154 2152 if (seeding_dev) { 2153 + char fsid_buf[BTRFS_UUID_UNPARSED_SIZE]; 2155 2154 ret = init_first_rw_device(trans, root, device); 2156 2155 if (ret) { 2157 2156 btrfs_abort_transaction(trans, root, ret); ··· 2167 2156 btrfs_abort_transaction(trans, root, ret); 2168 2157 goto error_trans; 2169 2158 } 2159 + 2160 + /* Sprouting would change fsid of the mounted root, 2161 + * so rename the fsid on the sysfs 2162 + */ 2163 + snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", 2164 + root->fs_info->fsid); 2165 + if (kobject_rename(&root->fs_info->super_kobj, fsid_buf)) 2166 + goto error_trans; 2170 2167 } else { 2171 2168 ret = btrfs_add_device(trans, root, device); 2172 2169 if (ret) { ··· 2224 2205 unlock_chunks(root); 2225 2206 btrfs_end_transaction(trans, root); 2226 2207 rcu_string_free(device->name); 2208 + btrfs_kobj_rm_device(root->fs_info, device); 2227 2209 kfree(device); 2228 2210 error: 2229 2211 blkdev_put(bdev, FMODE_EXCL);
+1 -1
fs/btrfs/zlib.c
··· 136 136 if (workspace->def_strm.total_in > 8192 && 137 137 workspace->def_strm.total_in < 138 138 workspace->def_strm.total_out) { 139 - ret = -EIO; 139 + ret = -E2BIG; 140 140 goto out; 141 141 } 142 142 /* we need another page for writing out. Test this
+1
include/uapi/linux/btrfs.h
··· 38 38 #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) 39 39 #define BTRFS_FSID_SIZE 16 40 40 #define BTRFS_UUID_SIZE 16 41 + #define BTRFS_UUID_UNPARSED_SIZE 37 41 42 42 43 #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0) 43 44