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:
"This is a small collection of fixes. It was rebased this morning, but
I was just fixing signed-off-by tags with the wrong email"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: fix access_ok() check in btrfs_ioctl_send()
Btrfs: make sure we cleanup all reloc roots if error happens
Btrfs: skip building backref tree for uuid and quota tree when doing balance relocation
Btrfs: fix an oops when doing balance relocation
Btrfs: don't miss skinny extent items on delayed ref head contention
btrfs: call mnt_drop_write after interrupted subvol deletion
Btrfs: don't clear the default compression type

+73 -42
+10 -12
fs/btrfs/extent-tree.c
··· 767 767 if (!path) 768 768 return -ENOMEM; 769 769 770 - if (metadata) { 771 - key.objectid = bytenr; 772 - key.type = BTRFS_METADATA_ITEM_KEY; 773 - key.offset = offset; 774 - } else { 775 - key.objectid = bytenr; 776 - key.type = BTRFS_EXTENT_ITEM_KEY; 777 - key.offset = offset; 778 - } 779 - 780 770 if (!trans) { 781 771 path->skip_locking = 1; 782 772 path->search_commit_root = 1; 783 773 } 774 + 775 + search_again: 776 + key.objectid = bytenr; 777 + key.offset = offset; 778 + if (metadata) 779 + key.type = BTRFS_METADATA_ITEM_KEY; 780 + else 781 + key.type = BTRFS_EXTENT_ITEM_KEY; 782 + 784 783 again: 785 784 ret = btrfs_search_slot(trans, root->fs_info->extent_root, 786 785 &key, path, 0, 0); ··· 787 788 goto out_free; 788 789 789 790 if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) { 790 - metadata = 0; 791 791 if (path->slots[0]) { 792 792 path->slots[0]--; 793 793 btrfs_item_key_to_cpu(path->nodes[0], &key, ··· 853 855 mutex_lock(&head->mutex); 854 856 mutex_unlock(&head->mutex); 855 857 btrfs_put_delayed_ref(&head->node); 856 - goto again; 858 + goto search_again; 857 859 } 858 860 if (head->extent_op && head->extent_op->update_flags) 859 861 extent_flags |= head->extent_op->flags_to_set;
+2 -1
fs/btrfs/ioctl.c
··· 2121 2121 2122 2122 err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); 2123 2123 if (err == -EINTR) 2124 - goto out; 2124 + goto out_drop_write; 2125 2125 dentry = lookup_one_len(vol_args->name, parent, namelen); 2126 2126 if (IS_ERR(dentry)) { 2127 2127 err = PTR_ERR(dentry); ··· 2284 2284 dput(dentry); 2285 2285 out_unlock_dir: 2286 2286 mutex_unlock(&dir->i_mutex); 2287 + out_drop_write: 2287 2288 mnt_drop_write_file(file); 2288 2289 out: 2289 2290 kfree(vol_args);
+57 -24
fs/btrfs/relocation.c
··· 571 571 root_objectid == BTRFS_CHUNK_TREE_OBJECTID || 572 572 root_objectid == BTRFS_DEV_TREE_OBJECTID || 573 573 root_objectid == BTRFS_TREE_LOG_OBJECTID || 574 - root_objectid == BTRFS_CSUM_TREE_OBJECTID) 574 + root_objectid == BTRFS_CSUM_TREE_OBJECTID || 575 + root_objectid == BTRFS_UUID_TREE_OBJECTID || 576 + root_objectid == BTRFS_QUOTA_TREE_OBJECTID) 575 577 return 1; 576 578 return 0; 577 579 } ··· 1266 1264 } 1267 1265 1268 1266 /* 1269 - * helper to update/delete the 'address of tree root -> reloc tree' 1267 + * helper to delete the 'address of tree root -> reloc tree' 1270 1268 * mapping 1271 1269 */ 1272 - static int __update_reloc_root(struct btrfs_root *root, int del) 1270 + static void __del_reloc_root(struct btrfs_root *root) 1273 1271 { 1274 1272 struct rb_node *rb_node; 1275 1273 struct mapping_node *node = NULL; ··· 1277 1275 1278 1276 spin_lock(&rc->reloc_root_tree.lock); 1279 1277 rb_node = tree_search(&rc->reloc_root_tree.rb_root, 1280 - root->commit_root->start); 1278 + root->node->start); 1279 + if (rb_node) { 1280 + node = rb_entry(rb_node, struct mapping_node, rb_node); 1281 + rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); 1282 + } 1283 + spin_unlock(&rc->reloc_root_tree.lock); 1284 + 1285 + if (!node) 1286 + return; 1287 + BUG_ON((struct btrfs_root *)node->data != root); 1288 + 1289 + spin_lock(&root->fs_info->trans_lock); 1290 + list_del_init(&root->root_list); 1291 + spin_unlock(&root->fs_info->trans_lock); 1292 + kfree(node); 1293 + } 1294 + 1295 + /* 1296 + * helper to update the 'address of tree root -> reloc tree' 1297 + * mapping 1298 + */ 1299 + static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr) 1300 + { 1301 + struct rb_node *rb_node; 1302 + struct mapping_node *node = NULL; 1303 + struct reloc_control *rc = root->fs_info->reloc_ctl; 1304 + 1305 + spin_lock(&rc->reloc_root_tree.lock); 1306 + rb_node = tree_search(&rc->reloc_root_tree.rb_root, 1307 + root->node->start); 1281 1308 if (rb_node) { 1282 1309 node = rb_entry(rb_node, struct mapping_node, rb_node); 1283 1310 rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); ··· 1317 1286 return 0; 1318 1287 BUG_ON((struct btrfs_root *)node->data != root); 1319 1288 1320 - if (!del) { 1321 - spin_lock(&rc->reloc_root_tree.lock); 1322 - node->bytenr = root->node->start; 1323 - rb_node = tree_insert(&rc->reloc_root_tree.rb_root, 1324 - node->bytenr, &node->rb_node); 1325 - spin_unlock(&rc->reloc_root_tree.lock); 1326 - if (rb_node) 1327 - backref_tree_panic(rb_node, -EEXIST, node->bytenr); 1328 - } else { 1329 - spin_lock(&root->fs_info->trans_lock); 1330 - list_del_init(&root->root_list); 1331 - spin_unlock(&root->fs_info->trans_lock); 1332 - kfree(node); 1333 - } 1289 + spin_lock(&rc->reloc_root_tree.lock); 1290 + node->bytenr = new_bytenr; 1291 + rb_node = tree_insert(&rc->reloc_root_tree.rb_root, 1292 + node->bytenr, &node->rb_node); 1293 + spin_unlock(&rc->reloc_root_tree.lock); 1294 + if (rb_node) 1295 + backref_tree_panic(rb_node, -EEXIST, node->bytenr); 1334 1296 return 0; 1335 1297 } 1336 1298 ··· 1444 1420 { 1445 1421 struct btrfs_root *reloc_root; 1446 1422 struct btrfs_root_item *root_item; 1447 - int del = 0; 1448 1423 int ret; 1449 1424 1450 1425 if (!root->reloc_root) ··· 1455 1432 if (root->fs_info->reloc_ctl->merge_reloc_tree && 1456 1433 btrfs_root_refs(root_item) == 0) { 1457 1434 root->reloc_root = NULL; 1458 - del = 1; 1435 + __del_reloc_root(reloc_root); 1459 1436 } 1460 - 1461 - __update_reloc_root(reloc_root, del); 1462 1437 1463 1438 if (reloc_root->commit_root != reloc_root->node) { 1464 1439 btrfs_set_root_node(root_item, reloc_root->node); ··· 2308 2287 while (!list_empty(list)) { 2309 2288 reloc_root = list_entry(list->next, struct btrfs_root, 2310 2289 root_list); 2311 - __update_reloc_root(reloc_root, 1); 2290 + __del_reloc_root(reloc_root); 2312 2291 free_extent_buffer(reloc_root->node); 2313 2292 free_extent_buffer(reloc_root->commit_root); 2314 2293 kfree(reloc_root); ··· 2353 2332 2354 2333 ret = merge_reloc_root(rc, root); 2355 2334 if (ret) { 2356 - __update_reloc_root(reloc_root, 1); 2335 + __del_reloc_root(reloc_root); 2357 2336 free_extent_buffer(reloc_root->node); 2358 2337 free_extent_buffer(reloc_root->commit_root); 2359 2338 kfree(reloc_root); ··· 2407 2386 out: 2408 2387 if (ret) { 2409 2388 btrfs_std_error(root->fs_info, ret); 2389 + if (!list_empty(&reloc_roots)) 2390 + free_reloc_roots(&reloc_roots); 2391 + 2392 + /* new reloc root may be added */ 2393 + mutex_lock(&root->fs_info->reloc_mutex); 2394 + list_splice_init(&rc->reloc_roots, &reloc_roots); 2395 + mutex_unlock(&root->fs_info->reloc_mutex); 2410 2396 if (!list_empty(&reloc_roots)) 2411 2397 free_reloc_roots(&reloc_roots); 2412 2398 } ··· 4549 4521 4550 4522 BUG_ON(rc->stage == UPDATE_DATA_PTRS && 4551 4523 root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); 4524 + 4525 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { 4526 + if (buf == root->node) 4527 + __update_reloc_root(root, cow->start); 4528 + } 4552 4529 4553 4530 level = btrfs_header_level(buf); 4554 4531 if (btrfs_header_generation(buf) <=
+2 -2
fs/btrfs/send.c
··· 4723 4723 } 4724 4724 4725 4725 if (!access_ok(VERIFY_READ, arg->clone_sources, 4726 - sizeof(*arg->clone_sources * 4727 - arg->clone_sources_count))) { 4726 + sizeof(*arg->clone_sources) * 4727 + arg->clone_sources_count)) { 4728 4728 ret = -EFAULT; 4729 4729 goto out; 4730 4730 }
+2 -3
fs/btrfs/super.c
··· 432 432 } else { 433 433 printk(KERN_INFO "btrfs: setting nodatacow\n"); 434 434 } 435 - info->compress_type = BTRFS_COMPRESS_NONE; 436 435 btrfs_clear_opt(info->mount_opt, COMPRESS); 437 436 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 438 437 btrfs_set_opt(info->mount_opt, NODATACOW); ··· 460 461 btrfs_set_fs_incompat(info, COMPRESS_LZO); 461 462 } else if (strncmp(args[0].from, "no", 2) == 0) { 462 463 compress_type = "no"; 463 - info->compress_type = BTRFS_COMPRESS_NONE; 464 464 btrfs_clear_opt(info->mount_opt, COMPRESS); 465 465 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 466 466 compress_force = false; ··· 472 474 btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); 473 475 pr_info("btrfs: force %s compression\n", 474 476 compress_type); 475 - } else 477 + } else if (btrfs_test_opt(root, COMPRESS)) { 476 478 pr_info("btrfs: use %s compression\n", 477 479 compress_type); 480 + } 478 481 break; 479 482 case Opt_ssd: 480 483 printk(KERN_INFO "btrfs: use ssd allocation scheme\n");