Whamcloud - gitweb
LU-3339 mdt: HSM on disk actions record
[fs/lustre-release.git] / lustre / mdt / mdt_capa.c
index 73d38dc..6e13b42 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,9 +40,6 @@
  * Author: Lai Siyao <lsy@clusterfs.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_MDS
 
 #include "mdt_internal.h"
@@ -157,7 +154,7 @@ int mdt_capa_keys_init(const struct lu_env *env, struct mdt_device *mdt)
         int                      rc;
         ENTRY;
 
-        mdsnum = mdt_md_site(mdt)->ms_node_id;
+       mdsnum = mdt_seq_site(mdt)->ss_node_id;
 
         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
         LASSERT(mti != NULL);
@@ -221,7 +218,7 @@ static int mdt_ck_thread_main(void *args)
         int                     rc;
         ENTRY;
 
-        cfs_daemonize_ctxt("mdt_ck");
+       unshare_fs_struct();
         cfs_block_allsigs();
 
         thread_set_flags(thread, SVC_RUNNING);
@@ -238,8 +235,8 @@ static int mdt_ck_thread_main(void *args)
         info = lu_context_key_get(&env.le_ctx, &mdt_thread_key);
         LASSERT(info != NULL);
 
-        tmp = &info->mti_capa_key;
-        mdsnum = mdt_md_site(mdt)->ms_node_id;
+       tmp = &info->mti_capa_key;
+       mdsnum = mdt_seq_site(mdt)->ss_node_id;
         while (1) {
                 l_wait_event(thread->t_ctl_waitq,
                              thread_is_stopping(thread) ||
@@ -259,17 +256,17 @@ static int mdt_ck_thread_main(void *args)
                 next = mdt->mdt_child;
                 rc = next->md_ops->mdo_update_capa_key(&env, next, tmp);
                 if (!rc) {
-                        cfs_spin_lock(&capa_lock);
-                        *bkey = *rkey;
-                        *rkey = *tmp;
-                        cfs_spin_unlock(&capa_lock);
-
-                        rc = write_capa_keys(&env, mdt, mdt->mdt_capa_keys);
-                        if (rc) {
-                                cfs_spin_lock(&capa_lock);
-                                *rkey = *bkey;
-                                memset(bkey, 0, sizeof(*bkey));
-                                cfs_spin_unlock(&capa_lock);
+                       spin_lock(&capa_lock);
+                       *bkey = *rkey;
+                       *rkey = *tmp;
+                       spin_unlock(&capa_lock);
+
+                       rc = write_capa_keys(&env, mdt, mdt->mdt_capa_keys);
+                       if (rc) {
+                               spin_lock(&capa_lock);
+                               *rkey = *bkey;
+                               memset(bkey, 0, sizeof(*bkey));
+                               spin_unlock(&capa_lock);
                         } else {
                                 set_capa_key_expiry(mdt);
                                 DEBUG_CAPA_KEY(D_SEC, rkey, "new");
@@ -293,18 +290,18 @@ static int mdt_ck_thread_main(void *args)
 
 int mdt_ck_thread_start(struct mdt_device *mdt)
 {
-        struct ptlrpc_thread *thread = &mdt->mdt_ck_thread;
-        int rc;
-
-        cfs_waitq_init(&thread->t_ctl_waitq);
-        rc = cfs_create_thread(mdt_ck_thread_main, mdt, CFS_DAEMON_FLAGS);
-        if (rc < 0) {
-                CERROR("cannot start mdt_ck thread, rc = %d\n", rc);
-                return rc;
-        }
-
-        l_wait_condition(thread->t_ctl_waitq, thread_is_running(thread));
-        return 0;
+       struct ptlrpc_thread *thread = &mdt->mdt_ck_thread;
+       cfs_task_t *task;
+
+       cfs_waitq_init(&thread->t_ctl_waitq);
+       task = kthread_run(mdt_ck_thread_main, mdt, "mdt_ck");
+       if (IS_ERR(task)) {
+               CERROR("cannot start mdt_ck thread, rc = %ld\n", PTR_ERR(task));
+               return PTR_ERR(task);
+       }
+
+       l_wait_condition(thread->t_ctl_waitq, thread_is_running(thread));
+       return 0;
 }
 
 void mdt_ck_thread_stop(struct mdt_device *mdt)