Commit daee2024 authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Song Liu

md: check level before create and exit io_acct_set

The bio_set (io_acct_set) is used by personalities to clone bio and
trace the timestamp of bio. Some personalities such as raid1/10 don't
need the bio_set, so add check to not create it unconditionally.

Also update the comment for md_account_bio to make it more clear.
Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarGuoqing Jiang <jiangguoqing@kylinos.cn>
Signed-off-by: default avatarSong Liu <song@kernel.org>
parent c32dc040
......@@ -2341,7 +2341,8 @@ int md_integrity_register(struct mddev *mddev)
pr_debug("md: data integrity enabled on %s\n", mdname(mddev));
if (bioset_integrity_create(&mddev->bio_set, BIO_POOL_SIZE) ||
bioset_integrity_create(&mddev->io_acct_set, BIO_POOL_SIZE)) {
(mddev->level != 1 && mddev->level != 10 &&
bioset_integrity_create(&mddev->io_acct_set, BIO_POOL_SIZE))) {
pr_err("md: failed to create integrity pool for %s\n",
mdname(mddev));
return -EINVAL;
......@@ -5570,7 +5571,8 @@ static void md_free(struct kobject *ko)
bioset_exit(&mddev->bio_set);
bioset_exit(&mddev->sync_set);
bioset_exit(&mddev->io_acct_set);
if (mddev->level != 1 && mddev->level != 10)
bioset_exit(&mddev->io_acct_set);
kfree(mddev);
}
......@@ -5866,7 +5868,8 @@ int md_run(struct mddev *mddev)
if (err)
goto exit_bio_set;
}
if (!bioset_initialized(&mddev->io_acct_set)) {
if (mddev->level != 1 && mddev->level != 10 &&
!bioset_initialized(&mddev->io_acct_set)) {
err = bioset_init(&mddev->io_acct_set, BIO_POOL_SIZE,
offsetof(struct md_io_acct, bio_clone), 0);
if (err)
......@@ -6048,7 +6051,8 @@ int md_run(struct mddev *mddev)
module_put(pers->owner);
md_bitmap_destroy(mddev);
abort:
bioset_exit(&mddev->io_acct_set);
if (mddev->level != 1 && mddev->level != 10)
bioset_exit(&mddev->io_acct_set);
exit_sync_set:
bioset_exit(&mddev->sync_set);
exit_bio_set:
......@@ -6276,7 +6280,8 @@ void md_stop(struct mddev *mddev)
__md_stop(mddev);
bioset_exit(&mddev->bio_set);
bioset_exit(&mddev->sync_set);
bioset_exit(&mddev->io_acct_set);
if (mddev->level != 1 && mddev->level != 10)
bioset_exit(&mddev->io_acct_set);
}
EXPORT_SYMBOL_GPL(md_stop);
......@@ -8593,7 +8598,10 @@ static void md_end_io_acct(struct bio *bio)
bio_endio(orig_bio);
}
/* used by personalities (raid0 and raid5) to account io stats */
/*
* Used by personalities that don't already clone the bio and thus can't
* easily add the timestamp to their extended bio structure.
*/
void md_account_bio(struct mddev *mddev, struct bio **bio)
{
struct md_io_acct *md_io_acct;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment