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

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

staging: lustre: obdecho: don't copy lu_site



While creating an echo device, echo_device_alloc() copies the lu_site
from MD stack, such kind of copy result in uninitialized mutex and
other potential issues.

Instead of copying the lu_site, we'd use the lu_site by pointer directly.

Signed-off-by: default avatarNiu Yawei <yawei.niu@intel.com>
Signed-off-by: default avatarOlaf Faaland <faaland1@llnl.gov>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6765
Reviewed-on: http://review.whamcloud.com/15657


Reviewed-by: default avatarBobi Jam <bobijam@hotmail.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@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 f0a3b550
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ struct echo_device {
	struct echo_client_obd *ed_ec;

	struct cl_site	  ed_site_myself;
	struct cl_site	 *ed_site;
	struct lu_site		*ed_site;
	struct lu_device       *ed_next;
};

@@ -527,17 +527,19 @@ static int echo_site_init(const struct lu_env *env, struct echo_device *ed)
	}

	rc = lu_site_init_finish(&site->cs_lu);
	if (rc)
	if (rc) {
		cl_site_fini(site);
		return rc;
	}

	ed->ed_site = site;
	ed->ed_site = &site->cs_lu;
	return 0;
}

static void echo_site_fini(const struct lu_env *env, struct echo_device *ed)
{
	if (ed->ed_site) {
		cl_site_fini(ed->ed_site);
		lu_site_fini(ed->ed_site);
		ed->ed_site = NULL;
	}
}
@@ -674,7 +676,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
			goto out_cleanup;
		}

		next->ld_site = &ed->ed_site->cs_lu;
		next->ld_site = ed->ed_site;
		rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
						next->ld_type->ldt_name,
							      NULL);
@@ -741,7 +743,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
	CDEBUG(D_INFO, "echo device:%p is going to be freed, next = %p\n",
	       ed, next);

	lu_site_purge(env, &ed->ed_site->cs_lu, -1);
	lu_site_purge(env, ed->ed_site, -1);

	/* check if there are objects still alive.
	 * It shouldn't have any object because lu_site_purge would cleanup
@@ -754,7 +756,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
	spin_unlock(&ec->ec_lock);

	/* purge again */
	lu_site_purge(env, &ed->ed_site->cs_lu, -1);
	lu_site_purge(env, ed->ed_site, -1);

	CDEBUG(D_INFO,
	       "Waiting for the reference of echo object to be dropped\n");
@@ -766,7 +768,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
		CERROR("echo_client still has objects at cleanup time, wait for 1 second\n");
		set_current_state(TASK_UNINTERRUPTIBLE);
		schedule_timeout(cfs_time_seconds(1));
		lu_site_purge(env, &ed->ed_site->cs_lu, -1);
		lu_site_purge(env, ed->ed_site, -1);
		spin_lock(&ec->ec_lock);
	}
	spin_unlock(&ec->ec_lock);
@@ -780,7 +782,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
	while (next)
		next = next->ld_type->ldt_ops->ldto_device_free(env, next);

	LASSERT(ed->ed_site == lu2cl_site(d->ld_site));
	LASSERT(ed->ed_site == d->ld_site);
	echo_site_fini(env, ed);
	cl_device_fini(&ed->ed_cl);
	kfree(ed);