Skip to content

Commit 5423399

Browse files
committed
md/raid5: change ->inactive_blocked to a bit-flag.
This allows us to easily add more (atomic) flags. Signed-off-by: NeilBrown <[email protected]>
1 parent 486f064 commit 5423399

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

drivers/md/raid5.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,20 +672,23 @@ get_active_stripe(struct r5conf *conf, sector_t sector,
672672
*(conf->hash_locks + hash));
673673
sh = __find_stripe(conf, sector, conf->generation - previous);
674674
if (!sh) {
675-
if (!conf->inactive_blocked)
675+
if (!test_bit(R5_INACTIVE_BLOCKED, &conf->cache_state))
676676
sh = get_free_stripe(conf, hash);
677677
if (noblock && sh == NULL)
678678
break;
679679
if (!sh) {
680-
conf->inactive_blocked = 1;
680+
set_bit(R5_INACTIVE_BLOCKED,
681+
&conf->cache_state);
681682
wait_event_lock_irq(
682683
conf->wait_for_stripe,
683684
!list_empty(conf->inactive_list + hash) &&
684685
(atomic_read(&conf->active_stripes)
685686
< (conf->max_nr_stripes * 3 / 4)
686-
|| !conf->inactive_blocked),
687+
|| !test_bit(R5_INACTIVE_BLOCKED,
688+
&conf->cache_state)),
687689
*(conf->hash_locks + hash));
688-
conf->inactive_blocked = 0;
690+
clear_bit(R5_INACTIVE_BLOCKED,
691+
&conf->cache_state);
689692
} else {
690693
init_stripe(sh, sector, previous);
691694
atomic_inc(&sh->count);
@@ -4602,7 +4605,7 @@ static int raid5_congested(struct mddev *mddev, int bits)
46024605
* how busy the stripe_cache is
46034606
*/
46044607

4605-
if (conf->inactive_blocked)
4608+
if (test_bit(R5_INACTIVE_BLOCKED, &conf->cache_state))
46064609
return 1;
46074610
if (conf->quiesce)
46084611
return 1;

drivers/md/raid5.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,11 @@ struct r5conf {
509509
struct llist_head released_stripes;
510510
wait_queue_head_t wait_for_stripe;
511511
wait_queue_head_t wait_for_overlap;
512-
int inactive_blocked; /* release of inactive stripes blocked,
513-
* waiting for 25% to be free
514-
*/
512+
unsigned long cache_state;
513+
#define R5_INACTIVE_BLOCKED 1 /* release of inactive stripes blocked,
514+
* waiting for 25% to be free
515+
*/
516+
515517
int pool_size; /* number of disks in stripeheads in pool */
516518
spinlock_t device_lock;
517519
struct disk_info *disks;
@@ -526,6 +528,7 @@ struct r5conf {
526528
int worker_cnt_per_group;
527529
};
528530

531+
529532
/*
530533
* Our supported algorithms
531534
*/

0 commit comments

Comments
 (0)