| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
|---|
| 2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * debug functionality for the dlm |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Copyright (C) 2004, 2008 Oracle. All rights reserved. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or |
|---|
| 11 | | - * modify it under the terms of the GNU General Public |
|---|
| 12 | | - * License as published by the Free Software Foundation; either |
|---|
| 13 | | - * version 2 of the License, or (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | | - * General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public |
|---|
| 21 | | - * License along with this program; if not, write to the |
|---|
| 22 | | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|---|
| 23 | | - * Boston, MA 021110-1307, USA. |
|---|
| 24 | | - * |
|---|
| 25 | 10 | */ |
|---|
| 26 | 11 | |
|---|
| 27 | 12 | #include <linux/types.h> |
|---|
| .. | .. |
|---|
| 32 | 17 | #include <linux/debugfs.h> |
|---|
| 33 | 18 | #include <linux/export.h> |
|---|
| 34 | 19 | |
|---|
| 35 | | -#include "cluster/heartbeat.h" |
|---|
| 36 | | -#include "cluster/nodemanager.h" |
|---|
| 37 | | -#include "cluster/tcp.h" |
|---|
| 20 | +#include "../cluster/heartbeat.h" |
|---|
| 21 | +#include "../cluster/nodemanager.h" |
|---|
| 22 | +#include "../cluster/tcp.h" |
|---|
| 38 | 23 | |
|---|
| 39 | 24 | #include "dlmapi.h" |
|---|
| 40 | 25 | #include "dlmcommon.h" |
|---|
| .. | .. |
|---|
| 42 | 27 | #include "dlmdebug.h" |
|---|
| 43 | 28 | |
|---|
| 44 | 29 | #define MLOG_MASK_PREFIX ML_DLM |
|---|
| 45 | | -#include "cluster/masklog.h" |
|---|
| 30 | +#include "../cluster/masklog.h" |
|---|
| 46 | 31 | |
|---|
| 47 | 32 | static int stringify_lockname(const char *lockname, int locklen, char *buf, |
|---|
| 48 | 33 | int len); |
|---|
| .. | .. |
|---|
| 259 | 244 | memcpy((__be64 *)&inode_blkno_be, |
|---|
| 260 | 245 | (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START], |
|---|
| 261 | 246 | sizeof(__be64)); |
|---|
| 262 | | - out += snprintf(buf + out, len - out, "%.*s%08x", |
|---|
| 247 | + out += scnprintf(buf + out, len - out, "%.*s%08x", |
|---|
| 263 | 248 | OCFS2_DENTRY_LOCK_INO_START - 1, lockname, |
|---|
| 264 | 249 | (unsigned int)be64_to_cpu(inode_blkno_be)); |
|---|
| 265 | 250 | } else |
|---|
| 266 | | - out += snprintf(buf + out, len - out, "%.*s", |
|---|
| 251 | + out += scnprintf(buf + out, len - out, "%.*s", |
|---|
| 267 | 252 | locklen, lockname); |
|---|
| 268 | 253 | return out; |
|---|
| 269 | 254 | } |
|---|
| .. | .. |
|---|
| 275 | 260 | int i = -1; |
|---|
| 276 | 261 | |
|---|
| 277 | 262 | while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes) |
|---|
| 278 | | - out += snprintf(buf + out, len - out, "%d ", i); |
|---|
| 263 | + out += scnprintf(buf + out, len - out, "%d ", i); |
|---|
| 279 | 264 | |
|---|
| 280 | 265 | return out; |
|---|
| 281 | 266 | } |
|---|
| .. | .. |
|---|
| 293 | 278 | mle_type = "MIG"; |
|---|
| 294 | 279 | |
|---|
| 295 | 280 | out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out); |
|---|
| 296 | | - out += snprintf(buf + out, len - out, |
|---|
| 281 | + out += scnprintf(buf + out, len - out, |
|---|
| 297 | 282 | "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", |
|---|
| 298 | 283 | mle_type, mle->master, mle->new_master, |
|---|
| 299 | 284 | !list_empty(&mle->hb_events), |
|---|
| 300 | 285 | !!mle->inuse, |
|---|
| 301 | 286 | kref_read(&mle->mle_refs)); |
|---|
| 302 | 287 | |
|---|
| 303 | | - out += snprintf(buf + out, len - out, "Maybe="); |
|---|
| 288 | + out += scnprintf(buf + out, len - out, "Maybe="); |
|---|
| 304 | 289 | out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES, |
|---|
| 305 | 290 | buf + out, len - out); |
|---|
| 306 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 291 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 307 | 292 | |
|---|
| 308 | | - out += snprintf(buf + out, len - out, "Vote="); |
|---|
| 293 | + out += scnprintf(buf + out, len - out, "Vote="); |
|---|
| 309 | 294 | out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES, |
|---|
| 310 | 295 | buf + out, len - out); |
|---|
| 311 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 296 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 312 | 297 | |
|---|
| 313 | | - out += snprintf(buf + out, len - out, "Response="); |
|---|
| 298 | + out += scnprintf(buf + out, len - out, "Response="); |
|---|
| 314 | 299 | out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES, |
|---|
| 315 | 300 | buf + out, len - out); |
|---|
| 316 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 301 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 317 | 302 | |
|---|
| 318 | | - out += snprintf(buf + out, len - out, "Node="); |
|---|
| 303 | + out += scnprintf(buf + out, len - out, "Node="); |
|---|
| 319 | 304 | out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES, |
|---|
| 320 | 305 | buf + out, len - out); |
|---|
| 321 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 306 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 322 | 307 | |
|---|
| 323 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 308 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 324 | 309 | |
|---|
| 325 | 310 | return out; |
|---|
| 326 | 311 | } |
|---|
| .. | .. |
|---|
| 368 | 353 | int out = 0; |
|---|
| 369 | 354 | unsigned long total = 0; |
|---|
| 370 | 355 | |
|---|
| 371 | | - out += snprintf(buf + out, len - out, |
|---|
| 356 | + out += scnprintf(buf + out, len - out, |
|---|
| 372 | 357 | "Dumping Purgelist for Domain: %s\n", dlm->name); |
|---|
| 373 | 358 | |
|---|
| 374 | 359 | spin_lock(&dlm->spinlock); |
|---|
| .. | .. |
|---|
| 380 | 365 | out += stringify_lockname(res->lockname.name, |
|---|
| 381 | 366 | res->lockname.len, |
|---|
| 382 | 367 | buf + out, len - out); |
|---|
| 383 | | - out += snprintf(buf + out, len - out, "\t%ld\n", |
|---|
| 368 | + out += scnprintf(buf + out, len - out, "\t%ld\n", |
|---|
| 384 | 369 | (jiffies - res->last_used)/HZ); |
|---|
| 385 | 370 | spin_unlock(&res->spinlock); |
|---|
| 386 | 371 | } |
|---|
| 387 | 372 | spin_unlock(&dlm->spinlock); |
|---|
| 388 | 373 | |
|---|
| 389 | | - out += snprintf(buf + out, len - out, "Total on list: %lu\n", total); |
|---|
| 374 | + out += scnprintf(buf + out, len - out, "Total on list: %lu\n", total); |
|---|
| 390 | 375 | |
|---|
| 391 | 376 | return out; |
|---|
| 392 | 377 | } |
|---|
| .. | .. |
|---|
| 425 | 410 | int i, out = 0; |
|---|
| 426 | 411 | unsigned long total = 0, longest = 0, bucket_count = 0; |
|---|
| 427 | 412 | |
|---|
| 428 | | - out += snprintf(buf + out, len - out, |
|---|
| 413 | + out += scnprintf(buf + out, len - out, |
|---|
| 429 | 414 | "Dumping MLEs for Domain: %s\n", dlm->name); |
|---|
| 430 | 415 | |
|---|
| 431 | 416 | spin_lock(&dlm->master_lock); |
|---|
| .. | .. |
|---|
| 443 | 428 | } |
|---|
| 444 | 429 | spin_unlock(&dlm->master_lock); |
|---|
| 445 | 430 | |
|---|
| 446 | | - out += snprintf(buf + out, len - out, |
|---|
| 431 | + out += scnprintf(buf + out, len - out, |
|---|
| 447 | 432 | "Total: %lu, Longest: %lu\n", total, longest); |
|---|
| 448 | 433 | return out; |
|---|
| 449 | 434 | } |
|---|
| .. | .. |
|---|
| 482 | 467 | |
|---|
| 483 | 468 | #define DEBUG_LOCK_VERSION 1 |
|---|
| 484 | 469 | spin_lock(&lock->spinlock); |
|---|
| 485 | | - out = snprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d," |
|---|
| 470 | + out = scnprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d," |
|---|
| 486 | 471 | "%d,%d,%d,%d\n", |
|---|
| 487 | 472 | DEBUG_LOCK_VERSION, |
|---|
| 488 | 473 | list_type, lock->ml.type, lock->ml.convert_type, |
|---|
| .. | .. |
|---|
| 506 | 491 | int i; |
|---|
| 507 | 492 | int out = 0; |
|---|
| 508 | 493 | |
|---|
| 509 | | - out += snprintf(buf + out, len - out, "NAME:"); |
|---|
| 494 | + out += scnprintf(buf + out, len - out, "NAME:"); |
|---|
| 510 | 495 | out += stringify_lockname(res->lockname.name, res->lockname.len, |
|---|
| 511 | 496 | buf + out, len - out); |
|---|
| 512 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 497 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 513 | 498 | |
|---|
| 514 | 499 | #define DEBUG_LRES_VERSION 1 |
|---|
| 515 | | - out += snprintf(buf + out, len - out, |
|---|
| 500 | + out += scnprintf(buf + out, len - out, |
|---|
| 516 | 501 | "LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d\n", |
|---|
| 517 | 502 | DEBUG_LRES_VERSION, |
|---|
| 518 | 503 | res->owner, res->state, res->last_used, |
|---|
| .. | .. |
|---|
| 524 | 509 | kref_read(&res->refs)); |
|---|
| 525 | 510 | |
|---|
| 526 | 511 | /* refmap */ |
|---|
| 527 | | - out += snprintf(buf + out, len - out, "RMAP:"); |
|---|
| 512 | + out += scnprintf(buf + out, len - out, "RMAP:"); |
|---|
| 528 | 513 | out += stringify_nodemap(res->refmap, O2NM_MAX_NODES, |
|---|
| 529 | 514 | buf + out, len - out); |
|---|
| 530 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 515 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 531 | 516 | |
|---|
| 532 | 517 | /* lvb */ |
|---|
| 533 | | - out += snprintf(buf + out, len - out, "LVBX:"); |
|---|
| 518 | + out += scnprintf(buf + out, len - out, "LVBX:"); |
|---|
| 534 | 519 | for (i = 0; i < DLM_LVB_LEN; i++) |
|---|
| 535 | | - out += snprintf(buf + out, len - out, |
|---|
| 520 | + out += scnprintf(buf + out, len - out, |
|---|
| 536 | 521 | "%02x", (unsigned char)res->lvb[i]); |
|---|
| 537 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 522 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 538 | 523 | |
|---|
| 539 | 524 | /* granted */ |
|---|
| 540 | 525 | list_for_each_entry(lock, &res->granted, list) |
|---|
| .. | .. |
|---|
| 548 | 533 | list_for_each_entry(lock, &res->blocked, list) |
|---|
| 549 | 534 | out += dump_lock(lock, 2, buf + out, len - out); |
|---|
| 550 | 535 | |
|---|
| 551 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 536 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 552 | 537 | |
|---|
| 553 | 538 | return out; |
|---|
| 554 | 539 | } |
|---|
| .. | .. |
|---|
| 698 | 683 | } |
|---|
| 699 | 684 | |
|---|
| 700 | 685 | /* Domain: xxxxxxxxxx Key: 0xdfbac769 */ |
|---|
| 701 | | - out += snprintf(buf + out, len - out, |
|---|
| 686 | + out += scnprintf(buf + out, len - out, |
|---|
| 702 | 687 | "Domain: %s Key: 0x%08x Protocol: %d.%d\n", |
|---|
| 703 | 688 | dlm->name, dlm->key, dlm->dlm_locking_proto.pv_major, |
|---|
| 704 | 689 | dlm->dlm_locking_proto.pv_minor); |
|---|
| 705 | 690 | |
|---|
| 706 | 691 | /* Thread Pid: xxx Node: xxx State: xxxxx */ |
|---|
| 707 | | - out += snprintf(buf + out, len - out, |
|---|
| 692 | + out += scnprintf(buf + out, len - out, |
|---|
| 708 | 693 | "Thread Pid: %d Node: %d State: %s\n", |
|---|
| 709 | 694 | task_pid_nr(dlm->dlm_thread_task), dlm->node_num, state); |
|---|
| 710 | 695 | |
|---|
| 711 | 696 | /* Number of Joins: xxx Joining Node: xxx */ |
|---|
| 712 | | - out += snprintf(buf + out, len - out, |
|---|
| 697 | + out += scnprintf(buf + out, len - out, |
|---|
| 713 | 698 | "Number of Joins: %d Joining Node: %d\n", |
|---|
| 714 | 699 | dlm->num_joins, dlm->joining_node); |
|---|
| 715 | 700 | |
|---|
| 716 | 701 | /* Domain Map: xx xx xx */ |
|---|
| 717 | | - out += snprintf(buf + out, len - out, "Domain Map: "); |
|---|
| 702 | + out += scnprintf(buf + out, len - out, "Domain Map: "); |
|---|
| 718 | 703 | out += stringify_nodemap(dlm->domain_map, O2NM_MAX_NODES, |
|---|
| 719 | 704 | buf + out, len - out); |
|---|
| 720 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 705 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 721 | 706 | |
|---|
| 722 | 707 | /* Exit Domain Map: xx xx xx */ |
|---|
| 723 | | - out += snprintf(buf + out, len - out, "Exit Domain Map: "); |
|---|
| 708 | + out += scnprintf(buf + out, len - out, "Exit Domain Map: "); |
|---|
| 724 | 709 | out += stringify_nodemap(dlm->exit_domain_map, O2NM_MAX_NODES, |
|---|
| 725 | 710 | buf + out, len - out); |
|---|
| 726 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 711 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 727 | 712 | |
|---|
| 728 | 713 | /* Live Map: xx xx xx */ |
|---|
| 729 | | - out += snprintf(buf + out, len - out, "Live Map: "); |
|---|
| 714 | + out += scnprintf(buf + out, len - out, "Live Map: "); |
|---|
| 730 | 715 | out += stringify_nodemap(dlm->live_nodes_map, O2NM_MAX_NODES, |
|---|
| 731 | 716 | buf + out, len - out); |
|---|
| 732 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 717 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 733 | 718 | |
|---|
| 734 | 719 | /* Lock Resources: xxx (xxx) */ |
|---|
| 735 | | - out += snprintf(buf + out, len - out, |
|---|
| 720 | + out += scnprintf(buf + out, len - out, |
|---|
| 736 | 721 | "Lock Resources: %d (%d)\n", |
|---|
| 737 | 722 | atomic_read(&dlm->res_cur_count), |
|---|
| 738 | 723 | atomic_read(&dlm->res_tot_count)); |
|---|
| .. | .. |
|---|
| 744 | 729 | cur_mles += atomic_read(&dlm->mle_cur_count[i]); |
|---|
| 745 | 730 | |
|---|
| 746 | 731 | /* MLEs: xxx (xxx) */ |
|---|
| 747 | | - out += snprintf(buf + out, len - out, |
|---|
| 732 | + out += scnprintf(buf + out, len - out, |
|---|
| 748 | 733 | "MLEs: %d (%d)\n", cur_mles, tot_mles); |
|---|
| 749 | 734 | |
|---|
| 750 | 735 | /* Blocking: xxx (xxx) */ |
|---|
| 751 | | - out += snprintf(buf + out, len - out, |
|---|
| 736 | + out += scnprintf(buf + out, len - out, |
|---|
| 752 | 737 | " Blocking: %d (%d)\n", |
|---|
| 753 | 738 | atomic_read(&dlm->mle_cur_count[DLM_MLE_BLOCK]), |
|---|
| 754 | 739 | atomic_read(&dlm->mle_tot_count[DLM_MLE_BLOCK])); |
|---|
| 755 | 740 | |
|---|
| 756 | 741 | /* Mastery: xxx (xxx) */ |
|---|
| 757 | | - out += snprintf(buf + out, len - out, |
|---|
| 742 | + out += scnprintf(buf + out, len - out, |
|---|
| 758 | 743 | " Mastery: %d (%d)\n", |
|---|
| 759 | 744 | atomic_read(&dlm->mle_cur_count[DLM_MLE_MASTER]), |
|---|
| 760 | 745 | atomic_read(&dlm->mle_tot_count[DLM_MLE_MASTER])); |
|---|
| 761 | 746 | |
|---|
| 762 | 747 | /* Migration: xxx (xxx) */ |
|---|
| 763 | | - out += snprintf(buf + out, len - out, |
|---|
| 748 | + out += scnprintf(buf + out, len - out, |
|---|
| 764 | 749 | " Migration: %d (%d)\n", |
|---|
| 765 | 750 | atomic_read(&dlm->mle_cur_count[DLM_MLE_MIGRATION]), |
|---|
| 766 | 751 | atomic_read(&dlm->mle_tot_count[DLM_MLE_MIGRATION])); |
|---|
| 767 | 752 | |
|---|
| 768 | 753 | /* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */ |
|---|
| 769 | | - out += snprintf(buf + out, len - out, |
|---|
| 754 | + out += scnprintf(buf + out, len - out, |
|---|
| 770 | 755 | "Lists: Dirty=%s Purge=%s PendingASTs=%s " |
|---|
| 771 | 756 | "PendingBASTs=%s\n", |
|---|
| 772 | 757 | (list_empty(&dlm->dirty_list) ? "Empty" : "InUse"), |
|---|
| .. | .. |
|---|
| 775 | 760 | (list_empty(&dlm->pending_basts) ? "Empty" : "InUse")); |
|---|
| 776 | 761 | |
|---|
| 777 | 762 | /* Purge Count: xxx Refs: xxx */ |
|---|
| 778 | | - out += snprintf(buf + out, len - out, |
|---|
| 763 | + out += scnprintf(buf + out, len - out, |
|---|
| 779 | 764 | "Purge Count: %d Refs: %d\n", dlm->purge_count, |
|---|
| 780 | 765 | kref_read(&dlm->dlm_refs)); |
|---|
| 781 | 766 | |
|---|
| 782 | 767 | /* Dead Node: xxx */ |
|---|
| 783 | | - out += snprintf(buf + out, len - out, |
|---|
| 768 | + out += scnprintf(buf + out, len - out, |
|---|
| 784 | 769 | "Dead Node: %d\n", dlm->reco.dead_node); |
|---|
| 785 | 770 | |
|---|
| 786 | 771 | /* What about DLM_RECO_STATE_FINALIZE? */ |
|---|
| .. | .. |
|---|
| 790 | 775 | state = "INACTIVE"; |
|---|
| 791 | 776 | |
|---|
| 792 | 777 | /* Recovery Pid: xxxx Master: xxx State: xxxx */ |
|---|
| 793 | | - out += snprintf(buf + out, len - out, |
|---|
| 778 | + out += scnprintf(buf + out, len - out, |
|---|
| 794 | 779 | "Recovery Pid: %d Master: %d State: %s\n", |
|---|
| 795 | 780 | task_pid_nr(dlm->dlm_reco_thread_task), |
|---|
| 796 | 781 | dlm->reco.new_master, state); |
|---|
| 797 | 782 | |
|---|
| 798 | 783 | /* Recovery Map: xx xx */ |
|---|
| 799 | | - out += snprintf(buf + out, len - out, "Recovery Map: "); |
|---|
| 784 | + out += scnprintf(buf + out, len - out, "Recovery Map: "); |
|---|
| 800 | 785 | out += stringify_nodemap(dlm->recovery_map, O2NM_MAX_NODES, |
|---|
| 801 | 786 | buf + out, len - out); |
|---|
| 802 | | - out += snprintf(buf + out, len - out, "\n"); |
|---|
| 787 | + out += scnprintf(buf + out, len - out, "\n"); |
|---|
| 803 | 788 | |
|---|
| 804 | 789 | /* Recovery Node State: */ |
|---|
| 805 | | - out += snprintf(buf + out, len - out, "Recovery Node State:\n"); |
|---|
| 790 | + out += scnprintf(buf + out, len - out, "Recovery Node State:\n"); |
|---|
| 806 | 791 | list_for_each_entry(node, &dlm->reco.node_data, list) { |
|---|
| 807 | 792 | switch (node->state) { |
|---|
| 808 | 793 | case DLM_RECO_NODE_DATA_INIT: |
|---|
| .. | .. |
|---|
| 830 | 815 | state = "BAD"; |
|---|
| 831 | 816 | break; |
|---|
| 832 | 817 | } |
|---|
| 833 | | - out += snprintf(buf + out, len - out, "\t%u - %s\n", |
|---|
| 818 | + out += scnprintf(buf + out, len - out, "\t%u - %s\n", |
|---|
| 834 | 819 | node->node_num, state); |
|---|
| 835 | 820 | } |
|---|
| 836 | 821 | |
|---|
| .. | .. |
|---|
| 866 | 851 | /* end - debug state funcs */ |
|---|
| 867 | 852 | |
|---|
| 868 | 853 | /* files in subroot */ |
|---|
| 869 | | -int dlm_debug_init(struct dlm_ctxt *dlm) |
|---|
| 854 | +void dlm_debug_init(struct dlm_ctxt *dlm) |
|---|
| 870 | 855 | { |
|---|
| 871 | | - struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; |
|---|
| 872 | | - |
|---|
| 873 | 856 | /* for dumping dlm_ctxt */ |
|---|
| 874 | | - dc->debug_state_dentry = debugfs_create_file(DLM_DEBUGFS_DLM_STATE, |
|---|
| 875 | | - S_IFREG|S_IRUSR, |
|---|
| 876 | | - dlm->dlm_debugfs_subroot, |
|---|
| 877 | | - dlm, &debug_state_fops); |
|---|
| 878 | | - if (!dc->debug_state_dentry) { |
|---|
| 879 | | - mlog_errno(-ENOMEM); |
|---|
| 880 | | - goto bail; |
|---|
| 881 | | - } |
|---|
| 857 | + debugfs_create_file(DLM_DEBUGFS_DLM_STATE, S_IFREG|S_IRUSR, |
|---|
| 858 | + dlm->dlm_debugfs_subroot, dlm, &debug_state_fops); |
|---|
| 882 | 859 | |
|---|
| 883 | 860 | /* for dumping lockres */ |
|---|
| 884 | | - dc->debug_lockres_dentry = |
|---|
| 885 | | - debugfs_create_file(DLM_DEBUGFS_LOCKING_STATE, |
|---|
| 886 | | - S_IFREG|S_IRUSR, |
|---|
| 887 | | - dlm->dlm_debugfs_subroot, |
|---|
| 888 | | - dlm, &debug_lockres_fops); |
|---|
| 889 | | - if (!dc->debug_lockres_dentry) { |
|---|
| 890 | | - mlog_errno(-ENOMEM); |
|---|
| 891 | | - goto bail; |
|---|
| 892 | | - } |
|---|
| 861 | + debugfs_create_file(DLM_DEBUGFS_LOCKING_STATE, S_IFREG|S_IRUSR, |
|---|
| 862 | + dlm->dlm_debugfs_subroot, dlm, &debug_lockres_fops); |
|---|
| 893 | 863 | |
|---|
| 894 | 864 | /* for dumping mles */ |
|---|
| 895 | | - dc->debug_mle_dentry = debugfs_create_file(DLM_DEBUGFS_MLE_STATE, |
|---|
| 896 | | - S_IFREG|S_IRUSR, |
|---|
| 897 | | - dlm->dlm_debugfs_subroot, |
|---|
| 898 | | - dlm, &debug_mle_fops); |
|---|
| 899 | | - if (!dc->debug_mle_dentry) { |
|---|
| 900 | | - mlog_errno(-ENOMEM); |
|---|
| 901 | | - goto bail; |
|---|
| 902 | | - } |
|---|
| 865 | + debugfs_create_file(DLM_DEBUGFS_MLE_STATE, S_IFREG|S_IRUSR, |
|---|
| 866 | + dlm->dlm_debugfs_subroot, dlm, &debug_mle_fops); |
|---|
| 903 | 867 | |
|---|
| 904 | 868 | /* for dumping lockres on the purge list */ |
|---|
| 905 | | - dc->debug_purgelist_dentry = |
|---|
| 906 | | - debugfs_create_file(DLM_DEBUGFS_PURGE_LIST, |
|---|
| 907 | | - S_IFREG|S_IRUSR, |
|---|
| 908 | | - dlm->dlm_debugfs_subroot, |
|---|
| 909 | | - dlm, &debug_purgelist_fops); |
|---|
| 910 | | - if (!dc->debug_purgelist_dentry) { |
|---|
| 911 | | - mlog_errno(-ENOMEM); |
|---|
| 912 | | - goto bail; |
|---|
| 913 | | - } |
|---|
| 914 | | - |
|---|
| 915 | | - return 0; |
|---|
| 916 | | - |
|---|
| 917 | | -bail: |
|---|
| 918 | | - return -ENOMEM; |
|---|
| 919 | | -} |
|---|
| 920 | | - |
|---|
| 921 | | -void dlm_debug_shutdown(struct dlm_ctxt *dlm) |
|---|
| 922 | | -{ |
|---|
| 923 | | - struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; |
|---|
| 924 | | - |
|---|
| 925 | | - if (dc) { |
|---|
| 926 | | - debugfs_remove(dc->debug_purgelist_dentry); |
|---|
| 927 | | - debugfs_remove(dc->debug_mle_dentry); |
|---|
| 928 | | - debugfs_remove(dc->debug_lockres_dentry); |
|---|
| 929 | | - debugfs_remove(dc->debug_state_dentry); |
|---|
| 930 | | - kfree(dc); |
|---|
| 931 | | - dc = NULL; |
|---|
| 932 | | - } |
|---|
| 869 | + debugfs_create_file(DLM_DEBUGFS_PURGE_LIST, S_IFREG|S_IRUSR, |
|---|
| 870 | + dlm->dlm_debugfs_subroot, dlm, |
|---|
| 871 | + &debug_purgelist_fops); |
|---|
| 933 | 872 | } |
|---|
| 934 | 873 | |
|---|
| 935 | 874 | /* subroot - domain dir */ |
|---|
| 936 | | -int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) |
|---|
| 875 | +void dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) |
|---|
| 937 | 876 | { |
|---|
| 938 | 877 | dlm->dlm_debugfs_subroot = debugfs_create_dir(dlm->name, |
|---|
| 939 | 878 | dlm_debugfs_root); |
|---|
| 940 | | - if (!dlm->dlm_debugfs_subroot) { |
|---|
| 941 | | - mlog_errno(-ENOMEM); |
|---|
| 942 | | - goto bail; |
|---|
| 943 | | - } |
|---|
| 944 | | - |
|---|
| 945 | | - dlm->dlm_debug_ctxt = kzalloc(sizeof(struct dlm_debug_ctxt), |
|---|
| 946 | | - GFP_KERNEL); |
|---|
| 947 | | - if (!dlm->dlm_debug_ctxt) { |
|---|
| 948 | | - mlog_errno(-ENOMEM); |
|---|
| 949 | | - goto bail; |
|---|
| 950 | | - } |
|---|
| 951 | | - |
|---|
| 952 | | - return 0; |
|---|
| 953 | | -bail: |
|---|
| 954 | | - dlm_destroy_debugfs_subroot(dlm); |
|---|
| 955 | | - return -ENOMEM; |
|---|
| 956 | 879 | } |
|---|
| 957 | 880 | |
|---|
| 958 | 881 | void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm) |
|---|
| 959 | 882 | { |
|---|
| 960 | | - debugfs_remove(dlm->dlm_debugfs_subroot); |
|---|
| 883 | + debugfs_remove_recursive(dlm->dlm_debugfs_subroot); |
|---|
| 961 | 884 | } |
|---|
| 962 | 885 | |
|---|
| 963 | 886 | /* debugfs root */ |
|---|
| 964 | | -int dlm_create_debugfs_root(void) |
|---|
| 887 | +void dlm_create_debugfs_root(void) |
|---|
| 965 | 888 | { |
|---|
| 966 | 889 | dlm_debugfs_root = debugfs_create_dir(DLM_DEBUGFS_DIR, NULL); |
|---|
| 967 | | - if (!dlm_debugfs_root) { |
|---|
| 968 | | - mlog_errno(-ENOMEM); |
|---|
| 969 | | - return -ENOMEM; |
|---|
| 970 | | - } |
|---|
| 971 | | - return 0; |
|---|
| 972 | 890 | } |
|---|
| 973 | 891 | |
|---|
| 974 | 892 | void dlm_destroy_debugfs_root(void) |
|---|