Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
axboe committed Feb 8, 2023
2 parents 0abe39d + 76fed01 commit a872818
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a872818

Please sign in to comment.