diff options
author | Martin Brandenburg <martin@omnibond.com> | 2016-09-28 14:50:46 -0400 |
---|---|---|
committer | Martin Brandenburg <martin@omnibond.com> | 2016-09-28 14:50:46 -0400 |
commit | b78b11985a36bfe768add17ffb70bbaf9d8d7627 (patch) | |
tree | 20915bb2586b22567d408c753bba346f131fa759 /fs/orangefs | |
parent | f808e138c0abd99bfce90ec8d4ef6406c2af714a (diff) | |
parent | 1d503617884ed43af1c03685e73ce23f155d3fa4 (diff) |
Merge branch 'misc' into for-next
Pull in an OrangeFS branch containing miscellaneous improvements.
- clean up debugfs globals
- remove dead code in sysfs
- reorganize duplicated sysfs attribute structs
- consolidate sysfs show and store functions
- remove duplicated sysfs_ops structures
- describe organization of sysfs
- make devreq_mutex static
- g_orangefs_stats -> orangefs_stats for consistency
- rename most remaining global variables
Diffstat (limited to 'fs/orangefs')
-rw-r--r-- | fs/orangefs/dcache.c | 2 | ||||
-rw-r--r-- | fs/orangefs/devorangefs-req.c | 154 | ||||
-rw-r--r-- | fs/orangefs/file.c | 6 | ||||
-rw-r--r-- | fs/orangefs/namei.c | 8 | ||||
-rw-r--r-- | fs/orangefs/orangefs-debugfs.c | 761 | ||||
-rw-r--r-- | fs/orangefs/orangefs-debugfs.h | 8 | ||||
-rw-r--r-- | fs/orangefs/orangefs-kernel.h | 47 | ||||
-rw-r--r-- | fs/orangefs/orangefs-mod.c | 86 | ||||
-rw-r--r-- | fs/orangefs/orangefs-sysfs.c | 1193 | ||||
-rw-r--r-- | fs/orangefs/orangefs-utils.c | 401 | ||||
-rw-r--r-- | fs/orangefs/protocol.h | 25 | ||||
-rw-r--r-- | fs/orangefs/super.c | 4 | ||||
-rw-r--r-- | fs/orangefs/waitqueue.c | 10 |
13 files changed, 994 insertions, 1711 deletions
diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c index 00235bf644dc..1e8fe844e69f 100644 --- a/fs/orangefs/dcache.c +++ b/fs/orangefs/dcache.c | |||
@@ -73,7 +73,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry) | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000; | 76 | dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; |
77 | ret = 1; | 77 | ret = 1; |
78 | out_release_op: | 78 | out_release_op: |
79 | op_release(new_op); | 79 | op_release(new_op); |
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c index ec1a5ff1d843..516ffb4dc9a0 100644 --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "orangefs-kernel.h" | 11 | #include "orangefs-kernel.h" |
12 | #include "orangefs-dev-proto.h" | 12 | #include "orangefs-dev-proto.h" |
13 | #include "orangefs-bufmap.h" | 13 | #include "orangefs-bufmap.h" |
14 | #include "orangefs-debugfs.h" | ||
14 | 15 | ||
15 | #include <linux/debugfs.h> | 16 | #include <linux/debugfs.h> |
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
@@ -21,6 +22,8 @@ uint32_t orangefs_userspace_version; | |||
21 | 22 | ||
22 | static int open_access_count; | 23 | static int open_access_count; |
23 | 24 | ||
25 | static DEFINE_MUTEX(devreq_mutex); | ||
26 | |||
24 | #define DUMP_DEVICE_ERROR() \ | 27 | #define DUMP_DEVICE_ERROR() \ |
25 | do { \ | 28 | do { \ |
26 | gossip_err("*****************************************************\n");\ | 29 | gossip_err("*****************************************************\n");\ |
@@ -45,7 +48,7 @@ static void orangefs_devreq_add_op(struct orangefs_kernel_op_s *op) | |||
45 | { | 48 | { |
46 | int index = hash_func(op->tag, hash_table_size); | 49 | int index = hash_func(op->tag, hash_table_size); |
47 | 50 | ||
48 | list_add_tail(&op->list, &htable_ops_in_progress[index]); | 51 | list_add_tail(&op->list, &orangefs_htable_ops_in_progress[index]); |
49 | } | 52 | } |
50 | 53 | ||
51 | /* | 54 | /* |
@@ -59,20 +62,20 @@ static struct orangefs_kernel_op_s *orangefs_devreq_remove_op(__u64 tag) | |||
59 | 62 | ||
60 | index = hash_func(tag, hash_table_size); | 63 | index = hash_func(tag, hash_table_size); |
61 | 64 | ||
62 | spin_lock(&htable_ops_in_progress_lock); | 65 | spin_lock(&orangefs_htable_ops_in_progress_lock); |
63 | list_for_each_entry_safe(op, | 66 | list_for_each_entry_safe(op, |
64 | next, | 67 | next, |
65 | &htable_ops_in_progress[index], | 68 | &orangefs_htable_ops_in_progress[index], |
66 | list) { | 69 | list) { |
67 | if (op->tag == tag && !op_state_purged(op) && | 70 | if (op->tag == tag && !op_state_purged(op) && |
68 | !op_state_given_up(op)) { | 71 | !op_state_given_up(op)) { |
69 | list_del_init(&op->list); | 72 | list_del_init(&op->list); |
70 | spin_unlock(&htable_ops_in_progress_lock); | 73 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
71 | return op; | 74 | return op; |
72 | } | 75 | } |
73 | } | 76 | } |
74 | 77 | ||
75 | spin_unlock(&htable_ops_in_progress_lock); | 78 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
76 | return NULL; | 79 | return NULL; |
77 | } | 80 | } |
78 | 81 | ||
@@ -278,11 +281,11 @@ restart: | |||
278 | if (ret != 0) | 281 | if (ret != 0) |
279 | goto error; | 282 | goto error; |
280 | 283 | ||
281 | spin_lock(&htable_ops_in_progress_lock); | 284 | spin_lock(&orangefs_htable_ops_in_progress_lock); |
282 | spin_lock(&cur_op->lock); | 285 | spin_lock(&cur_op->lock); |
283 | if (unlikely(op_state_given_up(cur_op))) { | 286 | if (unlikely(op_state_given_up(cur_op))) { |
284 | spin_unlock(&cur_op->lock); | 287 | spin_unlock(&cur_op->lock); |
285 | spin_unlock(&htable_ops_in_progress_lock); | 288 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
286 | complete(&cur_op->waitq); | 289 | complete(&cur_op->waitq); |
287 | goto restart; | 290 | goto restart; |
288 | } | 291 | } |
@@ -300,7 +303,7 @@ restart: | |||
300 | current->comm); | 303 | current->comm); |
301 | orangefs_devreq_add_op(cur_op); | 304 | orangefs_devreq_add_op(cur_op); |
302 | spin_unlock(&cur_op->lock); | 305 | spin_unlock(&cur_op->lock); |
303 | spin_unlock(&htable_ops_in_progress_lock); | 306 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
304 | 307 | ||
305 | /* The client only asks to read one size buffer. */ | 308 | /* The client only asks to read one size buffer. */ |
306 | return MAX_DEV_REQ_UPSIZE; | 309 | return MAX_DEV_REQ_UPSIZE; |
@@ -586,8 +589,6 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) | |||
586 | static __s32 max_down_size = MAX_DEV_REQ_DOWNSIZE; | 589 | static __s32 max_down_size = MAX_DEV_REQ_DOWNSIZE; |
587 | struct ORANGEFS_dev_map_desc user_desc; | 590 | struct ORANGEFS_dev_map_desc user_desc; |
588 | int ret = 0; | 591 | int ret = 0; |
589 | struct dev_mask_info_s mask_info = { 0 }; | ||
590 | struct dev_mask2_info_s mask2_info = { 0, 0 }; | ||
591 | int upstream_kmod = 1; | 592 | int upstream_kmod = 1; |
592 | struct orangefs_sb_info_s *orangefs_sb; | 593 | struct orangefs_sb_info_s *orangefs_sb; |
593 | 594 | ||
@@ -629,7 +630,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) | |||
629 | * all of the remounts are serviced (to avoid ops between | 630 | * all of the remounts are serviced (to avoid ops between |
630 | * mounts to fail) | 631 | * mounts to fail) |
631 | */ | 632 | */ |
632 | ret = mutex_lock_interruptible(&request_mutex); | 633 | ret = mutex_lock_interruptible(&orangefs_request_mutex); |
633 | if (ret < 0) | 634 | if (ret < 0) |
634 | return ret; | 635 | return ret; |
635 | gossip_debug(GOSSIP_DEV_DEBUG, | 636 | gossip_debug(GOSSIP_DEV_DEBUG, |
@@ -664,7 +665,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) | |||
664 | gossip_debug(GOSSIP_DEV_DEBUG, | 665 | gossip_debug(GOSSIP_DEV_DEBUG, |
665 | "%s: priority remount complete\n", | 666 | "%s: priority remount complete\n", |
666 | __func__); | 667 | __func__); |
667 | mutex_unlock(&request_mutex); | 668 | mutex_unlock(&orangefs_request_mutex); |
668 | return ret; | 669 | return ret; |
669 | 670 | ||
670 | case ORANGEFS_DEV_UPSTREAM: | 671 | case ORANGEFS_DEV_UPSTREAM: |
@@ -678,134 +679,11 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) | |||
678 | return ret; | 679 | return ret; |
679 | 680 | ||
680 | case ORANGEFS_DEV_CLIENT_MASK: | 681 | case ORANGEFS_DEV_CLIENT_MASK: |
681 | ret = copy_from_user(&mask2_info, | 682 | return orangefs_debugfs_new_client_mask((void __user *)arg); |
682 | (void __user *)arg, | ||
683 | sizeof(struct dev_mask2_info_s)); | ||
684 | |||
685 | if (ret != 0) | ||
686 | return -EIO; | ||
687 | |||
688 | client_debug_mask.mask1 = mask2_info.mask1_value; | ||
689 | client_debug_mask.mask2 = mask2_info.mask2_value; | ||
690 | |||
691 | pr_info("%s: client debug mask has been been received " | ||
692 | ":%llx: :%llx:\n", | ||
693 | __func__, | ||
694 | (unsigned long long)client_debug_mask.mask1, | ||
695 | (unsigned long long)client_debug_mask.mask2); | ||
696 | |||
697 | return ret; | ||
698 | |||
699 | case ORANGEFS_DEV_CLIENT_STRING: | 683 | case ORANGEFS_DEV_CLIENT_STRING: |
700 | ret = copy_from_user(&client_debug_array_string, | 684 | return orangefs_debugfs_new_client_string((void __user *)arg); |
701 | (void __user *)arg, | ||
702 | ORANGEFS_MAX_DEBUG_STRING_LEN); | ||
703 | /* | ||
704 | * The real client-core makes an effort to ensure | ||
705 | * that actual strings that aren't too long to fit in | ||
706 | * this buffer is what we get here. We're going to use | ||
707 | * string functions on the stuff we got, so we'll make | ||
708 | * this extra effort to try and keep from | ||
709 | * flowing out of this buffer when we use the string | ||
710 | * functions, even if somehow the stuff we end up | ||
711 | * with here is garbage. | ||
712 | */ | ||
713 | client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] = | ||
714 | '\0'; | ||
715 | |||
716 | if (ret != 0) { | ||
717 | pr_info("%s: CLIENT_STRING: copy_from_user failed\n", | ||
718 | __func__); | ||
719 | return -EIO; | ||
720 | } | ||
721 | |||
722 | pr_info("%s: client debug array string has been received.\n", | ||
723 | __func__); | ||
724 | |||
725 | if (!help_string_initialized) { | ||
726 | |||
727 | /* Free the "we don't know yet" default string... */ | ||
728 | kfree(debug_help_string); | ||
729 | |||
730 | /* build a proper debug help string */ | ||
731 | if (orangefs_prepare_debugfs_help_string(0)) { | ||
732 | gossip_err("%s: no debug help string \n", | ||
733 | __func__); | ||
734 | return -EIO; | ||
735 | } | ||
736 | |||
737 | /* Replace the boilerplate boot-time debug-help file. */ | ||
738 | debugfs_remove(help_file_dentry); | ||
739 | |||
740 | help_file_dentry = | ||
741 | debugfs_create_file( | ||
742 | ORANGEFS_KMOD_DEBUG_HELP_FILE, | ||
743 | 0444, | ||
744 | debug_dir, | ||
745 | debug_help_string, | ||
746 | &debug_help_fops); | ||
747 | |||
748 | if (!help_file_dentry) { | ||
749 | gossip_err("%s: debugfs_create_file failed for" | ||
750 | " :%s:!\n", | ||
751 | __func__, | ||
752 | ORANGEFS_KMOD_DEBUG_HELP_FILE); | ||
753 | return -EIO; | ||
754 | } | ||
755 | } | ||
756 | |||
757 | debug_mask_to_string(&client_debug_mask, 1); | ||
758 | |||
759 | debugfs_remove(client_debug_dentry); | ||
760 | |||
761 | orangefs_client_debug_init(); | ||
762 | |||
763 | help_string_initialized++; | ||
764 | |||
765 | return ret; | ||
766 | |||
767 | case ORANGEFS_DEV_DEBUG: | 685 | case ORANGEFS_DEV_DEBUG: |
768 | ret = copy_from_user(&mask_info, | 686 | return orangefs_debugfs_new_debug((void __user *)arg); |
769 | (void __user *)arg, | ||
770 | sizeof(mask_info)); | ||
771 | |||
772 | if (ret != 0) | ||
773 | return -EIO; | ||
774 | |||
775 | if (mask_info.mask_type == KERNEL_MASK) { | ||
776 | if ((mask_info.mask_value == 0) | ||
777 | && (kernel_mask_set_mod_init)) { | ||
778 | /* | ||
779 | * the kernel debug mask was set when the | ||
780 | * kernel module was loaded; don't override | ||
781 | * it if the client-core was started without | ||
782 | * a value for ORANGEFS_KMODMASK. | ||
783 | */ | ||
784 | return 0; | ||
785 | } | ||
786 | debug_mask_to_string(&mask_info.mask_value, | ||
787 | mask_info.mask_type); | ||
788 | gossip_debug_mask = mask_info.mask_value; | ||
789 | pr_info("%s: kernel debug mask has been modified to " | ||
790 | ":%s: :%llx:\n", | ||
791 | __func__, | ||
792 | kernel_debug_string, | ||
793 | (unsigned long long)gossip_debug_mask); | ||
794 | } else if (mask_info.mask_type == CLIENT_MASK) { | ||
795 | debug_mask_to_string(&mask_info.mask_value, | ||
796 | mask_info.mask_type); | ||
797 | pr_info("%s: client debug mask has been modified to" | ||
798 | ":%s: :%llx:\n", | ||
799 | __func__, | ||
800 | client_debug_string, | ||
801 | llu(mask_info.mask_value)); | ||
802 | } else { | ||
803 | gossip_lerr("Invalid mask type....\n"); | ||
804 | return -EINVAL; | ||
805 | } | ||
806 | |||
807 | return ret; | ||
808 | |||
809 | default: | 687 | default: |
810 | return -ENOIOCTLCMD; | 688 | return -ENOIOCTLCMD; |
811 | } | 689 | } |
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index fe5e1eac9561..3386886596d6 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c | |||
@@ -412,7 +412,7 @@ ssize_t orangefs_inode_read(struct inode *inode, | |||
412 | size_t bufmap_size; | 412 | size_t bufmap_size; |
413 | ssize_t ret = -EINVAL; | 413 | ssize_t ret = -EINVAL; |
414 | 414 | ||
415 | g_orangefs_stats.reads++; | 415 | orangefs_stats.reads++; |
416 | 416 | ||
417 | bufmap_size = orangefs_bufmap_size_query(); | 417 | bufmap_size = orangefs_bufmap_size_query(); |
418 | if (count > bufmap_size) { | 418 | if (count > bufmap_size) { |
@@ -453,7 +453,7 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter | |||
453 | 453 | ||
454 | gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_read_iter\n"); | 454 | gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_read_iter\n"); |
455 | 455 | ||
456 | g_orangefs_stats.reads++; | 456 | orangefs_stats.reads++; |
457 | 457 | ||
458 | rc = do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter); | 458 | rc = do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter); |
459 | iocb->ki_pos = pos; | 459 | iocb->ki_pos = pos; |
@@ -514,7 +514,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite | |||
514 | } | 514 | } |
515 | 515 | ||
516 | iocb->ki_pos = pos; | 516 | iocb->ki_pos = pos; |
517 | g_orangefs_stats.writes++; | 517 | orangefs_stats.writes++; |
518 | 518 | ||
519 | out: | 519 | out: |
520 | 520 | ||
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index 62c525936ee8..35269e31de92 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c | |||
@@ -72,7 +72,7 @@ static int orangefs_create(struct inode *dir, | |||
72 | 72 | ||
73 | d_instantiate(dentry, inode); | 73 | d_instantiate(dentry, inode); |
74 | unlock_new_inode(inode); | 74 | unlock_new_inode(inode); |
75 | dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000; | 75 | dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; |
76 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 76 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
77 | 77 | ||
78 | gossip_debug(GOSSIP_NAME_DEBUG, | 78 | gossip_debug(GOSSIP_NAME_DEBUG, |
@@ -183,7 +183,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, | |||
183 | goto out; | 183 | goto out; |
184 | } | 184 | } |
185 | 185 | ||
186 | dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000; | 186 | dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; |
187 | 187 | ||
188 | inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); | 188 | inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); |
189 | if (IS_ERR(inode)) { | 189 | if (IS_ERR(inode)) { |
@@ -322,7 +322,7 @@ static int orangefs_symlink(struct inode *dir, | |||
322 | 322 | ||
323 | d_instantiate(dentry, inode); | 323 | d_instantiate(dentry, inode); |
324 | unlock_new_inode(inode); | 324 | unlock_new_inode(inode); |
325 | dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000; | 325 | dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; |
326 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 326 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
327 | 327 | ||
328 | gossip_debug(GOSSIP_NAME_DEBUG, | 328 | gossip_debug(GOSSIP_NAME_DEBUG, |
@@ -386,7 +386,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode | |||
386 | 386 | ||
387 | d_instantiate(dentry, inode); | 387 | d_instantiate(dentry, inode); |
388 | unlock_new_inode(inode); | 388 | unlock_new_inode(inode); |
389 | dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000; | 389 | dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000; |
390 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 390 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
391 | 391 | ||
392 | gossip_debug(GOSSIP_NAME_DEBUG, | 392 | gossip_debug(GOSSIP_NAME_DEBUG, |
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c index 1714a737d556..9b24107c82a8 100644 --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c | |||
@@ -43,36 +43,35 @@ | |||
43 | #include "protocol.h" | 43 | #include "protocol.h" |
44 | #include "orangefs-kernel.h" | 44 | #include "orangefs-kernel.h" |
45 | 45 | ||
46 | static int orangefs_debug_disabled = 1; | 46 | #define DEBUG_HELP_STRING_SIZE 4096 |
47 | 47 | #define HELP_STRING_UNINITIALIZED \ | |
48 | static int orangefs_debug_help_open(struct inode *, struct file *); | 48 | "Client Debug Keywords are unknown until the first time\n" \ |
49 | "the client is started after boot.\n" | ||
50 | #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help" | ||
51 | #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug" | ||
52 | #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug" | ||
53 | #define ORANGEFS_VERBOSE "verbose" | ||
54 | #define ORANGEFS_ALL "all" | ||
49 | 55 | ||
50 | const struct file_operations debug_help_fops = { | 56 | /* |
51 | .open = orangefs_debug_help_open, | 57 | * An array of client_debug_mask will be built to hold debug keyword/mask |
52 | .read = seq_read, | 58 | * values fetched from userspace. |
53 | .release = seq_release, | 59 | */ |
54 | .llseek = seq_lseek, | 60 | struct client_debug_mask { |
61 | char *keyword; | ||
62 | __u64 mask1; | ||
63 | __u64 mask2; | ||
55 | }; | 64 | }; |
56 | 65 | ||
66 | static int orangefs_kernel_debug_init(void); | ||
67 | |||
68 | static int orangefs_debug_help_open(struct inode *, struct file *); | ||
57 | static void *help_start(struct seq_file *, loff_t *); | 69 | static void *help_start(struct seq_file *, loff_t *); |
58 | static void *help_next(struct seq_file *, void *, loff_t *); | 70 | static void *help_next(struct seq_file *, void *, loff_t *); |
59 | static void help_stop(struct seq_file *, void *); | 71 | static void help_stop(struct seq_file *, void *); |
60 | static int help_show(struct seq_file *, void *); | 72 | static int help_show(struct seq_file *, void *); |
61 | 73 | ||
62 | static const struct seq_operations help_debug_ops = { | 74 | static int orangefs_debug_open(struct inode *, struct file *); |
63 | .start = help_start, | ||
64 | .next = help_next, | ||
65 | .stop = help_stop, | ||
66 | .show = help_show, | ||
67 | }; | ||
68 | |||
69 | /* | ||
70 | * Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and | ||
71 | * ORANGEFS_KMOD_DEBUG_FILE. | ||
72 | */ | ||
73 | static DEFINE_MUTEX(orangefs_debug_lock); | ||
74 | |||
75 | int orangefs_debug_open(struct inode *, struct file *); | ||
76 | 75 | ||
77 | static ssize_t orangefs_debug_read(struct file *, | 76 | static ssize_t orangefs_debug_read(struct file *, |
78 | char __user *, | 77 | char __user *, |
@@ -84,6 +83,43 @@ static ssize_t orangefs_debug_write(struct file *, | |||
84 | size_t, | 83 | size_t, |
85 | loff_t *); | 84 | loff_t *); |
86 | 85 | ||
86 | static int orangefs_prepare_cdm_array(char *); | ||
87 | static void debug_mask_to_string(void *, int); | ||
88 | static void do_k_string(void *, int); | ||
89 | static void do_c_string(void *, int); | ||
90 | static int keyword_is_amalgam(char *); | ||
91 | static int check_amalgam_keyword(void *, int); | ||
92 | static void debug_string_to_mask(char *, void *, int); | ||
93 | static void do_c_mask(int, char *, struct client_debug_mask **); | ||
94 | static void do_k_mask(int, char *, __u64 **); | ||
95 | |||
96 | static char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN] = "none"; | ||
97 | static char *debug_help_string; | ||
98 | static char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
99 | static char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
100 | |||
101 | static struct dentry *help_file_dentry; | ||
102 | static struct dentry *client_debug_dentry; | ||
103 | static struct dentry *debug_dir; | ||
104 | |||
105 | static unsigned int kernel_mask_set_mod_init; | ||
106 | static int orangefs_debug_disabled = 1; | ||
107 | static int help_string_initialized; | ||
108 | |||
109 | static const struct seq_operations help_debug_ops = { | ||
110 | .start = help_start, | ||
111 | .next = help_next, | ||
112 | .stop = help_stop, | ||
113 | .show = help_show, | ||
114 | }; | ||
115 | |||
116 | const struct file_operations debug_help_fops = { | ||
117 | .open = orangefs_debug_help_open, | ||
118 | .read = seq_read, | ||
119 | .release = seq_release, | ||
120 | .llseek = seq_lseek, | ||
121 | }; | ||
122 | |||
87 | static const struct file_operations kernel_debug_fops = { | 123 | static const struct file_operations kernel_debug_fops = { |
88 | .open = orangefs_debug_open, | 124 | .open = orangefs_debug_open, |
89 | .read = orangefs_debug_read, | 125 | .read = orangefs_debug_read, |
@@ -91,15 +127,55 @@ static const struct file_operations kernel_debug_fops = { | |||
91 | .llseek = generic_file_llseek, | 127 | .llseek = generic_file_llseek, |
92 | }; | 128 | }; |
93 | 129 | ||
130 | static int client_all_index; | ||
131 | static int client_verbose_index; | ||
132 | |||
133 | static struct client_debug_mask *cdm_array; | ||
134 | static int cdm_element_count; | ||
135 | |||
136 | static struct client_debug_mask client_debug_mask; | ||
137 | |||
138 | /* | ||
139 | * Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and | ||
140 | * ORANGEFS_KMOD_DEBUG_FILE. | ||
141 | */ | ||
142 | static DEFINE_MUTEX(orangefs_debug_lock); | ||
143 | |||
94 | /* | 144 | /* |
95 | * initialize kmod debug operations, create orangefs debugfs dir and | 145 | * initialize kmod debug operations, create orangefs debugfs dir and |
96 | * ORANGEFS_KMOD_DEBUG_HELP_FILE. | 146 | * ORANGEFS_KMOD_DEBUG_HELP_FILE. |
97 | */ | 147 | */ |
98 | int orangefs_debugfs_init(void) | 148 | int orangefs_debugfs_init(int debug_mask) |
99 | { | 149 | { |
100 | |||
101 | int rc = -ENOMEM; | 150 | int rc = -ENOMEM; |
102 | 151 | ||
152 | /* convert input debug mask to a 64-bit unsigned integer */ | ||
153 | orangefs_gossip_debug_mask = (unsigned long long)debug_mask; | ||
154 | |||
155 | /* | ||
156 | * set the kernel's gossip debug string; invalid mask values will | ||
157 | * be ignored. | ||
158 | */ | ||
159 | debug_mask_to_string(&orangefs_gossip_debug_mask, 0); | ||
160 | |||
161 | /* remove any invalid values from the mask */ | ||
162 | debug_string_to_mask(kernel_debug_string, &orangefs_gossip_debug_mask, | ||
163 | 0); | ||
164 | |||
165 | /* | ||
166 | * if the mask has a non-zero value, then indicate that the mask | ||
167 | * was set when the kernel module was loaded. The orangefs dev ioctl | ||
168 | * command will look at this boolean to determine if the kernel's | ||
169 | * debug mask should be overwritten when the client-core is started. | ||
170 | */ | ||
171 | if (orangefs_gossip_debug_mask != 0) | ||
172 | kernel_mask_set_mod_init = true; | ||
173 | |||
174 | pr_info("%s: called with debug mask: :%s: :%llx:\n", | ||
175 | __func__, | ||
176 | kernel_debug_string, | ||
177 | (unsigned long long)orangefs_gossip_debug_mask); | ||
178 | |||
103 | debug_dir = debugfs_create_dir("orangefs", NULL); | 179 | debug_dir = debugfs_create_dir("orangefs", NULL); |
104 | if (!debug_dir) { | 180 | if (!debug_dir) { |
105 | pr_info("%s: debugfs_create_dir failed.\n", __func__); | 181 | pr_info("%s: debugfs_create_dir failed.\n", __func__); |
@@ -117,13 +193,58 @@ int orangefs_debugfs_init(void) | |||
117 | } | 193 | } |
118 | 194 | ||
119 | orangefs_debug_disabled = 0; | 195 | orangefs_debug_disabled = 0; |
196 | |||
197 | rc = orangefs_kernel_debug_init(); | ||
198 | |||
199 | out: | ||
200 | |||
201 | return rc; | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * initialize the kernel-debug file. | ||
206 | */ | ||
207 | static int orangefs_kernel_debug_init(void) | ||
208 | { | ||
209 | int rc = -ENOMEM; | ||
210 | struct dentry *ret; | ||
211 | char *k_buffer = NULL; | ||
212 | |||
213 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); | ||
214 | |||
215 | k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); | ||
216 | if (!k_buffer) | ||
217 | goto out; | ||
218 | |||
219 | if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { | ||
220 | strcpy(k_buffer, kernel_debug_string); | ||
221 | strcat(k_buffer, "\n"); | ||
222 | } else { | ||
223 | strcpy(k_buffer, "none\n"); | ||
224 | pr_info("%s: overflow 1!\n", __func__); | ||
225 | } | ||
226 | |||
227 | ret = debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, | ||
228 | 0444, | ||
229 | debug_dir, | ||
230 | k_buffer, | ||
231 | &kernel_debug_fops); | ||
232 | if (!ret) { | ||
233 | pr_info("%s: failed to create %s.\n", | ||
234 | __func__, | ||
235 | ORANGEFS_KMOD_DEBUG_FILE); | ||
236 | goto out; | ||
237 | } | ||
238 | |||
120 | rc = 0; | 239 | rc = 0; |
121 | 240 | ||
122 | out: | 241 | out: |
123 | 242 | ||
243 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); | ||
124 | return rc; | 244 | return rc; |
125 | } | 245 | } |
126 | 246 | ||
247 | |||
127 | void orangefs_debugfs_cleanup(void) | 248 | void orangefs_debugfs_cleanup(void) |
128 | { | 249 | { |
129 | debugfs_remove_recursive(debug_dir); | 250 | debugfs_remove_recursive(debug_dir); |
@@ -196,49 +317,6 @@ static int help_show(struct seq_file *m, void *v) | |||
196 | } | 317 | } |
197 | 318 | ||
198 | /* | 319 | /* |
199 | * initialize the kernel-debug file. | ||
200 | */ | ||
201 | int orangefs_kernel_debug_init(void) | ||
202 | { | ||
203 | int rc = -ENOMEM; | ||
204 | struct dentry *ret; | ||
205 | char *k_buffer = NULL; | ||
206 | |||
207 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); | ||
208 | |||
209 | k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); | ||
210 | if (!k_buffer) | ||
211 | goto out; | ||
212 | |||
213 | if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { | ||
214 | strcpy(k_buffer, kernel_debug_string); | ||
215 | strcat(k_buffer, "\n"); | ||
216 | } else { | ||
217 | strcpy(k_buffer, "none\n"); | ||
218 | pr_info("%s: overflow 1!\n", __func__); | ||
219 | } | ||
220 | |||
221 | ret = debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, | ||
222 | 0444, | ||
223 | debug_dir, | ||
224 | k_buffer, | ||
225 | &kernel_debug_fops); | ||
226 | if (!ret) { | ||
227 | pr_info("%s: failed to create %s.\n", | ||
228 | __func__, | ||
229 | ORANGEFS_KMOD_DEBUG_FILE); | ||
230 | goto out; | ||
231 | } | ||
232 | |||
233 | rc = 0; | ||
234 | |||
235 | out: | ||
236 | |||
237 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); | ||
238 | return rc; | ||
239 | } | ||
240 | |||
241 | /* | ||
242 | * initialize the client-debug file. | 320 | * initialize the client-debug file. |
243 | */ | 321 | */ |
244 | int orangefs_client_debug_init(void) | 322 | int orangefs_client_debug_init(void) |
@@ -282,7 +360,7 @@ out: | |||
282 | } | 360 | } |
283 | 361 | ||
284 | /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/ | 362 | /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/ |
285 | int orangefs_debug_open(struct inode *inode, struct file *file) | 363 | static int orangefs_debug_open(struct inode *inode, struct file *file) |
286 | { | 364 | { |
287 | int rc = -ENODEV; | 365 | int rc = -ENODEV; |
288 | 366 | ||
@@ -384,8 +462,8 @@ static ssize_t orangefs_debug_write(struct file *file, | |||
384 | */ | 462 | */ |
385 | if (!strcmp(file->f_path.dentry->d_name.name, | 463 | if (!strcmp(file->f_path.dentry->d_name.name, |
386 | ORANGEFS_KMOD_DEBUG_FILE)) { | 464 | ORANGEFS_KMOD_DEBUG_FILE)) { |
387 | debug_string_to_mask(buf, &gossip_debug_mask, 0); | 465 | debug_string_to_mask(buf, &orangefs_gossip_debug_mask, 0); |
388 | debug_mask_to_string(&gossip_debug_mask, 0); | 466 | debug_mask_to_string(&orangefs_gossip_debug_mask, 0); |
389 | debug_string = kernel_debug_string; | 467 | debug_string = kernel_debug_string; |
390 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, | 468 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, |
391 | "New kernel debug string is %s\n", | 469 | "New kernel debug string is %s\n", |
@@ -452,3 +530,546 @@ out: | |||
452 | kfree(buf); | 530 | kfree(buf); |
453 | return rc; | 531 | return rc; |
454 | } | 532 | } |
533 | |||
534 | /* | ||
535 | * After obtaining a string representation of the client's debug | ||
536 | * keywords and their associated masks, this function is called to build an | ||
537 | * array of these values. | ||
538 | */ | ||
539 | static int orangefs_prepare_cdm_array(char *debug_array_string) | ||
540 | { | ||
541 | int i; | ||
542 | int rc = -EINVAL; | ||
543 | char *cds_head = NULL; | ||
544 | char *cds_delimiter = NULL; | ||
545 | int keyword_len = 0; | ||
546 | |||
547 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
548 | |||
549 | /* | ||
550 | * figure out how many elements the cdm_array needs. | ||
551 | */ | ||
552 | for (i = 0; i < strlen(debug_array_string); i++) | ||
553 | if (debug_array_string[i] == '\n') | ||
554 | cdm_element_count++; | ||
555 | |||
556 | if (!cdm_element_count) { | ||
557 | pr_info("No elements in client debug array string!\n"); | ||
558 | goto out; | ||
559 | } | ||
560 | |||
561 | cdm_array = | ||
562 | kzalloc(cdm_element_count * sizeof(struct client_debug_mask), | ||
563 | GFP_KERNEL); | ||
564 | if (!cdm_array) { | ||
565 | pr_info("malloc failed for cdm_array!\n"); | ||
566 | rc = -ENOMEM; | ||
567 | goto out; | ||
568 | } | ||
569 | |||
570 | cds_head = debug_array_string; | ||
571 | |||
572 | for (i = 0; i < cdm_element_count; i++) { | ||
573 | cds_delimiter = strchr(cds_head, '\n'); | ||
574 | *cds_delimiter = '\0'; | ||
575 | |||
576 | keyword_len = strcspn(cds_head, " "); | ||
577 | |||
578 | cdm_array[i].keyword = kzalloc(keyword_len + 1, GFP_KERNEL); | ||
579 | if (!cdm_array[i].keyword) { | ||
580 | rc = -ENOMEM; | ||
581 | goto out; | ||
582 | } | ||
583 | |||
584 | sscanf(cds_head, | ||
585 | "%s %llx %llx", | ||
586 | cdm_array[i].keyword, | ||
587 | (unsigned long long *)&(cdm_array[i].mask1), | ||
588 | (unsigned long long *)&(cdm_array[i].mask2)); | ||
589 | |||
590 | if (!strcmp(cdm_array[i].keyword, ORANGEFS_VERBOSE)) | ||
591 | client_verbose_index = i; | ||
592 | |||
593 | if (!strcmp(cdm_array[i].keyword, ORANGEFS_ALL)) | ||
594 | client_all_index = i; | ||
595 | |||
596 | cds_head = cds_delimiter + 1; | ||
597 | } | ||
598 | |||
599 | rc = cdm_element_count; | ||
600 | |||
601 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: rc:%d:\n", __func__, rc); | ||
602 | |||
603 | out: | ||
604 | |||
605 | return rc; | ||
606 | |||
607 | } | ||
608 | |||
609 | /* | ||
610 | * /sys/kernel/debug/orangefs/debug-help can be catted to | ||
611 | * see all the available kernel and client debug keywords. | ||
612 | * | ||
613 | * When the kernel boots, we have no idea what keywords the | ||
614 | * client supports, nor their associated masks. | ||
615 | * | ||
616 | * We pass through this function once at boot and stamp a | ||
617 | * boilerplate "we don't know" message for the client in the | ||
618 | * debug-help file. We pass through here again when the client | ||
619 | * starts and then we can fill out the debug-help file fully. | ||
620 | * | ||
621 | * The client might be restarted any number of times between | ||
622 | * reboots, we only build the debug-help file the first time. | ||
623 | */ | ||
624 | int orangefs_prepare_debugfs_help_string(int at_boot) | ||
625 | { | ||
626 | int rc = -EINVAL; | ||
627 | int i; | ||
628 | int byte_count = 0; | ||
629 | char *client_title = "Client Debug Keywords:\n"; | ||
630 | char *kernel_title = "Kernel Debug Keywords:\n"; | ||
631 | |||
632 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
633 | |||
634 | if (at_boot) { | ||
635 | byte_count += strlen(HELP_STRING_UNINITIALIZED); | ||
636 | client_title = HELP_STRING_UNINITIALIZED; | ||
637 | } else { | ||
638 | /* | ||
639 | * fill the client keyword/mask array and remember | ||
640 | * how many elements there were. | ||
641 | */ | ||
642 | cdm_element_count = | ||
643 | orangefs_prepare_cdm_array(client_debug_array_string); | ||
644 | if (cdm_element_count <= 0) | ||
645 | goto out; | ||
646 | |||
647 | /* Count the bytes destined for debug_help_string. */ | ||
648 | byte_count += strlen(client_title); | ||
649 | |||
650 | for (i = 0; i < cdm_element_count; i++) { | ||
651 | byte_count += strlen(cdm_array[i].keyword + 2); | ||
652 | if (byte_count >= DEBUG_HELP_STRING_SIZE) { | ||
653 | pr_info("%s: overflow 1!\n", __func__); | ||
654 | goto out; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | gossip_debug(GOSSIP_UTILS_DEBUG, | ||
659 | "%s: cdm_element_count:%d:\n", | ||
660 | __func__, | ||
661 | cdm_element_count); | ||
662 | } | ||
663 | |||
664 | byte_count += strlen(kernel_title); | ||
665 | for (i = 0; i < num_kmod_keyword_mask_map; i++) { | ||
666 | byte_count += | ||
667 | strlen(s_kmod_keyword_mask_map[i].keyword + 2); | ||
668 | if (byte_count >= DEBUG_HELP_STRING_SIZE) { | ||
669 | pr_info("%s: overflow 2!\n", __func__); | ||
670 | goto out; | ||
671 | } | ||
672 | } | ||
673 | |||
674 | /* build debug_help_string. */ | ||
675 | debug_help_string = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL); | ||
676 | if (!debug_help_string) { | ||
677 | rc = -ENOMEM; | ||
678 | goto out; | ||
679 | } | ||
680 | |||
681 | strcat(debug_help_string, client_title); | ||
682 | |||
683 | if (!at_boot) { | ||
684 | for (i = 0; i < cdm_element_count; i++) { | ||
685 | strcat(debug_help_string, "\t"); | ||
686 | strcat(debug_help_string, cdm_array[i].keyword); | ||
687 | strcat(debug_help_string, "\n"); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | strcat(debug_help_string, "\n"); | ||
692 | strcat(debug_help_string, kernel_title); | ||
693 | |||
694 | for (i = 0; i < num_kmod_keyword_mask_map; i++) { | ||
695 | strcat(debug_help_string, "\t"); | ||
696 | strcat(debug_help_string, s_kmod_keyword_mask_map[i].keyword); | ||
697 | strcat(debug_help_string, "\n"); | ||
698 | } | ||
699 | |||
700 | rc = 0; | ||
701 | |||
702 | out: | ||
703 | |||
704 | return rc; | ||
705 | |||
706 | } | ||
707 | |||
708 | /* | ||
709 | * kernel = type 0 | ||
710 | * client = type 1 | ||
711 | */ | ||
712 | static void debug_mask_to_string(void *mask, int type) | ||
713 | { | ||
714 | int i; | ||
715 | int len = 0; | ||
716 | char *debug_string; | ||
717 | int element_count = 0; | ||
718 | |||
719 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
720 | |||
721 | if (type) { | ||
722 | debug_string = client_debug_string; | ||
723 | element_count = cdm_element_count; | ||
724 | } else { | ||
725 | debug_string = kernel_debug_string; | ||
726 | element_count = num_kmod_keyword_mask_map; | ||
727 | } | ||
728 | |||
729 | memset(debug_string, 0, ORANGEFS_MAX_DEBUG_STRING_LEN); | ||
730 | |||
731 | /* | ||
732 | * Some keywords, like "all" or "verbose", are amalgams of | ||
733 | * numerous other keywords. Make a special check for those | ||
734 | * before grinding through the whole mask only to find out | ||
735 | * later... | ||
736 | */ | ||
737 | if (check_amalgam_keyword(mask, type)) | ||
738 | goto out; | ||
739 | |||
740 | /* Build the debug string. */ | ||
741 | for (i = 0; i < element_count; i++) | ||
742 | if (type) | ||
743 | do_c_string(mask, i); | ||
744 | else | ||
745 | do_k_string(mask, i); | ||
746 | |||
747 | len = strlen(debug_string); | ||
748 | |||
749 | if ((len) && (type)) | ||
750 | client_debug_string[len - 1] = '\0'; | ||
751 | else if (len) | ||
752 | kernel_debug_string[len - 1] = '\0'; | ||
753 | else if (type) | ||
754 | strcpy(client_debug_string, "none"); | ||
755 | else | ||
756 | strcpy(kernel_debug_string, "none"); | ||
757 | |||
758 | out: | ||
759 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_string); | ||
760 | |||
761 | return; | ||
762 | |||
763 | } | ||
764 | |||
765 | static void do_k_string(void *k_mask, int index) | ||
766 | { | ||
767 | __u64 *mask = (__u64 *) k_mask; | ||
768 | |||
769 | if (keyword_is_amalgam((char *) s_kmod_keyword_mask_map[index].keyword)) | ||
770 | goto out; | ||
771 | |||
772 | if (*mask & s_kmod_keyword_mask_map[index].mask_val) { | ||
773 | if ((strlen(kernel_debug_string) + | ||
774 | strlen(s_kmod_keyword_mask_map[index].keyword)) | ||
775 | < ORANGEFS_MAX_DEBUG_STRING_LEN - 1) { | ||
776 | strcat(kernel_debug_string, | ||
777 | s_kmod_keyword_mask_map[index].keyword); | ||
778 | strcat(kernel_debug_string, ","); | ||
779 | } else { | ||
780 | gossip_err("%s: overflow!\n", __func__); | ||
781 | strcpy(kernel_debug_string, ORANGEFS_ALL); | ||
782 | goto out; | ||
783 | } | ||
784 | } | ||
785 | |||
786 | out: | ||
787 | |||
788 | return; | ||
789 | } | ||
790 | |||
791 | static void do_c_string(void *c_mask, int index) | ||
792 | { | ||
793 | struct client_debug_mask *mask = (struct client_debug_mask *) c_mask; | ||
794 | |||
795 | if (keyword_is_amalgam(cdm_array[index].keyword)) | ||
796 | goto out; | ||
797 | |||
798 | if ((mask->mask1 & cdm_array[index].mask1) || | ||
799 | (mask->mask2 & cdm_array[index].mask2)) { | ||
800 | if ((strlen(client_debug_string) + | ||
801 | strlen(cdm_array[index].keyword) + 1) | ||
802 | < ORANGEFS_MAX_DEBUG_STRING_LEN - 2) { | ||
803 | strcat(client_debug_string, | ||
804 | cdm_array[index].keyword); | ||
805 | strcat(client_debug_string, ","); | ||
806 | } else { | ||
807 | gossip_err("%s: overflow!\n", __func__); | ||
808 | strcpy(client_debug_string, ORANGEFS_ALL); | ||
809 | goto out; | ||
810 | } | ||
811 | } | ||
812 | out: | ||
813 | return; | ||
814 | } | ||
815 | |||
816 | static int keyword_is_amalgam(char *keyword) | ||
817 | { | ||
818 | int rc = 0; | ||
819 | |||
820 | if ((!strcmp(keyword, ORANGEFS_ALL)) || (!strcmp(keyword, ORANGEFS_VERBOSE))) | ||
821 | rc = 1; | ||
822 | |||
823 | return rc; | ||
824 | } | ||
825 | |||
826 | /* | ||
827 | * kernel = type 0 | ||
828 | * client = type 1 | ||
829 | * | ||
830 | * return 1 if we found an amalgam. | ||
831 | */ | ||
832 | static int check_amalgam_keyword(void *mask, int type) | ||
833 | { | ||
834 | __u64 *k_mask; | ||
835 | struct client_debug_mask *c_mask; | ||
836 | int k_all_index = num_kmod_keyword_mask_map - 1; | ||
837 | int rc = 0; | ||
838 | |||
839 | if (type) { | ||
840 | c_mask = (struct client_debug_mask *) mask; | ||
841 | |||
842 | if ((c_mask->mask1 == cdm_array[client_all_index].mask1) && | ||
843 | (c_mask->mask2 == cdm_array[client_all_index].mask2)) { | ||
844 | strcpy(client_debug_string, ORANGEFS_ALL); | ||
845 | rc = 1; | ||
846 | goto out; | ||
847 | } | ||
848 | |||
849 | if ((c_mask->mask1 == cdm_array[client_verbose_index].mask1) && | ||
850 | (c_mask->mask2 == cdm_array[client_verbose_index].mask2)) { | ||
851 | strcpy(client_debug_string, ORANGEFS_VERBOSE); | ||
852 | rc = 1; | ||
853 | goto out; | ||
854 | } | ||
855 | |||
856 | } else { | ||
857 | k_mask = (__u64 *) mask; | ||
858 | |||
859 | if (*k_mask >= s_kmod_keyword_mask_map[k_all_index].mask_val) { | ||
860 | strcpy(kernel_debug_string, ORANGEFS_ALL); | ||
861 | rc = 1; | ||
862 | goto out; | ||
863 | } | ||
864 | } | ||
865 | |||
866 | out: | ||
867 | |||
868 | return rc; | ||
869 | } | ||
870 | |||
871 | /* | ||
872 | * kernel = type 0 | ||
873 | * client = type 1 | ||
874 | */ | ||
875 | static void debug_string_to_mask(char *debug_string, void *mask, int type) | ||
876 | { | ||
877 | char *unchecked_keyword; | ||
878 | int i; | ||
879 | char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL); | ||
880 | char *original_pointer; | ||
881 | int element_count = 0; | ||
882 | struct client_debug_mask *c_mask = NULL; | ||
883 | __u64 *k_mask = NULL; | ||
884 | |||
885 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
886 | |||
887 | if (type) { | ||
888 | c_mask = (struct client_debug_mask *)mask; | ||
889 | element_count = cdm_element_count; | ||
890 | } else { | ||
891 | k_mask = (__u64 *)mask; | ||
892 | *k_mask = 0; | ||
893 | element_count = num_kmod_keyword_mask_map; | ||
894 | } | ||
895 | |||
896 | original_pointer = strsep_fodder; | ||
897 | while ((unchecked_keyword = strsep(&strsep_fodder, ","))) | ||
898 | if (strlen(unchecked_keyword)) { | ||
899 | for (i = 0; i < element_count; i++) | ||
900 | if (type) | ||
901 | do_c_mask(i, | ||
902 | unchecked_keyword, | ||
903 | &c_mask); | ||
904 | else | ||
905 | do_k_mask(i, | ||
906 | unchecked_keyword, | ||
907 | &k_mask); | ||
908 | } | ||
909 | |||
910 | kfree(original_pointer); | ||
911 | } | ||
912 | |||
913 | static void do_c_mask(int i, char *unchecked_keyword, | ||
914 | struct client_debug_mask **sane_mask) | ||
915 | { | ||
916 | |||
917 | if (!strcmp(cdm_array[i].keyword, unchecked_keyword)) { | ||
918 | (**sane_mask).mask1 = (**sane_mask).mask1 | cdm_array[i].mask1; | ||
919 | (**sane_mask).mask2 = (**sane_mask).mask2 | cdm_array[i].mask2; | ||
920 | } | ||
921 | } | ||
922 | |||
923 | static void do_k_mask(int i, char *unchecked_keyword, __u64 **sane_mask) | ||
924 | { | ||
925 | |||
926 | if (!strcmp(s_kmod_keyword_mask_map[i].keyword, unchecked_keyword)) | ||
927 | **sane_mask = (**sane_mask) | | ||
928 | s_kmod_keyword_mask_map[i].mask_val; | ||
929 | } | ||
930 | |||
931 | int orangefs_debugfs_new_client_mask(void __user *arg) | ||
932 | { | ||
933 | struct dev_mask2_info_s mask2_info = {0}; | ||
934 | int ret; | ||
935 | |||
936 | ret = copy_from_user(&mask2_info, | ||
937 | (void __user *)arg, | ||
938 | sizeof(struct dev_mask2_info_s)); | ||
939 | |||
940 | if (ret != 0) | ||
941 | return -EIO; | ||
942 | |||
943 | client_debug_mask.mask1 = mask2_info.mask1_value; | ||
944 | client_debug_mask.mask2 = mask2_info.mask2_value; | ||
945 | |||
946 | pr_info("%s: client debug mask has been been received " | ||
947 | ":%llx: :%llx:\n", | ||
948 | __func__, | ||
949 | (unsigned long long)client_debug_mask.mask1, | ||
950 | (unsigned long long)client_debug_mask.mask2); | ||
951 | |||
952 | return ret; | ||
953 | } | ||
954 | |||
955 | int orangefs_debugfs_new_client_string(void __user *arg) | ||
956 | { | ||
957 | int ret; | ||
958 | |||
959 | ret = copy_from_user(&client_debug_array_string, | ||
960 | (void __user *)arg, | ||
961 | ORANGEFS_MAX_DEBUG_STRING_LEN); | ||
962 | if (ret != 0) | ||
963 | return -EIO; | ||
964 | |||
965 | /* | ||
966 | * The real client-core makes an effort to ensure | ||
967 | * that actual strings that aren't too long to fit in | ||
968 | * this buffer is what we get here. We're going to use | ||
969 | * string functions on the stuff we got, so we'll make | ||
970 | * this extra effort to try and keep from | ||
971 | * flowing out of this buffer when we use the string | ||
972 | * functions, even if somehow the stuff we end up | ||
973 | * with here is garbage. | ||
974 | */ | ||
975 | client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] = | ||
976 | '\0'; | ||
977 | |||
978 | if (ret != 0) { | ||
979 | pr_info("%s: CLIENT_STRING: copy_from_user failed\n", | ||
980 | __func__); | ||
981 | return -EIO; | ||
982 | } | ||
983 | |||
984 | pr_info("%s: client debug array string has been received.\n", | ||
985 | __func__); | ||
986 | |||
987 | if (!help_string_initialized) { | ||
988 | |||
989 | /* Free the "we don't know yet" default string... */ | ||
990 | kfree(debug_help_string); | ||
991 | |||
992 | /* build a proper debug help string */ | ||
993 | if (orangefs_prepare_debugfs_help_string(0)) { | ||
994 | gossip_err("%s: no debug help string \n", | ||
995 | __func__); | ||
996 | return -EIO; | ||
997 | } | ||
998 | |||
999 | /* Replace the boilerplate boot-time debug-help file. */ | ||
1000 | debugfs_remove(help_file_dentry); | ||
1001 | |||
1002 | help_file_dentry = | ||
1003 | debugfs_create_file( | ||
1004 | ORANGEFS_KMOD_DEBUG_HELP_FILE, | ||
1005 | 0444, | ||
1006 | debug_dir, | ||
1007 | debug_help_string, | ||
1008 | &debug_help_fops); | ||
1009 | |||
1010 | if (!help_file_dentry) { | ||
1011 | gossip_err("%s: debugfs_create_file failed for" | ||
1012 | " :%s:!\n", | ||
1013 | __func__, | ||
1014 | ORANGEFS_KMOD_DEBUG_HELP_FILE); | ||
1015 | return -EIO; | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1019 | debug_mask_to_string(&client_debug_mask, 1); | ||
1020 | |||
1021 | debugfs_remove(client_debug_dentry); | ||
1022 | |||
1023 | orangefs_client_debug_init(); | ||
1024 | |||
1025 | help_string_initialized++; | ||
1026 | |||
1027 | return ret; | ||
1028 | } | ||
1029 | |||
1030 | int orangefs_debugfs_new_debug(void __user *arg) | ||
1031 | { | ||
1032 | struct dev_mask_info_s mask_info = {0}; | ||
1033 | int ret; | ||
1034 | |||
1035 | ret = copy_from_user(&mask_info, | ||
1036 | (void __user *)arg, | ||
1037 | sizeof(mask_info)); | ||
1038 | |||
1039 | if (ret != 0) | ||
1040 | return -EIO; | ||
1041 | |||
1042 | if (mask_info.mask_type == KERNEL_MASK) { | ||
1043 | if ((mask_info.mask_value == 0) | ||
1044 | && (kernel_mask_set_mod_init)) { | ||
1045 | /* | ||
1046 | * the kernel debug mask was set when the | ||
1047 | * kernel module was loaded; don't override | ||
1048 | * it if the client-core was started without | ||
1049 | * a value for ORANGEFS_KMODMASK. | ||
1050 | */ | ||
1051 | return 0; | ||
1052 | } | ||
1053 | debug_mask_to_string(&mask_info.mask_value, | ||
1054 | mask_info.mask_type); | ||
1055 | orangefs_gossip_debug_mask = mask_info.mask_value; | ||
1056 | pr_info("%s: kernel debug mask has been modified to " | ||
1057 | ":%s: :%llx:\n", | ||
1058 | __func__, | ||
1059 | kernel_debug_string, | ||
1060 | (unsigned long long)orangefs_gossip_debug_mask); | ||
1061 | } else if (mask_info.mask_type == CLIENT_MASK) { | ||
1062 | debug_mask_to_string(&mask_info.mask_value, | ||
1063 | mask_info.mask_type); | ||
1064 | pr_info("%s: client debug mask has been modified to" | ||
1065 | ":%s: :%llx:\n", | ||
1066 | __func__, | ||
1067 | client_debug_string, | ||
1068 | llu(mask_info.mask_value)); | ||
1069 | } else { | ||
1070 | gossip_lerr("Invalid mask type....\n"); | ||
1071 | return -EINVAL; | ||
1072 | } | ||
1073 | |||
1074 | return ret; | ||
1075 | } | ||
diff --git a/fs/orangefs/orangefs-debugfs.h b/fs/orangefs/orangefs-debugfs.h index e4828c0e3ef9..803517269ba6 100644 --- a/fs/orangefs/orangefs-debugfs.h +++ b/fs/orangefs/orangefs-debugfs.h | |||
@@ -1,3 +1,7 @@ | |||
1 | int orangefs_debugfs_init(void); | 1 | int orangefs_debugfs_init(int); |
2 | int orangefs_kernel_debug_init(void); | ||
3 | void orangefs_debugfs_cleanup(void); | 2 | void orangefs_debugfs_cleanup(void); |
3 | int orangefs_client_debug_init(void); | ||
4 | int orangefs_prepare_debugfs_help_string(int); | ||
5 | int orangefs_debugfs_new_client_mask(void __user *); | ||
6 | int orangefs_debugfs_new_client_string(void __user *); | ||
7 | int orangefs_debugfs_new_debug(void __user *); | ||
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index 6cf3f467fd89..0a82048f3aaf 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h | |||
@@ -100,16 +100,6 @@ enum orangefs_vfs_op_states { | |||
100 | }; | 100 | }; |
101 | 101 | ||
102 | /* | 102 | /* |
103 | * An array of client_debug_mask will be built to hold debug keyword/mask | ||
104 | * values fetched from userspace. | ||
105 | */ | ||
106 | struct client_debug_mask { | ||
107 | char *keyword; | ||
108 | __u64 mask1; | ||
109 | __u64 mask2; | ||
110 | }; | ||
111 | |||
112 | /* | ||
113 | * orangefs kernel memory related flags | 103 | * orangefs kernel memory related flags |
114 | */ | 104 | */ |
115 | 105 | ||
@@ -119,29 +109,6 @@ struct client_debug_mask { | |||
119 | #define ORANGEFS_CACHE_CREATE_FLAGS 0 | 109 | #define ORANGEFS_CACHE_CREATE_FLAGS 0 |
120 | #endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */ | 110 | #endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */ |
121 | 111 | ||
122 | /* these functions are defined in orangefs-utils.c */ | ||
123 | int orangefs_prepare_cdm_array(char *debug_array_string); | ||
124 | int orangefs_prepare_debugfs_help_string(int); | ||
125 | |||
126 | /* defined in orangefs-debugfs.c */ | ||
127 | int orangefs_client_debug_init(void); | ||
128 | |||
129 | void debug_string_to_mask(char *, void *, int); | ||
130 | void do_c_mask(int, char *, struct client_debug_mask **); | ||
131 | void do_k_mask(int, char *, __u64 **); | ||
132 | |||
133 | void debug_mask_to_string(void *, int); | ||
134 | void do_k_string(void *, int); | ||
135 | void do_c_string(void *, int); | ||
136 | int check_amalgam_keyword(void *, int); | ||
137 | int keyword_is_amalgam(char *); | ||
138 | |||
139 | /*these variables are defined in orangefs-mod.c */ | ||
140 | extern char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
141 | extern char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
142 | extern char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
143 | extern unsigned int kernel_mask_set_mod_init; | ||
144 | |||
145 | extern int orangefs_init_acl(struct inode *inode, struct inode *dir); | 112 | extern int orangefs_init_acl(struct inode *inode, struct inode *dir); |
146 | extern const struct xattr_handler *orangefs_xattr_handlers[]; | 113 | extern const struct xattr_handler *orangefs_xattr_handlers[]; |
147 | 114 | ||
@@ -331,7 +298,7 @@ struct orangefs_stats { | |||
331 | unsigned long writes; | 298 | unsigned long writes; |
332 | }; | 299 | }; |
333 | 300 | ||
334 | extern struct orangefs_stats g_orangefs_stats; | 301 | extern struct orangefs_stats orangefs_stats; |
335 | 302 | ||
336 | /* | 303 | /* |
337 | * NOTE: See Documentation/filesystems/porting for information | 304 | * NOTE: See Documentation/filesystems/porting for information |
@@ -547,20 +514,18 @@ bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op); | |||
547 | 514 | ||
548 | int orangefs_normalize_to_errno(__s32 error_code); | 515 | int orangefs_normalize_to_errno(__s32 error_code); |
549 | 516 | ||
550 | extern struct mutex devreq_mutex; | 517 | extern struct mutex orangefs_request_mutex; |
551 | extern struct mutex request_mutex; | ||
552 | extern int debug; | ||
553 | extern int op_timeout_secs; | 518 | extern int op_timeout_secs; |
554 | extern int slot_timeout_secs; | 519 | extern int slot_timeout_secs; |
555 | extern int dcache_timeout_msecs; | 520 | extern int orangefs_dcache_timeout_msecs; |
556 | extern int getattr_timeout_msecs; | 521 | extern int orangefs_getattr_timeout_msecs; |
557 | extern struct list_head orangefs_superblocks; | 522 | extern struct list_head orangefs_superblocks; |
558 | extern spinlock_t orangefs_superblocks_lock; | 523 | extern spinlock_t orangefs_superblocks_lock; |
559 | extern struct list_head orangefs_request_list; | 524 | extern struct list_head orangefs_request_list; |
560 | extern spinlock_t orangefs_request_list_lock; | 525 | extern spinlock_t orangefs_request_list_lock; |
561 | extern wait_queue_head_t orangefs_request_list_waitq; | 526 | extern wait_queue_head_t orangefs_request_list_waitq; |
562 | extern struct list_head *htable_ops_in_progress; | 527 | extern struct list_head *orangefs_htable_ops_in_progress; |
563 | extern spinlock_t htable_ops_in_progress_lock; | 528 | extern spinlock_t orangefs_htable_ops_in_progress_lock; |
564 | extern int hash_table_size; | 529 | extern int hash_table_size; |
565 | 530 | ||
566 | extern const struct address_space_operations orangefs_address_operations; | 531 | extern const struct address_space_operations orangefs_address_operations; |
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c index e9fd5755c05f..2e5b03065f34 100644 --- a/fs/orangefs/orangefs-mod.c +++ b/fs/orangefs/orangefs-mod.c | |||
@@ -21,34 +21,17 @@ | |||
21 | * global variables declared here | 21 | * global variables declared here |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* array of client debug keyword/mask values */ | 24 | struct orangefs_stats orangefs_stats; |
25 | struct client_debug_mask *cdm_array; | ||
26 | int cdm_element_count; | ||
27 | |||
28 | char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN] = "none"; | ||
29 | char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
30 | char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; | ||
31 | |||
32 | char *debug_help_string; | ||
33 | int help_string_initialized; | ||
34 | struct dentry *help_file_dentry; | ||
35 | struct dentry *client_debug_dentry; | ||
36 | struct dentry *debug_dir; | ||
37 | int client_verbose_index; | ||
38 | int client_all_index; | ||
39 | struct orangefs_stats g_orangefs_stats; | ||
40 | 25 | ||
41 | /* the size of the hash tables for ops in progress */ | 26 | /* the size of the hash tables for ops in progress */ |
42 | int hash_table_size = 509; | 27 | int hash_table_size = 509; |
43 | 28 | ||
44 | static ulong module_parm_debug_mask; | 29 | static ulong module_parm_debug_mask; |
45 | __u64 gossip_debug_mask; | 30 | __u64 orangefs_gossip_debug_mask; |
46 | struct client_debug_mask client_debug_mask = { NULL, 0, 0 }; | ||
47 | unsigned int kernel_mask_set_mod_init; /* implicitly false */ | ||
48 | int op_timeout_secs = ORANGEFS_DEFAULT_OP_TIMEOUT_SECS; | 31 | int op_timeout_secs = ORANGEFS_DEFAULT_OP_TIMEOUT_SECS; |
49 | int slot_timeout_secs = ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS; | 32 | int slot_timeout_secs = ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS; |
50 | int dcache_timeout_msecs = 50; | 33 | int orangefs_dcache_timeout_msecs = 50; |
51 | int getattr_timeout_msecs = 50; | 34 | int orangefs_getattr_timeout_msecs = 50; |
52 | 35 | ||
53 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
54 | MODULE_AUTHOR("ORANGEFS Development Team"); | 37 | MODULE_AUTHOR("ORANGEFS Development Team"); |
@@ -71,20 +54,17 @@ module_param(module_parm_debug_mask, ulong, 0644); | |||
71 | module_param(op_timeout_secs, int, 0); | 54 | module_param(op_timeout_secs, int, 0); |
72 | module_param(slot_timeout_secs, int, 0); | 55 | module_param(slot_timeout_secs, int, 0); |
73 | 56 | ||
74 | /* synchronizes the request device file */ | ||
75 | DEFINE_MUTEX(devreq_mutex); | ||
76 | |||
77 | /* | 57 | /* |
78 | * Blocks non-priority requests from being queued for servicing. This | 58 | * Blocks non-priority requests from being queued for servicing. This |
79 | * could be used for protecting the request list data structure, but | 59 | * could be used for protecting the request list data structure, but |
80 | * for now it's only being used to stall the op addition to the request | 60 | * for now it's only being used to stall the op addition to the request |
81 | * list | 61 | * list |
82 | */ | 62 | */ |
83 | DEFINE_MUTEX(request_mutex); | 63 | DEFINE_MUTEX(orangefs_request_mutex); |
84 | 64 | ||
85 | /* hash table for storing operations waiting for matching downcall */ | 65 | /* hash table for storing operations waiting for matching downcall */ |
86 | struct list_head *htable_ops_in_progress; | 66 | struct list_head *orangefs_htable_ops_in_progress; |
87 | DEFINE_SPINLOCK(htable_ops_in_progress_lock); | 67 | DEFINE_SPINLOCK(orangefs_htable_ops_in_progress_lock); |
88 | 68 | ||
89 | /* list for queueing upcall operations */ | 69 | /* list for queueing upcall operations */ |
90 | LIST_HEAD(orangefs_request_list); | 70 | LIST_HEAD(orangefs_request_list); |
@@ -100,32 +80,6 @@ static int __init orangefs_init(void) | |||
100 | int ret = -1; | 80 | int ret = -1; |
101 | __u32 i = 0; | 81 | __u32 i = 0; |
102 | 82 | ||
103 | /* convert input debug mask to a 64-bit unsigned integer */ | ||
104 | gossip_debug_mask = (unsigned long long) module_parm_debug_mask; | ||
105 | |||
106 | /* | ||
107 | * set the kernel's gossip debug string; invalid mask values will | ||
108 | * be ignored. | ||
109 | */ | ||
110 | debug_mask_to_string(&gossip_debug_mask, 0); | ||
111 | |||
112 | /* remove any invalid values from the mask */ | ||
113 | debug_string_to_mask(kernel_debug_string, &gossip_debug_mask, 0); | ||
114 | |||
115 | /* | ||
116 | * if the mask has a non-zero value, then indicate that the mask | ||
117 | * was set when the kernel module was loaded. The orangefs dev ioctl | ||
118 | * command will look at this boolean to determine if the kernel's | ||
119 | * debug mask should be overwritten when the client-core is started. | ||
120 | */ | ||
121 | if (gossip_debug_mask != 0) | ||
122 | kernel_mask_set_mod_init = true; | ||
123 | |||
124 | pr_info("%s: called with debug mask: :%s: :%llx:\n", | ||
125 | __func__, | ||
126 | kernel_debug_string, | ||
127 | (unsigned long long)gossip_debug_mask); | ||
128 | |||
129 | ret = bdi_init(&orangefs_backing_dev_info); | 83 | ret = bdi_init(&orangefs_backing_dev_info); |
130 | 84 | ||
131 | if (ret) | 85 | if (ret) |
@@ -146,9 +100,9 @@ static int __init orangefs_init(void) | |||
146 | if (ret < 0) | 100 | if (ret < 0) |
147 | goto cleanup_op; | 101 | goto cleanup_op; |
148 | 102 | ||
149 | htable_ops_in_progress = | 103 | orangefs_htable_ops_in_progress = |
150 | kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL); | 104 | kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL); |
151 | if (!htable_ops_in_progress) { | 105 | if (!orangefs_htable_ops_in_progress) { |
152 | gossip_err("Failed to initialize op hashtable"); | 106 | gossip_err("Failed to initialize op hashtable"); |
153 | ret = -ENOMEM; | 107 | ret = -ENOMEM; |
154 | goto cleanup_inode; | 108 | goto cleanup_inode; |
@@ -156,7 +110,7 @@ static int __init orangefs_init(void) | |||
156 | 110 | ||
157 | /* initialize a doubly linked at each hash table index */ | 111 | /* initialize a doubly linked at each hash table index */ |
158 | for (i = 0; i < hash_table_size; i++) | 112 | for (i = 0; i < hash_table_size; i++) |
159 | INIT_LIST_HEAD(&htable_ops_in_progress[i]); | 113 | INIT_LIST_HEAD(&orangefs_htable_ops_in_progress[i]); |
160 | 114 | ||
161 | ret = fsid_key_table_initialize(); | 115 | ret = fsid_key_table_initialize(); |
162 | if (ret < 0) | 116 | if (ret < 0) |
@@ -179,14 +133,10 @@ static int __init orangefs_init(void) | |||
179 | if (ret) | 133 | if (ret) |
180 | goto cleanup_key_table; | 134 | goto cleanup_key_table; |
181 | 135 | ||
182 | ret = orangefs_debugfs_init(); | 136 | ret = orangefs_debugfs_init(module_parm_debug_mask); |
183 | if (ret) | 137 | if (ret) |
184 | goto debugfs_init_failed; | 138 | goto debugfs_init_failed; |
185 | 139 | ||
186 | ret = orangefs_kernel_debug_init(); | ||
187 | if (ret) | ||
188 | goto kernel_debug_init_failed; | ||
189 | |||
190 | ret = orangefs_sysfs_init(); | 140 | ret = orangefs_sysfs_init(); |
191 | if (ret) | 141 | if (ret) |
192 | goto sysfs_init_failed; | 142 | goto sysfs_init_failed; |
@@ -214,8 +164,6 @@ cleanup_device: | |||
214 | 164 | ||
215 | sysfs_init_failed: | 165 | sysfs_init_failed: |
216 | 166 | ||
217 | kernel_debug_init_failed: | ||
218 | |||
219 | debugfs_init_failed: | 167 | debugfs_init_failed: |
220 | orangefs_debugfs_cleanup(); | 168 | orangefs_debugfs_cleanup(); |
221 | 169 | ||
@@ -223,7 +171,7 @@ cleanup_key_table: | |||
223 | fsid_key_table_finalize(); | 171 | fsid_key_table_finalize(); |
224 | 172 | ||
225 | cleanup_progress_table: | 173 | cleanup_progress_table: |
226 | kfree(htable_ops_in_progress); | 174 | kfree(orangefs_htable_ops_in_progress); |
227 | 175 | ||
228 | cleanup_inode: | 176 | cleanup_inode: |
229 | orangefs_inode_cache_finalize(); | 177 | orangefs_inode_cache_finalize(); |
@@ -250,12 +198,12 @@ static void __exit orangefs_exit(void) | |||
250 | orangefs_dev_cleanup(); | 198 | orangefs_dev_cleanup(); |
251 | BUG_ON(!list_empty(&orangefs_request_list)); | 199 | BUG_ON(!list_empty(&orangefs_request_list)); |
252 | for (i = 0; i < hash_table_size; i++) | 200 | for (i = 0; i < hash_table_size; i++) |
253 | BUG_ON(!list_empty(&htable_ops_in_progress[i])); | 201 | BUG_ON(!list_empty(&orangefs_htable_ops_in_progress[i])); |
254 | 202 | ||
255 | orangefs_inode_cache_finalize(); | 203 | orangefs_inode_cache_finalize(); |
256 | op_cache_finalize(); | 204 | op_cache_finalize(); |
257 | 205 | ||
258 | kfree(htable_ops_in_progress); | 206 | kfree(orangefs_htable_ops_in_progress); |
259 | 207 | ||
260 | bdi_destroy(&orangefs_backing_dev_info); | 208 | bdi_destroy(&orangefs_backing_dev_info); |
261 | 209 | ||
@@ -274,10 +222,10 @@ void purge_inprogress_ops(void) | |||
274 | struct orangefs_kernel_op_s *op; | 222 | struct orangefs_kernel_op_s *op; |
275 | struct orangefs_kernel_op_s *next; | 223 | struct orangefs_kernel_op_s *next; |
276 | 224 | ||
277 | spin_lock(&htable_ops_in_progress_lock); | 225 | spin_lock(&orangefs_htable_ops_in_progress_lock); |
278 | list_for_each_entry_safe(op, | 226 | list_for_each_entry_safe(op, |
279 | next, | 227 | next, |
280 | &htable_ops_in_progress[i], | 228 | &orangefs_htable_ops_in_progress[i], |
281 | list) { | 229 | list) { |
282 | set_op_state_purged(op); | 230 | set_op_state_purged(op); |
283 | gossip_debug(GOSSIP_DEV_DEBUG, | 231 | gossip_debug(GOSSIP_DEV_DEBUG, |
@@ -287,7 +235,7 @@ void purge_inprogress_ops(void) | |||
287 | op->op_state, | 235 | op->op_state, |
288 | current->comm); | 236 | current->comm); |
289 | } | 237 | } |
290 | spin_unlock(&htable_ops_in_progress_lock); | 238 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
291 | } | 239 | } |
292 | } | 240 | } |
293 | 241 | ||
diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c index ed5ee33d0f7e..a799546a67f7 100644 --- a/fs/orangefs/orangefs-sysfs.c +++ b/fs/orangefs/orangefs-sysfs.c | |||
@@ -139,159 +139,34 @@ | |||
139 | #define PC_KOBJ_ID "pc" | 139 | #define PC_KOBJ_ID "pc" |
140 | #define STATS_KOBJ_ID "stats" | 140 | #define STATS_KOBJ_ID "stats" |
141 | 141 | ||
142 | struct orangefs_obj { | 142 | /* |
143 | struct kobject kobj; | 143 | * Every item calls orangefs_attr_show and orangefs_attr_store through |
144 | int op_timeout_secs; | 144 | * orangefs_sysfs_ops. They look at the orangefs_attributes further below to |
145 | int perf_counter_reset; | 145 | * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or |
146 | int perf_history_size; | 146 | * sysfs_service_op_store. |
147 | int perf_time_interval_secs; | 147 | */ |
148 | int slot_timeout_secs; | ||
149 | int dcache_timeout_msecs; | ||
150 | int getattr_timeout_msecs; | ||
151 | }; | ||
152 | |||
153 | struct acache_orangefs_obj { | ||
154 | struct kobject kobj; | ||
155 | int hard_limit; | ||
156 | int reclaim_percentage; | ||
157 | int soft_limit; | ||
158 | int timeout_msecs; | ||
159 | }; | ||
160 | |||
161 | struct capcache_orangefs_obj { | ||
162 | struct kobject kobj; | ||
163 | int hard_limit; | ||
164 | int reclaim_percentage; | ||
165 | int soft_limit; | ||
166 | int timeout_secs; | ||
167 | }; | ||
168 | |||
169 | struct ccache_orangefs_obj { | ||
170 | struct kobject kobj; | ||
171 | int hard_limit; | ||
172 | int reclaim_percentage; | ||
173 | int soft_limit; | ||
174 | int timeout_secs; | ||
175 | }; | ||
176 | |||
177 | struct ncache_orangefs_obj { | ||
178 | struct kobject kobj; | ||
179 | int hard_limit; | ||
180 | int reclaim_percentage; | ||
181 | int soft_limit; | ||
182 | int timeout_msecs; | ||
183 | }; | ||
184 | |||
185 | struct pc_orangefs_obj { | ||
186 | struct kobject kobj; | ||
187 | char *acache; | ||
188 | char *capcache; | ||
189 | char *ncache; | ||
190 | }; | ||
191 | |||
192 | struct stats_orangefs_obj { | ||
193 | struct kobject kobj; | ||
194 | int reads; | ||
195 | int writes; | ||
196 | }; | ||
197 | 148 | ||
198 | struct orangefs_attribute { | 149 | struct orangefs_attribute { |
199 | struct attribute attr; | 150 | struct attribute attr; |
200 | ssize_t (*show)(struct orangefs_obj *orangefs_obj, | 151 | ssize_t (*show)(struct kobject *kobj, |
201 | struct orangefs_attribute *attr, | 152 | struct orangefs_attribute *attr, |
202 | char *buf); | 153 | char *buf); |
203 | ssize_t (*store)(struct orangefs_obj *orangefs_obj, | 154 | ssize_t (*store)(struct kobject *kobj, |
204 | struct orangefs_attribute *attr, | 155 | struct orangefs_attribute *attr, |
205 | const char *buf, | 156 | const char *buf, |
206 | size_t count); | 157 | size_t count); |
207 | }; | 158 | }; |
208 | 159 | ||
209 | struct acache_orangefs_attribute { | ||
210 | struct attribute attr; | ||
211 | ssize_t (*show)(struct acache_orangefs_obj *acache_orangefs_obj, | ||
212 | struct acache_orangefs_attribute *attr, | ||
213 | char *buf); | ||
214 | ssize_t (*store)(struct acache_orangefs_obj *acache_orangefs_obj, | ||
215 | struct acache_orangefs_attribute *attr, | ||
216 | const char *buf, | ||
217 | size_t count); | ||
218 | }; | ||
219 | |||
220 | struct capcache_orangefs_attribute { | ||
221 | struct attribute attr; | ||
222 | ssize_t (*show)(struct capcache_orangefs_obj *capcache_orangefs_obj, | ||
223 | struct capcache_orangefs_attribute *attr, | ||
224 | char *buf); | ||
225 | ssize_t (*store)(struct capcache_orangefs_obj *capcache_orangefs_obj, | ||
226 | struct capcache_orangefs_attribute *attr, | ||
227 | const char *buf, | ||
228 | size_t count); | ||
229 | }; | ||
230 | |||
231 | struct ccache_orangefs_attribute { | ||
232 | struct attribute attr; | ||
233 | ssize_t (*show)(struct ccache_orangefs_obj *ccache_orangefs_obj, | ||
234 | struct ccache_orangefs_attribute *attr, | ||
235 | char *buf); | ||
236 | ssize_t (*store)(struct ccache_orangefs_obj *ccache_orangefs_obj, | ||
237 | struct ccache_orangefs_attribute *attr, | ||
238 | const char *buf, | ||
239 | size_t count); | ||
240 | }; | ||
241 | |||
242 | struct ncache_orangefs_attribute { | ||
243 | struct attribute attr; | ||
244 | ssize_t (*show)(struct ncache_orangefs_obj *ncache_orangefs_obj, | ||
245 | struct ncache_orangefs_attribute *attr, | ||
246 | char *buf); | ||
247 | ssize_t (*store)(struct ncache_orangefs_obj *ncache_orangefs_obj, | ||
248 | struct ncache_orangefs_attribute *attr, | ||
249 | const char *buf, | ||
250 | size_t count); | ||
251 | }; | ||
252 | |||
253 | struct pc_orangefs_attribute { | ||
254 | struct attribute attr; | ||
255 | ssize_t (*show)(struct pc_orangefs_obj *pc_orangefs_obj, | ||
256 | struct pc_orangefs_attribute *attr, | ||
257 | char *buf); | ||
258 | ssize_t (*store)(struct pc_orangefs_obj *pc_orangefs_obj, | ||
259 | struct pc_orangefs_attribute *attr, | ||
260 | const char *buf, | ||
261 | size_t count); | ||
262 | }; | ||
263 | |||
264 | struct stats_orangefs_attribute { | ||
265 | struct attribute attr; | ||
266 | ssize_t (*show)(struct stats_orangefs_obj *stats_orangefs_obj, | ||
267 | struct stats_orangefs_attribute *attr, | ||
268 | char *buf); | ||
269 | ssize_t (*store)(struct stats_orangefs_obj *stats_orangefs_obj, | ||
270 | struct stats_orangefs_attribute *attr, | ||
271 | const char *buf, | ||
272 | size_t count); | ||
273 | }; | ||
274 | |||
275 | static ssize_t orangefs_attr_show(struct kobject *kobj, | 160 | static ssize_t orangefs_attr_show(struct kobject *kobj, |
276 | struct attribute *attr, | 161 | struct attribute *attr, |
277 | char *buf) | 162 | char *buf) |
278 | { | 163 | { |
279 | struct orangefs_attribute *attribute; | 164 | struct orangefs_attribute *attribute; |
280 | struct orangefs_obj *orangefs_obj; | ||
281 | int rc; | ||
282 | 165 | ||
283 | attribute = container_of(attr, struct orangefs_attribute, attr); | 166 | attribute = container_of(attr, struct orangefs_attribute, attr); |
284 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | 167 | if (!attribute->show) |
285 | 168 | return -EIO; | |
286 | if (!attribute->show) { | 169 | return attribute->show(kobj, attribute, buf); |
287 | rc = -EIO; | ||
288 | goto out; | ||
289 | } | ||
290 | |||
291 | rc = attribute->show(orangefs_obj, attribute, buf); | ||
292 | |||
293 | out: | ||
294 | return rc; | ||
295 | } | 170 | } |
296 | 171 | ||
297 | static ssize_t orangefs_attr_store(struct kobject *kobj, | 172 | static ssize_t orangefs_attr_store(struct kobject *kobj, |
@@ -300,24 +175,15 @@ static ssize_t orangefs_attr_store(struct kobject *kobj, | |||
300 | size_t len) | 175 | size_t len) |
301 | { | 176 | { |
302 | struct orangefs_attribute *attribute; | 177 | struct orangefs_attribute *attribute; |
303 | struct orangefs_obj *orangefs_obj; | ||
304 | int rc; | ||
305 | 178 | ||
306 | gossip_debug(GOSSIP_SYSFS_DEBUG, | 179 | if (!strcmp(kobj->name, PC_KOBJ_ID) || |
307 | "orangefs_attr_store: start\n"); | 180 | !strcmp(kobj->name, STATS_KOBJ_ID)) |
181 | return -EPERM; | ||
308 | 182 | ||
309 | attribute = container_of(attr, struct orangefs_attribute, attr); | 183 | attribute = container_of(attr, struct orangefs_attribute, attr); |
310 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | 184 | if (!attribute->store) |
311 | 185 | return -EIO; | |
312 | if (!attribute->store) { | 186 | return attribute->store(kobj, attribute, buf, len); |
313 | rc = -EIO; | ||
314 | goto out; | ||
315 | } | ||
316 | |||
317 | rc = attribute->store(orangefs_obj, attribute, buf, len); | ||
318 | |||
319 | out: | ||
320 | return rc; | ||
321 | } | 187 | } |
322 | 188 | ||
323 | static const struct sysfs_ops orangefs_sysfs_ops = { | 189 | static const struct sysfs_ops orangefs_sysfs_ops = { |
@@ -325,402 +191,58 @@ static const struct sysfs_ops orangefs_sysfs_ops = { | |||
325 | .store = orangefs_attr_store, | 191 | .store = orangefs_attr_store, |
326 | }; | 192 | }; |
327 | 193 | ||
328 | static ssize_t acache_orangefs_attr_show(struct kobject *kobj, | 194 | static ssize_t sysfs_int_show(struct kobject *kobj, |
329 | struct attribute *attr, | 195 | struct orangefs_attribute *attr, char *buf) |
330 | char *buf) | ||
331 | { | ||
332 | struct acache_orangefs_attribute *attribute; | ||
333 | struct acache_orangefs_obj *acache_orangefs_obj; | ||
334 | int rc; | ||
335 | |||
336 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); | ||
337 | acache_orangefs_obj = | ||
338 | container_of(kobj, struct acache_orangefs_obj, kobj); | ||
339 | |||
340 | if (!attribute->show) { | ||
341 | rc = -EIO; | ||
342 | goto out; | ||
343 | } | ||
344 | |||
345 | rc = attribute->show(acache_orangefs_obj, attribute, buf); | ||
346 | |||
347 | out: | ||
348 | return rc; | ||
349 | } | ||
350 | |||
351 | static ssize_t acache_orangefs_attr_store(struct kobject *kobj, | ||
352 | struct attribute *attr, | ||
353 | const char *buf, | ||
354 | size_t len) | ||
355 | { | ||
356 | struct acache_orangefs_attribute *attribute; | ||
357 | struct acache_orangefs_obj *acache_orangefs_obj; | ||
358 | int rc; | ||
359 | |||
360 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
361 | "acache_orangefs_attr_store: start\n"); | ||
362 | |||
363 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); | ||
364 | acache_orangefs_obj = | ||
365 | container_of(kobj, struct acache_orangefs_obj, kobj); | ||
366 | |||
367 | if (!attribute->store) { | ||
368 | rc = -EIO; | ||
369 | goto out; | ||
370 | } | ||
371 | |||
372 | rc = attribute->store(acache_orangefs_obj, attribute, buf, len); | ||
373 | |||
374 | out: | ||
375 | return rc; | ||
376 | } | ||
377 | |||
378 | static const struct sysfs_ops acache_orangefs_sysfs_ops = { | ||
379 | .show = acache_orangefs_attr_show, | ||
380 | .store = acache_orangefs_attr_store, | ||
381 | }; | ||
382 | |||
383 | static ssize_t capcache_orangefs_attr_show(struct kobject *kobj, | ||
384 | struct attribute *attr, | ||
385 | char *buf) | ||
386 | { | ||
387 | struct capcache_orangefs_attribute *attribute; | ||
388 | struct capcache_orangefs_obj *capcache_orangefs_obj; | ||
389 | int rc; | ||
390 | |||
391 | attribute = | ||
392 | container_of(attr, struct capcache_orangefs_attribute, attr); | ||
393 | capcache_orangefs_obj = | ||
394 | container_of(kobj, struct capcache_orangefs_obj, kobj); | ||
395 | |||
396 | if (!attribute->show) { | ||
397 | rc = -EIO; | ||
398 | goto out; | ||
399 | } | ||
400 | |||
401 | rc = attribute->show(capcache_orangefs_obj, attribute, buf); | ||
402 | |||
403 | out: | ||
404 | return rc; | ||
405 | } | ||
406 | |||
407 | static ssize_t capcache_orangefs_attr_store(struct kobject *kobj, | ||
408 | struct attribute *attr, | ||
409 | const char *buf, | ||
410 | size_t len) | ||
411 | { | ||
412 | struct capcache_orangefs_attribute *attribute; | ||
413 | struct capcache_orangefs_obj *capcache_orangefs_obj; | ||
414 | int rc; | ||
415 | |||
416 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
417 | "capcache_orangefs_attr_store: start\n"); | ||
418 | |||
419 | attribute = | ||
420 | container_of(attr, struct capcache_orangefs_attribute, attr); | ||
421 | capcache_orangefs_obj = | ||
422 | container_of(kobj, struct capcache_orangefs_obj, kobj); | ||
423 | |||
424 | if (!attribute->store) { | ||
425 | rc = -EIO; | ||
426 | goto out; | ||
427 | } | ||
428 | |||
429 | rc = attribute->store(capcache_orangefs_obj, attribute, buf, len); | ||
430 | |||
431 | out: | ||
432 | return rc; | ||
433 | } | ||
434 | |||
435 | static const struct sysfs_ops capcache_orangefs_sysfs_ops = { | ||
436 | .show = capcache_orangefs_attr_show, | ||
437 | .store = capcache_orangefs_attr_store, | ||
438 | }; | ||
439 | |||
440 | static ssize_t ccache_orangefs_attr_show(struct kobject *kobj, | ||
441 | struct attribute *attr, | ||
442 | char *buf) | ||
443 | { | ||
444 | struct ccache_orangefs_attribute *attribute; | ||
445 | struct ccache_orangefs_obj *ccache_orangefs_obj; | ||
446 | int rc; | ||
447 | |||
448 | attribute = | ||
449 | container_of(attr, struct ccache_orangefs_attribute, attr); | ||
450 | ccache_orangefs_obj = | ||
451 | container_of(kobj, struct ccache_orangefs_obj, kobj); | ||
452 | |||
453 | if (!attribute->show) { | ||
454 | rc = -EIO; | ||
455 | goto out; | ||
456 | } | ||
457 | |||
458 | rc = attribute->show(ccache_orangefs_obj, attribute, buf); | ||
459 | |||
460 | out: | ||
461 | return rc; | ||
462 | } | ||
463 | |||
464 | static ssize_t ccache_orangefs_attr_store(struct kobject *kobj, | ||
465 | struct attribute *attr, | ||
466 | const char *buf, | ||
467 | size_t len) | ||
468 | { | ||
469 | struct ccache_orangefs_attribute *attribute; | ||
470 | struct ccache_orangefs_obj *ccache_orangefs_obj; | ||
471 | int rc; | ||
472 | |||
473 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
474 | "ccache_orangefs_attr_store: start\n"); | ||
475 | |||
476 | attribute = | ||
477 | container_of(attr, struct ccache_orangefs_attribute, attr); | ||
478 | ccache_orangefs_obj = | ||
479 | container_of(kobj, struct ccache_orangefs_obj, kobj); | ||
480 | |||
481 | if (!attribute->store) { | ||
482 | rc = -EIO; | ||
483 | goto out; | ||
484 | } | ||
485 | |||
486 | rc = attribute->store(ccache_orangefs_obj, attribute, buf, len); | ||
487 | |||
488 | out: | ||
489 | return rc; | ||
490 | } | ||
491 | |||
492 | static const struct sysfs_ops ccache_orangefs_sysfs_ops = { | ||
493 | .show = ccache_orangefs_attr_show, | ||
494 | .store = ccache_orangefs_attr_store, | ||
495 | }; | ||
496 | |||
497 | static ssize_t ncache_orangefs_attr_show(struct kobject *kobj, | ||
498 | struct attribute *attr, | ||
499 | char *buf) | ||
500 | { | ||
501 | struct ncache_orangefs_attribute *attribute; | ||
502 | struct ncache_orangefs_obj *ncache_orangefs_obj; | ||
503 | int rc; | ||
504 | |||
505 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); | ||
506 | ncache_orangefs_obj = | ||
507 | container_of(kobj, struct ncache_orangefs_obj, kobj); | ||
508 | |||
509 | if (!attribute->show) { | ||
510 | rc = -EIO; | ||
511 | goto out; | ||
512 | } | ||
513 | |||
514 | rc = attribute->show(ncache_orangefs_obj, attribute, buf); | ||
515 | |||
516 | out: | ||
517 | return rc; | ||
518 | } | ||
519 | |||
520 | static ssize_t ncache_orangefs_attr_store(struct kobject *kobj, | ||
521 | struct attribute *attr, | ||
522 | const char *buf, | ||
523 | size_t len) | ||
524 | { | ||
525 | struct ncache_orangefs_attribute *attribute; | ||
526 | struct ncache_orangefs_obj *ncache_orangefs_obj; | ||
527 | int rc; | ||
528 | |||
529 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
530 | "ncache_orangefs_attr_store: start\n"); | ||
531 | |||
532 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); | ||
533 | ncache_orangefs_obj = | ||
534 | container_of(kobj, struct ncache_orangefs_obj, kobj); | ||
535 | |||
536 | if (!attribute->store) { | ||
537 | rc = -EIO; | ||
538 | goto out; | ||
539 | } | ||
540 | |||
541 | rc = attribute->store(ncache_orangefs_obj, attribute, buf, len); | ||
542 | |||
543 | out: | ||
544 | return rc; | ||
545 | } | ||
546 | |||
547 | static const struct sysfs_ops ncache_orangefs_sysfs_ops = { | ||
548 | .show = ncache_orangefs_attr_show, | ||
549 | .store = ncache_orangefs_attr_store, | ||
550 | }; | ||
551 | |||
552 | static ssize_t pc_orangefs_attr_show(struct kobject *kobj, | ||
553 | struct attribute *attr, | ||
554 | char *buf) | ||
555 | { | ||
556 | struct pc_orangefs_attribute *attribute; | ||
557 | struct pc_orangefs_obj *pc_orangefs_obj; | ||
558 | int rc; | ||
559 | |||
560 | attribute = container_of(attr, struct pc_orangefs_attribute, attr); | ||
561 | pc_orangefs_obj = | ||
562 | container_of(kobj, struct pc_orangefs_obj, kobj); | ||
563 | |||
564 | if (!attribute->show) { | ||
565 | rc = -EIO; | ||
566 | goto out; | ||
567 | } | ||
568 | |||
569 | rc = attribute->show(pc_orangefs_obj, attribute, buf); | ||
570 | |||
571 | out: | ||
572 | return rc; | ||
573 | } | ||
574 | |||
575 | static const struct sysfs_ops pc_orangefs_sysfs_ops = { | ||
576 | .show = pc_orangefs_attr_show, | ||
577 | }; | ||
578 | |||
579 | static ssize_t stats_orangefs_attr_show(struct kobject *kobj, | ||
580 | struct attribute *attr, | ||
581 | char *buf) | ||
582 | { | ||
583 | struct stats_orangefs_attribute *attribute; | ||
584 | struct stats_orangefs_obj *stats_orangefs_obj; | ||
585 | int rc; | ||
586 | |||
587 | attribute = container_of(attr, struct stats_orangefs_attribute, attr); | ||
588 | stats_orangefs_obj = | ||
589 | container_of(kobj, struct stats_orangefs_obj, kobj); | ||
590 | |||
591 | if (!attribute->show) { | ||
592 | rc = -EIO; | ||
593 | goto out; | ||
594 | } | ||
595 | |||
596 | rc = attribute->show(stats_orangefs_obj, attribute, buf); | ||
597 | |||
598 | out: | ||
599 | return rc; | ||
600 | } | ||
601 | |||
602 | static const struct sysfs_ops stats_orangefs_sysfs_ops = { | ||
603 | .show = stats_orangefs_attr_show, | ||
604 | }; | ||
605 | |||
606 | static void orangefs_release(struct kobject *kobj) | ||
607 | { | ||
608 | struct orangefs_obj *orangefs_obj; | ||
609 | |||
610 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | ||
611 | kfree(orangefs_obj); | ||
612 | } | ||
613 | |||
614 | static void acache_orangefs_release(struct kobject *kobj) | ||
615 | { | ||
616 | struct acache_orangefs_obj *acache_orangefs_obj; | ||
617 | |||
618 | acache_orangefs_obj = | ||
619 | container_of(kobj, struct acache_orangefs_obj, kobj); | ||
620 | kfree(acache_orangefs_obj); | ||
621 | } | ||
622 | |||
623 | static void capcache_orangefs_release(struct kobject *kobj) | ||
624 | { | ||
625 | struct capcache_orangefs_obj *capcache_orangefs_obj; | ||
626 | |||
627 | capcache_orangefs_obj = | ||
628 | container_of(kobj, struct capcache_orangefs_obj, kobj); | ||
629 | kfree(capcache_orangefs_obj); | ||
630 | } | ||
631 | |||
632 | static void ccache_orangefs_release(struct kobject *kobj) | ||
633 | { | ||
634 | struct ccache_orangefs_obj *ccache_orangefs_obj; | ||
635 | |||
636 | ccache_orangefs_obj = | ||
637 | container_of(kobj, struct ccache_orangefs_obj, kobj); | ||
638 | kfree(ccache_orangefs_obj); | ||
639 | } | ||
640 | |||
641 | static void ncache_orangefs_release(struct kobject *kobj) | ||
642 | { | ||
643 | struct ncache_orangefs_obj *ncache_orangefs_obj; | ||
644 | |||
645 | ncache_orangefs_obj = | ||
646 | container_of(kobj, struct ncache_orangefs_obj, kobj); | ||
647 | kfree(ncache_orangefs_obj); | ||
648 | } | ||
649 | |||
650 | static void pc_orangefs_release(struct kobject *kobj) | ||
651 | { | ||
652 | struct pc_orangefs_obj *pc_orangefs_obj; | ||
653 | |||
654 | pc_orangefs_obj = | ||
655 | container_of(kobj, struct pc_orangefs_obj, kobj); | ||
656 | kfree(pc_orangefs_obj); | ||
657 | } | ||
658 | |||
659 | static void stats_orangefs_release(struct kobject *kobj) | ||
660 | { | ||
661 | struct stats_orangefs_obj *stats_orangefs_obj; | ||
662 | |||
663 | stats_orangefs_obj = | ||
664 | container_of(kobj, struct stats_orangefs_obj, kobj); | ||
665 | kfree(stats_orangefs_obj); | ||
666 | } | ||
667 | |||
668 | static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr) | ||
669 | { | 196 | { |
670 | int rc = -EIO; | 197 | int rc = -EIO; |
671 | struct orangefs_attribute *orangefs_attr; | ||
672 | struct stats_orangefs_attribute *stats_orangefs_attr; | ||
673 | 198 | ||
674 | gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id); | 199 | gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", |
200 | kobj->name); | ||
675 | 201 | ||
676 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | 202 | if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { |
677 | orangefs_attr = (struct orangefs_attribute *)attr; | 203 | if (!strcmp(attr->attr.name, "op_timeout_secs")) { |
678 | |||
679 | if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) { | ||
680 | rc = scnprintf(buf, | 204 | rc = scnprintf(buf, |
681 | PAGE_SIZE, | 205 | PAGE_SIZE, |
682 | "%d\n", | 206 | "%d\n", |
683 | op_timeout_secs); | 207 | op_timeout_secs); |
684 | goto out; | 208 | goto out; |
685 | } else if (!strcmp(orangefs_attr->attr.name, | 209 | } else if (!strcmp(attr->attr.name, |
686 | "slot_timeout_secs")) { | 210 | "slot_timeout_secs")) { |
687 | rc = scnprintf(buf, | 211 | rc = scnprintf(buf, |
688 | PAGE_SIZE, | 212 | PAGE_SIZE, |
689 | "%d\n", | 213 | "%d\n", |
690 | slot_timeout_secs); | 214 | slot_timeout_secs); |
691 | goto out; | 215 | goto out; |
692 | } else if (!strcmp(orangefs_attr->attr.name, | 216 | } else if (!strcmp(attr->attr.name, |
693 | "dcache_timeout_msecs")) { | 217 | "dcache_timeout_msecs")) { |
694 | rc = scnprintf(buf, | 218 | rc = scnprintf(buf, |
695 | PAGE_SIZE, | 219 | PAGE_SIZE, |
696 | "%d\n", | 220 | "%d\n", |
697 | dcache_timeout_msecs); | 221 | orangefs_dcache_timeout_msecs); |
698 | goto out; | 222 | goto out; |
699 | } else if (!strcmp(orangefs_attr->attr.name, | 223 | } else if (!strcmp(attr->attr.name, |
700 | "getattr_timeout_msecs")) { | 224 | "getattr_timeout_msecs")) { |
701 | rc = scnprintf(buf, | 225 | rc = scnprintf(buf, |
702 | PAGE_SIZE, | 226 | PAGE_SIZE, |
703 | "%d\n", | 227 | "%d\n", |
704 | getattr_timeout_msecs); | 228 | orangefs_getattr_timeout_msecs); |
705 | goto out; | 229 | goto out; |
706 | } else { | 230 | } else { |
707 | goto out; | 231 | goto out; |
708 | } | 232 | } |
709 | 233 | ||
710 | } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) { | 234 | } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) { |
711 | stats_orangefs_attr = (struct stats_orangefs_attribute *)attr; | 235 | if (!strcmp(attr->attr.name, "reads")) { |
712 | |||
713 | if (!strcmp(stats_orangefs_attr->attr.name, "reads")) { | ||
714 | rc = scnprintf(buf, | 236 | rc = scnprintf(buf, |
715 | PAGE_SIZE, | 237 | PAGE_SIZE, |
716 | "%lu\n", | 238 | "%lu\n", |
717 | g_orangefs_stats.reads); | 239 | orangefs_stats.reads); |
718 | goto out; | 240 | goto out; |
719 | } else if (!strcmp(stats_orangefs_attr->attr.name, "writes")) { | 241 | } else if (!strcmp(attr->attr.name, "writes")) { |
720 | rc = scnprintf(buf, | 242 | rc = scnprintf(buf, |
721 | PAGE_SIZE, | 243 | PAGE_SIZE, |
722 | "%lu\n", | 244 | "%lu\n", |
723 | g_orangefs_stats.writes); | 245 | orangefs_stats.writes); |
724 | goto out; | 246 | goto out; |
725 | } else { | 247 | } else { |
726 | goto out; | 248 | goto out; |
@@ -732,45 +254,13 @@ out: | |||
732 | return rc; | 254 | return rc; |
733 | } | 255 | } |
734 | 256 | ||
735 | static ssize_t int_orangefs_show(struct orangefs_obj *orangefs_obj, | 257 | static ssize_t sysfs_int_store(struct kobject *kobj, |
736 | struct orangefs_attribute *attr, | 258 | struct orangefs_attribute *attr, const char *buf, size_t count) |
737 | char *buf) | ||
738 | { | ||
739 | int rc; | ||
740 | |||
741 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
742 | "int_orangefs_show:start attr->attr.name:%s:\n", | ||
743 | attr->attr.name); | ||
744 | |||
745 | rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr); | ||
746 | |||
747 | return rc; | ||
748 | } | ||
749 | |||
750 | static ssize_t int_stats_show(struct stats_orangefs_obj *stats_orangefs_obj, | ||
751 | struct stats_orangefs_attribute *attr, | ||
752 | char *buf) | ||
753 | { | ||
754 | int rc; | ||
755 | |||
756 | gossip_debug(GOSSIP_SYSFS_DEBUG, | ||
757 | "int_stats_show:start attr->attr.name:%s:\n", | ||
758 | attr->attr.name); | ||
759 | |||
760 | rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr); | ||
761 | |||
762 | return rc; | ||
763 | } | ||
764 | |||
765 | static ssize_t int_store(struct orangefs_obj *orangefs_obj, | ||
766 | struct orangefs_attribute *attr, | ||
767 | const char *buf, | ||
768 | size_t count) | ||
769 | { | 259 | { |
770 | int rc = 0; | 260 | int rc = 0; |
771 | 261 | ||
772 | gossip_debug(GOSSIP_SYSFS_DEBUG, | 262 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
773 | "int_store: start attr->attr.name:%s: buf:%s:\n", | 263 | "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n", |
774 | attr->attr.name, buf); | 264 | attr->attr.name, buf); |
775 | 265 | ||
776 | if (!strcmp(attr->attr.name, "op_timeout_secs")) { | 266 | if (!strcmp(attr->attr.name, "op_timeout_secs")) { |
@@ -780,10 +270,10 @@ static ssize_t int_store(struct orangefs_obj *orangefs_obj, | |||
780 | rc = kstrtoint(buf, 0, &slot_timeout_secs); | 270 | rc = kstrtoint(buf, 0, &slot_timeout_secs); |
781 | goto out; | 271 | goto out; |
782 | } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) { | 272 | } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) { |
783 | rc = kstrtoint(buf, 0, &dcache_timeout_msecs); | 273 | rc = kstrtoint(buf, 0, &orangefs_dcache_timeout_msecs); |
784 | goto out; | 274 | goto out; |
785 | } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { | 275 | } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { |
786 | rc = kstrtoint(buf, 0, &getattr_timeout_msecs); | 276 | rc = kstrtoint(buf, 0, &orangefs_getattr_timeout_msecs); |
787 | goto out; | 277 | goto out; |
788 | } else { | 278 | } else { |
789 | goto out; | 279 | goto out; |
@@ -801,24 +291,19 @@ out: | |||
801 | /* | 291 | /* |
802 | * obtain attribute values from userspace with a service operation. | 292 | * obtain attribute values from userspace with a service operation. |
803 | */ | 293 | */ |
804 | static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr) | 294 | static ssize_t sysfs_service_op_show(struct kobject *kobj, |
295 | struct orangefs_attribute *attr, char *buf) | ||
805 | { | 296 | { |
806 | struct orangefs_kernel_op_s *new_op = NULL; | 297 | struct orangefs_kernel_op_s *new_op = NULL; |
807 | int rc = 0; | 298 | int rc = 0; |
808 | char *ser_op_type = NULL; | 299 | char *ser_op_type = NULL; |
809 | struct orangefs_attribute *orangefs_attr; | ||
810 | struct acache_orangefs_attribute *acache_attr; | ||
811 | struct capcache_orangefs_attribute *capcache_attr; | ||
812 | struct ccache_orangefs_attribute *ccache_attr; | ||
813 | struct ncache_orangefs_attribute *ncache_attr; | ||
814 | struct pc_orangefs_attribute *pc_attr; | ||
815 | __u32 op_alloc_type; | 300 | __u32 op_alloc_type; |
816 | 301 | ||
817 | gossip_debug(GOSSIP_SYSFS_DEBUG, | 302 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
818 | "sysfs_service_op_show: id:%s:\n", | 303 | "sysfs_service_op_show: id:%s:\n", |
819 | kobj_id); | 304 | kobj->name); |
820 | 305 | ||
821 | if (strcmp(kobj_id, PC_KOBJ_ID)) | 306 | if (strcmp(kobj->name, PC_KOBJ_ID)) |
822 | op_alloc_type = ORANGEFS_VFS_OP_PARAM; | 307 | op_alloc_type = ORANGEFS_VFS_OP_PARAM; |
823 | else | 308 | else |
824 | op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT; | 309 | op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT; |
@@ -836,148 +321,135 @@ static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr) | |||
836 | goto out; | 321 | goto out; |
837 | } | 322 | } |
838 | 323 | ||
839 | if (strcmp(kobj_id, PC_KOBJ_ID)) | 324 | if (strcmp(kobj->name, PC_KOBJ_ID)) |
840 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET; | 325 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET; |
841 | 326 | ||
842 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | 327 | if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { |
843 | orangefs_attr = (struct orangefs_attribute *)attr; | ||
844 | |||
845 | /* Drop unsupported requests first. */ | 328 | /* Drop unsupported requests first. */ |
846 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && | 329 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && |
847 | (!strcmp(orangefs_attr->attr.name, "readahead_count") || | 330 | (!strcmp(attr->attr.name, "readahead_count") || |
848 | !strcmp(orangefs_attr->attr.name, "readahead_size") || | 331 | !strcmp(attr->attr.name, "readahead_size") || |
849 | !strcmp(orangefs_attr->attr.name, | 332 | !strcmp(attr->attr.name, "readahead_count_size"))) { |
850 | "readahead_count_size"))) { | ||
851 | rc = -EINVAL; | 333 | rc = -EINVAL; |
852 | goto out; | 334 | goto out; |
853 | } | 335 | } |
854 | 336 | ||
855 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) | 337 | if (!strcmp(attr->attr.name, "perf_history_size")) |
856 | new_op->upcall.req.param.op = | 338 | new_op->upcall.req.param.op = |
857 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; | 339 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
858 | else if (!strcmp(orangefs_attr->attr.name, | 340 | else if (!strcmp(attr->attr.name, |
859 | "perf_time_interval_secs")) | 341 | "perf_time_interval_secs")) |
860 | new_op->upcall.req.param.op = | 342 | new_op->upcall.req.param.op = |
861 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; | 343 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
862 | else if (!strcmp(orangefs_attr->attr.name, | 344 | else if (!strcmp(attr->attr.name, |
863 | "perf_counter_reset")) | 345 | "perf_counter_reset")) |
864 | new_op->upcall.req.param.op = | 346 | new_op->upcall.req.param.op = |
865 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; | 347 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
866 | 348 | ||
867 | else if (!strcmp(orangefs_attr->attr.name, | 349 | else if (!strcmp(attr->attr.name, |
868 | "readahead_count")) | 350 | "readahead_count")) |
869 | new_op->upcall.req.param.op = | 351 | new_op->upcall.req.param.op = |
870 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; | 352 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; |
871 | 353 | ||
872 | else if (!strcmp(orangefs_attr->attr.name, | 354 | else if (!strcmp(attr->attr.name, |
873 | "readahead_size")) | 355 | "readahead_size")) |
874 | new_op->upcall.req.param.op = | 356 | new_op->upcall.req.param.op = |
875 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; | 357 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; |
876 | 358 | ||
877 | else if (!strcmp(orangefs_attr->attr.name, | 359 | else if (!strcmp(attr->attr.name, |
878 | "readahead_count_size")) | 360 | "readahead_count_size")) |
879 | new_op->upcall.req.param.op = | 361 | new_op->upcall.req.param.op = |
880 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; | 362 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
881 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { | 363 | } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) { |
882 | acache_attr = (struct acache_orangefs_attribute *)attr; | 364 | if (!strcmp(attr->attr.name, "timeout_msecs")) |
883 | |||
884 | if (!strcmp(acache_attr->attr.name, "timeout_msecs")) | ||
885 | new_op->upcall.req.param.op = | 365 | new_op->upcall.req.param.op = |
886 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; | 366 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
887 | 367 | ||
888 | if (!strcmp(acache_attr->attr.name, "hard_limit")) | 368 | if (!strcmp(attr->attr.name, "hard_limit")) |
889 | new_op->upcall.req.param.op = | 369 | new_op->upcall.req.param.op = |
890 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; | 370 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
891 | 371 | ||
892 | if (!strcmp(acache_attr->attr.name, "soft_limit")) | 372 | if (!strcmp(attr->attr.name, "soft_limit")) |
893 | new_op->upcall.req.param.op = | 373 | new_op->upcall.req.param.op = |
894 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; | 374 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
895 | 375 | ||
896 | if (!strcmp(acache_attr->attr.name, "reclaim_percentage")) | 376 | if (!strcmp(attr->attr.name, "reclaim_percentage")) |
897 | new_op->upcall.req.param.op = | 377 | new_op->upcall.req.param.op = |
898 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; | 378 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
899 | 379 | ||
900 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { | 380 | } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) { |
901 | capcache_attr = (struct capcache_orangefs_attribute *)attr; | 381 | if (!strcmp(attr->attr.name, "timeout_secs")) |
902 | |||
903 | if (!strcmp(capcache_attr->attr.name, "timeout_secs")) | ||
904 | new_op->upcall.req.param.op = | 382 | new_op->upcall.req.param.op = |
905 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; | 383 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
906 | 384 | ||
907 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) | 385 | if (!strcmp(attr->attr.name, "hard_limit")) |
908 | new_op->upcall.req.param.op = | 386 | new_op->upcall.req.param.op = |
909 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; | 387 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
910 | 388 | ||
911 | if (!strcmp(capcache_attr->attr.name, "soft_limit")) | 389 | if (!strcmp(attr->attr.name, "soft_limit")) |
912 | new_op->upcall.req.param.op = | 390 | new_op->upcall.req.param.op = |
913 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; | 391 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
914 | 392 | ||
915 | if (!strcmp(capcache_attr->attr.name, "reclaim_percentage")) | 393 | if (!strcmp(attr->attr.name, "reclaim_percentage")) |
916 | new_op->upcall.req.param.op = | 394 | new_op->upcall.req.param.op = |
917 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; | 395 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
918 | 396 | ||
919 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { | 397 | } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) { |
920 | ccache_attr = (struct ccache_orangefs_attribute *)attr; | 398 | if (!strcmp(attr->attr.name, "timeout_secs")) |
921 | |||
922 | if (!strcmp(ccache_attr->attr.name, "timeout_secs")) | ||
923 | new_op->upcall.req.param.op = | 399 | new_op->upcall.req.param.op = |
924 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; | 400 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
925 | 401 | ||
926 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) | 402 | if (!strcmp(attr->attr.name, "hard_limit")) |
927 | new_op->upcall.req.param.op = | 403 | new_op->upcall.req.param.op = |
928 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; | 404 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
929 | 405 | ||
930 | if (!strcmp(ccache_attr->attr.name, "soft_limit")) | 406 | if (!strcmp(attr->attr.name, "soft_limit")) |
931 | new_op->upcall.req.param.op = | 407 | new_op->upcall.req.param.op = |
932 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; | 408 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
933 | 409 | ||
934 | if (!strcmp(ccache_attr->attr.name, "reclaim_percentage")) | 410 | if (!strcmp(attr->attr.name, "reclaim_percentage")) |
935 | new_op->upcall.req.param.op = | 411 | new_op->upcall.req.param.op = |
936 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; | 412 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
937 | 413 | ||
938 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { | 414 | } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) { |
939 | ncache_attr = (struct ncache_orangefs_attribute *)attr; | 415 | if (!strcmp(attr->attr.name, "timeout_msecs")) |
940 | |||
941 | if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) | ||
942 | new_op->upcall.req.param.op = | 416 | new_op->upcall.req.param.op = |
943 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; | 417 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
944 | 418 | ||
945 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) | 419 | if (!strcmp(attr->attr.name, "hard_limit")) |
946 | new_op->upcall.req.param.op = | 420 | new_op->upcall.req.param.op = |
947 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; | 421 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
948 | 422 | ||
949 | if (!strcmp(ncache_attr->attr.name, "soft_limit")) | 423 | if (!strcmp(attr->attr.name, "soft_limit")) |
950 | new_op->upcall.req.param.op = | 424 | new_op->upcall.req.param.op = |
951 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; | 425 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
952 | 426 | ||
953 | if (!strcmp(ncache_attr->attr.name, "reclaim_percentage")) | 427 | if (!strcmp(attr->attr.name, "reclaim_percentage")) |
954 | new_op->upcall.req.param.op = | 428 | new_op->upcall.req.param.op = |
955 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; | 429 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
956 | 430 | ||
957 | } else if (!strcmp(kobj_id, PC_KOBJ_ID)) { | 431 | } else if (!strcmp(kobj->name, PC_KOBJ_ID)) { |
958 | pc_attr = (struct pc_orangefs_attribute *)attr; | 432 | if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID)) |
959 | |||
960 | if (!strcmp(pc_attr->attr.name, ACACHE_KOBJ_ID)) | ||
961 | new_op->upcall.req.perf_count.type = | 433 | new_op->upcall.req.perf_count.type = |
962 | ORANGEFS_PERF_COUNT_REQUEST_ACACHE; | 434 | ORANGEFS_PERF_COUNT_REQUEST_ACACHE; |
963 | 435 | ||
964 | if (!strcmp(pc_attr->attr.name, CAPCACHE_KOBJ_ID)) | 436 | if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID)) |
965 | new_op->upcall.req.perf_count.type = | 437 | new_op->upcall.req.perf_count.type = |
966 | ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE; | 438 | ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE; |
967 | 439 | ||
968 | if (!strcmp(pc_attr->attr.name, NCACHE_KOBJ_ID)) | 440 | if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID)) |
969 | new_op->upcall.req.perf_count.type = | 441 | new_op->upcall.req.perf_count.type = |
970 | ORANGEFS_PERF_COUNT_REQUEST_NCACHE; | 442 | ORANGEFS_PERF_COUNT_REQUEST_NCACHE; |
971 | 443 | ||
972 | } else { | 444 | } else { |
973 | gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n", | 445 | gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n", |
974 | kobj_id); | 446 | kobj->name); |
975 | rc = -EINVAL; | 447 | rc = -EINVAL; |
976 | goto out; | 448 | goto out; |
977 | } | 449 | } |
978 | 450 | ||
979 | 451 | ||
980 | if (strcmp(kobj_id, PC_KOBJ_ID)) | 452 | if (strcmp(kobj->name, PC_KOBJ_ID)) |
981 | ser_op_type = "orangefs_param"; | 453 | ser_op_type = "orangefs_param"; |
982 | else | 454 | else |
983 | ser_op_type = "orangefs_perf_count"; | 455 | ser_op_type = "orangefs_perf_count"; |
@@ -990,7 +462,7 @@ static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr) | |||
990 | 462 | ||
991 | out: | 463 | out: |
992 | if (!rc) { | 464 | if (!rc) { |
993 | if (strcmp(kobj_id, PC_KOBJ_ID)) { | 465 | if (strcmp(kobj->name, PC_KOBJ_ID)) { |
994 | if (new_op->upcall.req.param.op == | 466 | if (new_op->upcall.req.param.op == |
995 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { | 467 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { |
996 | rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", | 468 | rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", |
@@ -1017,77 +489,6 @@ out: | |||
1017 | 489 | ||
1018 | } | 490 | } |
1019 | 491 | ||
1020 | static ssize_t service_orangefs_show(struct orangefs_obj *orangefs_obj, | ||
1021 | struct orangefs_attribute *attr, | ||
1022 | char *buf) | ||
1023 | { | ||
1024 | int rc = 0; | ||
1025 | |||
1026 | rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr); | ||
1027 | |||
1028 | return rc; | ||
1029 | } | ||
1030 | |||
1031 | static ssize_t | ||
1032 | service_acache_show(struct acache_orangefs_obj *acache_orangefs_obj, | ||
1033 | struct acache_orangefs_attribute *attr, | ||
1034 | char *buf) | ||
1035 | { | ||
1036 | int rc = 0; | ||
1037 | |||
1038 | rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr); | ||
1039 | |||
1040 | return rc; | ||
1041 | } | ||
1042 | |||
1043 | static ssize_t service_capcache_show(struct capcache_orangefs_obj | ||
1044 | *capcache_orangefs_obj, | ||
1045 | struct capcache_orangefs_attribute *attr, | ||
1046 | char *buf) | ||
1047 | { | ||
1048 | int rc = 0; | ||
1049 | |||
1050 | rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr); | ||
1051 | |||
1052 | return rc; | ||
1053 | } | ||
1054 | |||
1055 | static ssize_t service_ccache_show(struct ccache_orangefs_obj | ||
1056 | *ccache_orangefs_obj, | ||
1057 | struct ccache_orangefs_attribute *attr, | ||
1058 | char *buf) | ||
1059 | { | ||
1060 | int rc = 0; | ||
1061 | |||
1062 | rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr); | ||
1063 | |||
1064 | return rc; | ||
1065 | } | ||
1066 | |||
1067 | static ssize_t | ||
1068 | service_ncache_show(struct ncache_orangefs_obj *ncache_orangefs_obj, | ||
1069 | struct ncache_orangefs_attribute *attr, | ||
1070 | char *buf) | ||
1071 | { | ||
1072 | int rc = 0; | ||
1073 | |||
1074 | rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr); | ||
1075 | |||
1076 | return rc; | ||
1077 | } | ||
1078 | |||
1079 | static ssize_t | ||
1080 | service_pc_show(struct pc_orangefs_obj *pc_orangefs_obj, | ||
1081 | struct pc_orangefs_attribute *attr, | ||
1082 | char *buf) | ||
1083 | { | ||
1084 | int rc = 0; | ||
1085 | |||
1086 | rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr); | ||
1087 | |||
1088 | return rc; | ||
1089 | } | ||
1090 | |||
1091 | /* | 492 | /* |
1092 | * pass attribute values back to userspace with a service operation. | 493 | * pass attribute values back to userspace with a service operation. |
1093 | * | 494 | * |
@@ -1099,20 +500,16 @@ static ssize_t | |||
1099 | * We want to return 1 if we think everything went OK, and | 500 | * We want to return 1 if we think everything went OK, and |
1100 | * EINVAL if not. | 501 | * EINVAL if not. |
1101 | */ | 502 | */ |
1102 | static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | 503 | static ssize_t sysfs_service_op_store(struct kobject *kobj, |
504 | struct orangefs_attribute *attr, const char *buf, size_t count) | ||
1103 | { | 505 | { |
1104 | struct orangefs_kernel_op_s *new_op = NULL; | 506 | struct orangefs_kernel_op_s *new_op = NULL; |
1105 | int val = 0; | 507 | int val = 0; |
1106 | int rc = 0; | 508 | int rc = 0; |
1107 | struct orangefs_attribute *orangefs_attr; | ||
1108 | struct acache_orangefs_attribute *acache_attr; | ||
1109 | struct capcache_orangefs_attribute *capcache_attr; | ||
1110 | struct ccache_orangefs_attribute *ccache_attr; | ||
1111 | struct ncache_orangefs_attribute *ncache_attr; | ||
1112 | 509 | ||
1113 | gossip_debug(GOSSIP_SYSFS_DEBUG, | 510 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
1114 | "sysfs_service_op_store: id:%s:\n", | 511 | "sysfs_service_op_store: id:%s:\n", |
1115 | kobj_id); | 512 | kobj->name); |
1116 | 513 | ||
1117 | new_op = op_alloc(ORANGEFS_VFS_OP_PARAM); | 514 | new_op = op_alloc(ORANGEFS_VFS_OP_PARAM); |
1118 | if (!new_op) | 515 | if (!new_op) |
@@ -1131,9 +528,8 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1131 | * The value we want to send back to userspace is in buf, unless this | 528 | * The value we want to send back to userspace is in buf, unless this |
1132 | * there are two parameters, which is specially handled below. | 529 | * there are two parameters, which is specially handled below. |
1133 | */ | 530 | */ |
1134 | if (strcmp(kobj_id, ORANGEFS_KOBJ_ID) || | 531 | if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) || |
1135 | strcmp(((struct orangefs_attribute *)attr)->attr.name, | 532 | strcmp(attr->attr.name, "readahead_count_size")) { |
1136 | "readahead_count_size")) { | ||
1137 | rc = kstrtoint(buf, 0, &val); | 533 | rc = kstrtoint(buf, 0, &val); |
1138 | if (rc) | 534 | if (rc) |
1139 | goto out; | 535 | goto out; |
@@ -1141,19 +537,17 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1141 | 537 | ||
1142 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET; | 538 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET; |
1143 | 539 | ||
1144 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | 540 | if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { |
1145 | orangefs_attr = (struct orangefs_attribute *)attr; | ||
1146 | /* Drop unsupported requests first. */ | 541 | /* Drop unsupported requests first. */ |
1147 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && | 542 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && |
1148 | (!strcmp(orangefs_attr->attr.name, "readahead_count") || | 543 | (!strcmp(attr->attr.name, "readahead_count") || |
1149 | !strcmp(orangefs_attr->attr.name, "readahead_size") || | 544 | !strcmp(attr->attr.name, "readahead_size") || |
1150 | !strcmp(orangefs_attr->attr.name, | 545 | !strcmp(attr->attr.name, "readahead_count_size"))) { |
1151 | "readahead_count_size"))) { | ||
1152 | rc = -EINVAL; | 546 | rc = -EINVAL; |
1153 | goto out; | 547 | goto out; |
1154 | } | 548 | } |
1155 | 549 | ||
1156 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) { | 550 | if (!strcmp(attr->attr.name, "perf_history_size")) { |
1157 | if (val > 0) { | 551 | if (val > 0) { |
1158 | new_op->upcall.req.param.op = | 552 | new_op->upcall.req.param.op = |
1159 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; | 553 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
@@ -1161,7 +555,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1161 | rc = 0; | 555 | rc = 0; |
1162 | goto out; | 556 | goto out; |
1163 | } | 557 | } |
1164 | } else if (!strcmp(orangefs_attr->attr.name, | 558 | } else if (!strcmp(attr->attr.name, |
1165 | "perf_time_interval_secs")) { | 559 | "perf_time_interval_secs")) { |
1166 | if (val > 0) { | 560 | if (val > 0) { |
1167 | new_op->upcall.req.param.op = | 561 | new_op->upcall.req.param.op = |
@@ -1170,7 +564,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1170 | rc = 0; | 564 | rc = 0; |
1171 | goto out; | 565 | goto out; |
1172 | } | 566 | } |
1173 | } else if (!strcmp(orangefs_attr->attr.name, | 567 | } else if (!strcmp(attr->attr.name, |
1174 | "perf_counter_reset")) { | 568 | "perf_counter_reset")) { |
1175 | if ((val == 0) || (val == 1)) { | 569 | if ((val == 0) || (val == 1)) { |
1176 | new_op->upcall.req.param.op = | 570 | new_op->upcall.req.param.op = |
@@ -1179,7 +573,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1179 | rc = 0; | 573 | rc = 0; |
1180 | goto out; | 574 | goto out; |
1181 | } | 575 | } |
1182 | } else if (!strcmp(orangefs_attr->attr.name, | 576 | } else if (!strcmp(attr->attr.name, |
1183 | "readahead_count")) { | 577 | "readahead_count")) { |
1184 | if ((val >= 0)) { | 578 | if ((val >= 0)) { |
1185 | new_op->upcall.req.param.op = | 579 | new_op->upcall.req.param.op = |
@@ -1188,7 +582,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1188 | rc = 0; | 582 | rc = 0; |
1189 | goto out; | 583 | goto out; |
1190 | } | 584 | } |
1191 | } else if (!strcmp(orangefs_attr->attr.name, | 585 | } else if (!strcmp(attr->attr.name, |
1192 | "readahead_size")) { | 586 | "readahead_size")) { |
1193 | if ((val >= 0)) { | 587 | if ((val >= 0)) { |
1194 | new_op->upcall.req.param.op = | 588 | new_op->upcall.req.param.op = |
@@ -1197,7 +591,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1197 | rc = 0; | 591 | rc = 0; |
1198 | goto out; | 592 | goto out; |
1199 | } | 593 | } |
1200 | } else if (!strcmp(orangefs_attr->attr.name, | 594 | } else if (!strcmp(attr->attr.name, |
1201 | "readahead_count_size")) { | 595 | "readahead_count_size")) { |
1202 | int val1, val2; | 596 | int val1, val2; |
1203 | rc = sscanf(buf, "%d %d", &val1, &val2); | 597 | rc = sscanf(buf, "%d %d", &val1, &val2); |
@@ -1215,7 +609,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1215 | new_op->upcall.req.param.u.value32[0] = val1; | 609 | new_op->upcall.req.param.u.value32[0] = val1; |
1216 | new_op->upcall.req.param.u.value32[1] = val2; | 610 | new_op->upcall.req.param.u.value32[1] = val2; |
1217 | goto value_set; | 611 | goto value_set; |
1218 | } else if (!strcmp(orangefs_attr->attr.name, | 612 | } else if (!strcmp(attr->attr.name, |
1219 | "perf_counter_reset")) { | 613 | "perf_counter_reset")) { |
1220 | if ((val > 0)) { | 614 | if ((val > 0)) { |
1221 | new_op->upcall.req.param.op = | 615 | new_op->upcall.req.param.op = |
@@ -1226,10 +620,8 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1226 | } | 620 | } |
1227 | } | 621 | } |
1228 | 622 | ||
1229 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { | 623 | } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) { |
1230 | acache_attr = (struct acache_orangefs_attribute *)attr; | 624 | if (!strcmp(attr->attr.name, "hard_limit")) { |
1231 | |||
1232 | if (!strcmp(acache_attr->attr.name, "hard_limit")) { | ||
1233 | if (val > -1) { | 625 | if (val > -1) { |
1234 | new_op->upcall.req.param.op = | 626 | new_op->upcall.req.param.op = |
1235 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; | 627 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
@@ -1237,7 +629,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1237 | rc = 0; | 629 | rc = 0; |
1238 | goto out; | 630 | goto out; |
1239 | } | 631 | } |
1240 | } else if (!strcmp(acache_attr->attr.name, "soft_limit")) { | 632 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
1241 | if (val > -1) { | 633 | if (val > -1) { |
1242 | new_op->upcall.req.param.op = | 634 | new_op->upcall.req.param.op = |
1243 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; | 635 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
@@ -1245,7 +637,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1245 | rc = 0; | 637 | rc = 0; |
1246 | goto out; | 638 | goto out; |
1247 | } | 639 | } |
1248 | } else if (!strcmp(acache_attr->attr.name, | 640 | } else if (!strcmp(attr->attr.name, |
1249 | "reclaim_percentage")) { | 641 | "reclaim_percentage")) { |
1250 | if ((val > -1) && (val < 101)) { | 642 | if ((val > -1) && (val < 101)) { |
1251 | new_op->upcall.req.param.op = | 643 | new_op->upcall.req.param.op = |
@@ -1254,7 +646,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1254 | rc = 0; | 646 | rc = 0; |
1255 | goto out; | 647 | goto out; |
1256 | } | 648 | } |
1257 | } else if (!strcmp(acache_attr->attr.name, "timeout_msecs")) { | 649 | } else if (!strcmp(attr->attr.name, "timeout_msecs")) { |
1258 | if (val > -1) { | 650 | if (val > -1) { |
1259 | new_op->upcall.req.param.op = | 651 | new_op->upcall.req.param.op = |
1260 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; | 652 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
@@ -1264,10 +656,8 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1264 | } | 656 | } |
1265 | } | 657 | } |
1266 | 658 | ||
1267 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { | 659 | } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) { |
1268 | capcache_attr = (struct capcache_orangefs_attribute *)attr; | 660 | if (!strcmp(attr->attr.name, "hard_limit")) { |
1269 | |||
1270 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) { | ||
1271 | if (val > -1) { | 661 | if (val > -1) { |
1272 | new_op->upcall.req.param.op = | 662 | new_op->upcall.req.param.op = |
1273 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; | 663 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
@@ -1275,7 +665,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1275 | rc = 0; | 665 | rc = 0; |
1276 | goto out; | 666 | goto out; |
1277 | } | 667 | } |
1278 | } else if (!strcmp(capcache_attr->attr.name, "soft_limit")) { | 668 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
1279 | if (val > -1) { | 669 | if (val > -1) { |
1280 | new_op->upcall.req.param.op = | 670 | new_op->upcall.req.param.op = |
1281 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; | 671 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
@@ -1283,7 +673,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1283 | rc = 0; | 673 | rc = 0; |
1284 | goto out; | 674 | goto out; |
1285 | } | 675 | } |
1286 | } else if (!strcmp(capcache_attr->attr.name, | 676 | } else if (!strcmp(attr->attr.name, |
1287 | "reclaim_percentage")) { | 677 | "reclaim_percentage")) { |
1288 | if ((val > -1) && (val < 101)) { | 678 | if ((val > -1) && (val < 101)) { |
1289 | new_op->upcall.req.param.op = | 679 | new_op->upcall.req.param.op = |
@@ -1292,7 +682,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1292 | rc = 0; | 682 | rc = 0; |
1293 | goto out; | 683 | goto out; |
1294 | } | 684 | } |
1295 | } else if (!strcmp(capcache_attr->attr.name, "timeout_secs")) { | 685 | } else if (!strcmp(attr->attr.name, "timeout_secs")) { |
1296 | if (val > -1) { | 686 | if (val > -1) { |
1297 | new_op->upcall.req.param.op = | 687 | new_op->upcall.req.param.op = |
1298 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; | 688 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
@@ -1302,10 +692,8 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1302 | } | 692 | } |
1303 | } | 693 | } |
1304 | 694 | ||
1305 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { | 695 | } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) { |
1306 | ccache_attr = (struct ccache_orangefs_attribute *)attr; | 696 | if (!strcmp(attr->attr.name, "hard_limit")) { |
1307 | |||
1308 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) { | ||
1309 | if (val > -1) { | 697 | if (val > -1) { |
1310 | new_op->upcall.req.param.op = | 698 | new_op->upcall.req.param.op = |
1311 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; | 699 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
@@ -1313,7 +701,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1313 | rc = 0; | 701 | rc = 0; |
1314 | goto out; | 702 | goto out; |
1315 | } | 703 | } |
1316 | } else if (!strcmp(ccache_attr->attr.name, "soft_limit")) { | 704 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
1317 | if (val > -1) { | 705 | if (val > -1) { |
1318 | new_op->upcall.req.param.op = | 706 | new_op->upcall.req.param.op = |
1319 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; | 707 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
@@ -1321,7 +709,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1321 | rc = 0; | 709 | rc = 0; |
1322 | goto out; | 710 | goto out; |
1323 | } | 711 | } |
1324 | } else if (!strcmp(ccache_attr->attr.name, | 712 | } else if (!strcmp(attr->attr.name, |
1325 | "reclaim_percentage")) { | 713 | "reclaim_percentage")) { |
1326 | if ((val > -1) && (val < 101)) { | 714 | if ((val > -1) && (val < 101)) { |
1327 | new_op->upcall.req.param.op = | 715 | new_op->upcall.req.param.op = |
@@ -1330,7 +718,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1330 | rc = 0; | 718 | rc = 0; |
1331 | goto out; | 719 | goto out; |
1332 | } | 720 | } |
1333 | } else if (!strcmp(ccache_attr->attr.name, "timeout_secs")) { | 721 | } else if (!strcmp(attr->attr.name, "timeout_secs")) { |
1334 | if (val > -1) { | 722 | if (val > -1) { |
1335 | new_op->upcall.req.param.op = | 723 | new_op->upcall.req.param.op = |
1336 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; | 724 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
@@ -1340,10 +728,8 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1340 | } | 728 | } |
1341 | } | 729 | } |
1342 | 730 | ||
1343 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { | 731 | } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) { |
1344 | ncache_attr = (struct ncache_orangefs_attribute *)attr; | 732 | if (!strcmp(attr->attr.name, "hard_limit")) { |
1345 | |||
1346 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) { | ||
1347 | if (val > -1) { | 733 | if (val > -1) { |
1348 | new_op->upcall.req.param.op = | 734 | new_op->upcall.req.param.op = |
1349 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; | 735 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
@@ -1351,7 +737,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1351 | rc = 0; | 737 | rc = 0; |
1352 | goto out; | 738 | goto out; |
1353 | } | 739 | } |
1354 | } else if (!strcmp(ncache_attr->attr.name, "soft_limit")) { | 740 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
1355 | if (val > -1) { | 741 | if (val > -1) { |
1356 | new_op->upcall.req.param.op = | 742 | new_op->upcall.req.param.op = |
1357 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; | 743 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
@@ -1359,7 +745,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1359 | rc = 0; | 745 | rc = 0; |
1360 | goto out; | 746 | goto out; |
1361 | } | 747 | } |
1362 | } else if (!strcmp(ncache_attr->attr.name, | 748 | } else if (!strcmp(attr->attr.name, |
1363 | "reclaim_percentage")) { | 749 | "reclaim_percentage")) { |
1364 | if ((val > -1) && (val < 101)) { | 750 | if ((val > -1) && (val < 101)) { |
1365 | new_op->upcall.req.param.op = | 751 | new_op->upcall.req.param.op = |
@@ -1368,7 +754,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1368 | rc = 0; | 754 | rc = 0; |
1369 | goto out; | 755 | goto out; |
1370 | } | 756 | } |
1371 | } else if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) { | 757 | } else if (!strcmp(attr->attr.name, "timeout_msecs")) { |
1372 | if (val > -1) { | 758 | if (val > -1) { |
1373 | new_op->upcall.req.param.op = | 759 | new_op->upcall.req.param.op = |
1374 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; | 760 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
@@ -1380,7 +766,7 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) | |||
1380 | 766 | ||
1381 | } else { | 767 | } else { |
1382 | gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n", | 768 | gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n", |
1383 | kobj_id); | 769 | kobj->name); |
1384 | rc = -EINVAL; | 770 | rc = -EINVAL; |
1385 | goto out; | 771 | goto out; |
1386 | } | 772 | } |
@@ -1399,7 +785,7 @@ value_set: | |||
1399 | rc); | 785 | rc); |
1400 | rc = 0; | 786 | rc = 0; |
1401 | } else { | 787 | } else { |
1402 | rc = 1; | 788 | rc = count; |
1403 | } | 789 | } |
1404 | 790 | ||
1405 | out: | 791 | out: |
@@ -1411,133 +797,47 @@ out: | |||
1411 | return rc; | 797 | return rc; |
1412 | } | 798 | } |
1413 | 799 | ||
1414 | static ssize_t | ||
1415 | service_orangefs_store(struct orangefs_obj *orangefs_obj, | ||
1416 | struct orangefs_attribute *attr, | ||
1417 | const char *buf, | ||
1418 | size_t count) | ||
1419 | { | ||
1420 | int rc = 0; | ||
1421 | |||
1422 | rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr); | ||
1423 | |||
1424 | /* rc should have an errno value if the service_op went bad. */ | ||
1425 | if (rc == 1) | ||
1426 | rc = count; | ||
1427 | |||
1428 | return rc; | ||
1429 | } | ||
1430 | |||
1431 | static ssize_t | ||
1432 | service_acache_store(struct acache_orangefs_obj *acache_orangefs_obj, | ||
1433 | struct acache_orangefs_attribute *attr, | ||
1434 | const char *buf, | ||
1435 | size_t count) | ||
1436 | { | ||
1437 | int rc = 0; | ||
1438 | |||
1439 | rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr); | ||
1440 | |||
1441 | /* rc should have an errno value if the service_op went bad. */ | ||
1442 | if (rc == 1) | ||
1443 | rc = count; | ||
1444 | |||
1445 | return rc; | ||
1446 | } | ||
1447 | |||
1448 | static ssize_t | ||
1449 | service_capcache_store(struct capcache_orangefs_obj | ||
1450 | *capcache_orangefs_obj, | ||
1451 | struct capcache_orangefs_attribute *attr, | ||
1452 | const char *buf, | ||
1453 | size_t count) | ||
1454 | { | ||
1455 | int rc = 0; | ||
1456 | |||
1457 | rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr); | ||
1458 | |||
1459 | /* rc should have an errno value if the service_op went bad. */ | ||
1460 | if (rc == 1) | ||
1461 | rc = count; | ||
1462 | |||
1463 | return rc; | ||
1464 | } | ||
1465 | |||
1466 | static ssize_t service_ccache_store(struct ccache_orangefs_obj | ||
1467 | *ccache_orangefs_obj, | ||
1468 | struct ccache_orangefs_attribute *attr, | ||
1469 | const char *buf, | ||
1470 | size_t count) | ||
1471 | { | ||
1472 | int rc = 0; | ||
1473 | |||
1474 | rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr); | ||
1475 | |||
1476 | /* rc should have an errno value if the service_op went bad. */ | ||
1477 | if (rc == 1) | ||
1478 | rc = count; | ||
1479 | |||
1480 | return rc; | ||
1481 | } | ||
1482 | |||
1483 | static ssize_t | ||
1484 | service_ncache_store(struct ncache_orangefs_obj *ncache_orangefs_obj, | ||
1485 | struct ncache_orangefs_attribute *attr, | ||
1486 | const char *buf, | ||
1487 | size_t count) | ||
1488 | { | ||
1489 | int rc = 0; | ||
1490 | |||
1491 | rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr); | ||
1492 | |||
1493 | /* rc should have an errno value if the service_op went bad. */ | ||
1494 | if (rc == 1) | ||
1495 | rc = count; | ||
1496 | |||
1497 | return rc; | ||
1498 | } | ||
1499 | |||
1500 | static struct orangefs_attribute op_timeout_secs_attribute = | 800 | static struct orangefs_attribute op_timeout_secs_attribute = |
1501 | __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store); | 801 | __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store); |
1502 | 802 | ||
1503 | static struct orangefs_attribute slot_timeout_secs_attribute = | 803 | static struct orangefs_attribute slot_timeout_secs_attribute = |
1504 | __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store); | 804 | __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store); |
1505 | 805 | ||
1506 | static struct orangefs_attribute dcache_timeout_msecs_attribute = | 806 | static struct orangefs_attribute dcache_timeout_msecs_attribute = |
1507 | __ATTR(dcache_timeout_msecs, 0664, int_orangefs_show, int_store); | 807 | __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store); |
1508 | 808 | ||
1509 | static struct orangefs_attribute getattr_timeout_msecs_attribute = | 809 | static struct orangefs_attribute getattr_timeout_msecs_attribute = |
1510 | __ATTR(getattr_timeout_msecs, 0664, int_orangefs_show, int_store); | 810 | __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store); |
1511 | 811 | ||
1512 | static struct orangefs_attribute readahead_count_attribute = | 812 | static struct orangefs_attribute readahead_count_attribute = |
1513 | __ATTR(readahead_count, 0664, service_orangefs_show, | 813 | __ATTR(readahead_count, 0664, sysfs_service_op_show, |
1514 | service_orangefs_store); | 814 | sysfs_service_op_store); |
1515 | 815 | ||
1516 | static struct orangefs_attribute readahead_size_attribute = | 816 | static struct orangefs_attribute readahead_size_attribute = |
1517 | __ATTR(readahead_size, 0664, service_orangefs_show, | 817 | __ATTR(readahead_size, 0664, sysfs_service_op_show, |
1518 | service_orangefs_store); | 818 | sysfs_service_op_store); |
1519 | 819 | ||
1520 | static struct orangefs_attribute readahead_count_size_attribute = | 820 | static struct orangefs_attribute readahead_count_size_attribute = |
1521 | __ATTR(readahead_count_size, 0664, service_orangefs_show, | 821 | __ATTR(readahead_count_size, 0664, sysfs_service_op_show, |
1522 | service_orangefs_store); | 822 | sysfs_service_op_store); |
1523 | 823 | ||
1524 | static struct orangefs_attribute perf_counter_reset_attribute = | 824 | static struct orangefs_attribute perf_counter_reset_attribute = |
1525 | __ATTR(perf_counter_reset, | 825 | __ATTR(perf_counter_reset, |
1526 | 0664, | 826 | 0664, |
1527 | service_orangefs_show, | 827 | sysfs_service_op_show, |
1528 | service_orangefs_store); | 828 | sysfs_service_op_store); |
1529 | 829 | ||
1530 | static struct orangefs_attribute perf_history_size_attribute = | 830 | static struct orangefs_attribute perf_history_size_attribute = |
1531 | __ATTR(perf_history_size, | 831 | __ATTR(perf_history_size, |
1532 | 0664, | 832 | 0664, |
1533 | service_orangefs_show, | 833 | sysfs_service_op_show, |
1534 | service_orangefs_store); | 834 | sysfs_service_op_store); |
1535 | 835 | ||
1536 | static struct orangefs_attribute perf_time_interval_secs_attribute = | 836 | static struct orangefs_attribute perf_time_interval_secs_attribute = |
1537 | __ATTR(perf_time_interval_secs, | 837 | __ATTR(perf_time_interval_secs, |
1538 | 0664, | 838 | 0664, |
1539 | service_orangefs_show, | 839 | sysfs_service_op_show, |
1540 | service_orangefs_store); | 840 | sysfs_service_op_store); |
1541 | 841 | ||
1542 | static struct attribute *orangefs_default_attrs[] = { | 842 | static struct attribute *orangefs_default_attrs[] = { |
1543 | &op_timeout_secs_attribute.attr, | 843 | &op_timeout_secs_attribute.attr, |
@@ -1555,33 +855,32 @@ static struct attribute *orangefs_default_attrs[] = { | |||
1555 | 855 | ||
1556 | static struct kobj_type orangefs_ktype = { | 856 | static struct kobj_type orangefs_ktype = { |
1557 | .sysfs_ops = &orangefs_sysfs_ops, | 857 | .sysfs_ops = &orangefs_sysfs_ops, |
1558 | .release = orangefs_release, | ||
1559 | .default_attrs = orangefs_default_attrs, | 858 | .default_attrs = orangefs_default_attrs, |
1560 | }; | 859 | }; |
1561 | 860 | ||
1562 | static struct acache_orangefs_attribute acache_hard_limit_attribute = | 861 | static struct orangefs_attribute acache_hard_limit_attribute = |
1563 | __ATTR(hard_limit, | 862 | __ATTR(hard_limit, |
1564 | 0664, | 863 | 0664, |
1565 | service_acache_show, | 864 | sysfs_service_op_show, |
1566 | service_acache_store); | 865 | sysfs_service_op_store); |
1567 | 866 | ||
1568 | static struct acache_orangefs_attribute acache_reclaim_percent_attribute = | 867 | static struct orangefs_attribute acache_reclaim_percent_attribute = |
1569 | __ATTR(reclaim_percentage, | 868 | __ATTR(reclaim_percentage, |
1570 | 0664, | 869 | 0664, |
1571 | service_acache_show, | 870 | sysfs_service_op_show, |
1572 | service_acache_store); | 871 | sysfs_service_op_store); |
1573 | 872 | ||
1574 | static struct acache_orangefs_attribute acache_soft_limit_attribute = | 873 | static struct orangefs_attribute acache_soft_limit_attribute = |
1575 | __ATTR(soft_limit, | 874 | __ATTR(soft_limit, |
1576 | 0664, | 875 | 0664, |
1577 | service_acache_show, | 876 | sysfs_service_op_show, |
1578 | service_acache_store); | 877 | sysfs_service_op_store); |
1579 | 878 | ||
1580 | static struct acache_orangefs_attribute acache_timeout_msecs_attribute = | 879 | static struct orangefs_attribute acache_timeout_msecs_attribute = |
1581 | __ATTR(timeout_msecs, | 880 | __ATTR(timeout_msecs, |
1582 | 0664, | 881 | 0664, |
1583 | service_acache_show, | 882 | sysfs_service_op_show, |
1584 | service_acache_store); | 883 | sysfs_service_op_store); |
1585 | 884 | ||
1586 | static struct attribute *acache_orangefs_default_attrs[] = { | 885 | static struct attribute *acache_orangefs_default_attrs[] = { |
1587 | &acache_hard_limit_attribute.attr, | 886 | &acache_hard_limit_attribute.attr, |
@@ -1592,34 +891,33 @@ static struct attribute *acache_orangefs_default_attrs[] = { | |||
1592 | }; | 891 | }; |
1593 | 892 | ||
1594 | static struct kobj_type acache_orangefs_ktype = { | 893 | static struct kobj_type acache_orangefs_ktype = { |
1595 | .sysfs_ops = &acache_orangefs_sysfs_ops, | 894 | .sysfs_ops = &orangefs_sysfs_ops, |
1596 | .release = acache_orangefs_release, | ||
1597 | .default_attrs = acache_orangefs_default_attrs, | 895 | .default_attrs = acache_orangefs_default_attrs, |
1598 | }; | 896 | }; |
1599 | 897 | ||
1600 | static struct capcache_orangefs_attribute capcache_hard_limit_attribute = | 898 | static struct orangefs_attribute capcache_hard_limit_attribute = |
1601 | __ATTR(hard_limit, | 899 | __ATTR(hard_limit, |
1602 | 0664, | 900 | 0664, |
1603 | service_capcache_show, | 901 | sysfs_service_op_show, |
1604 | service_capcache_store); | 902 | sysfs_service_op_store); |
1605 | 903 | ||
1606 | static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute = | 904 | static struct orangefs_attribute capcache_reclaim_percent_attribute = |
1607 | __ATTR(reclaim_percentage, | 905 | __ATTR(reclaim_percentage, |
1608 | 0664, | 906 | 0664, |
1609 | service_capcache_show, | 907 | sysfs_service_op_show, |
1610 | service_capcache_store); | 908 | sysfs_service_op_store); |
1611 | 909 | ||
1612 | static struct capcache_orangefs_attribute capcache_soft_limit_attribute = | 910 | static struct orangefs_attribute capcache_soft_limit_attribute = |
1613 | __ATTR(soft_limit, | 911 | __ATTR(soft_limit, |
1614 | 0664, | 912 | 0664, |
1615 | service_capcache_show, | 913 | sysfs_service_op_show, |
1616 | service_capcache_store); | 914 | sysfs_service_op_store); |
1617 | 915 | ||
1618 | static struct capcache_orangefs_attribute capcache_timeout_secs_attribute = | 916 | static struct orangefs_attribute capcache_timeout_secs_attribute = |
1619 | __ATTR(timeout_secs, | 917 | __ATTR(timeout_secs, |
1620 | 0664, | 918 | 0664, |
1621 | service_capcache_show, | 919 | sysfs_service_op_show, |
1622 | service_capcache_store); | 920 | sysfs_service_op_store); |
1623 | 921 | ||
1624 | static struct attribute *capcache_orangefs_default_attrs[] = { | 922 | static struct attribute *capcache_orangefs_default_attrs[] = { |
1625 | &capcache_hard_limit_attribute.attr, | 923 | &capcache_hard_limit_attribute.attr, |
@@ -1630,34 +928,33 @@ static struct attribute *capcache_orangefs_default_attrs[] = { | |||
1630 | }; | 928 | }; |
1631 | 929 | ||
1632 | static struct kobj_type capcache_orangefs_ktype = { | 930 | static struct kobj_type capcache_orangefs_ktype = { |
1633 | .sysfs_ops = &capcache_orangefs_sysfs_ops, | 931 | .sysfs_ops = &orangefs_sysfs_ops, |
1634 | .release = capcache_orangefs_release, | ||
1635 | .default_attrs = capcache_orangefs_default_attrs, | 932 | .default_attrs = capcache_orangefs_default_attrs, |
1636 | }; | 933 | }; |
1637 | 934 | ||
1638 | static struct ccache_orangefs_attribute ccache_hard_limit_attribute = | 935 | static struct orangefs_attribute ccache_hard_limit_attribute = |
1639 | __ATTR(hard_limit, | 936 | __ATTR(hard_limit, |
1640 | 0664, | 937 | 0664, |
1641 | service_ccache_show, | 938 | sysfs_service_op_show, |
1642 | service_ccache_store); | 939 | sysfs_service_op_store); |
1643 | 940 | ||
1644 | static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute = | 941 | static struct orangefs_attribute ccache_reclaim_percent_attribute = |
1645 | __ATTR(reclaim_percentage, | 942 | __ATTR(reclaim_percentage, |
1646 | 0664, | 943 | 0664, |
1647 | service_ccache_show, | 944 | sysfs_service_op_show, |
1648 | service_ccache_store); | 945 | sysfs_service_op_store); |
1649 | 946 | ||
1650 | static struct ccache_orangefs_attribute ccache_soft_limit_attribute = | 947 | static struct orangefs_attribute ccache_soft_limit_attribute = |
1651 | __ATTR(soft_limit, | 948 | __ATTR(soft_limit, |
1652 | 0664, | 949 | 0664, |
1653 | service_ccache_show, | 950 | sysfs_service_op_show, |
1654 | service_ccache_store); | 951 | sysfs_service_op_store); |
1655 | 952 | ||
1656 | static struct ccache_orangefs_attribute ccache_timeout_secs_attribute = | 953 | static struct orangefs_attribute ccache_timeout_secs_attribute = |
1657 | __ATTR(timeout_secs, | 954 | __ATTR(timeout_secs, |
1658 | 0664, | 955 | 0664, |
1659 | service_ccache_show, | 956 | sysfs_service_op_show, |
1660 | service_ccache_store); | 957 | sysfs_service_op_store); |
1661 | 958 | ||
1662 | static struct attribute *ccache_orangefs_default_attrs[] = { | 959 | static struct attribute *ccache_orangefs_default_attrs[] = { |
1663 | &ccache_hard_limit_attribute.attr, | 960 | &ccache_hard_limit_attribute.attr, |
@@ -1668,34 +965,33 @@ static struct attribute *ccache_orangefs_default_attrs[] = { | |||
1668 | }; | 965 | }; |
1669 | 966 | ||
1670 | static struct kobj_type ccache_orangefs_ktype = { | 967 | static struct kobj_type ccache_orangefs_ktype = { |
1671 | .sysfs_ops = &ccache_orangefs_sysfs_ops, | 968 | .sysfs_ops = &orangefs_sysfs_ops, |
1672 | .release = ccache_orangefs_release, | ||
1673 | .default_attrs = ccache_orangefs_default_attrs, | 969 | .default_attrs = ccache_orangefs_default_attrs, |
1674 | }; | 970 | }; |
1675 | 971 | ||
1676 | static struct ncache_orangefs_attribute ncache_hard_limit_attribute = | 972 | static struct orangefs_attribute ncache_hard_limit_attribute = |
1677 | __ATTR(hard_limit, | 973 | __ATTR(hard_limit, |
1678 | 0664, | 974 | 0664, |
1679 | service_ncache_show, | 975 | sysfs_service_op_show, |
1680 | service_ncache_store); | 976 | sysfs_service_op_store); |
1681 | 977 | ||
1682 | static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute = | 978 | static struct orangefs_attribute ncache_reclaim_percent_attribute = |
1683 | __ATTR(reclaim_percentage, | 979 | __ATTR(reclaim_percentage, |
1684 | 0664, | 980 | 0664, |
1685 | service_ncache_show, | 981 | sysfs_service_op_show, |
1686 | service_ncache_store); | 982 | sysfs_service_op_store); |
1687 | 983 | ||
1688 | static struct ncache_orangefs_attribute ncache_soft_limit_attribute = | 984 | static struct orangefs_attribute ncache_soft_limit_attribute = |
1689 | __ATTR(soft_limit, | 985 | __ATTR(soft_limit, |
1690 | 0664, | 986 | 0664, |
1691 | service_ncache_show, | 987 | sysfs_service_op_show, |
1692 | service_ncache_store); | 988 | sysfs_service_op_store); |
1693 | 989 | ||
1694 | static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute = | 990 | static struct orangefs_attribute ncache_timeout_msecs_attribute = |
1695 | __ATTR(timeout_msecs, | 991 | __ATTR(timeout_msecs, |
1696 | 0664, | 992 | 0664, |
1697 | service_ncache_show, | 993 | sysfs_service_op_show, |
1698 | service_ncache_store); | 994 | sysfs_service_op_store); |
1699 | 995 | ||
1700 | static struct attribute *ncache_orangefs_default_attrs[] = { | 996 | static struct attribute *ncache_orangefs_default_attrs[] = { |
1701 | &ncache_hard_limit_attribute.attr, | 997 | &ncache_hard_limit_attribute.attr, |
@@ -1706,27 +1002,26 @@ static struct attribute *ncache_orangefs_default_attrs[] = { | |||
1706 | }; | 1002 | }; |
1707 | 1003 | ||
1708 | static struct kobj_type ncache_orangefs_ktype = { | 1004 | static struct kobj_type ncache_orangefs_ktype = { |
1709 | .sysfs_ops = &ncache_orangefs_sysfs_ops, | 1005 | .sysfs_ops = &orangefs_sysfs_ops, |
1710 | .release = ncache_orangefs_release, | ||
1711 | .default_attrs = ncache_orangefs_default_attrs, | 1006 | .default_attrs = ncache_orangefs_default_attrs, |
1712 | }; | 1007 | }; |
1713 | 1008 | ||
1714 | static struct pc_orangefs_attribute pc_acache_attribute = | 1009 | static struct orangefs_attribute pc_acache_attribute = |
1715 | __ATTR(acache, | 1010 | __ATTR(acache, |
1716 | 0664, | 1011 | 0664, |
1717 | service_pc_show, | 1012 | sysfs_service_op_show, |
1718 | NULL); | 1013 | NULL); |
1719 | 1014 | ||
1720 | static struct pc_orangefs_attribute pc_capcache_attribute = | 1015 | static struct orangefs_attribute pc_capcache_attribute = |
1721 | __ATTR(capcache, | 1016 | __ATTR(capcache, |
1722 | 0664, | 1017 | 0664, |
1723 | service_pc_show, | 1018 | sysfs_service_op_show, |
1724 | NULL); | 1019 | NULL); |
1725 | 1020 | ||
1726 | static struct pc_orangefs_attribute pc_ncache_attribute = | 1021 | static struct orangefs_attribute pc_ncache_attribute = |
1727 | __ATTR(ncache, | 1022 | __ATTR(ncache, |
1728 | 0664, | 1023 | 0664, |
1729 | service_pc_show, | 1024 | sysfs_service_op_show, |
1730 | NULL); | 1025 | NULL); |
1731 | 1026 | ||
1732 | static struct attribute *pc_orangefs_default_attrs[] = { | 1027 | static struct attribute *pc_orangefs_default_attrs[] = { |
@@ -1737,21 +1032,20 @@ static struct attribute *pc_orangefs_default_attrs[] = { | |||
1737 | }; | 1032 | }; |
1738 | 1033 | ||
1739 | static struct kobj_type pc_orangefs_ktype = { | 1034 | static struct kobj_type pc_orangefs_ktype = { |
1740 | .sysfs_ops = &pc_orangefs_sysfs_ops, | 1035 | .sysfs_ops = &orangefs_sysfs_ops, |
1741 | .release = pc_orangefs_release, | ||
1742 | .default_attrs = pc_orangefs_default_attrs, | 1036 | .default_attrs = pc_orangefs_default_attrs, |
1743 | }; | 1037 | }; |
1744 | 1038 | ||
1745 | static struct stats_orangefs_attribute stats_reads_attribute = | 1039 | static struct orangefs_attribute stats_reads_attribute = |
1746 | __ATTR(reads, | 1040 | __ATTR(reads, |
1747 | 0664, | 1041 | 0664, |
1748 | int_stats_show, | 1042 | sysfs_int_show, |
1749 | NULL); | 1043 | NULL); |
1750 | 1044 | ||
1751 | static struct stats_orangefs_attribute stats_writes_attribute = | 1045 | static struct orangefs_attribute stats_writes_attribute = |
1752 | __ATTR(writes, | 1046 | __ATTR(writes, |
1753 | 0664, | 1047 | 0664, |
1754 | int_stats_show, | 1048 | sysfs_int_show, |
1755 | NULL); | 1049 | NULL); |
1756 | 1050 | ||
1757 | static struct attribute *stats_orangefs_default_attrs[] = { | 1051 | static struct attribute *stats_orangefs_default_attrs[] = { |
@@ -1761,18 +1055,17 @@ static struct attribute *stats_orangefs_default_attrs[] = { | |||
1761 | }; | 1055 | }; |
1762 | 1056 | ||
1763 | static struct kobj_type stats_orangefs_ktype = { | 1057 | static struct kobj_type stats_orangefs_ktype = { |
1764 | .sysfs_ops = &stats_orangefs_sysfs_ops, | 1058 | .sysfs_ops = &orangefs_sysfs_ops, |
1765 | .release = stats_orangefs_release, | ||
1766 | .default_attrs = stats_orangefs_default_attrs, | 1059 | .default_attrs = stats_orangefs_default_attrs, |
1767 | }; | 1060 | }; |
1768 | 1061 | ||
1769 | static struct orangefs_obj *orangefs_obj; | 1062 | static struct kobject *orangefs_obj; |
1770 | static struct acache_orangefs_obj *acache_orangefs_obj; | 1063 | static struct kobject *acache_orangefs_obj; |
1771 | static struct capcache_orangefs_obj *capcache_orangefs_obj; | 1064 | static struct kobject *capcache_orangefs_obj; |
1772 | static struct ccache_orangefs_obj *ccache_orangefs_obj; | 1065 | static struct kobject *ccache_orangefs_obj; |
1773 | static struct ncache_orangefs_obj *ncache_orangefs_obj; | 1066 | static struct kobject *ncache_orangefs_obj; |
1774 | static struct pc_orangefs_obj *pc_orangefs_obj; | 1067 | static struct kobject *pc_orangefs_obj; |
1775 | static struct stats_orangefs_obj *stats_orangefs_obj; | 1068 | static struct kobject *stats_orangefs_obj; |
1776 | 1069 | ||
1777 | int orangefs_sysfs_init(void) | 1070 | int orangefs_sysfs_init(void) |
1778 | { | 1071 | { |
@@ -1785,7 +1078,7 @@ int orangefs_sysfs_init(void) | |||
1785 | if (!orangefs_obj) | 1078 | if (!orangefs_obj) |
1786 | goto out; | 1079 | goto out; |
1787 | 1080 | ||
1788 | rc = kobject_init_and_add(&orangefs_obj->kobj, | 1081 | rc = kobject_init_and_add(orangefs_obj, |
1789 | &orangefs_ktype, | 1082 | &orangefs_ktype, |
1790 | fs_kobj, | 1083 | fs_kobj, |
1791 | ORANGEFS_KOBJ_ID); | 1084 | ORANGEFS_KOBJ_ID); |
@@ -1793,7 +1086,7 @@ int orangefs_sysfs_init(void) | |||
1793 | if (rc) | 1086 | if (rc) |
1794 | goto ofs_obj_bail; | 1087 | goto ofs_obj_bail; |
1795 | 1088 | ||
1796 | kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD); | 1089 | kobject_uevent(orangefs_obj, KOBJ_ADD); |
1797 | 1090 | ||
1798 | /* create /sys/fs/orangefs/acache. */ | 1091 | /* create /sys/fs/orangefs/acache. */ |
1799 | acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); | 1092 | acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); |
@@ -1802,15 +1095,15 @@ int orangefs_sysfs_init(void) | |||
1802 | goto ofs_obj_bail; | 1095 | goto ofs_obj_bail; |
1803 | } | 1096 | } |
1804 | 1097 | ||
1805 | rc = kobject_init_and_add(&acache_orangefs_obj->kobj, | 1098 | rc = kobject_init_and_add(acache_orangefs_obj, |
1806 | &acache_orangefs_ktype, | 1099 | &acache_orangefs_ktype, |
1807 | &orangefs_obj->kobj, | 1100 | orangefs_obj, |
1808 | ACACHE_KOBJ_ID); | 1101 | ACACHE_KOBJ_ID); |
1809 | 1102 | ||
1810 | if (rc) | 1103 | if (rc) |
1811 | goto acache_obj_bail; | 1104 | goto acache_obj_bail; |
1812 | 1105 | ||
1813 | kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD); | 1106 | kobject_uevent(acache_orangefs_obj, KOBJ_ADD); |
1814 | 1107 | ||
1815 | /* create /sys/fs/orangefs/capcache. */ | 1108 | /* create /sys/fs/orangefs/capcache. */ |
1816 | capcache_orangefs_obj = | 1109 | capcache_orangefs_obj = |
@@ -1820,14 +1113,14 @@ int orangefs_sysfs_init(void) | |||
1820 | goto acache_obj_bail; | 1113 | goto acache_obj_bail; |
1821 | } | 1114 | } |
1822 | 1115 | ||
1823 | rc = kobject_init_and_add(&capcache_orangefs_obj->kobj, | 1116 | rc = kobject_init_and_add(capcache_orangefs_obj, |
1824 | &capcache_orangefs_ktype, | 1117 | &capcache_orangefs_ktype, |
1825 | &orangefs_obj->kobj, | 1118 | orangefs_obj, |
1826 | CAPCACHE_KOBJ_ID); | 1119 | CAPCACHE_KOBJ_ID); |
1827 | if (rc) | 1120 | if (rc) |
1828 | goto capcache_obj_bail; | 1121 | goto capcache_obj_bail; |
1829 | 1122 | ||
1830 | kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD); | 1123 | kobject_uevent(capcache_orangefs_obj, KOBJ_ADD); |
1831 | 1124 | ||
1832 | /* create /sys/fs/orangefs/ccache. */ | 1125 | /* create /sys/fs/orangefs/ccache. */ |
1833 | ccache_orangefs_obj = | 1126 | ccache_orangefs_obj = |
@@ -1837,14 +1130,14 @@ int orangefs_sysfs_init(void) | |||
1837 | goto capcache_obj_bail; | 1130 | goto capcache_obj_bail; |
1838 | } | 1131 | } |
1839 | 1132 | ||
1840 | rc = kobject_init_and_add(&ccache_orangefs_obj->kobj, | 1133 | rc = kobject_init_and_add(ccache_orangefs_obj, |
1841 | &ccache_orangefs_ktype, | 1134 | &ccache_orangefs_ktype, |
1842 | &orangefs_obj->kobj, | 1135 | orangefs_obj, |
1843 | CCACHE_KOBJ_ID); | 1136 | CCACHE_KOBJ_ID); |
1844 | if (rc) | 1137 | if (rc) |
1845 | goto ccache_obj_bail; | 1138 | goto ccache_obj_bail; |
1846 | 1139 | ||
1847 | kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD); | 1140 | kobject_uevent(ccache_orangefs_obj, KOBJ_ADD); |
1848 | 1141 | ||
1849 | /* create /sys/fs/orangefs/ncache. */ | 1142 | /* create /sys/fs/orangefs/ncache. */ |
1850 | ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); | 1143 | ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); |
@@ -1853,15 +1146,15 @@ int orangefs_sysfs_init(void) | |||
1853 | goto ccache_obj_bail; | 1146 | goto ccache_obj_bail; |
1854 | } | 1147 | } |
1855 | 1148 | ||
1856 | rc = kobject_init_and_add(&ncache_orangefs_obj->kobj, | 1149 | rc = kobject_init_and_add(ncache_orangefs_obj, |
1857 | &ncache_orangefs_ktype, | 1150 | &ncache_orangefs_ktype, |
1858 | &orangefs_obj->kobj, | 1151 | orangefs_obj, |
1859 | NCACHE_KOBJ_ID); | 1152 | NCACHE_KOBJ_ID); |
1860 | 1153 | ||
1861 | if (rc) | 1154 | if (rc) |
1862 | goto ncache_obj_bail; | 1155 | goto ncache_obj_bail; |
1863 | 1156 | ||
1864 | kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD); | 1157 | kobject_uevent(ncache_orangefs_obj, KOBJ_ADD); |
1865 | 1158 | ||
1866 | /* create /sys/fs/orangefs/perf_counters. */ | 1159 | /* create /sys/fs/orangefs/perf_counters. */ |
1867 | pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); | 1160 | pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); |
@@ -1870,15 +1163,15 @@ int orangefs_sysfs_init(void) | |||
1870 | goto ncache_obj_bail; | 1163 | goto ncache_obj_bail; |
1871 | } | 1164 | } |
1872 | 1165 | ||
1873 | rc = kobject_init_and_add(&pc_orangefs_obj->kobj, | 1166 | rc = kobject_init_and_add(pc_orangefs_obj, |
1874 | &pc_orangefs_ktype, | 1167 | &pc_orangefs_ktype, |
1875 | &orangefs_obj->kobj, | 1168 | orangefs_obj, |
1876 | "perf_counters"); | 1169 | "perf_counters"); |
1877 | 1170 | ||
1878 | if (rc) | 1171 | if (rc) |
1879 | goto pc_obj_bail; | 1172 | goto pc_obj_bail; |
1880 | 1173 | ||
1881 | kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD); | 1174 | kobject_uevent(pc_orangefs_obj, KOBJ_ADD); |
1882 | 1175 | ||
1883 | /* create /sys/fs/orangefs/stats. */ | 1176 | /* create /sys/fs/orangefs/stats. */ |
1884 | stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); | 1177 | stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); |
@@ -1887,37 +1180,31 @@ int orangefs_sysfs_init(void) | |||
1887 | goto pc_obj_bail; | 1180 | goto pc_obj_bail; |
1888 | } | 1181 | } |
1889 | 1182 | ||
1890 | rc = kobject_init_and_add(&stats_orangefs_obj->kobj, | 1183 | rc = kobject_init_and_add(stats_orangefs_obj, |
1891 | &stats_orangefs_ktype, | 1184 | &stats_orangefs_ktype, |
1892 | &orangefs_obj->kobj, | 1185 | orangefs_obj, |
1893 | STATS_KOBJ_ID); | 1186 | STATS_KOBJ_ID); |
1894 | 1187 | ||
1895 | if (rc) | 1188 | if (rc) |
1896 | goto stats_obj_bail; | 1189 | goto stats_obj_bail; |
1897 | 1190 | ||
1898 | kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD); | 1191 | kobject_uevent(stats_orangefs_obj, KOBJ_ADD); |
1899 | goto out; | 1192 | goto out; |
1900 | 1193 | ||
1901 | stats_obj_bail: | 1194 | stats_obj_bail: |
1902 | kobject_put(&stats_orangefs_obj->kobj); | 1195 | kobject_put(stats_orangefs_obj); |
1903 | |||
1904 | pc_obj_bail: | 1196 | pc_obj_bail: |
1905 | kobject_put(&pc_orangefs_obj->kobj); | 1197 | kobject_put(pc_orangefs_obj); |
1906 | |||
1907 | ncache_obj_bail: | 1198 | ncache_obj_bail: |
1908 | kobject_put(&ncache_orangefs_obj->kobj); | 1199 | kobject_put(ncache_orangefs_obj); |
1909 | |||
1910 | ccache_obj_bail: | 1200 | ccache_obj_bail: |
1911 | kobject_put(&ccache_orangefs_obj->kobj); | 1201 | kobject_put(ccache_orangefs_obj); |
1912 | |||
1913 | capcache_obj_bail: | 1202 | capcache_obj_bail: |
1914 | kobject_put(&capcache_orangefs_obj->kobj); | 1203 | kobject_put(capcache_orangefs_obj); |
1915 | |||
1916 | acache_obj_bail: | 1204 | acache_obj_bail: |
1917 | kobject_put(&acache_orangefs_obj->kobj); | 1205 | kobject_put(acache_orangefs_obj); |
1918 | |||
1919 | ofs_obj_bail: | 1206 | ofs_obj_bail: |
1920 | kobject_put(&orangefs_obj->kobj); | 1207 | kobject_put(orangefs_obj); |
1921 | out: | 1208 | out: |
1922 | return rc; | 1209 | return rc; |
1923 | } | 1210 | } |
@@ -1925,13 +1212,11 @@ out: | |||
1925 | void orangefs_sysfs_exit(void) | 1212 | void orangefs_sysfs_exit(void) |
1926 | { | 1213 | { |
1927 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n"); | 1214 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n"); |
1928 | 1215 | kobject_put(acache_orangefs_obj); | |
1929 | kobject_put(&acache_orangefs_obj->kobj); | 1216 | kobject_put(capcache_orangefs_obj); |
1930 | kobject_put(&capcache_orangefs_obj->kobj); | 1217 | kobject_put(ccache_orangefs_obj); |
1931 | kobject_put(&ccache_orangefs_obj->kobj); | 1218 | kobject_put(ncache_orangefs_obj); |
1932 | kobject_put(&ncache_orangefs_obj->kobj); | 1219 | kobject_put(pc_orangefs_obj); |
1933 | kobject_put(&pc_orangefs_obj->kobj); | 1220 | kobject_put(stats_orangefs_obj); |
1934 | kobject_put(&stats_orangefs_obj->kobj); | 1221 | kobject_put(orangefs_obj); |
1935 | |||
1936 | kobject_put(&orangefs_obj->kobj); | ||
1937 | } | 1222 | } |
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c index 9a99285fe310..06af81f71e10 100644 --- a/fs/orangefs/orangefs-utils.c +++ b/fs/orangefs/orangefs-utils.c | |||
@@ -347,7 +347,8 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass) | |||
347 | inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) | | 347 | inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) | |
348 | orangefs_inode_perms(&new_op->downcall.resp.getattr.attributes); | 348 | orangefs_inode_perms(&new_op->downcall.resp.getattr.attributes); |
349 | 349 | ||
350 | orangefs_inode->getattr_time = jiffies + getattr_timeout_msecs*HZ/1000; | 350 | orangefs_inode->getattr_time = jiffies + |
351 | orangefs_getattr_timeout_msecs*HZ/1000; | ||
351 | ret = 0; | 352 | ret = 0; |
352 | out: | 353 | out: |
353 | op_release(new_op); | 354 | op_release(new_op); |
@@ -656,401 +657,3 @@ __s32 ORANGEFS_util_translate_mode(int mode) | |||
656 | return ret; | 657 | return ret; |
657 | } | 658 | } |
658 | #undef NUM_MODES | 659 | #undef NUM_MODES |
659 | |||
660 | /* | ||
661 | * After obtaining a string representation of the client's debug | ||
662 | * keywords and their associated masks, this function is called to build an | ||
663 | * array of these values. | ||
664 | */ | ||
665 | int orangefs_prepare_cdm_array(char *debug_array_string) | ||
666 | { | ||
667 | int i; | ||
668 | int rc = -EINVAL; | ||
669 | char *cds_head = NULL; | ||
670 | char *cds_delimiter = NULL; | ||
671 | int keyword_len = 0; | ||
672 | |||
673 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
674 | |||
675 | /* | ||
676 | * figure out how many elements the cdm_array needs. | ||
677 | */ | ||
678 | for (i = 0; i < strlen(debug_array_string); i++) | ||
679 | if (debug_array_string[i] == '\n') | ||
680 | cdm_element_count++; | ||
681 | |||
682 | if (!cdm_element_count) { | ||
683 | pr_info("No elements in client debug array string!\n"); | ||
684 | goto out; | ||
685 | } | ||
686 | |||
687 | cdm_array = | ||
688 | kzalloc(cdm_element_count * sizeof(struct client_debug_mask), | ||
689 | GFP_KERNEL); | ||
690 | if (!cdm_array) { | ||
691 | pr_info("malloc failed for cdm_array!\n"); | ||
692 | rc = -ENOMEM; | ||
693 | goto out; | ||
694 | } | ||
695 | |||
696 | cds_head = debug_array_string; | ||
697 | |||
698 | for (i = 0; i < cdm_element_count; i++) { | ||
699 | cds_delimiter = strchr(cds_head, '\n'); | ||
700 | *cds_delimiter = '\0'; | ||
701 | |||
702 | keyword_len = strcspn(cds_head, " "); | ||
703 | |||
704 | cdm_array[i].keyword = kzalloc(keyword_len + 1, GFP_KERNEL); | ||
705 | if (!cdm_array[i].keyword) { | ||
706 | rc = -ENOMEM; | ||
707 | goto out; | ||
708 | } | ||
709 | |||
710 | sscanf(cds_head, | ||
711 | "%s %llx %llx", | ||
712 | cdm_array[i].keyword, | ||
713 | (unsigned long long *)&(cdm_array[i].mask1), | ||
714 | (unsigned long long *)&(cdm_array[i].mask2)); | ||
715 | |||
716 | if (!strcmp(cdm_array[i].keyword, ORANGEFS_VERBOSE)) | ||
717 | client_verbose_index = i; | ||
718 | |||
719 | if (!strcmp(cdm_array[i].keyword, ORANGEFS_ALL)) | ||
720 | client_all_index = i; | ||
721 | |||
722 | cds_head = cds_delimiter + 1; | ||
723 | } | ||
724 | |||
725 | rc = cdm_element_count; | ||
726 | |||
727 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: rc:%d:\n", __func__, rc); | ||
728 | |||
729 | out: | ||
730 | |||
731 | return rc; | ||
732 | |||
733 | } | ||
734 | |||
735 | /* | ||
736 | * /sys/kernel/debug/orangefs/debug-help can be catted to | ||
737 | * see all the available kernel and client debug keywords. | ||
738 | * | ||
739 | * When the kernel boots, we have no idea what keywords the | ||
740 | * client supports, nor their associated masks. | ||
741 | * | ||
742 | * We pass through this function once at boot and stamp a | ||
743 | * boilerplate "we don't know" message for the client in the | ||
744 | * debug-help file. We pass through here again when the client | ||
745 | * starts and then we can fill out the debug-help file fully. | ||
746 | * | ||
747 | * The client might be restarted any number of times between | ||
748 | * reboots, we only build the debug-help file the first time. | ||
749 | */ | ||
750 | int orangefs_prepare_debugfs_help_string(int at_boot) | ||
751 | { | ||
752 | int rc = -EINVAL; | ||
753 | int i; | ||
754 | int byte_count = 0; | ||
755 | char *client_title = "Client Debug Keywords:\n"; | ||
756 | char *kernel_title = "Kernel Debug Keywords:\n"; | ||
757 | |||
758 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
759 | |||
760 | if (at_boot) { | ||
761 | byte_count += strlen(HELP_STRING_UNINITIALIZED); | ||
762 | client_title = HELP_STRING_UNINITIALIZED; | ||
763 | } else { | ||
764 | /* | ||
765 | * fill the client keyword/mask array and remember | ||
766 | * how many elements there were. | ||
767 | */ | ||
768 | cdm_element_count = | ||
769 | orangefs_prepare_cdm_array(client_debug_array_string); | ||
770 | if (cdm_element_count <= 0) | ||
771 | goto out; | ||
772 | |||
773 | /* Count the bytes destined for debug_help_string. */ | ||
774 | byte_count += strlen(client_title); | ||
775 | |||
776 | for (i = 0; i < cdm_element_count; i++) { | ||
777 | byte_count += strlen(cdm_array[i].keyword + 2); | ||
778 | if (byte_count >= DEBUG_HELP_STRING_SIZE) { | ||
779 | pr_info("%s: overflow 1!\n", __func__); | ||
780 | goto out; | ||
781 | } | ||
782 | } | ||
783 | |||
784 | gossip_debug(GOSSIP_UTILS_DEBUG, | ||
785 | "%s: cdm_element_count:%d:\n", | ||
786 | __func__, | ||
787 | cdm_element_count); | ||
788 | } | ||
789 | |||
790 | byte_count += strlen(kernel_title); | ||
791 | for (i = 0; i < num_kmod_keyword_mask_map; i++) { | ||
792 | byte_count += | ||
793 | strlen(s_kmod_keyword_mask_map[i].keyword + 2); | ||
794 | if (byte_count >= DEBUG_HELP_STRING_SIZE) { | ||
795 | pr_info("%s: overflow 2!\n", __func__); | ||
796 | goto out; | ||
797 | } | ||
798 | } | ||
799 | |||
800 | /* build debug_help_string. */ | ||
801 | debug_help_string = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL); | ||
802 | if (!debug_help_string) { | ||
803 | rc = -ENOMEM; | ||
804 | goto out; | ||
805 | } | ||
806 | |||
807 | strcat(debug_help_string, client_title); | ||
808 | |||
809 | if (!at_boot) { | ||
810 | for (i = 0; i < cdm_element_count; i++) { | ||
811 | strcat(debug_help_string, "\t"); | ||
812 | strcat(debug_help_string, cdm_array[i].keyword); | ||
813 | strcat(debug_help_string, "\n"); | ||
814 | } | ||
815 | } | ||
816 | |||
817 | strcat(debug_help_string, "\n"); | ||
818 | strcat(debug_help_string, kernel_title); | ||
819 | |||
820 | for (i = 0; i < num_kmod_keyword_mask_map; i++) { | ||
821 | strcat(debug_help_string, "\t"); | ||
822 | strcat(debug_help_string, s_kmod_keyword_mask_map[i].keyword); | ||
823 | strcat(debug_help_string, "\n"); | ||
824 | } | ||
825 | |||
826 | rc = 0; | ||
827 | |||
828 | out: | ||
829 | |||
830 | return rc; | ||
831 | |||
832 | } | ||
833 | |||
834 | /* | ||
835 | * kernel = type 0 | ||
836 | * client = type 1 | ||
837 | */ | ||
838 | void debug_mask_to_string(void *mask, int type) | ||
839 | { | ||
840 | int i; | ||
841 | int len = 0; | ||
842 | char *debug_string; | ||
843 | int element_count = 0; | ||
844 | |||
845 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
846 | |||
847 | if (type) { | ||
848 | debug_string = client_debug_string; | ||
849 | element_count = cdm_element_count; | ||
850 | } else { | ||
851 | debug_string = kernel_debug_string; | ||
852 | element_count = num_kmod_keyword_mask_map; | ||
853 | } | ||
854 | |||
855 | memset(debug_string, 0, ORANGEFS_MAX_DEBUG_STRING_LEN); | ||
856 | |||
857 | /* | ||
858 | * Some keywords, like "all" or "verbose", are amalgams of | ||
859 | * numerous other keywords. Make a special check for those | ||
860 | * before grinding through the whole mask only to find out | ||
861 | * later... | ||
862 | */ | ||
863 | if (check_amalgam_keyword(mask, type)) | ||
864 | goto out; | ||
865 | |||
866 | /* Build the debug string. */ | ||
867 | for (i = 0; i < element_count; i++) | ||
868 | if (type) | ||
869 | do_c_string(mask, i); | ||
870 | else | ||
871 | do_k_string(mask, i); | ||
872 | |||
873 | len = strlen(debug_string); | ||
874 | |||
875 | if ((len) && (type)) | ||
876 | client_debug_string[len - 1] = '\0'; | ||
877 | else if (len) | ||
878 | kernel_debug_string[len - 1] = '\0'; | ||
879 | else if (type) | ||
880 | strcpy(client_debug_string, "none"); | ||
881 | else | ||
882 | strcpy(kernel_debug_string, "none"); | ||
883 | |||
884 | out: | ||
885 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_string); | ||
886 | |||
887 | return; | ||
888 | |||
889 | } | ||
890 | |||
891 | void do_k_string(void *k_mask, int index) | ||
892 | { | ||
893 | __u64 *mask = (__u64 *) k_mask; | ||
894 | |||
895 | if (keyword_is_amalgam((char *) s_kmod_keyword_mask_map[index].keyword)) | ||
896 | goto out; | ||
897 | |||
898 | if (*mask & s_kmod_keyword_mask_map[index].mask_val) { | ||
899 | if ((strlen(kernel_debug_string) + | ||
900 | strlen(s_kmod_keyword_mask_map[index].keyword)) | ||
901 | < ORANGEFS_MAX_DEBUG_STRING_LEN - 1) { | ||
902 | strcat(kernel_debug_string, | ||
903 | s_kmod_keyword_mask_map[index].keyword); | ||
904 | strcat(kernel_debug_string, ","); | ||
905 | } else { | ||
906 | gossip_err("%s: overflow!\n", __func__); | ||
907 | strcpy(kernel_debug_string, ORANGEFS_ALL); | ||
908 | goto out; | ||
909 | } | ||
910 | } | ||
911 | |||
912 | out: | ||
913 | |||
914 | return; | ||
915 | } | ||
916 | |||
917 | void do_c_string(void *c_mask, int index) | ||
918 | { | ||
919 | struct client_debug_mask *mask = (struct client_debug_mask *) c_mask; | ||
920 | |||
921 | if (keyword_is_amalgam(cdm_array[index].keyword)) | ||
922 | goto out; | ||
923 | |||
924 | if ((mask->mask1 & cdm_array[index].mask1) || | ||
925 | (mask->mask2 & cdm_array[index].mask2)) { | ||
926 | if ((strlen(client_debug_string) + | ||
927 | strlen(cdm_array[index].keyword) + 1) | ||
928 | < ORANGEFS_MAX_DEBUG_STRING_LEN - 2) { | ||
929 | strcat(client_debug_string, | ||
930 | cdm_array[index].keyword); | ||
931 | strcat(client_debug_string, ","); | ||
932 | } else { | ||
933 | gossip_err("%s: overflow!\n", __func__); | ||
934 | strcpy(client_debug_string, ORANGEFS_ALL); | ||
935 | goto out; | ||
936 | } | ||
937 | } | ||
938 | out: | ||
939 | return; | ||
940 | } | ||
941 | |||
942 | int keyword_is_amalgam(char *keyword) | ||
943 | { | ||
944 | int rc = 0; | ||
945 | |||
946 | if ((!strcmp(keyword, ORANGEFS_ALL)) || (!strcmp(keyword, ORANGEFS_VERBOSE))) | ||
947 | rc = 1; | ||
948 | |||
949 | return rc; | ||
950 | } | ||
951 | |||
952 | /* | ||
953 | * kernel = type 0 | ||
954 | * client = type 1 | ||
955 | * | ||
956 | * return 1 if we found an amalgam. | ||
957 | */ | ||
958 | int check_amalgam_keyword(void *mask, int type) | ||
959 | { | ||
960 | __u64 *k_mask; | ||
961 | struct client_debug_mask *c_mask; | ||
962 | int k_all_index = num_kmod_keyword_mask_map - 1; | ||
963 | int rc = 0; | ||
964 | |||
965 | if (type) { | ||
966 | c_mask = (struct client_debug_mask *) mask; | ||
967 | |||
968 | if ((c_mask->mask1 == cdm_array[client_all_index].mask1) && | ||
969 | (c_mask->mask2 == cdm_array[client_all_index].mask2)) { | ||
970 | strcpy(client_debug_string, ORANGEFS_ALL); | ||
971 | rc = 1; | ||
972 | goto out; | ||
973 | } | ||
974 | |||
975 | if ((c_mask->mask1 == cdm_array[client_verbose_index].mask1) && | ||
976 | (c_mask->mask2 == cdm_array[client_verbose_index].mask2)) { | ||
977 | strcpy(client_debug_string, ORANGEFS_VERBOSE); | ||
978 | rc = 1; | ||
979 | goto out; | ||
980 | } | ||
981 | |||
982 | } else { | ||
983 | k_mask = (__u64 *) mask; | ||
984 | |||
985 | if (*k_mask >= s_kmod_keyword_mask_map[k_all_index].mask_val) { | ||
986 | strcpy(kernel_debug_string, ORANGEFS_ALL); | ||
987 | rc = 1; | ||
988 | goto out; | ||
989 | } | ||
990 | } | ||
991 | |||
992 | out: | ||
993 | |||
994 | return rc; | ||
995 | } | ||
996 | |||
997 | /* | ||
998 | * kernel = type 0 | ||
999 | * client = type 1 | ||
1000 | */ | ||
1001 | void debug_string_to_mask(char *debug_string, void *mask, int type) | ||
1002 | { | ||
1003 | char *unchecked_keyword; | ||
1004 | int i; | ||
1005 | char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL); | ||
1006 | char *original_pointer; | ||
1007 | int element_count = 0; | ||
1008 | struct client_debug_mask *c_mask; | ||
1009 | __u64 *k_mask; | ||
1010 | |||
1011 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); | ||
1012 | |||
1013 | if (type) { | ||
1014 | c_mask = (struct client_debug_mask *)mask; | ||
1015 | element_count = cdm_element_count; | ||
1016 | } else { | ||
1017 | k_mask = (__u64 *)mask; | ||
1018 | *k_mask = 0; | ||
1019 | element_count = num_kmod_keyword_mask_map; | ||
1020 | } | ||
1021 | |||
1022 | original_pointer = strsep_fodder; | ||
1023 | while ((unchecked_keyword = strsep(&strsep_fodder, ","))) | ||
1024 | if (strlen(unchecked_keyword)) { | ||
1025 | for (i = 0; i < element_count; i++) | ||
1026 | if (type) | ||
1027 | do_c_mask(i, | ||
1028 | unchecked_keyword, | ||
1029 | &c_mask); | ||
1030 | else | ||
1031 | do_k_mask(i, | ||
1032 | unchecked_keyword, | ||
1033 | &k_mask); | ||
1034 | } | ||
1035 | |||
1036 | kfree(original_pointer); | ||
1037 | } | ||
1038 | |||
1039 | void do_c_mask(int i, | ||
1040 | char *unchecked_keyword, | ||
1041 | struct client_debug_mask **sane_mask) | ||
1042 | { | ||
1043 | |||
1044 | if (!strcmp(cdm_array[i].keyword, unchecked_keyword)) { | ||
1045 | (**sane_mask).mask1 = (**sane_mask).mask1 | cdm_array[i].mask1; | ||
1046 | (**sane_mask).mask2 = (**sane_mask).mask2 | cdm_array[i].mask2; | ||
1047 | } | ||
1048 | } | ||
1049 | |||
1050 | void do_k_mask(int i, char *unchecked_keyword, __u64 **sane_mask) | ||
1051 | { | ||
1052 | |||
1053 | if (!strcmp(s_kmod_keyword_mask_map[i].keyword, unchecked_keyword)) | ||
1054 | **sane_mask = (**sane_mask) | | ||
1055 | s_kmod_keyword_mask_map[i].mask_val; | ||
1056 | } | ||
diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index 3d7418c728f5..971307ad69be 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h | |||
@@ -4,26 +4,6 @@ | |||
4 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
5 | #include <linux/ioctl.h> | 5 | #include <linux/ioctl.h> |
6 | 6 | ||
7 | extern struct client_debug_mask *cdm_array; | ||
8 | extern char *debug_help_string; | ||
9 | extern int help_string_initialized; | ||
10 | extern struct dentry *debug_dir; | ||
11 | extern struct dentry *help_file_dentry; | ||
12 | extern struct dentry *client_debug_dentry; | ||
13 | extern const struct file_operations debug_help_fops; | ||
14 | extern int client_all_index; | ||
15 | extern int client_verbose_index; | ||
16 | extern int cdm_element_count; | ||
17 | #define DEBUG_HELP_STRING_SIZE 4096 | ||
18 | #define HELP_STRING_UNINITIALIZED \ | ||
19 | "Client Debug Keywords are unknown until the first time\n" \ | ||
20 | "the client is started after boot.\n" | ||
21 | #define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help" | ||
22 | #define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug" | ||
23 | #define ORANGEFS_CLIENT_DEBUG_FILE "client-debug" | ||
24 | #define ORANGEFS_VERBOSE "verbose" | ||
25 | #define ORANGEFS_ALL "all" | ||
26 | |||
27 | /* pvfs2-config.h ***********************************************************/ | 7 | /* pvfs2-config.h ***********************************************************/ |
28 | #define ORANGEFS_VERSION_MAJOR 2 | 8 | #define ORANGEFS_VERSION_MAJOR 2 |
29 | #define ORANGEFS_VERSION_MINOR 9 | 9 | #define ORANGEFS_VERSION_MINOR 9 |
@@ -426,13 +406,12 @@ do { \ | |||
426 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ | 406 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ |
427 | } while (0) | 407 | } while (0) |
428 | #else | 408 | #else |
429 | extern __u64 gossip_debug_mask; | 409 | extern __u64 orangefs_gossip_debug_mask; |
430 | extern struct client_debug_mask client_debug_mask; | ||
431 | 410 | ||
432 | /* try to avoid function call overhead by checking masks in macro */ | 411 | /* try to avoid function call overhead by checking masks in macro */ |
433 | #define gossip_debug(mask, fmt, ...) \ | 412 | #define gossip_debug(mask, fmt, ...) \ |
434 | do { \ | 413 | do { \ |
435 | if (gossip_debug_mask & (mask)) \ | 414 | if (orangefs_gossip_debug_mask & (mask)) \ |
436 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ | 415 | printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ |
437 | } while (0) | 416 | } while (0) |
438 | #endif /* GOSSIP_DISABLE_DEBUG */ | 417 | #endif /* GOSSIP_DISABLE_DEBUG */ |
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index b4ab1c1e8278..166f3a59d2e4 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c | |||
@@ -557,8 +557,8 @@ void orangefs_kill_sb(struct super_block *sb) | |||
557 | * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us | 557 | * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us |
558 | * gets completed before we free the dang thing. | 558 | * gets completed before we free the dang thing. |
559 | */ | 559 | */ |
560 | mutex_lock(&request_mutex); | 560 | mutex_lock(&orangefs_request_mutex); |
561 | mutex_unlock(&request_mutex); | 561 | mutex_unlock(&orangefs_request_mutex); |
562 | 562 | ||
563 | /* free the orangefs superblock private data */ | 563 | /* free the orangefs superblock private data */ |
564 | kfree(ORANGEFS_SB(sb)); | 564 | kfree(ORANGEFS_SB(sb)); |
diff --git a/fs/orangefs/waitqueue.c b/fs/orangefs/waitqueue.c index 31635bc303fe..abcfa3fa9992 100644 --- a/fs/orangefs/waitqueue.c +++ b/fs/orangefs/waitqueue.c | |||
@@ -87,9 +87,9 @@ retry_servicing: | |||
87 | */ | 87 | */ |
88 | if (!(flags & ORANGEFS_OP_NO_MUTEX)) { | 88 | if (!(flags & ORANGEFS_OP_NO_MUTEX)) { |
89 | if (flags & ORANGEFS_OP_INTERRUPTIBLE) | 89 | if (flags & ORANGEFS_OP_INTERRUPTIBLE) |
90 | ret = mutex_lock_interruptible(&request_mutex); | 90 | ret = mutex_lock_interruptible(&orangefs_request_mutex); |
91 | else | 91 | else |
92 | ret = mutex_lock_killable(&request_mutex); | 92 | ret = mutex_lock_killable(&orangefs_request_mutex); |
93 | /* | 93 | /* |
94 | * check to see if we were interrupted while waiting for | 94 | * check to see if we were interrupted while waiting for |
95 | * mutex | 95 | * mutex |
@@ -129,7 +129,7 @@ retry_servicing: | |||
129 | spin_unlock(&orangefs_request_list_lock); | 129 | spin_unlock(&orangefs_request_list_lock); |
130 | 130 | ||
131 | if (!(flags & ORANGEFS_OP_NO_MUTEX)) | 131 | if (!(flags & ORANGEFS_OP_NO_MUTEX)) |
132 | mutex_unlock(&request_mutex); | 132 | mutex_unlock(&orangefs_request_mutex); |
133 | 133 | ||
134 | ret = wait_for_matching_downcall(op, timeout, | 134 | ret = wait_for_matching_downcall(op, timeout, |
135 | flags & ORANGEFS_OP_INTERRUPTIBLE); | 135 | flags & ORANGEFS_OP_INTERRUPTIBLE); |
@@ -272,9 +272,9 @@ static void | |||
272 | } else if (op_state_in_progress(op)) { | 272 | } else if (op_state_in_progress(op)) { |
273 | /* op must be removed from the in progress htable */ | 273 | /* op must be removed from the in progress htable */ |
274 | spin_unlock(&op->lock); | 274 | spin_unlock(&op->lock); |
275 | spin_lock(&htable_ops_in_progress_lock); | 275 | spin_lock(&orangefs_htable_ops_in_progress_lock); |
276 | list_del_init(&op->list); | 276 | list_del_init(&op->list); |
277 | spin_unlock(&htable_ops_in_progress_lock); | 277 | spin_unlock(&orangefs_htable_ops_in_progress_lock); |
278 | gossip_debug(GOSSIP_WAIT_DEBUG, | 278 | gossip_debug(GOSSIP_WAIT_DEBUG, |
279 | "Interrupted: Removed op %p" | 279 | "Interrupted: Removed op %p" |
280 | " from htable_ops_in_progress\n", | 280 | " from htable_ops_in_progress\n", |