diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-11 22:22:59 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-11 22:25:12 -0400 |
commit | f3976e3733e97a0e96f5fc6349d1e82b25116043 (patch) | |
tree | 87ab725ba56735f2157e77dc6bc4bc1c910890b2 /libbcachefs/super-io.c | |
parent | bcee0320dcb53adb3786330a00a101840f2939d0 (diff) |
Update bcachefs sources to b0788c47d9 bcachefs: Fix check_version_upgrade()
Diffstat (limited to 'libbcachefs/super-io.c')
-rw-r--r-- | libbcachefs/super-io.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libbcachefs/super-io.c b/libbcachefs/super-io.c index 86270288..b6021b73 100644 --- a/libbcachefs/super-io.c +++ b/libbcachefs/super-io.c @@ -198,8 +198,14 @@ int bch2_sb_realloc(struct bch_sb_handle *sb, unsigned u64s) if (dynamic_fault("bcachefs:add:super_realloc")) return -BCH_ERR_ENOMEM_sb_realloc_injected; + new_sb = krealloc(sb->sb, new_buffer_size, GFP_NOFS|__GFP_ZERO); + if (!new_sb) + return -BCH_ERR_ENOMEM_sb_buf_realloc; + + sb->sb = new_sb; + if (sb->have_bio) { - unsigned nr_bvecs = DIV_ROUND_UP(new_buffer_size, PAGE_SIZE); + unsigned nr_bvecs = buf_pages(sb->sb, new_buffer_size); bio = bio_kmalloc(nr_bvecs, GFP_KERNEL); if (!bio) @@ -211,11 +217,6 @@ int bch2_sb_realloc(struct bch_sb_handle *sb, unsigned u64s) sb->bio = bio; } - new_sb = krealloc(sb->sb, new_buffer_size, GFP_NOFS|__GFP_ZERO); - if (!new_sb) - return -BCH_ERR_ENOMEM_sb_buf_realloc; - - sb->sb = new_sb; sb->buffer_size = new_buffer_size; return 0; @@ -547,7 +548,9 @@ static int __copy_super(struct bch_sb_handle *dst_handle, struct bch_sb *src) d = (src_f ? le32_to_cpu(src_f->u64s) : 0) - (dst_f ? le32_to_cpu(dst_f->u64s) : 0); if (d > 0) { - int ret = bch2_sb_realloc(dst_handle, le32_to_cpu(dst_handle->sb->u64s) + d); + int ret = bch2_sb_realloc(dst_handle, + le32_to_cpu(dst_handle->sb->u64s) + d); + if (ret) return ret; |