/* -*- 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_semaphore_t ptltrace_mutex;
+static cfs_waitq_t ptltrace_debug_ctlwq;
void
kptllnd_ptltrace_to_file(char *filename)
filp = cfs_filp_open(filename,
O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600, &rc);
if (filp == NULL) {
- CERROR("Error %d creating %s\n", rc, filename);
+ if (rc != -EEXIST)
+ CERROR("Error %d creating %s\n", rc, filename);
goto out;
}
break;
}
- LASSERT (start >= tmpbuf && start + len <= tmpbuf + PAGE_SIZE);
+ if (start < tmpbuf || start + len > tmpbuf + PAGE_SIZE) {
+ CERROR("ptl_proc_read bug: %p for %d not in %p for %ld\n",
+ start, len, tmpbuf, PAGE_SIZE);
+ break;
+ }
rc = cfs_filp_write(filp, start, len, cfs_filp_poff(filp));
if (rc != len) {
{
static char fname[1024];
- libcfs_daemonize("ptltracedump");
+ libcfs_daemonize("kpt_ptltrace_dump");
/* serialise with other instances of me */
- mutex_down(&ptltrace_mutex);
+ cfs_mutex_down(&ptltrace_mutex);
snprintf(fname, sizeof(fname), "%s.%ld.%ld",
*kptllnd_tunables.kptl_ptltrace_basename,
kptllnd_ptltrace_to_file(fname);
- mutex_up(&ptltrace_mutex);
+ cfs_mutex_up(&ptltrace_mutex);
/* unblock my creator */
- mutex_up(&ptltrace_signal);
-
+ cfs_waitq_signal(&ptltrace_debug_ctlwq);
return 0;
}
void
kptllnd_dump_ptltrace(void)
{
- int rc;
+ int rc;
+ cfs_waitlink_t wait;
+ ENTRY;
- if (!*kptllnd_tunables.kptl_ptltrace_on_timeout)
- return;
+ /* taken from libcfs_debug_dumplog */
+ cfs_waitlink_init(&wait);
+ cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
+ cfs_waitq_add(&ptltrace_debug_ctlwq, &wait);
rc = cfs_kernel_thread(kptllnd_dump_ptltrace_thread,
(void *)(long)cfs_curproc_pid(),
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 cfs_kernel_thread() failed */
+ cfs_waitq_del(&ptltrace_debug_ctlwq, &wait);
+ cfs_set_current_state(CFS_TASK_RUNNING);
+ EXIT;
}
void
kptllnd_init_ptltrace(void)
{
+ cfs_waitq_init(&ptltrace_debug_ctlwq);
+ cfs_init_mutex(&ptltrace_mutex);
}
-
#endif