Skip to content

Commit 093e037

Browse files
committed
Revert "btrfs: use proper endianness accessors for super_copy"
This reverts commit 3c181c1. The offending patch was merged in 4.16-rc4 and was promptly applied to stable kernels 4.14.25 and 4.15.8. The patch causes a corruption in several superblock items on big-endian machines because of messed up endianity conversions. The damage is manually repairable. A filesystem cannot be mounted again after it has been unmounted once. We do a full revert and not a fixup so stable can pick that patch ASAP. Fixes: 3c181c1 ("btrfs: use proper endianness accessors for super_copy") Link: https://lkml.kernel.org/r/[email protected] CC: [email protected] # 4.14+ Reported-by: Christoph Biedl <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 18bf591 commit 093e037

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

fs/btrfs/sysfs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj,
423423
{
424424
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
425425

426-
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->nodesize);
426+
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize);
427427
}
428428

429429
BTRFS_ATTR(, nodesize, btrfs_nodesize_show);
@@ -433,7 +433,8 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
433433
{
434434
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
435435

436-
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->sectorsize);
436+
return snprintf(buf, PAGE_SIZE, "%u\n",
437+
fs_info->super_copy->sectorsize);
437438
}
438439

439440
BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show);
@@ -443,7 +444,8 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
443444
{
444445
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
445446

446-
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->sectorsize);
447+
return snprintf(buf, PAGE_SIZE, "%u\n",
448+
fs_info->super_copy->sectorsize);
447449
}
448450

449451
BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);

fs/btrfs/transaction.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,23 +1722,19 @@ static void update_super_roots(struct btrfs_fs_info *fs_info)
17221722

17231723
super = fs_info->super_copy;
17241724

1725-
/* update latest btrfs_super_block::chunk_root refs */
17261725
root_item = &fs_info->chunk_root->root_item;
1727-
btrfs_set_super_chunk_root(super, root_item->bytenr);
1728-
btrfs_set_super_chunk_root_generation(super, root_item->generation);
1729-
btrfs_set_super_chunk_root_level(super, root_item->level);
1726+
super->chunk_root = root_item->bytenr;
1727+
super->chunk_root_generation = root_item->generation;
1728+
super->chunk_root_level = root_item->level;
17301729

1731-
/* update latest btrfs_super_block::root refs */
17321730
root_item = &fs_info->tree_root->root_item;
1733-
btrfs_set_super_root(super, root_item->bytenr);
1734-
btrfs_set_super_generation(super, root_item->generation);
1735-
btrfs_set_super_root_level(super, root_item->level);
1736-
1731+
super->root = root_item->bytenr;
1732+
super->generation = root_item->generation;
1733+
super->root_level = root_item->level;
17371734
if (btrfs_test_opt(fs_info, SPACE_CACHE))
1738-
btrfs_set_super_cache_generation(super, root_item->generation);
1735+
super->cache_generation = root_item->generation;
17391736
if (test_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags))
1740-
btrfs_set_super_uuid_tree_generation(super,
1741-
root_item->generation);
1737+
super->uuid_tree_generation = root_item->generation;
17421738
}
17431739

17441740
int btrfs_transaction_in_commit(struct btrfs_fs_info *info)

0 commit comments

Comments
 (0)