[PATCH] raid5: fix incorrectly counter of conf->empty_inactive_list_nr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The counter conf->empty_inactive_list_nr is only used for determine if
the raid5 is congested which is deal with in function
raid5_congested(). It was increased in get_free_stripe() when
conf->inactive_list got emptied and decreased in
release_inactive_stripe_list() when  splice temp_inactive_list to
conf->inactive_list. However, this could cause to problem when
raid5_get_active_stripe was called, this function may call
list_del_init(&sh->lru) to delete sh from  "conf->inactive_list +
hash" which may cause  "conf->inactive_list + hash" to be empty when
atomic_inc_not_zero(&sh->count) got false.
 I have found conf->empty_inactive_list_nr to be negative number
during my random test.
Is there anything out of my thinking?

--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -659,6 +659,7 @@ raid5_get_active_stripe(struct r5conf *conf,
sector_t sector,
 {
        struct stripe_head *sh;
        int hash = stripe_hash_locks_hash(sector);
+       int inc_empty_inactive_list_flag;

        pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector);

@@ -703,7 +704,14 @@ raid5_get_active_stripe(struct r5conf *conf,
sector_t sector,
                                        atomic_inc(&conf->active_stripes);
                                BUG_ON(list_empty(&sh->lru) &&
                                       !test_bit(STRIPE_EXPANDING, &sh->state));
+
+                               inc_empty_inactive_list_flag = 0;
+                               if(!list_empty(conf->inactive_list + hash))
+                                       inc_empty_inactive_list_flag = 1;
                                list_del_init(&sh->lru);
+                               if(list_empty(conf->inactive_list +
hash) && inc_empty_inactive_list_flag)
+
atomic_inc(&conf->empty_inactive_list_nr);
+
                                if (sh->group) {
                                        sh->group->stripes_cnt--;
                                        sh->group = NULL;
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux