Commit bf4f776d authored by Jens Axboe's avatar Jens Axboe

Merge tag 'md-6.10-20240425' of...

Merge tag 'md-6.10-20240425' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.10/block

Pull MD fixes from Song:

"These changes contain various fixes by Yu Kuai, Li Nan, and
 Florian-Ewald Mueller."

* tag 'md-6.10-20240425' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
  md: don't account sync_io if iostats of the disk is disabled
  md: Fix overflow in is_mddev_idle
  md: add check for sleepers in md_wakeup_thread()
  md/raid5: fix deadlock that raid5d() wait for itself to clear MD_SB_CHANGE_PENDING
parents 57787fa4 9d1110f9
...@@ -8087,6 +8087,7 @@ void md_wakeup_thread(struct md_thread __rcu *thread) ...@@ -8087,6 +8087,7 @@ void md_wakeup_thread(struct md_thread __rcu *thread)
if (t) { if (t) {
pr_debug("md: waking up MD thread %s.\n", t->tsk->comm); pr_debug("md: waking up MD thread %s.\n", t->tsk->comm);
set_bit(THREAD_WAKEUP, &t->flags); set_bit(THREAD_WAKEUP, &t->flags);
if (wq_has_sleeper(&t->wqueue))
wake_up(&t->wqueue); wake_up(&t->wqueue);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -8576,14 +8577,19 @@ static int is_mddev_idle(struct mddev *mddev, int init) ...@@ -8576,14 +8577,19 @@ static int is_mddev_idle(struct mddev *mddev, int init)
{ {
struct md_rdev *rdev; struct md_rdev *rdev;
int idle; int idle;
int curr_events; long long curr_events;
idle = 1; idle = 1;
rcu_read_lock(); rcu_read_lock();
rdev_for_each_rcu(rdev, mddev) { rdev_for_each_rcu(rdev, mddev) {
struct gendisk *disk = rdev->bdev->bd_disk; struct gendisk *disk = rdev->bdev->bd_disk;
curr_events = (int)part_stat_read_accum(disk->part0, sectors) -
atomic_read(&disk->sync_io); if (!init && !blk_queue_io_stat(disk->queue))
continue;
curr_events =
(long long)part_stat_read_accum(disk->part0, sectors) -
atomic64_read(&disk->sync_io);
/* sync IO will cause sync_io to increase before the disk_stats /* sync IO will cause sync_io to increase before the disk_stats
* as sync_io is counted when a request starts, and * as sync_io is counted when a request starts, and
* disk_stats is counted when it completes. * disk_stats is counted when it completes.
......
...@@ -51,7 +51,7 @@ struct md_rdev { ...@@ -51,7 +51,7 @@ struct md_rdev {
sector_t sectors; /* Device size (in 512bytes sectors) */ sector_t sectors; /* Device size (in 512bytes sectors) */
struct mddev *mddev; /* RAID array if running */ struct mddev *mddev; /* RAID array if running */
int last_events; /* IO event timestamp */ long long last_events; /* IO event timestamp */
/* /*
* If meta_bdev is non-NULL, it means that a separate device is * If meta_bdev is non-NULL, it means that a separate device is
...@@ -621,7 +621,8 @@ extern void mddev_unlock(struct mddev *mddev); ...@@ -621,7 +621,8 @@ extern void mddev_unlock(struct mddev *mddev);
static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors) static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
{ {
atomic_add(nr_sectors, &bdev->bd_disk->sync_io); if (blk_queue_io_stat(bdev->bd_disk->queue))
atomic64_add(nr_sectors, &bdev->bd_disk->sync_io);
} }
static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors)
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
*/ */
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/raid/pq.h> #include <linux/raid/pq.h>
#include <linux/async_tx.h> #include <linux/async_tx.h>
...@@ -6734,6 +6733,9 @@ static void raid5d(struct md_thread *thread) ...@@ -6734,6 +6733,9 @@ static void raid5d(struct md_thread *thread)
int batch_size, released; int batch_size, released;
unsigned int offset; unsigned int offset;
if (test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags))
break;
released = release_stripe_list(conf, conf->temp_inactive_list); released = release_stripe_list(conf, conf->temp_inactive_list);
if (released) if (released)
clear_bit(R5_DID_ALLOC, &conf->cache_state); clear_bit(R5_DID_ALLOC, &conf->cache_state);
...@@ -6770,18 +6772,7 @@ static void raid5d(struct md_thread *thread) ...@@ -6770,18 +6772,7 @@ static void raid5d(struct md_thread *thread)
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
md_check_recovery(mddev); md_check_recovery(mddev);
spin_lock_irq(&conf->device_lock); spin_lock_irq(&conf->device_lock);
/*
* Waiting on MD_SB_CHANGE_PENDING below may deadlock
* seeing md_check_recovery() is needed to clear
* the flag when using mdmon.
*/
continue;
} }
wait_event_lock_irq(mddev->sb_wait,
!test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags),
conf->device_lock);
} }
pr_debug("%d stripes handled\n", handled); pr_debug("%d stripes handled\n", handled);
......
...@@ -172,7 +172,7 @@ struct gendisk { ...@@ -172,7 +172,7 @@ struct gendisk {
struct list_head slave_bdevs; struct list_head slave_bdevs;
#endif #endif
struct timer_rand_state *random; struct timer_rand_state *random;
atomic_t sync_io; /* RAID */ atomic64_t sync_io; /* RAID */
struct disk_events *ev; struct disk_events *ev;
#ifdef CONFIG_BLK_DEV_ZONED #ifdef CONFIG_BLK_DEV_ZONED
......
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