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 got corner cases for updating i_size that ceph was hitting,
error handling for quotas when we run out of space, a very subtle
snapshot deletion race, a crash while removing devices, and one
deadlock between subvolume creation and the sb_internal code (thanks
lockdep)."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: move d_instantiate outside the transaction during mksubvol
Btrfs: fix EDQUOT handling in btrfs_delalloc_reserve_metadata
Btrfs: fix possible stale data exposure
Btrfs: fix missing i_size update
Btrfs: fix race between snapshot deletion and getting inode
Btrfs: fix missing release of the space/qgroup reservation in start_transaction()
Btrfs: fix wrong sync_writers decrement in btrfs_file_aio_write()
Btrfs: do not merge logged extents if we've removed them from the tree
btrfs: don't try to notify udev about missing devices

+87 -36
+10 -12
fs/btrfs/extent-tree.c
··· 4534 4534 unsigned nr_extents = 0; 4535 4535 int extra_reserve = 0; 4536 4536 enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL; 4537 - int ret; 4537 + int ret = 0; 4538 4538 bool delalloc_lock = true; 4539 4539 4540 4540 /* If we are a free space inode we need to not flush since we will be in ··· 4579 4579 csum_bytes = BTRFS_I(inode)->csum_bytes; 4580 4580 spin_unlock(&BTRFS_I(inode)->lock); 4581 4581 4582 - if (root->fs_info->quota_enabled) { 4582 + if (root->fs_info->quota_enabled) 4583 4583 ret = btrfs_qgroup_reserve(root, num_bytes + 4584 4584 nr_extents * root->leafsize); 4585 - if (ret) { 4586 - spin_lock(&BTRFS_I(inode)->lock); 4587 - calc_csum_metadata_size(inode, num_bytes, 0); 4588 - spin_unlock(&BTRFS_I(inode)->lock); 4589 - if (delalloc_lock) 4590 - mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); 4591 - return ret; 4592 - } 4593 - } 4594 4585 4595 - ret = reserve_metadata_bytes(root, block_rsv, to_reserve, flush); 4586 + /* 4587 + * ret != 0 here means the qgroup reservation failed, we go straight to 4588 + * the shared error handling then. 4589 + */ 4590 + if (ret == 0) 4591 + ret = reserve_metadata_bytes(root, block_rsv, 4592 + to_reserve, flush); 4593 + 4596 4594 if (ret) { 4597 4595 u64 to_free = 0; 4598 4596 unsigned dropped;
+2 -1
fs/btrfs/extent_map.c
··· 288 288 void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em) 289 289 { 290 290 clear_bit(EXTENT_FLAG_LOGGING, &em->flags); 291 - try_merge_map(tree, em); 291 + if (em->in_tree) 292 + try_merge_map(tree, em); 292 293 } 293 294 294 295 /**
+20 -5
fs/btrfs/file.c
··· 293 293 struct btrfs_key key; 294 294 struct btrfs_ioctl_defrag_range_args range; 295 295 int num_defrag; 296 + int index; 297 + int ret; 296 298 297 299 /* get the inode */ 298 300 key.objectid = defrag->root; 299 301 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); 300 302 key.offset = (u64)-1; 303 + 304 + index = srcu_read_lock(&fs_info->subvol_srcu); 305 + 301 306 inode_root = btrfs_read_fs_root_no_name(fs_info, &key); 302 307 if (IS_ERR(inode_root)) { 303 - kmem_cache_free(btrfs_inode_defrag_cachep, defrag); 304 - return PTR_ERR(inode_root); 308 + ret = PTR_ERR(inode_root); 309 + goto cleanup; 310 + } 311 + if (btrfs_root_refs(&inode_root->root_item) == 0) { 312 + ret = -ENOENT; 313 + goto cleanup; 305 314 } 306 315 307 316 key.objectid = defrag->ino; ··· 318 309 key.offset = 0; 319 310 inode = btrfs_iget(fs_info->sb, &key, inode_root, NULL); 320 311 if (IS_ERR(inode)) { 321 - kmem_cache_free(btrfs_inode_defrag_cachep, defrag); 322 - return PTR_ERR(inode); 312 + ret = PTR_ERR(inode); 313 + goto cleanup; 323 314 } 315 + srcu_read_unlock(&fs_info->subvol_srcu, index); 324 316 325 317 /* do a chunk of defrag */ 326 318 clear_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags); ··· 356 346 357 347 iput(inode); 358 348 return 0; 349 + cleanup: 350 + srcu_read_unlock(&fs_info->subvol_srcu, index); 351 + kmem_cache_free(btrfs_inode_defrag_cachep, defrag); 352 + return ret; 359 353 } 360 354 361 355 /* ··· 1608 1594 if (err < 0 && num_written > 0) 1609 1595 num_written = err; 1610 1596 } 1611 - out: 1597 + 1612 1598 if (sync) 1613 1599 atomic_dec(&BTRFS_I(inode)->sync_writers); 1600 + out: 1614 1601 sb_end_write(inode->i_sb); 1615 1602 current->backing_dev_info = NULL; 1616 1603 return num_written ? num_written : err;
+4 -1
fs/btrfs/ioctl.c
··· 515 515 516 516 BUG_ON(ret); 517 517 518 - d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); 519 518 fail: 520 519 if (async_transid) { 521 520 *async_transid = trans->transid; ··· 524 525 } 525 526 if (err && !ret) 526 527 ret = err; 528 + 529 + if (!ret) 530 + d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); 531 + 527 532 return ret; 528 533 } 529 534
+10 -3
fs/btrfs/ordered-data.c
··· 836 836 * if the disk i_size is already at the inode->i_size, or 837 837 * this ordered extent is inside the disk i_size, we're done 838 838 */ 839 - if (disk_i_size == i_size || offset <= disk_i_size) { 839 + if (disk_i_size == i_size) 840 840 goto out; 841 - } 841 + 842 + /* 843 + * We still need to update disk_i_size if outstanding_isize is greater 844 + * than disk_i_size. 845 + */ 846 + if (offset <= disk_i_size && 847 + (!ordered || ordered->outstanding_isize <= disk_i_size)) 848 + goto out; 842 849 843 850 /* 844 851 * walk backward from this ordered extent to disk_i_size. ··· 877 870 break; 878 871 if (test->file_offset >= i_size) 879 872 break; 880 - if (test->file_offset >= disk_i_size) { 873 + if (entry_end(test) > disk_i_size) { 881 874 /* 882 875 * we don't update disk_i_size now, so record this 883 876 * undealt i_size. Or we will not know the real
+20 -5
fs/btrfs/scrub.c
··· 580 580 int corrected = 0; 581 581 struct btrfs_key key; 582 582 struct inode *inode = NULL; 583 + struct btrfs_fs_info *fs_info; 583 584 u64 end = offset + PAGE_SIZE - 1; 584 585 struct btrfs_root *local_root; 586 + int srcu_index; 585 587 586 588 key.objectid = root; 587 589 key.type = BTRFS_ROOT_ITEM_KEY; 588 590 key.offset = (u64)-1; 589 - local_root = btrfs_read_fs_root_no_name(fixup->root->fs_info, &key); 590 - if (IS_ERR(local_root)) 591 + 592 + fs_info = fixup->root->fs_info; 593 + srcu_index = srcu_read_lock(&fs_info->subvol_srcu); 594 + 595 + local_root = btrfs_read_fs_root_no_name(fs_info, &key); 596 + if (IS_ERR(local_root)) { 597 + srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); 591 598 return PTR_ERR(local_root); 599 + } 592 600 593 601 key.type = BTRFS_INODE_ITEM_KEY; 594 602 key.objectid = inum; 595 603 key.offset = 0; 596 - inode = btrfs_iget(fixup->root->fs_info->sb, &key, local_root, NULL); 604 + inode = btrfs_iget(fs_info->sb, &key, local_root, NULL); 605 + srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); 597 606 if (IS_ERR(inode)) 598 607 return PTR_ERR(inode); 599 608 ··· 615 606 } 616 607 617 608 if (PageUptodate(page)) { 618 - struct btrfs_fs_info *fs_info; 619 609 if (PageDirty(page)) { 620 610 /* 621 611 * we need to write the data to the defect sector. the ··· 3188 3180 u64 physical_for_dev_replace; 3189 3181 u64 len; 3190 3182 struct btrfs_fs_info *fs_info = nocow_ctx->sctx->dev_root->fs_info; 3183 + int srcu_index; 3191 3184 3192 3185 key.objectid = root; 3193 3186 key.type = BTRFS_ROOT_ITEM_KEY; 3194 3187 key.offset = (u64)-1; 3188 + 3189 + srcu_index = srcu_read_lock(&fs_info->subvol_srcu); 3190 + 3195 3191 local_root = btrfs_read_fs_root_no_name(fs_info, &key); 3196 - if (IS_ERR(local_root)) 3192 + if (IS_ERR(local_root)) { 3193 + srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); 3197 3194 return PTR_ERR(local_root); 3195 + } 3198 3196 3199 3197 key.type = BTRFS_INODE_ITEM_KEY; 3200 3198 key.objectid = inum; 3201 3199 key.offset = 0; 3202 3200 inode = btrfs_iget(fs_info->sb, &key, local_root, NULL); 3201 + srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); 3203 3202 if (IS_ERR(inode)) 3204 3203 return PTR_ERR(inode); 3205 3204
+19 -8
fs/btrfs/transaction.c
··· 333 333 &root->fs_info->trans_block_rsv, 334 334 num_bytes, flush); 335 335 if (ret) 336 - return ERR_PTR(ret); 336 + goto reserve_fail; 337 337 } 338 338 again: 339 339 h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS); 340 - if (!h) 341 - return ERR_PTR(-ENOMEM); 340 + if (!h) { 341 + ret = -ENOMEM; 342 + goto alloc_fail; 343 + } 342 344 343 345 /* 344 346 * If we are JOIN_NOLOCK we're already committing a transaction and ··· 367 365 if (ret < 0) { 368 366 /* We must get the transaction if we are JOIN_NOLOCK. */ 369 367 BUG_ON(type == TRANS_JOIN_NOLOCK); 370 - 371 - if (type < TRANS_JOIN_NOLOCK) 372 - sb_end_intwrite(root->fs_info->sb); 373 - kmem_cache_free(btrfs_trans_handle_cachep, h); 374 - return ERR_PTR(ret); 368 + goto join_fail; 375 369 } 376 370 377 371 cur_trans = root->fs_info->running_transaction; ··· 408 410 if (!current->journal_info && type != TRANS_USERSPACE) 409 411 current->journal_info = h; 410 412 return h; 413 + 414 + join_fail: 415 + if (type < TRANS_JOIN_NOLOCK) 416 + sb_end_intwrite(root->fs_info->sb); 417 + kmem_cache_free(btrfs_trans_handle_cachep, h); 418 + alloc_fail: 419 + if (num_bytes) 420 + btrfs_block_rsv_release(root, &root->fs_info->trans_block_rsv, 421 + num_bytes); 422 + reserve_fail: 423 + if (qgroup_reserved) 424 + btrfs_qgroup_free(root, qgroup_reserved); 425 + return ERR_PTR(ret); 411 426 } 412 427 413 428 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
+2 -1
fs/btrfs/volumes.c
··· 1556 1556 ret = 0; 1557 1557 1558 1558 /* Notify udev that device has changed */ 1559 - btrfs_kobject_uevent(bdev, KOBJ_CHANGE); 1559 + if (bdev) 1560 + btrfs_kobject_uevent(bdev, KOBJ_CHANGE); 1560 1561 1561 1562 error_brelse: 1562 1563 brelse(bh);