Skip to content

Commit edf6b0e

Browse files
committed
Merge tag 'for-5.9-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: "A few more fixes: - regression fix for a crash after failed snapshot creation - one more lockep fix: use nofs allocation when allocating missing device - fix reloc tree leak on degraded mount - make some extent buffer alignment checks less strict to mount filesystems created by btrfs-convert" * tag 'for-5.9-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix NULL pointer dereference after failure to create snapshot btrfs: free data reloc tree on failed mount btrfs: require only sector size alignment for parent eb bytenr btrfs: fix lockdep splat in add_missing_dev
2 parents 5a3c558 + 2d892cc commit edf6b0e

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

fs/btrfs/disk-io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3418,6 +3418,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
34183418
btrfs_put_block_group_cache(fs_info);
34193419

34203420
fail_tree_roots:
3421+
if (fs_info->data_reloc_root)
3422+
btrfs_drop_and_free_fs_root(fs_info, fs_info->data_reloc_root);
34213423
free_root_pointers(fs_info, true);
34223424
invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
34233425

fs/btrfs/extent-tree.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,11 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
400400
if (type == BTRFS_SHARED_BLOCK_REF_KEY) {
401401
ASSERT(eb->fs_info);
402402
/*
403-
* Every shared one has parent tree
404-
* block, which must be aligned to
405-
* nodesize.
403+
* Every shared one has parent tree block,
404+
* which must be aligned to sector size.
406405
*/
407406
if (offset &&
408-
IS_ALIGNED(offset, eb->fs_info->nodesize))
407+
IS_ALIGNED(offset, eb->fs_info->sectorsize))
409408
return type;
410409
}
411410
} else if (is_data == BTRFS_REF_TYPE_DATA) {
@@ -414,12 +413,11 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
414413
if (type == BTRFS_SHARED_DATA_REF_KEY) {
415414
ASSERT(eb->fs_info);
416415
/*
417-
* Every shared one has parent tree
418-
* block, which must be aligned to
419-
* nodesize.
416+
* Every shared one has parent tree block,
417+
* which must be aligned to sector size.
420418
*/
421419
if (offset &&
422-
IS_ALIGNED(offset, eb->fs_info->nodesize))
420+
IS_ALIGNED(offset, eb->fs_info->sectorsize))
423421
return type;
424422
}
425423
} else {
@@ -429,8 +427,9 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
429427
}
430428

431429
btrfs_print_leaf((struct extent_buffer *)eb);
432-
btrfs_err(eb->fs_info, "eb %llu invalid extent inline ref type %d",
433-
eb->start, type);
430+
btrfs_err(eb->fs_info,
431+
"eb %llu iref 0x%lx invalid extent inline ref type %d",
432+
eb->start, (unsigned long)iref, type);
434433
WARN_ON(1);
435434

436435
return BTRFS_REF_TYPE_INVALID;

fs/btrfs/print-tree.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
9595
* offset is supposed to be a tree block which
9696
* must be aligned to nodesize.
9797
*/
98-
if (!IS_ALIGNED(offset, eb->fs_info->nodesize))
99-
pr_info("\t\t\t(parent %llu is NOT ALIGNED to nodesize %llu)\n",
100-
offset, (unsigned long long)eb->fs_info->nodesize);
98+
if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
99+
pr_info(
100+
"\t\t\t(parent %llu not aligned to sectorsize %u)\n",
101+
offset, eb->fs_info->sectorsize);
101102
break;
102103
case BTRFS_EXTENT_DATA_REF_KEY:
103104
dref = (struct btrfs_extent_data_ref *)(&iref->offset);
@@ -112,8 +113,9 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
112113
* must be aligned to nodesize.
113114
*/
114115
if (!IS_ALIGNED(offset, eb->fs_info->nodesize))
115-
pr_info("\t\t\t(parent %llu is NOT ALIGNED to nodesize %llu)\n",
116-
offset, (unsigned long long)eb->fs_info->nodesize);
116+
pr_info(
117+
"\t\t\t(parent %llu not aligned to sectorsize %u)\n",
118+
offset, eb->fs_info->sectorsize);
117119
break;
118120
default:
119121
pr_cont("(extent %llu has INVALID ref type %d)\n",

fs/btrfs/transaction.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
16361636
pending->snap = btrfs_get_new_fs_root(fs_info, objectid, pending->anon_dev);
16371637
if (IS_ERR(pending->snap)) {
16381638
ret = PTR_ERR(pending->snap);
1639+
pending->snap = NULL;
16391640
btrfs_abort_transaction(trans, ret);
16401641
goto fail;
16411642
}

fs/btrfs/volumes.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <linux/sched.h>
7+
#include <linux/sched/mm.h>
78
#include <linux/bio.h>
89
#include <linux/slab.h>
910
#include <linux/blkdev.h>
@@ -6484,8 +6485,17 @@ static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices,
64846485
u64 devid, u8 *dev_uuid)
64856486
{
64866487
struct btrfs_device *device;
6488+
unsigned int nofs_flag;
64876489

6490+
/*
6491+
* We call this under the chunk_mutex, so we want to use NOFS for this
6492+
* allocation, however we don't want to change btrfs_alloc_device() to
6493+
* always do NOFS because we use it in a lot of other GFP_KERNEL safe
6494+
* places.
6495+
*/
6496+
nofs_flag = memalloc_nofs_save();
64886497
device = btrfs_alloc_device(NULL, &devid, dev_uuid);
6498+
memalloc_nofs_restore(nofs_flag);
64896499
if (IS_ERR(device))
64906500
return device;
64916501

0 commit comments

Comments
 (0)