X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_capa.c;h=76e2c6f73063379839d33a38e760ed8cdb1dd753;hp=a40d839e877c7bf750e1779b224079f34550583b;hb=49c61548c35d67f34120fd64916a55fd20a6ab68;hpb=adb6cea0b70ac465b2a47635d9dc45d64ab1605b diff --git a/lustre/mdt/mdt_capa.c b/lustre/mdt/mdt_capa.c index a40d839..76e2c6f 100644 --- a/lustre/mdt/mdt_capa.c +++ b/lustre/mdt/mdt_capa.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +26,8 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -40,9 +40,6 @@ * Author: Lai Siyao */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_MDS #include "mdt_internal.h" @@ -89,10 +86,18 @@ static int write_capa_keys(const struct lu_env *env, int i, rc; mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key); - 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)); + th = dt_trans_create(env, mdt->mdt_bottom); + if (IS_ERR(th)) + RETURN(PTR_ERR(th)); + + rc = dt_declare_record_write(env, mdt->mdt_ck_obj, + sizeof(*tmp) * 3, 0, th); + if (rc) + goto stop; + + rc = dt_trans_start_local(env, mdt->mdt_bottom, th); + if (rc) + goto stop; tmp = &mti->mti_capa_key; @@ -106,7 +111,8 @@ static int write_capa_keys(const struct lu_env *env, break; } - mdt_trans_stop(env, mdt, th); +stop: + dt_trans_stop(env, mdt->mdt_bottom, th); CDEBUG(D_INFO, "write capability keys rc = %d:\n", rc); return rc; @@ -148,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); @@ -192,7 +198,7 @@ void mdt_ck_timer_callback(unsigned long castmeharder) struct ptlrpc_thread *thread = &mdt->mdt_ck_thread; ENTRY; - thread->t_flags |= SVC_EVENT; + thread_add_flags(thread, SVC_EVENT); cfs_waitq_signal(&thread->t_ctl_waitq); EXIT; } @@ -215,7 +221,7 @@ static int mdt_ck_thread_main(void *args) cfs_daemonize_ctxt("mdt_ck"); cfs_block_allsigs(); - thread->t_flags = SVC_RUNNING; + thread_set_flags(thread, SVC_RUNNING); cfs_waitq_signal(&thread->t_ctl_waitq); rc = lu_env_init(&env, LCT_MD_THREAD|LCT_REMEMBER|LCT_NOREF); @@ -229,16 +235,17 @@ 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->t_flags & (SVC_STOPPING | SVC_EVENT), + thread_is_stopping(thread) || + thread_is_event(thread), &lwi); - if (thread->t_flags & SVC_STOPPING) + if (thread_is_stopping(thread)) break; - thread->t_flags &= ~SVC_EVENT; + thread_clear_flags(thread, SVC_EVENT); if (cfs_time_before(cfs_time_current(), mdt->mdt_ck_expiry)) break; @@ -249,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"); @@ -276,7 +283,7 @@ static int mdt_ck_thread_main(void *args) } lu_env_fini(&env); - thread->t_flags = SVC_STOPPED; + thread_set_flags(thread, SVC_STOPPED); cfs_waitq_signal(&thread->t_ctl_waitq); RETURN(0); } @@ -293,7 +300,7 @@ int mdt_ck_thread_start(struct mdt_device *mdt) return rc; } - l_wait_condition(thread->t_ctl_waitq, thread->t_flags & SVC_RUNNING); + l_wait_condition(thread->t_ctl_waitq, thread_is_running(thread)); return 0; } @@ -301,10 +308,10 @@ void mdt_ck_thread_stop(struct mdt_device *mdt) { struct ptlrpc_thread *thread = &mdt->mdt_ck_thread; - if (!(thread->t_flags & SVC_RUNNING)) + if (!thread_is_running(thread)) return; - thread->t_flags = SVC_STOPPING; + thread_set_flags(thread, SVC_STOPPING); cfs_waitq_signal(&thread->t_ctl_waitq); - l_wait_condition(thread->t_ctl_waitq, thread->t_flags & SVC_STOPPED); + l_wait_condition(thread->t_ctl_waitq, thread_is_stopped(thread)); }