Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33ddd841 authored by Niu Yawei's avatar Niu Yawei Committed by Greg Kroah-Hartman
Browse files

staging: lustre: obdclass: serialize lu_site purge



Umount process relies on lu_site_purge(-1) to purge all
objects before umount, however, if there happen to have a
cache shrinker which calls lu_site_purge(nr) in parallel,
some objects may still being freed by cache shrinker even
after the lu_site_purge(-1) called by umount done.

This can be simply fixed by serializing purge threads,
since it doesn't make any sense to have them in parallel.

Signed-off-by: default avatarNiu Yawei <yawei.niu@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5331
Reviewed-on: http://review.whamcloud.com/11099


Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Reviewed-by: default avatarMike Pershin <mike.pershin@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 638814f6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -622,6 +622,11 @@ struct lu_site {
	struct list_head		ls_ld_linkage;
	spinlock_t		ls_ld_lock;

	/**
	 * Lock to serialize site purge.
	 */
	struct mutex		ls_purge_mutex;

	/**
	 * lu_site stats
	 */
+7 −0
Original line number Diff line number Diff line
@@ -354,6 +354,11 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
	start = s->ls_purge_start;
	bnr = (nr == ~0) ? -1 : nr / CFS_HASH_NBKT(s->ls_obj_hash) + 1;
 again:
	/*
	 * It doesn't make any sense to make purge threads parallel, that can
	 * only bring troubles to us. See LU-5331.
	 */
	mutex_lock(&s->ls_purge_mutex);
	did_sth = 0;
	cfs_hash_for_each_bucket(s->ls_obj_hash, &bd, i) {
		if (i < start)
@@ -399,6 +404,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
		if (nr == 0)
			break;
	}
	mutex_unlock(&s->ls_purge_mutex);

	if (nr != 0 && did_sth && start != 0) {
		start = 0; /* restart from the first bucket */
@@ -983,6 +989,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
	char name[16];

	memset(s, 0, sizeof(*s));
	mutex_init(&s->ls_purge_mutex);
	snprintf(name, 16, "lu_site_%s", top->ld_type->ldt_name);
	for (bits = lu_htable_order(top); bits >= LU_SITE_BITS_MIN; bits--) {
		s->ls_obj_hash = cfs_hash_create(name, bits, bits,