diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-02-08 16:59:35 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-02-08 16:59:35 -0700 |
commit | a872818f484d69944c10be555941b2a73f6e1d4f (patch) | |
tree | cfd8694bedd41a4a5cb6a3a9c7899704182fcfe4 | |
parent | 0abe39dec065133e3f92a52219c3728fe7d7617f (diff) | |
parent | 76fed01420bb8b0e282745a4945925b25751d42b (diff) |
Merge branch 'md-next' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.3/block
Pull MD fix from Song:
"This commit fixes a rare crash during the takeover process."
* 'md-next' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
md: account io_acct_set usage with active_io
-rw-r--r-- | drivers/md/md.c | 6 | ||||
-rw-r--r-- | drivers/md/md.h | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 1961105712b7..927a43db5dfb 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8628,12 +8628,15 @@ static void md_end_io_acct(struct bio *bio) { struct md_io_acct *md_io_acct = bio->bi_private; struct bio *orig_bio = md_io_acct->orig_bio; + struct mddev *mddev = md_io_acct->mddev; orig_bio->bi_status = bio->bi_status; bio_end_io_acct(orig_bio, md_io_acct->start_time); bio_put(bio); bio_endio(orig_bio); + + percpu_ref_put(&mddev->active_io); } /* @@ -8649,10 +8652,13 @@ void md_account_bio(struct mddev *mddev, struct bio **bio) if (!blk_queue_io_stat(bdev->bd_disk->queue)) return; + percpu_ref_get(&mddev->active_io); + clone = bio_alloc_clone(bdev, *bio, GFP_NOIO, &mddev->io_acct_set); md_io_acct = container_of(clone, struct md_io_acct, bio_clone); md_io_acct->orig_bio = *bio; md_io_acct->start_time = bio_start_io_acct(*bio); + md_io_acct->mddev = mddev; clone->bi_end_io = md_end_io_acct; clone->bi_private = md_io_acct; diff --git a/drivers/md/md.h b/drivers/md/md.h index 6335cb86e52e..e148e3c83b0d 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -710,9 +710,10 @@ struct md_thread { }; struct md_io_acct { - struct bio *orig_bio; - unsigned long start_time; - struct bio bio_clone; + struct mddev *mddev; + struct bio *orig_bio; + unsigned long start_time; + struct bio bio_clone; }; #define THREAD_WAKEUP 0 |