Whamcloud - gitweb
b=19964 SOM cleanups, part2
[fs/lustre-release.git] / lustre / mdt / mdt_capa.c
index 0f23e09..9672420 100644 (file)
@@ -1,29 +1,43 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  lustre/mdt/mdt_capa.c
- *  Lustre Metadata Target (mdt) capability key read/write/update.
+ * GPL HEADER START
  *
- *  Copyright (C) 2005 Cluster File Systems, Inc.
- *   Author: Lai Siyao <lsy@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   You may have signed or agreed to another license before downloading
- *   this software.  If so, you are bound by the terms and conditions
- *   of that agreement, and the following does not apply to you.  See the
- *   LICENSE file included with this distribution for more information.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   If you did not agree to a different license, then this copy of Lustre
- *   is open source software; you can redistribute it and/or modify it
- *   under the terms of version 2 of the GNU General Public License as
- *   published by the Free Software Foundation.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   In either case, Lustre is distributed in the hope that it will be
- *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   license text for more details.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mdt/mdt_capa.c
+ *
+ * Lustre Metadata Target (mdt) capability key read/write/update.
+ *
+ * Author: Lai Siyao <lsy@clusterfs.com>
  */
 
 #ifndef EXPORT_SYMTAB
@@ -46,10 +60,6 @@ static void make_capa_key(struct lustre_capa_key *key,
         ll_get_random_bytes(key->lk_key, sizeof(key->lk_key));
 }
 
-enum {
-        MDT_TXN_CAPA_KEYS_WRITE_CREDITS = 1
-};
-
 static inline void lck_cpu_to_le(struct lustre_capa_key *tgt,
                                  struct lustre_capa_key *src)
 {
@@ -79,8 +89,8 @@ static int write_capa_keys(const struct lu_env *env,
         int i, rc;
 
         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
-
-        th = mdt_trans_start(env, mdt, MDT_TXN_CAPA_KEYS_WRITE_CREDITS);
+        mdt_trans_credit_init(env, mdt, MDT_TXN_CAPA_KEYS_WRITE_OP);
+        th = mdt_trans_start(env, mdt);
         if (IS_ERR(th))
                 RETURN(PTR_ERR(th));
 
@@ -89,9 +99,9 @@ static int write_capa_keys(const struct lu_env *env,
         for (i = 0; i < 2; i++) {
                 lck_cpu_to_le(tmp, &keys[i]);
 
-                rc = mdt_record_write(env, mdt->mdt_ck_obj,
-                                      mdt_buf_const(env, tmp, sizeof(*tmp)),
-                                      &off, th);
+                rc = dt_record_write(env, mdt->mdt_ck_obj,
+                                     mdt_buf_const(env, tmp, sizeof(*tmp)),
+                                     &off, th);
                 if (rc)
                         break;
         }
@@ -115,8 +125,8 @@ static int read_capa_keys(const struct lu_env *env,
         tmp = &mti->mti_capa_key;
 
         for (i = 0; i < 2; i++) {
-                rc = mdt_record_read(env, mdt->mdt_ck_obj,
-                                     mdt_buf(env, tmp, sizeof(*tmp)), &off);
+                rc = dt_record_read(env, mdt->mdt_ck_obj,
+                                    mdt_buf(env, tmp, sizeof(*tmp)), &off);
                 if (rc)
                         return rc;
 
@@ -138,7 +148,7 @@ int mdt_capa_keys_init(const struct lu_env *env, struct mdt_device *mdt)
         int                      rc;
         ENTRY;
 
-        mdsnum = mdt->mdt_md_dev.md_lu_dev.ld_site->ls_node_id;
+        mdsnum = mdt_md_site(mdt)->ms_node_id;
 
         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
         LASSERT(mti != NULL);
@@ -202,24 +212,25 @@ static int mdt_ck_thread_main(void *args)
         int                     rc;
         ENTRY;
 
-        ptlrpc_daemonize("mdt_ck");
+        cfs_daemonize_ctxt("mdt_ck");
         cfs_block_allsigs();
 
         thread->t_flags = SVC_RUNNING;
         cfs_waitq_signal(&thread->t_ctl_waitq);
 
-        rc = lu_env_init(&env, NULL, LCT_MD_THREAD);
+        rc = lu_env_init(&env, LCT_MD_THREAD|LCT_REMEMBER|LCT_NOREF);
         if (rc)
                 RETURN(rc);
 
         thread->t_env = &env;
         env.le_ctx.lc_thread = thread;
+        env.le_ctx.lc_cookie = 0x1;
 
         info = lu_context_key_get(&env.le_ctx, &mdt_thread_key);
         LASSERT(info != NULL);
 
         tmp = &info->mti_capa_key;
-        mdsnum = mdt->mdt_md_dev.md_lu_dev.ld_site->ls_node_id;
+        mdsnum = mdt_md_site(mdt)->ms_node_id;
         while (1) {
                 l_wait_event(thread->t_ctl_waitq,
                              thread->t_flags & (SVC_STOPPING | SVC_EVENT),
@@ -298,5 +309,3 @@ void mdt_ck_thread_stop(struct mdt_device *mdt)
         cfs_waitq_signal(&thread->t_ctl_waitq);
         cfs_wait_event(thread->t_ctl_waitq, thread->t_flags & SVC_STOPPED);
 }
-
-