Whamcloud - gitweb
LU-8592 mdt: hold mdt_device::mdt_md_root until service stop
[fs/lustre-release.git] / lustre / mdt / mdt_open.c
index 8d64eb8..9bd929f 100644 (file)
@@ -1189,10 +1189,22 @@ static int mdt_lock_root_xattr(struct mdt_thread_info *info,
                        return PTR_ERR(md_root);
 
                spin_lock(&mdt->mdt_lock);
                        return PTR_ERR(md_root);
 
                spin_lock(&mdt->mdt_lock);
-               if (mdt->mdt_md_root != NULL)
-                       mdt_object_put(info->mti_env, mdt->mdt_md_root);
-               mdt->mdt_md_root = md_root;
-               spin_unlock(&mdt->mdt_lock);
+               if (mdt->mdt_md_root != NULL) {
+                       spin_unlock(&mdt->mdt_lock);
+
+                       LASSERTF(mdt->mdt_md_root == md_root,
+                                "Different root object ("
+                                DFID") instances, %p, %p\n",
+                                PFID(&info->mti_tmp_fid1),
+                                mdt->mdt_md_root, md_root);
+                       LASSERT(atomic_read(
+                               &md_root->mot_obj.lo_header->loh_ref) > 1);
+
+                       mdt_object_put(info->mti_env, md_root);
+               } else {
+                       mdt->mdt_md_root = md_root;
+                       spin_unlock(&mdt->mdt_lock);
+               }
        }
 
        if (md_root->mot_cache_attr || !mdt_object_remote(md_root))
        }
 
        if (md_root->mot_cache_attr || !mdt_object_remote(md_root))