diff options
author | Yu Kuai <yukuai3@huawei.com> | 2024-08-26 10:44:22 +0300 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2024-08-27 20:14:15 +0300 |
commit | 7545d385ec7e4c0d5e86e7cde4fe3fb8f4555fb9 (patch) | |
tree | 5ba7f4a1d188c7ca8feaf6509a1a05101eca60c4 /drivers/md/md.c | |
parent | 7add9db6ba3e9bd12d2be97abbc13f3881a515db (diff) | |
download | linux-7545d385ec7e4c0d5e86e7cde4fe3fb8f4555fb9.tar.xz |
md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
Other than internal api get_bitmap_from_slot(), all other places will
set returned bitmap to mddev->bitmap. So move the setting of
mddev->bitmap into md_bitmap_create() to simplify code.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-13-yukuai1@huaweicloud.com
Signed-off-by: Song Liu <song@kernel.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index f86e6911318f..7a041640c313 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -6224,16 +6224,10 @@ int md_run(struct mddev *mddev) } if (err == 0 && pers->sync_request && (mddev->bitmap_info.file || mddev->bitmap_info.offset)) { - struct bitmap *bitmap; - - bitmap = md_bitmap_create(mddev, -1); - if (IS_ERR(bitmap)) { - err = PTR_ERR(bitmap); + err = md_bitmap_create(mddev, -1); + if (err) pr_warn("%s: failed to create bitmap (%d)\n", mdname(mddev), err); - } else - mddev->bitmap = bitmap; - } if (err) goto bitmap_abort; @@ -7288,14 +7282,10 @@ static int set_bitmap_file(struct mddev *mddev, int fd) err = 0; if (mddev->pers) { if (fd >= 0) { - struct bitmap *bitmap; - - bitmap = md_bitmap_create(mddev, -1); - if (!IS_ERR(bitmap)) { - mddev->bitmap = bitmap; + err = md_bitmap_create(mddev, -1); + if (!err) err = md_bitmap_load(mddev); - } else - err = PTR_ERR(bitmap); + if (err) { md_bitmap_destroy(mddev); fd = -1; @@ -7304,6 +7294,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd) md_bitmap_destroy(mddev); } } + if (fd < 0) { struct file *f = mddev->bitmap_info.file; if (f) { @@ -7572,7 +7563,6 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) goto err; } if (info->state & (1<<MD_SB_BITMAP_PRESENT)) { - struct bitmap *bitmap; /* add the bitmap */ if (mddev->bitmap) { rv = -EEXIST; @@ -7586,12 +7576,10 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) mddev->bitmap_info.default_offset; mddev->bitmap_info.space = mddev->bitmap_info.default_space; - bitmap = md_bitmap_create(mddev, -1); - if (!IS_ERR(bitmap)) { - mddev->bitmap = bitmap; + rv = md_bitmap_create(mddev, -1); + if (!rv) rv = md_bitmap_load(mddev); - } else - rv = PTR_ERR(bitmap); + if (rv) md_bitmap_destroy(mddev); } else { |