X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Fklnds%2Fptllnd%2Fptllnd_ptltrace.c;h=e85ab5a8068291546ea971108799bbb52f4d7939;hb=d2f2601baff3fb8add503ecab932c20c26f9a118;hp=d82682002ca517db270f8031282cba96c0d90992;hpb=9547728b67695dc7bf5a9d2dec7cf7afc24c5211;p=fs%2Flustre-release.git diff --git a/lnet/klnds/ptllnd/ptllnd_ptltrace.c b/lnet/klnds/ptllnd/ptllnd_ptltrace.c index d826820..e85ab5a 100644 --- a/lnet/klnds/ptllnd/ptllnd_ptltrace.c +++ b/lnet/klnds/ptllnd/ptllnd_ptltrace.c @@ -1,25 +1,44 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (C) 2006 Cluster File Systems, Inc. All rights reserved. + * GPL HEADER START * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This file is confidential source code owned by Cluster File Systems. - * No viewing, modification, compilation, redistribution, or any other - * form of use is permitted except through a signed license agreement. + * 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. * - * If you have not signed such an agreement, then you have no rights to - * this file. Please destroy it immediately and contact CFS. + * 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). * + * 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 + * + * 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. */ #include "ptllnd.h" #ifdef CRAY_XT3 static struct semaphore ptltrace_mutex; -static struct semaphore ptltrace_signal; +static cfs_waitq_t ptltrace_debug_ctlwq; void kptllnd_ptltrace_to_file(char *filename) @@ -117,7 +136,7 @@ kptllnd_dump_ptltrace_thread(void *arg) { static char fname[1024]; - libcfs_daemonize("ptltracedump"); + libcfs_daemonize("kpt_ptltrace_dump"); /* serialise with other instances of me */ mutex_down(&ptltrace_mutex); @@ -131,8 +150,7 @@ kptllnd_dump_ptltrace_thread(void *arg) mutex_up(&ptltrace_mutex); /* unblock my creator */ - mutex_up(&ptltrace_signal); - + cfs_waitq_signal(&ptltrace_debug_ctlwq); return 0; } @@ -140,9 +158,13 @@ void kptllnd_dump_ptltrace(void) { int rc; + cfs_waitlink_t wait; + ENTRY; - if (!*kptllnd_tunables.kptl_ptltrace_on_timeout) - return; + /* taken from libcfs_debug_dumplog */ + cfs_waitlink_init(&wait); + set_current_state(TASK_INTERRUPTIBLE); + cfs_waitq_add(&ptltrace_debug_ctlwq, &wait); rc = cfs_kernel_thread(kptllnd_dump_ptltrace_thread, (void *)(long)cfs_curproc_pid(), @@ -150,28 +172,19 @@ kptllnd_dump_ptltrace(void) if (rc < 0) { CERROR("Error %d starting ptltrace dump thread\n", rc); } else { - /* block until thread completes */ - mutex_down(&ptltrace_signal); + cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE); } -} -void -kptllnd_init_ptltrace(void) -{ - init_mutex(&ptltrace_mutex); - init_mutex_locked(&ptltrace_signal); -} - -#else - -void -kptllnd_dump_ptltrace(void) -{ + /* teardown if kernel_thread() failed */ + cfs_waitq_del(&ptltrace_debug_ctlwq, &wait); + set_current_state(TASK_RUNNING); + EXIT; } void kptllnd_init_ptltrace(void) { + cfs_waitq_init(&ptltrace_debug_ctlwq); + init_mutex(&ptltrace_mutex); } - #endif