1 // SPDX-License-Identifier: GPL-2.0
3 * What: /sys/kernel/debug/orangefs/debug-help
5 * Contact: Mike Marshall <hubcap@omnibond.com>
7 * List of client and kernel debug keywords.
10 * What: /sys/kernel/debug/orangefs/client-debug
12 * Contact: Mike Marshall <hubcap@omnibond.com>
14 * Debug setting for "the client", the userspace
15 * helper for the kernel module.
18 * What: /sys/kernel/debug/orangefs/kernel-debug
20 * Contact: Mike Marshall <hubcap@omnibond.com>
22 * Debug setting for the orangefs kernel module.
24 * Any of the keywords, or comma-separated lists
25 * of keywords, from debug-help can be catted to
26 * client-debug or kernel-debug.
28 * "none", "all" and "verbose" are special keywords
29 * for client-debug. Setting client-debug to "all"
30 * is kind of like trying to drink water from a
31 * fire hose, "verbose" triggers most of the same
32 * output except for the constant flow of output
33 * from the main wait loop.
35 * "none" and "all" are similar settings for kernel-debug
36 * no need for a "verbose".
38 #include <linux/debugfs.h>
39 #include <linux/slab.h>
41 #include <linux/uaccess.h>
43 #include "orangefs-debugfs.h"
45 #include "orangefs-kernel.h"
47 #define DEBUG_HELP_STRING_SIZE 4096
48 #define HELP_STRING_UNINITIALIZED \
49 "Client Debug Keywords are unknown until the first time\n" \
50 "the client is started after boot.\n"
51 #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help"
52 #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug"
53 #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug"
54 #define ORANGEFS_VERBOSE "verbose"
55 #define ORANGEFS_ALL "all"
58 * An array of client_debug_mask will be built to hold debug keyword/mask
59 * values fetched from userspace.
61 struct client_debug_mask
{
67 static int orangefs_kernel_debug_init(void);
69 static int orangefs_debug_help_open(struct inode
*, struct file
*);
70 static void *help_start(struct seq_file
*, loff_t
*);
71 static void *help_next(struct seq_file
*, void *, loff_t
*);
72 static void help_stop(struct seq_file
*, void *);
73 static int help_show(struct seq_file
*, void *);
75 static int orangefs_debug_open(struct inode
*, struct file
*);
77 static ssize_t
orangefs_debug_read(struct file
*,
82 static ssize_t
orangefs_debug_write(struct file
*,
87 static int orangefs_prepare_cdm_array(char *);
88 static void debug_mask_to_string(void *, int);
89 static void do_k_string(void *, int);
90 static void do_c_string(void *, int);
91 static int keyword_is_amalgam(char *);
92 static int check_amalgam_keyword(void *, int);
93 static void debug_string_to_mask(char *, void *, int);
94 static void do_c_mask(int, char *, struct client_debug_mask
**);
95 static void do_k_mask(int, char *, __u64
**);
97 static char kernel_debug_string
[ORANGEFS_MAX_DEBUG_STRING_LEN
] = "none";
98 static char *debug_help_string
;
99 static char client_debug_string
[ORANGEFS_MAX_DEBUG_STRING_LEN
];
100 static char client_debug_array_string
[ORANGEFS_MAX_DEBUG_STRING_LEN
];
102 static struct dentry
*help_file_dentry
;
103 static struct dentry
*client_debug_dentry
;
104 static struct dentry
*debug_dir
;
106 static unsigned int kernel_mask_set_mod_init
;
107 static int orangefs_debug_disabled
= 1;
108 static int help_string_initialized
;
110 static const struct seq_operations help_debug_ops
= {
117 const struct file_operations debug_help_fops
= {
118 .owner
= THIS_MODULE
,
119 .open
= orangefs_debug_help_open
,
121 .release
= seq_release
,
125 static const struct file_operations kernel_debug_fops
= {
126 .owner
= THIS_MODULE
,
127 .open
= orangefs_debug_open
,
128 .read
= orangefs_debug_read
,
129 .write
= orangefs_debug_write
,
130 .llseek
= generic_file_llseek
,
133 static int client_all_index
;
134 static int client_verbose_index
;
136 static struct client_debug_mask
*cdm_array
;
137 static int cdm_element_count
;
139 static struct client_debug_mask client_debug_mask
;
142 * Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and
143 * ORANGEFS_KMOD_DEBUG_FILE.
145 static DEFINE_MUTEX(orangefs_debug_lock
);
147 /* Used to protect data in ORANGEFS_KMOD_DEBUG_HELP_FILE */
148 static DEFINE_MUTEX(orangefs_help_file_lock
);
151 * initialize kmod debug operations, create orangefs debugfs dir and
152 * ORANGEFS_KMOD_DEBUG_HELP_FILE.
154 int orangefs_debugfs_init(int debug_mask
)
158 /* convert input debug mask to a 64-bit unsigned integer */
159 orangefs_gossip_debug_mask
= (unsigned long long)debug_mask
;
162 * set the kernel's gossip debug string; invalid mask values will
165 debug_mask_to_string(&orangefs_gossip_debug_mask
, 0);
167 /* remove any invalid values from the mask */
168 debug_string_to_mask(kernel_debug_string
, &orangefs_gossip_debug_mask
,
172 * if the mask has a non-zero value, then indicate that the mask
173 * was set when the kernel module was loaded. The orangefs dev ioctl
174 * command will look at this boolean to determine if the kernel's
175 * debug mask should be overwritten when the client-core is started.
177 if (orangefs_gossip_debug_mask
!= 0)
178 kernel_mask_set_mod_init
= true;
180 pr_info("%s: called with debug mask: :%s: :%llx:\n",
183 (unsigned long long)orangefs_gossip_debug_mask
);
185 debug_dir
= debugfs_create_dir("orangefs", NULL
);
187 pr_info("%s: debugfs_create_dir failed.\n", __func__
);
191 help_file_dentry
= debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE
,
196 if (!help_file_dentry
) {
197 pr_info("%s: debugfs_create_file failed.\n", __func__
);
201 orangefs_debug_disabled
= 0;
203 rc
= orangefs_kernel_debug_init();
211 * initialize the kernel-debug file.
213 static int orangefs_kernel_debug_init(void)
217 char *k_buffer
= NULL
;
219 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "%s: start\n", __func__
);
221 k_buffer
= kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN
, GFP_KERNEL
);
225 if (strlen(kernel_debug_string
) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN
) {
226 strcpy(k_buffer
, kernel_debug_string
);
227 strcat(k_buffer
, "\n");
229 strcpy(k_buffer
, "none\n");
230 pr_info("%s: overflow 1!\n", __func__
);
233 ret
= debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE
,
239 pr_info("%s: failed to create %s.\n",
241 ORANGEFS_KMOD_DEBUG_FILE
);
249 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "%s: rc:%d:\n", __func__
, rc
);
254 void orangefs_debugfs_cleanup(void)
256 debugfs_remove_recursive(debug_dir
);
259 /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */
260 static int orangefs_debug_help_open(struct inode
*inode
, struct file
*file
)
265 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
266 "orangefs_debug_help_open: start\n");
268 if (orangefs_debug_disabled
)
271 ret
= seq_open(file
, &help_debug_ops
);
275 ((struct seq_file
*)(file
->private_data
))->private = inode
->i_private
;
280 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
281 "orangefs_debug_help_open: rc:%d:\n",
287 * I think start always gets called again after stop. Start
288 * needs to return NULL when it is done. The whole "payload"
289 * in this case is a single (long) string, so by the second
290 * time we get to start (pos = 1), we're done.
292 static void *help_start(struct seq_file
*m
, loff_t
*pos
)
294 void *payload
= NULL
;
296 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "help_start: start\n");
298 mutex_lock(&orangefs_help_file_lock
);
301 payload
= m
->private;
306 static void *help_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
308 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "help_next: start\n");
313 static void help_stop(struct seq_file
*m
, void *p
)
315 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "help_stop: start\n");
316 mutex_unlock(&orangefs_help_file_lock
);
319 static int help_show(struct seq_file
*m
, void *v
)
321 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "help_show: start\n");
329 * initialize the client-debug file.
331 int orangefs_client_debug_init(void)
335 char *c_buffer
= NULL
;
337 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "%s: start\n", __func__
);
339 c_buffer
= kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN
, GFP_KERNEL
);
343 if (strlen(client_debug_string
) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN
) {
344 strcpy(c_buffer
, client_debug_string
);
345 strcat(c_buffer
, "\n");
347 strcpy(c_buffer
, "none\n");
348 pr_info("%s: overflow! 2\n", __func__
);
351 client_debug_dentry
= debugfs_create_file(ORANGEFS_CLIENT_DEBUG_FILE
,
356 if (!client_debug_dentry
) {
357 pr_info("%s: failed to create updated %s.\n",
359 ORANGEFS_CLIENT_DEBUG_FILE
);
367 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "%s: rc:%d:\n", __func__
, rc
);
371 /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/
372 static int orangefs_debug_open(struct inode
*inode
, struct file
*file
)
376 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
377 "%s: orangefs_debug_disabled: %d\n",
379 orangefs_debug_disabled
);
381 if (orangefs_debug_disabled
)
385 mutex_lock(&orangefs_debug_lock
);
386 file
->private_data
= inode
->i_private
;
387 mutex_unlock(&orangefs_debug_lock
);
390 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
391 "orangefs_debug_open: rc: %d\n",
396 static ssize_t
orangefs_debug_read(struct file
*file
,
403 ssize_t read_ret
= -ENOMEM
;
405 gossip_debug(GOSSIP_DEBUGFS_DEBUG
, "orangefs_debug_read: start\n");
407 buf
= kmalloc(ORANGEFS_MAX_DEBUG_STRING_LEN
, GFP_KERNEL
);
411 mutex_lock(&orangefs_debug_lock
);
412 sprintf_ret
= sprintf(buf
, "%s", (char *)file
->private_data
);
413 mutex_unlock(&orangefs_debug_lock
);
415 read_ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, sprintf_ret
);
420 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
421 "orangefs_debug_read: ret: %zu\n",
427 static ssize_t
orangefs_debug_write(struct file
*file
,
428 const char __user
*ubuf
,
436 struct orangefs_kernel_op_s
*new_op
= NULL
;
437 struct client_debug_mask c_mask
= { NULL
, 0, 0 };
440 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
441 "orangefs_debug_write: %pD\n",
448 * Thwart users who try to jamb a ridiculous number
449 * of bytes into the debug file...
451 if (count
> ORANGEFS_MAX_DEBUG_STRING_LEN
+ 1) {
453 count
= ORANGEFS_MAX_DEBUG_STRING_LEN
+ 1;
456 buf
= kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN
, GFP_KERNEL
);
460 if (copy_from_user(buf
, ubuf
, count
- 1)) {
461 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
462 "%s: copy_from_user failed!\n",
468 * Map the keyword string from userspace into a valid debug mask.
469 * The mapping process involves mapping the human-inputted string
470 * into a valid mask, and then rebuilding the string from the
471 * verified valid mask.
473 * A service operation is required to set a new client-side
476 if (!strcmp(file
->f_path
.dentry
->d_name
.name
,
477 ORANGEFS_KMOD_DEBUG_FILE
)) {
478 debug_string_to_mask(buf
, &orangefs_gossip_debug_mask
, 0);
479 debug_mask_to_string(&orangefs_gossip_debug_mask
, 0);
480 debug_string
= kernel_debug_string
;
481 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
482 "New kernel debug string is %s\n",
483 kernel_debug_string
);
485 /* Can't reset client debug mask if client is not running. */
486 if (is_daemon_in_service()) {
487 pr_info("%s: Client not running :%d:\n",
489 is_daemon_in_service());
493 debug_string_to_mask(buf
, &c_mask
, 1);
494 debug_mask_to_string(&c_mask
, 1);
495 debug_string
= client_debug_string
;
497 new_op
= op_alloc(ORANGEFS_VFS_OP_PARAM
);
499 pr_info("%s: op_alloc failed!\n", __func__
);
503 new_op
->upcall
.req
.param
.op
=
504 ORANGEFS_PARAM_REQUEST_OP_TWO_MASK_VALUES
;
505 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_SET
;
506 memset(new_op
->upcall
.req
.param
.s_value
,
508 ORANGEFS_MAX_DEBUG_STRING_LEN
);
509 sprintf(new_op
->upcall
.req
.param
.s_value
,
514 /* service_operation returns 0 on success... */
515 rc
= service_operation(new_op
,
517 ORANGEFS_OP_INTERRUPTIBLE
);
520 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
521 "%s: service_operation failed! rc:%d:\n",
528 mutex_lock(&orangefs_debug_lock
);
529 s
= file_inode(file
)->i_private
;
530 memset(s
, 0, ORANGEFS_MAX_DEBUG_STRING_LEN
);
531 sprintf(s
, "%s\n", debug_string
);
532 mutex_unlock(&orangefs_debug_lock
);
541 gossip_debug(GOSSIP_DEBUGFS_DEBUG
,
542 "orangefs_debug_write: rc: %d\n",
549 * After obtaining a string representation of the client's debug
550 * keywords and their associated masks, this function is called to build an
551 * array of these values.
553 static int orangefs_prepare_cdm_array(char *debug_array_string
)
557 char *cds_head
= NULL
;
558 char *cds_delimiter
= NULL
;
561 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: start\n", __func__
);
564 * figure out how many elements the cdm_array needs.
566 for (i
= 0; i
< strlen(debug_array_string
); i
++)
567 if (debug_array_string
[i
] == '\n')
570 if (!cdm_element_count
) {
571 pr_info("No elements in client debug array string!\n");
575 cdm_array
= kcalloc(cdm_element_count
, sizeof(*cdm_array
), GFP_KERNEL
);
581 cds_head
= debug_array_string
;
583 for (i
= 0; i
< cdm_element_count
; i
++) {
584 cds_delimiter
= strchr(cds_head
, '\n');
585 *cds_delimiter
= '\0';
587 keyword_len
= strcspn(cds_head
, " ");
589 cdm_array
[i
].keyword
= kzalloc(keyword_len
+ 1, GFP_KERNEL
);
590 if (!cdm_array
[i
].keyword
) {
597 cdm_array
[i
].keyword
,
598 (unsigned long long *)&(cdm_array
[i
].mask1
),
599 (unsigned long long *)&(cdm_array
[i
].mask2
));
601 if (!strcmp(cdm_array
[i
].keyword
, ORANGEFS_VERBOSE
))
602 client_verbose_index
= i
;
604 if (!strcmp(cdm_array
[i
].keyword
, ORANGEFS_ALL
))
605 client_all_index
= i
;
607 cds_head
= cds_delimiter
+ 1;
610 rc
= cdm_element_count
;
612 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: rc:%d:\n", __func__
, rc
);
621 * /sys/kernel/debug/orangefs/debug-help can be catted to
622 * see all the available kernel and client debug keywords.
624 * When orangefs.ko initializes, we have no idea what keywords the
625 * client supports, nor their associated masks.
627 * We pass through this function once at module-load and stamp a
628 * boilerplate "we don't know" message for the client in the
629 * debug-help file. We pass through here again when the client
630 * starts and then we can fill out the debug-help file fully.
632 * The client might be restarted any number of times between
633 * module reloads, we only build the debug-help file the first time.
635 int orangefs_prepare_debugfs_help_string(int at_boot
)
637 char *client_title
= "Client Debug Keywords:\n";
638 char *kernel_title
= "Kernel Debug Keywords:\n";
639 size_t string_size
= DEBUG_HELP_STRING_SIZE
;
645 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: start\n", __func__
);
648 client_title
= HELP_STRING_UNINITIALIZED
;
650 /* build a new debug_help_string. */
651 new = kzalloc(DEBUG_HELP_STRING_SIZE
, GFP_KERNEL
);
658 * strlcat(dst, src, size) will append at most
659 * "size - strlen(dst) - 1" bytes of src onto dst,
660 * null terminating the result, and return the total
661 * length of the string it tried to create.
663 * We'll just plow through here building our new debug
664 * help string and let strlcat take care of assuring that
665 * dst doesn't overflow.
667 strlcat(new, client_title
, string_size
);
672 * fill the client keyword/mask array and remember
673 * how many elements there were.
676 orangefs_prepare_cdm_array(client_debug_array_string
);
677 if (cdm_element_count
<= 0) {
682 for (i
= 0; i
< cdm_element_count
; i
++) {
683 strlcat(new, "\t", string_size
);
684 strlcat(new, cdm_array
[i
].keyword
, string_size
);
685 strlcat(new, "\n", string_size
);
689 strlcat(new, "\n", string_size
);
690 strlcat(new, kernel_title
, string_size
);
692 for (i
= 0; i
< num_kmod_keyword_mask_map
; i
++) {
693 strlcat(new, "\t", string_size
);
694 strlcat(new, s_kmod_keyword_mask_map
[i
].keyword
, string_size
);
695 result_size
= strlcat(new, "\n", string_size
);
698 /* See if we tried to put too many bytes into "new"... */
699 if (result_size
>= string_size
) {
705 debug_help_string
= new;
707 mutex_lock(&orangefs_help_file_lock
);
708 memset(debug_help_string
, 0, DEBUG_HELP_STRING_SIZE
);
709 strlcat(debug_help_string
, new, string_size
);
710 mutex_unlock(&orangefs_help_file_lock
);
723 static void debug_mask_to_string(void *mask
, int type
)
728 int element_count
= 0;
730 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: start\n", __func__
);
733 debug_string
= client_debug_string
;
734 element_count
= cdm_element_count
;
736 debug_string
= kernel_debug_string
;
737 element_count
= num_kmod_keyword_mask_map
;
740 memset(debug_string
, 0, ORANGEFS_MAX_DEBUG_STRING_LEN
);
743 * Some keywords, like "all" or "verbose", are amalgams of
744 * numerous other keywords. Make a special check for those
745 * before grinding through the whole mask only to find out
748 if (check_amalgam_keyword(mask
, type
))
751 /* Build the debug string. */
752 for (i
= 0; i
< element_count
; i
++)
754 do_c_string(mask
, i
);
756 do_k_string(mask
, i
);
758 len
= strlen(debug_string
);
761 client_debug_string
[len
- 1] = '\0';
763 kernel_debug_string
[len
- 1] = '\0';
765 strcpy(client_debug_string
, "none");
767 strcpy(kernel_debug_string
, "none");
770 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: string:%s:\n", __func__
, debug_string
);
776 static void do_k_string(void *k_mask
, int index
)
778 __u64
*mask
= (__u64
*) k_mask
;
780 if (keyword_is_amalgam((char *) s_kmod_keyword_mask_map
[index
].keyword
))
783 if (*mask
& s_kmod_keyword_mask_map
[index
].mask_val
) {
784 if ((strlen(kernel_debug_string
) +
785 strlen(s_kmod_keyword_mask_map
[index
].keyword
))
786 < ORANGEFS_MAX_DEBUG_STRING_LEN
- 1) {
787 strcat(kernel_debug_string
,
788 s_kmod_keyword_mask_map
[index
].keyword
);
789 strcat(kernel_debug_string
, ",");
791 gossip_err("%s: overflow!\n", __func__
);
792 strcpy(kernel_debug_string
, ORANGEFS_ALL
);
802 static void do_c_string(void *c_mask
, int index
)
804 struct client_debug_mask
*mask
= (struct client_debug_mask
*) c_mask
;
806 if (keyword_is_amalgam(cdm_array
[index
].keyword
))
809 if ((mask
->mask1
& cdm_array
[index
].mask1
) ||
810 (mask
->mask2
& cdm_array
[index
].mask2
)) {
811 if ((strlen(client_debug_string
) +
812 strlen(cdm_array
[index
].keyword
) + 1)
813 < ORANGEFS_MAX_DEBUG_STRING_LEN
- 2) {
814 strcat(client_debug_string
,
815 cdm_array
[index
].keyword
);
816 strcat(client_debug_string
, ",");
818 gossip_err("%s: overflow!\n", __func__
);
819 strcpy(client_debug_string
, ORANGEFS_ALL
);
827 static int keyword_is_amalgam(char *keyword
)
831 if ((!strcmp(keyword
, ORANGEFS_ALL
)) || (!strcmp(keyword
, ORANGEFS_VERBOSE
)))
841 * return 1 if we found an amalgam.
843 static int check_amalgam_keyword(void *mask
, int type
)
846 struct client_debug_mask
*c_mask
;
847 int k_all_index
= num_kmod_keyword_mask_map
- 1;
851 c_mask
= (struct client_debug_mask
*) mask
;
853 if ((c_mask
->mask1
== cdm_array
[client_all_index
].mask1
) &&
854 (c_mask
->mask2
== cdm_array
[client_all_index
].mask2
)) {
855 strcpy(client_debug_string
, ORANGEFS_ALL
);
860 if ((c_mask
->mask1
== cdm_array
[client_verbose_index
].mask1
) &&
861 (c_mask
->mask2
== cdm_array
[client_verbose_index
].mask2
)) {
862 strcpy(client_debug_string
, ORANGEFS_VERBOSE
);
868 k_mask
= (__u64
*) mask
;
870 if (*k_mask
>= s_kmod_keyword_mask_map
[k_all_index
].mask_val
) {
871 strcpy(kernel_debug_string
, ORANGEFS_ALL
);
886 static void debug_string_to_mask(char *debug_string
, void *mask
, int type
)
888 char *unchecked_keyword
;
890 char *strsep_fodder
= kstrdup(debug_string
, GFP_KERNEL
);
891 char *original_pointer
;
892 int element_count
= 0;
893 struct client_debug_mask
*c_mask
= NULL
;
894 __u64
*k_mask
= NULL
;
896 gossip_debug(GOSSIP_UTILS_DEBUG
, "%s: start\n", __func__
);
899 c_mask
= (struct client_debug_mask
*)mask
;
900 element_count
= cdm_element_count
;
902 k_mask
= (__u64
*)mask
;
904 element_count
= num_kmod_keyword_mask_map
;
907 original_pointer
= strsep_fodder
;
908 while ((unchecked_keyword
= strsep(&strsep_fodder
, ",")))
909 if (strlen(unchecked_keyword
)) {
910 for (i
= 0; i
< element_count
; i
++)
921 kfree(original_pointer
);
924 static void do_c_mask(int i
, char *unchecked_keyword
,
925 struct client_debug_mask
**sane_mask
)
928 if (!strcmp(cdm_array
[i
].keyword
, unchecked_keyword
)) {
929 (**sane_mask
).mask1
= (**sane_mask
).mask1
| cdm_array
[i
].mask1
;
930 (**sane_mask
).mask2
= (**sane_mask
).mask2
| cdm_array
[i
].mask2
;
934 static void do_k_mask(int i
, char *unchecked_keyword
, __u64
**sane_mask
)
937 if (!strcmp(s_kmod_keyword_mask_map
[i
].keyword
, unchecked_keyword
))
938 **sane_mask
= (**sane_mask
) |
939 s_kmod_keyword_mask_map
[i
].mask_val
;
942 int orangefs_debugfs_new_client_mask(void __user
*arg
)
944 struct dev_mask2_info_s mask2_info
= {0};
947 ret
= copy_from_user(&mask2_info
,
949 sizeof(struct dev_mask2_info_s
));
954 client_debug_mask
.mask1
= mask2_info
.mask1_value
;
955 client_debug_mask
.mask2
= mask2_info
.mask2_value
;
957 pr_info("%s: client debug mask has been been received "
960 (unsigned long long)client_debug_mask
.mask1
,
961 (unsigned long long)client_debug_mask
.mask2
);
966 int orangefs_debugfs_new_client_string(void __user
*arg
)
970 ret
= copy_from_user(&client_debug_array_string
,
972 ORANGEFS_MAX_DEBUG_STRING_LEN
);
975 pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
981 * The real client-core makes an effort to ensure
982 * that actual strings that aren't too long to fit in
983 * this buffer is what we get here. We're going to use
984 * string functions on the stuff we got, so we'll make
985 * this extra effort to try and keep from
986 * flowing out of this buffer when we use the string
987 * functions, even if somehow the stuff we end up
988 * with here is garbage.
990 client_debug_array_string
[ORANGEFS_MAX_DEBUG_STRING_LEN
- 1] =
993 pr_info("%s: client debug array string has been received.\n",
996 if (!help_string_initialized
) {
998 /* Build a proper debug help string. */
999 ret
= orangefs_prepare_debugfs_help_string(0);
1001 gossip_err("%s: no debug help string \n",
1008 debug_mask_to_string(&client_debug_mask
, 1);
1010 debugfs_remove(client_debug_dentry
);
1012 orangefs_client_debug_init();
1014 help_string_initialized
++;
1019 int orangefs_debugfs_new_debug(void __user
*arg
)
1021 struct dev_mask_info_s mask_info
= {0};
1024 ret
= copy_from_user(&mask_info
,
1031 if (mask_info
.mask_type
== KERNEL_MASK
) {
1032 if ((mask_info
.mask_value
== 0)
1033 && (kernel_mask_set_mod_init
)) {
1035 * the kernel debug mask was set when the
1036 * kernel module was loaded; don't override
1037 * it if the client-core was started without
1038 * a value for ORANGEFS_KMODMASK.
1042 debug_mask_to_string(&mask_info
.mask_value
,
1043 mask_info
.mask_type
);
1044 orangefs_gossip_debug_mask
= mask_info
.mask_value
;
1045 pr_info("%s: kernel debug mask has been modified to "
1048 kernel_debug_string
,
1049 (unsigned long long)orangefs_gossip_debug_mask
);
1050 } else if (mask_info
.mask_type
== CLIENT_MASK
) {
1051 debug_mask_to_string(&mask_info
.mask_value
,
1052 mask_info
.mask_type
);
1053 pr_info("%s: client debug mask has been modified to"
1056 client_debug_string
,
1057 llu(mask_info
.mask_value
));
1059 gossip_lerr("Invalid mask type....\n");