From 7436dc65b5c51534a572a71c4fb78cc965254a76 Mon Sep 17 00:00:00 2001
From: huanghua <huanghua>
Date: Thu, 6 Nov 2008 03:25:10 +0000
Subject: [PATCH] Branch HEAD b=17083 i=yury.umanets i=nikita.danilov

Before destroying the whole mdt stack, just wait a little bit for the
obd_zombie_impexp_thread to destroy all the exports.
---
 lustre/mdt/mdt_handler.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c
index 3640dc98fd..42a6e78200 100644
--- a/lustre/mdt/mdt_handler.c
+++ b/lustre/mdt/mdt_handler.c
@@ -3811,6 +3811,19 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m)
         struct obd_device *obd = m->mdt_md_dev.md_lu_dev.ld_obd;
         ENTRY;
 
+        /* At this point, obd exports might still be on the "obd_zombie_exports"
+         * list, and obd_zombie_impexp_thread() is trying to destroy them.
+         * We wait a little bit until all exports (except the self-export) 
+         * have been destroyed, because the whole mdt stack might be accessed
+         * in mdt_destroy_export(). This will not be a long time, maybe one or
+         * two seconds are enough. This is not a problem while umounting.
+         *
+         * The three references that should be remaining are the
+         * obd_self_export and the attach and setup references.
+         */
+        while (atomic_read(&obd->obd_refcount) > 3)
+                cfs_schedule_timeout(CFS_TASK_UNINT, cfs_time_seconds(1));
+
         ping_evictor_stop();
 
         target_recovery_fini(obd);
-- 
GitLab