Unverified Commit 844655fd authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents c3a5ce23 1e76628c
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -2350,7 +2350,7 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
	atomic_inc(&conf->active_stripes);

	raid5_release_stripe(sh);
	conf->max_nr_stripes++;
	WRITE_ONCE(conf->max_nr_stripes, conf->max_nr_stripes + 1);
	return 1;
}

@@ -2647,7 +2647,7 @@ static int drop_one_stripe(struct r5conf *conf)
	shrink_buffers(sh);
	free_stripe(conf->slab_cache, sh);
	atomic_dec(&conf->active_stripes);
	conf->max_nr_stripes--;
	WRITE_ONCE(conf->max_nr_stripes, conf->max_nr_stripes - 1);
	return 1;
}

@@ -6570,7 +6570,7 @@ raid5_set_cache_size(struct mddev *mddev, int size)
	if (size <= 16 || size > 32768)
		return -EINVAL;

	conf->min_nr_stripes = size;
	WRITE_ONCE(conf->min_nr_stripes, size);
	mutex_lock(&conf->cache_size_mutex);
	while (size < conf->max_nr_stripes &&
	       drop_one_stripe(conf))
@@ -6582,7 +6582,7 @@ raid5_set_cache_size(struct mddev *mddev, int size)
	mutex_lock(&conf->cache_size_mutex);
	while (size > conf->max_nr_stripes)
		if (!grow_one_stripe(conf, GFP_KERNEL)) {
			conf->min_nr_stripes = conf->max_nr_stripes;
			WRITE_ONCE(conf->min_nr_stripes, conf->max_nr_stripes);
			result = -ENOMEM;
			break;
		}
@@ -7146,11 +7146,13 @@ static unsigned long raid5_cache_count(struct shrinker *shrink,
				       struct shrink_control *sc)
{
	struct r5conf *conf = container_of(shrink, struct r5conf, shrinker);
	int max_stripes = READ_ONCE(conf->max_nr_stripes);
	int min_stripes = READ_ONCE(conf->min_nr_stripes);

	if (conf->max_nr_stripes < conf->min_nr_stripes)
	if (max_stripes < min_stripes)
		/* unlikely, but not impossible */
		return 0;
	return conf->max_nr_stripes - conf->min_nr_stripes;
	return max_stripes - min_stripes;
}

static struct r5conf *setup_conf(struct mddev *mddev)