Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-6.15-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:

- revert device path canonicalization, this does not work as intended
with namespaces and is not reliable in all setups

- fix crash in scrub when checksum tree is not valid, e.g. when mounted
with rescue=ignoredatacsums

- fix crash when tracepoint btrfs_prelim_ref_insert is enabled

- other minor fixups:
- open code folio_index(), meant to be used in MM code
- use matching type for sizeof in compression allocation

* tag 'for-6.15-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: open code folio_index() in btree_clear_folio_dirty_tag()
Revert "btrfs: canonicalize the device path before adding it"
btrfs: avoid NULL pointer dereference if no valid csum tree
btrfs: handle empty eb->folios in num_extent_folios()
btrfs: correct the order of prelim_ref arguments in btrfs__prelim_ref
btrfs: compression: adjust cb->compressed_folios allocation type

+9 -96
+1 -1
fs/btrfs/compression.c
··· 606 606 free_extent_map(em); 607 607 608 608 cb->nr_folios = DIV_ROUND_UP(compressed_len, PAGE_SIZE); 609 - cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct page *), GFP_NOFS); 609 + cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct folio *), GFP_NOFS); 610 610 if (!cb->compressed_folios) { 611 611 ret = BLK_STS_RESOURCE; 612 612 goto out_free_bio;
+2 -2
fs/btrfs/extent_io.c
··· 3508 3508 ASSERT(folio_test_locked(folio)); 3509 3509 xa_lock_irq(&folio->mapping->i_pages); 3510 3510 if (!folio_test_dirty(folio)) 3511 - __xa_clear_mark(&folio->mapping->i_pages, 3512 - folio_index(folio), PAGECACHE_TAG_DIRTY); 3511 + __xa_clear_mark(&folio->mapping->i_pages, folio->index, 3512 + PAGECACHE_TAG_DIRTY); 3513 3513 xa_unlock_irq(&folio->mapping->i_pages); 3514 3514 } 3515 3515
+2
fs/btrfs/extent_io.h
··· 298 298 */ 299 299 static inline int __pure num_extent_folios(const struct extent_buffer *eb) 300 300 { 301 + if (!eb->folios[0]) 302 + return 0; 301 303 if (folio_order(eb->folios[0])) 302 304 return 1; 303 305 return num_extent_pages(eb);
+2 -2
fs/btrfs/scrub.c
··· 1541 1541 u64 extent_gen; 1542 1542 int ret; 1543 1543 1544 - if (unlikely(!extent_root)) { 1545 - btrfs_err(fs_info, "no valid extent root for scrub"); 1544 + if (unlikely(!extent_root || !csum_root)) { 1545 + btrfs_err(fs_info, "no valid extent or csum root for scrub"); 1546 1546 return -EUCLEAN; 1547 1547 } 1548 1548 memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) *
+1 -90
fs/btrfs/volumes.c
··· 733 733 return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; 734 734 } 735 735 736 - /* 737 - * We can have very weird soft links passed in. 738 - * One example is "/proc/self/fd/<fd>", which can be a soft link to 739 - * a block device. 740 - * 741 - * But it's never a good idea to use those weird names. 742 - * Here we check if the path (not following symlinks) is a good one inside 743 - * "/dev/". 744 - */ 745 - static bool is_good_dev_path(const char *dev_path) 746 - { 747 - struct path path = { .mnt = NULL, .dentry = NULL }; 748 - char *path_buf = NULL; 749 - char *resolved_path; 750 - bool is_good = false; 751 - int ret; 752 - 753 - if (!dev_path) 754 - goto out; 755 - 756 - path_buf = kmalloc(PATH_MAX, GFP_KERNEL); 757 - if (!path_buf) 758 - goto out; 759 - 760 - /* 761 - * Do not follow soft link, just check if the original path is inside 762 - * "/dev/". 763 - */ 764 - ret = kern_path(dev_path, 0, &path); 765 - if (ret) 766 - goto out; 767 - resolved_path = d_path(&path, path_buf, PATH_MAX); 768 - if (IS_ERR(resolved_path)) 769 - goto out; 770 - if (strncmp(resolved_path, "/dev/", strlen("/dev/"))) 771 - goto out; 772 - is_good = true; 773 - out: 774 - kfree(path_buf); 775 - path_put(&path); 776 - return is_good; 777 - } 778 - 779 - static int get_canonical_dev_path(const char *dev_path, char *canonical) 780 - { 781 - struct path path = { .mnt = NULL, .dentry = NULL }; 782 - char *path_buf = NULL; 783 - char *resolved_path; 784 - int ret; 785 - 786 - if (!dev_path) { 787 - ret = -EINVAL; 788 - goto out; 789 - } 790 - 791 - path_buf = kmalloc(PATH_MAX, GFP_KERNEL); 792 - if (!path_buf) { 793 - ret = -ENOMEM; 794 - goto out; 795 - } 796 - 797 - ret = kern_path(dev_path, LOOKUP_FOLLOW, &path); 798 - if (ret) 799 - goto out; 800 - resolved_path = d_path(&path, path_buf, PATH_MAX); 801 - if (IS_ERR(resolved_path)) { 802 - ret = PTR_ERR(resolved_path); 803 - goto out; 804 - } 805 - ret = strscpy(canonical, resolved_path, PATH_MAX); 806 - out: 807 - kfree(path_buf); 808 - path_put(&path); 809 - return ret; 810 - } 811 - 812 736 static bool is_same_device(struct btrfs_device *device, const char *new_path) 813 737 { 814 738 struct path old = { .mnt = NULL, .dentry = NULL }; ··· 1437 1513 bool new_device_added = false; 1438 1514 struct btrfs_device *device = NULL; 1439 1515 struct file *bdev_file; 1440 - char *canonical_path = NULL; 1441 1516 u64 bytenr; 1442 1517 dev_t devt; 1443 1518 int ret; 1444 1519 1445 1520 lockdep_assert_held(&uuid_mutex); 1446 1521 1447 - if (!is_good_dev_path(path)) { 1448 - canonical_path = kmalloc(PATH_MAX, GFP_KERNEL); 1449 - if (canonical_path) { 1450 - ret = get_canonical_dev_path(path, canonical_path); 1451 - if (ret < 0) { 1452 - kfree(canonical_path); 1453 - canonical_path = NULL; 1454 - } 1455 - } 1456 - } 1457 1522 /* 1458 1523 * Avoid an exclusive open here, as the systemd-udev may initiate the 1459 1524 * device scan which may race with the user's mount or mkfs command, ··· 1487 1574 goto free_disk_super; 1488 1575 } 1489 1576 1490 - device = device_list_add(canonical_path ? : path, disk_super, 1491 - &new_device_added); 1577 + device = device_list_add(path, disk_super, &new_device_added); 1492 1578 if (!IS_ERR(device) && new_device_added) 1493 1579 btrfs_free_stale_devices(device->devt, device); 1494 1580 ··· 1496 1584 1497 1585 error_bdev_put: 1498 1586 fput(bdev_file); 1499 - kfree(canonical_path); 1500 1587 1501 1588 return device; 1502 1589 }
+1 -1
include/trace/events/btrfs.h
··· 1928 1928 TP_PROTO(const struct btrfs_fs_info *fs_info, 1929 1929 const struct prelim_ref *oldref, 1930 1930 const struct prelim_ref *newref, u64 tree_size), 1931 - TP_ARGS(fs_info, newref, oldref, tree_size), 1931 + TP_ARGS(fs_info, oldref, newref, tree_size), 1932 1932 1933 1933 TP_STRUCT__entry_btrfs( 1934 1934 __field( u64, root_id )