md: add infra for active_aligned_reads changes
PATCH v2 1/11 md: add infra for active_aligned_reads changes
Prepare to smoothly change the type of active_aligned_reads from atomic_t to percpu_ref.
Signed-off-by Keisuke TADA <[email protected]>
Signed-off-by Toshifumi OHTAKE <[email protected]>
--- drivers/md/raid5.c | 12 ++++++------ drivers/md/raid5.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-)
drivers/md/raid5.c +6 -6
@@ -5435,7 +5435,7 @@ static void raid5_align_endio(struct bio *bi)if (!error) {bio_endio (raid_bi); -if (atomic_dec_and_test (&conf->active_aligned_reads)) +if (active_aligned_reads_dec_and_test (conf))wake_up (&conf->wait_for_quiescent);return ; }
@@ -5499,7 +5499,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) did_inc = false;if (conf->quiesce ==0 ) { -atomic_inc (&conf->active_aligned_reads); +active_aligned_reads_inc (conf); did_inc = true; }/* need a memory barrier to detect the race with raid5_quiesce() */
@@ -5507,12 +5507,12 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)/* quiesce is in progress, so we need to undo io activation and wait * for it to finish */ -if (did_inc &&atomic_dec_and_test (&conf->active_aligned_reads)) +if (did_inc &&active_aligned_reads_dec_and_test (conf))wake_up (&conf->wait_for_quiescent);spin_lock_irq (&conf->device_lock);wait_event_lock_irq (conf->wait_for_quiescent, conf->quiesce ==0 , conf->device_lock); -atomic_inc (&conf->active_aligned_reads); +active_aligned_reads_inc (conf);spin_unlock_irq (&conf->device_lock); }
@@ -6608,7 +6608,7 @@ static int retry_aligned_read(struct r5conf *conf, struct bio *raid_bio,bio_endio (raid_bio); -if (atomic_dec_and_test (&conf->active_aligned_reads)) +if (active_aligned_reads_dec_and_test (conf))wake_up (&conf->wait_for_quiescent);return handled; }
@@ -8586,7 +8586,7 @@ static void raid5_quiesce(struct mddev *mddev, int quiesce)smp_store_release (&conf->quiesce,2 );wait_event_cmd (conf->wait_for_quiescent,atomic_read (&conf->active_stripes) ==0 && -atomic_read (&conf->active_aligned_reads) ==0 , +active_aligned_reads_is_zero (conf),unlock_all_device_hash_locks_irq (conf),lock_all_device_hash_locks_irq (conf)); conf->quiesce =1 ;
drivers/md/raid5.h +20 -0
@@ -696,6 +696,26 @@ struct r5conf {struct r5pending_data *next_pending_data; }; +static inline void active_aligned_reads_inc (struct r5conf *conf) +{ +atomic_inc (&conf->active_aligned_reads); +} + +static inline void active_aligned_reads_dec (struct r5conf *conf) +{ +atomic_dec (&conf->active_aligned_reads); +} + +static inline bool active_aligned_reads_is_zero (struct r5conf *conf) +{ +return atomic_read (&conf->active_aligned_reads) ==0 ; +} + +static inline bool active_aligned_reads_dec_and_test (struct r5conf *conf) +{ +return atomic_dec_and_test (&conf->active_aligned_reads); +} +#if PAGE_SIZE ==DEFAULT_STRIPE_SIZE #define RAID5_STRIPE_SIZE (conf) STRIPE_SIZE#define RAID5_STRIPE_SHIFT (conf) STRIPE_SHIFT
Signature · 1 line
2.34.1