forked from Minki/linux
orangefs: miscellaneous improvements and feature negotiation
Two OrangeFS updates: "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" "Pull in an OrangeFS branch containing improvements which the userspace component and the kernel to negotiate mutually supported features." -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJX8pDdAAoJEPVzxHxs4+kh7nwP/3WGpkj6N2/v6QiCWM5srU5u IoTZ7ivr4eFc5CkmvrpznH5B4kvLWqJxuuECACYrFX95FTGFovE+OLHsNP+OG48V nCdjsWxNSzvY/yTvABDCNFzs/O+oh3Zc8L0NvsMJY4EtsRg2rCWwOOffO8vOTtOp t8u+CED1Jiz4ARdyPL63uCsP+2u1SBlKFyTdkmUTjlbw2e0g1JgbFHe8Y23a6F9S z5c+IKuzISXGDMt0h6pknoAPlHk2OikNv96Sm9ONOVgmp3I/BeM006FkPMM5eDa1 gV7awrCHYrFT/2jxNgnzXEYYQlJo1UDfkIDFLVT90yiH9IOdFSBC1GacoypL1r82 FEAcGhvJ4GnH+r0UASPfwdxU7Nmfh3TIGa50CSo/ycOobvZ9tQFCXgQs8lPTXG+Z ifjB8pbw97Z/oN4Z8ts+yFJMZo/6pa244YSla4CYP4+huoRtkX6S78EhLNqFkGW0 VZG3nEwlMKuyb5B9eKVmV8UQLjt6GG4LJwrRdW9je+fyLvpBVFURUEvg9BySTT/c 5kRpSCfY9KCQPdJlo+w+yhWt5I7p65b1TPbjAjvLJ0uoqWoN8bz+z/U95hAZZjTG MvWyYofi59561F9FxlIKHYv8OeGpEvFeMdbjDEl6c2Rp0eOJgmlsFbPHOC1BBI8t xxbqZrlLutCEyBbixndp =dINE -----END PGP SIGNATURE----- Merge tag 'for-hubcap-v4.9-more' into for-next orangefs: miscellaneous improvements and feature negotiation Two OrangeFS updates: "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" "Pull in an OrangeFS branch containing improvements which the userspace component and the kernel to negotiate mutually supported features."
This commit is contained in:
commit
5891b4fe63
@ -73,7 +73,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
|
||||
}
|
||||
}
|
||||
|
||||
dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
|
||||
dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
|
||||
ret = 1;
|
||||
out_release_op:
|
||||
op_release(new_op);
|
||||
|
@ -11,14 +11,19 @@
|
||||
#include "orangefs-kernel.h"
|
||||
#include "orangefs-dev-proto.h"
|
||||
#include "orangefs-bufmap.h"
|
||||
#include "orangefs-debugfs.h"
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
/* this file implements the /dev/pvfs2-req device node */
|
||||
|
||||
uint32_t orangefs_userspace_version;
|
||||
|
||||
static int open_access_count;
|
||||
|
||||
static DEFINE_MUTEX(devreq_mutex);
|
||||
|
||||
#define DUMP_DEVICE_ERROR() \
|
||||
do { \
|
||||
gossip_err("*****************************************************\n");\
|
||||
@ -43,7 +48,7 @@ static void orangefs_devreq_add_op(struct orangefs_kernel_op_s *op)
|
||||
{
|
||||
int index = hash_func(op->tag, hash_table_size);
|
||||
|
||||
list_add_tail(&op->list, &htable_ops_in_progress[index]);
|
||||
list_add_tail(&op->list, &orangefs_htable_ops_in_progress[index]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -57,20 +62,20 @@ static struct orangefs_kernel_op_s *orangefs_devreq_remove_op(__u64 tag)
|
||||
|
||||
index = hash_func(tag, hash_table_size);
|
||||
|
||||
spin_lock(&htable_ops_in_progress_lock);
|
||||
spin_lock(&orangefs_htable_ops_in_progress_lock);
|
||||
list_for_each_entry_safe(op,
|
||||
next,
|
||||
&htable_ops_in_progress[index],
|
||||
&orangefs_htable_ops_in_progress[index],
|
||||
list) {
|
||||
if (op->tag == tag && !op_state_purged(op) &&
|
||||
!op_state_given_up(op)) {
|
||||
list_del_init(&op->list);
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -276,11 +281,11 @@ restart:
|
||||
if (ret != 0)
|
||||
goto error;
|
||||
|
||||
spin_lock(&htable_ops_in_progress_lock);
|
||||
spin_lock(&orangefs_htable_ops_in_progress_lock);
|
||||
spin_lock(&cur_op->lock);
|
||||
if (unlikely(op_state_given_up(cur_op))) {
|
||||
spin_unlock(&cur_op->lock);
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
complete(&cur_op->waitq);
|
||||
goto restart;
|
||||
}
|
||||
@ -298,7 +303,7 @@ restart:
|
||||
current->comm);
|
||||
orangefs_devreq_add_op(cur_op);
|
||||
spin_unlock(&cur_op->lock);
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
|
||||
/* The client only asks to read one size buffer. */
|
||||
return MAX_DEV_REQ_UPSIZE;
|
||||
@ -387,6 +392,13 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
if (!orangefs_userspace_version) {
|
||||
orangefs_userspace_version = head.version;
|
||||
} else if (orangefs_userspace_version != head.version) {
|
||||
gossip_err("Error: userspace version changes\n");
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
/* remove the op from the in progress hash table */
|
||||
op = orangefs_devreq_remove_op(head.tag);
|
||||
if (!op) {
|
||||
@ -527,6 +539,7 @@ static int orangefs_devreq_release(struct inode *inode, struct file *file)
|
||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||
"pvfs2-client-core: device close complete\n");
|
||||
open_access_count = 0;
|
||||
orangefs_userspace_version = 0;
|
||||
mutex_unlock(&devreq_mutex);
|
||||
return 0;
|
||||
}
|
||||
@ -576,8 +589,6 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
|
||||
static __s32 max_down_size = MAX_DEV_REQ_DOWNSIZE;
|
||||
struct ORANGEFS_dev_map_desc user_desc;
|
||||
int ret = 0;
|
||||
struct dev_mask_info_s mask_info = { 0 };
|
||||
struct dev_mask2_info_s mask2_info = { 0, 0 };
|
||||
int upstream_kmod = 1;
|
||||
struct orangefs_sb_info_s *orangefs_sb;
|
||||
|
||||
@ -619,7 +630,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
|
||||
* all of the remounts are serviced (to avoid ops between
|
||||
* mounts to fail)
|
||||
*/
|
||||
ret = mutex_lock_interruptible(&request_mutex);
|
||||
ret = mutex_lock_interruptible(&orangefs_request_mutex);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||
@ -654,7 +665,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
|
||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||
"%s: priority remount complete\n",
|
||||
__func__);
|
||||
mutex_unlock(&request_mutex);
|
||||
mutex_unlock(&orangefs_request_mutex);
|
||||
return ret;
|
||||
|
||||
case ORANGEFS_DEV_UPSTREAM:
|
||||
@ -668,134 +679,11 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
|
||||
return ret;
|
||||
|
||||
case ORANGEFS_DEV_CLIENT_MASK:
|
||||
ret = copy_from_user(&mask2_info,
|
||||
(void __user *)arg,
|
||||
sizeof(struct dev_mask2_info_s));
|
||||
|
||||
if (ret != 0)
|
||||
return -EIO;
|
||||
|
||||
client_debug_mask.mask1 = mask2_info.mask1_value;
|
||||
client_debug_mask.mask2 = mask2_info.mask2_value;
|
||||
|
||||
pr_info("%s: client debug mask has been been received "
|
||||
":%llx: :%llx:\n",
|
||||
__func__,
|
||||
(unsigned long long)client_debug_mask.mask1,
|
||||
(unsigned long long)client_debug_mask.mask2);
|
||||
|
||||
return ret;
|
||||
|
||||
return orangefs_debugfs_new_client_mask((void __user *)arg);
|
||||
case ORANGEFS_DEV_CLIENT_STRING:
|
||||
ret = copy_from_user(&client_debug_array_string,
|
||||
(void __user *)arg,
|
||||
ORANGEFS_MAX_DEBUG_STRING_LEN);
|
||||
/*
|
||||
* The real client-core makes an effort to ensure
|
||||
* that actual strings that aren't too long to fit in
|
||||
* this buffer is what we get here. We're going to use
|
||||
* string functions on the stuff we got, so we'll make
|
||||
* this extra effort to try and keep from
|
||||
* flowing out of this buffer when we use the string
|
||||
* functions, even if somehow the stuff we end up
|
||||
* with here is garbage.
|
||||
*/
|
||||
client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] =
|
||||
'\0';
|
||||
|
||||
if (ret != 0) {
|
||||
pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
|
||||
__func__);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pr_info("%s: client debug array string has been received.\n",
|
||||
__func__);
|
||||
|
||||
if (!help_string_initialized) {
|
||||
|
||||
/* Free the "we don't know yet" default string... */
|
||||
kfree(debug_help_string);
|
||||
|
||||
/* build a proper debug help string */
|
||||
if (orangefs_prepare_debugfs_help_string(0)) {
|
||||
gossip_err("%s: no debug help string \n",
|
||||
__func__);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Replace the boilerplate boot-time debug-help file. */
|
||||
debugfs_remove(help_file_dentry);
|
||||
|
||||
help_file_dentry =
|
||||
debugfs_create_file(
|
||||
ORANGEFS_KMOD_DEBUG_HELP_FILE,
|
||||
0444,
|
||||
debug_dir,
|
||||
debug_help_string,
|
||||
&debug_help_fops);
|
||||
|
||||
if (!help_file_dentry) {
|
||||
gossip_err("%s: debugfs_create_file failed for"
|
||||
" :%s:!\n",
|
||||
__func__,
|
||||
ORANGEFS_KMOD_DEBUG_HELP_FILE);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
debug_mask_to_string(&client_debug_mask, 1);
|
||||
|
||||
debugfs_remove(client_debug_dentry);
|
||||
|
||||
orangefs_client_debug_init();
|
||||
|
||||
help_string_initialized++;
|
||||
|
||||
return ret;
|
||||
|
||||
return orangefs_debugfs_new_client_string((void __user *)arg);
|
||||
case ORANGEFS_DEV_DEBUG:
|
||||
ret = copy_from_user(&mask_info,
|
||||
(void __user *)arg,
|
||||
sizeof(mask_info));
|
||||
|
||||
if (ret != 0)
|
||||
return -EIO;
|
||||
|
||||
if (mask_info.mask_type == KERNEL_MASK) {
|
||||
if ((mask_info.mask_value == 0)
|
||||
&& (kernel_mask_set_mod_init)) {
|
||||
/*
|
||||
* the kernel debug mask was set when the
|
||||
* kernel module was loaded; don't override
|
||||
* it if the client-core was started without
|
||||
* a value for ORANGEFS_KMODMASK.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
debug_mask_to_string(&mask_info.mask_value,
|
||||
mask_info.mask_type);
|
||||
gossip_debug_mask = mask_info.mask_value;
|
||||
pr_info("%s: kernel debug mask has been modified to "
|
||||
":%s: :%llx:\n",
|
||||
__func__,
|
||||
kernel_debug_string,
|
||||
(unsigned long long)gossip_debug_mask);
|
||||
} else if (mask_info.mask_type == CLIENT_MASK) {
|
||||
debug_mask_to_string(&mask_info.mask_value,
|
||||
mask_info.mask_type);
|
||||
pr_info("%s: client debug mask has been modified to"
|
||||
":%s: :%llx:\n",
|
||||
__func__,
|
||||
client_debug_string,
|
||||
llu(mask_info.mask_value));
|
||||
} else {
|
||||
gossip_lerr("Invalid mask type....\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
return orangefs_debugfs_new_debug((void __user *)arg);
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
@ -101,6 +101,11 @@ struct orangefs_fs_key_response {
|
||||
char fs_key[FS_KEY_BUF_SIZE];
|
||||
};
|
||||
|
||||
/* 2.9.6 */
|
||||
struct orangefs_features_response {
|
||||
__u64 features;
|
||||
};
|
||||
|
||||
struct orangefs_downcall_s {
|
||||
__s32 type;
|
||||
__s32 status;
|
||||
@ -122,6 +127,7 @@ struct orangefs_downcall_s {
|
||||
struct orangefs_param_response param;
|
||||
struct orangefs_perf_count_response perf_count;
|
||||
struct orangefs_fs_key_response fs_key;
|
||||
struct orangefs_features_response features;
|
||||
} resp;
|
||||
};
|
||||
|
||||
|
@ -412,7 +412,7 @@ ssize_t orangefs_inode_read(struct inode *inode,
|
||||
size_t bufmap_size;
|
||||
ssize_t ret = -EINVAL;
|
||||
|
||||
g_orangefs_stats.reads++;
|
||||
orangefs_stats.reads++;
|
||||
|
||||
bufmap_size = orangefs_bufmap_size_query();
|
||||
if (count > bufmap_size) {
|
||||
@ -453,7 +453,7 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter
|
||||
|
||||
gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_read_iter\n");
|
||||
|
||||
g_orangefs_stats.reads++;
|
||||
orangefs_stats.reads++;
|
||||
|
||||
rc = do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter);
|
||||
iocb->ki_pos = pos;
|
||||
@ -514,7 +514,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
|
||||
}
|
||||
|
||||
iocb->ki_pos = pos;
|
||||
g_orangefs_stats.writes++;
|
||||
orangefs_stats.writes++;
|
||||
|
||||
out:
|
||||
|
||||
@ -624,11 +624,14 @@ static int orangefs_file_release(struct inode *inode, struct file *file)
|
||||
if (file->f_path.dentry->d_inode &&
|
||||
file->f_path.dentry->d_inode->i_mapping &&
|
||||
mapping_nrpages(&file->f_path.dentry->d_inode->i_data)) {
|
||||
gossip_debug(GOSSIP_INODE_DEBUG,
|
||||
"calling flush_racache on %pU\n",
|
||||
get_khandle_from_ino(inode));
|
||||
flush_racache(inode);
|
||||
gossip_debug(GOSSIP_INODE_DEBUG, "flush_racache finished\n");
|
||||
if (orangefs_features & ORANGEFS_FEATURE_READAHEAD) {
|
||||
gossip_debug(GOSSIP_INODE_DEBUG,
|
||||
"calling flush_racache on %pU\n",
|
||||
get_khandle_from_ino(inode));
|
||||
flush_racache(inode);
|
||||
gossip_debug(GOSSIP_INODE_DEBUG,
|
||||
"flush_racache finished\n");
|
||||
}
|
||||
truncate_inode_pages(file->f_path.dentry->d_inode->i_mapping,
|
||||
0);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ static int orangefs_create(struct inode *dir,
|
||||
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
|
||||
dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
|
||||
ORANGEFS_I(inode)->getattr_time = jiffies - 1;
|
||||
|
||||
gossip_debug(GOSSIP_NAME_DEBUG,
|
||||
@ -183,7 +183,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
|
||||
goto out;
|
||||
}
|
||||
|
||||
dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
|
||||
dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
|
||||
|
||||
inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
|
||||
if (IS_ERR(inode)) {
|
||||
@ -322,7 +322,7 @@ static int orangefs_symlink(struct inode *dir,
|
||||
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
|
||||
dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
|
||||
ORANGEFS_I(inode)->getattr_time = jiffies - 1;
|
||||
|
||||
gossip_debug(GOSSIP_NAME_DEBUG,
|
||||
@ -386,7 +386,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
|
||||
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
dentry->d_time = jiffies + dcache_timeout_msecs*HZ/1000;
|
||||
dentry->d_time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
|
||||
ORANGEFS_I(inode)->getattr_time = jiffies - 1;
|
||||
|
||||
gossip_debug(GOSSIP_NAME_DEBUG,
|
||||
|
@ -97,6 +97,8 @@ char *get_opname_string(struct orangefs_kernel_op_s *new_op)
|
||||
return "OP_FSYNC";
|
||||
else if (type == ORANGEFS_VFS_OP_FSKEY)
|
||||
return "OP_FSKEY";
|
||||
else if (type == ORANGEFS_VFS_OP_FEATURES)
|
||||
return "OP_FEATURES";
|
||||
}
|
||||
return "OP_UNKNOWN?";
|
||||
}
|
||||
|
@ -43,36 +43,35 @@
|
||||
#include "protocol.h"
|
||||
#include "orangefs-kernel.h"
|
||||
|
||||
static int orangefs_debug_disabled = 1;
|
||||
#define DEBUG_HELP_STRING_SIZE 4096
|
||||
#define HELP_STRING_UNINITIALIZED \
|
||||
"Client Debug Keywords are unknown until the first time\n" \
|
||||
"the client is started after boot.\n"
|
||||
#define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help"
|
||||
#define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug"
|
||||
#define ORANGEFS_CLIENT_DEBUG_FILE "client-debug"
|
||||
#define ORANGEFS_VERBOSE "verbose"
|
||||
#define ORANGEFS_ALL "all"
|
||||
|
||||
static int orangefs_debug_help_open(struct inode *, struct file *);
|
||||
|
||||
const struct file_operations debug_help_fops = {
|
||||
.open = orangefs_debug_help_open,
|
||||
.read = seq_read,
|
||||
.release = seq_release,
|
||||
.llseek = seq_lseek,
|
||||
/*
|
||||
* An array of client_debug_mask will be built to hold debug keyword/mask
|
||||
* values fetched from userspace.
|
||||
*/
|
||||
struct client_debug_mask {
|
||||
char *keyword;
|
||||
__u64 mask1;
|
||||
__u64 mask2;
|
||||
};
|
||||
|
||||
static int orangefs_kernel_debug_init(void);
|
||||
|
||||
static int orangefs_debug_help_open(struct inode *, struct file *);
|
||||
static void *help_start(struct seq_file *, loff_t *);
|
||||
static void *help_next(struct seq_file *, void *, loff_t *);
|
||||
static void help_stop(struct seq_file *, void *);
|
||||
static int help_show(struct seq_file *, void *);
|
||||
|
||||
static const struct seq_operations help_debug_ops = {
|
||||
.start = help_start,
|
||||
.next = help_next,
|
||||
.stop = help_stop,
|
||||
.show = help_show,
|
||||
};
|
||||
|
||||
/*
|
||||
* Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and
|
||||
* ORANGEFS_KMOD_DEBUG_FILE.
|
||||
*/
|
||||
static DEFINE_MUTEX(orangefs_debug_lock);
|
||||
|
||||
int orangefs_debug_open(struct inode *, struct file *);
|
||||
static int orangefs_debug_open(struct inode *, struct file *);
|
||||
|
||||
static ssize_t orangefs_debug_read(struct file *,
|
||||
char __user *,
|
||||
@ -84,6 +83,43 @@ static ssize_t orangefs_debug_write(struct file *,
|
||||
size_t,
|
||||
loff_t *);
|
||||
|
||||
static int orangefs_prepare_cdm_array(char *);
|
||||
static void debug_mask_to_string(void *, int);
|
||||
static void do_k_string(void *, int);
|
||||
static void do_c_string(void *, int);
|
||||
static int keyword_is_amalgam(char *);
|
||||
static int check_amalgam_keyword(void *, int);
|
||||
static void debug_string_to_mask(char *, void *, int);
|
||||
static void do_c_mask(int, char *, struct client_debug_mask **);
|
||||
static void do_k_mask(int, char *, __u64 **);
|
||||
|
||||
static char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN] = "none";
|
||||
static char *debug_help_string;
|
||||
static char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
static char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
|
||||
static struct dentry *help_file_dentry;
|
||||
static struct dentry *client_debug_dentry;
|
||||
static struct dentry *debug_dir;
|
||||
|
||||
static unsigned int kernel_mask_set_mod_init;
|
||||
static int orangefs_debug_disabled = 1;
|
||||
static int help_string_initialized;
|
||||
|
||||
static const struct seq_operations help_debug_ops = {
|
||||
.start = help_start,
|
||||
.next = help_next,
|
||||
.stop = help_stop,
|
||||
.show = help_show,
|
||||
};
|
||||
|
||||
const struct file_operations debug_help_fops = {
|
||||
.open = orangefs_debug_help_open,
|
||||
.read = seq_read,
|
||||
.release = seq_release,
|
||||
.llseek = seq_lseek,
|
||||
};
|
||||
|
||||
static const struct file_operations kernel_debug_fops = {
|
||||
.open = orangefs_debug_open,
|
||||
.read = orangefs_debug_read,
|
||||
@ -91,15 +127,55 @@ static const struct file_operations kernel_debug_fops = {
|
||||
.llseek = generic_file_llseek,
|
||||
};
|
||||
|
||||
static int client_all_index;
|
||||
static int client_verbose_index;
|
||||
|
||||
static struct client_debug_mask *cdm_array;
|
||||
static int cdm_element_count;
|
||||
|
||||
static struct client_debug_mask client_debug_mask;
|
||||
|
||||
/*
|
||||
* Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and
|
||||
* ORANGEFS_KMOD_DEBUG_FILE.
|
||||
*/
|
||||
static DEFINE_MUTEX(orangefs_debug_lock);
|
||||
|
||||
/*
|
||||
* initialize kmod debug operations, create orangefs debugfs dir and
|
||||
* ORANGEFS_KMOD_DEBUG_HELP_FILE.
|
||||
*/
|
||||
int orangefs_debugfs_init(void)
|
||||
int orangefs_debugfs_init(int debug_mask)
|
||||
{
|
||||
|
||||
int rc = -ENOMEM;
|
||||
|
||||
/* convert input debug mask to a 64-bit unsigned integer */
|
||||
orangefs_gossip_debug_mask = (unsigned long long)debug_mask;
|
||||
|
||||
/*
|
||||
* set the kernel's gossip debug string; invalid mask values will
|
||||
* be ignored.
|
||||
*/
|
||||
debug_mask_to_string(&orangefs_gossip_debug_mask, 0);
|
||||
|
||||
/* remove any invalid values from the mask */
|
||||
debug_string_to_mask(kernel_debug_string, &orangefs_gossip_debug_mask,
|
||||
0);
|
||||
|
||||
/*
|
||||
* if the mask has a non-zero value, then indicate that the mask
|
||||
* was set when the kernel module was loaded. The orangefs dev ioctl
|
||||
* command will look at this boolean to determine if the kernel's
|
||||
* debug mask should be overwritten when the client-core is started.
|
||||
*/
|
||||
if (orangefs_gossip_debug_mask != 0)
|
||||
kernel_mask_set_mod_init = true;
|
||||
|
||||
pr_info("%s: called with debug mask: :%s: :%llx:\n",
|
||||
__func__,
|
||||
kernel_debug_string,
|
||||
(unsigned long long)orangefs_gossip_debug_mask);
|
||||
|
||||
debug_dir = debugfs_create_dir("orangefs", NULL);
|
||||
if (!debug_dir) {
|
||||
pr_info("%s: debugfs_create_dir failed.\n", __func__);
|
||||
@ -117,13 +193,58 @@ int orangefs_debugfs_init(void)
|
||||
}
|
||||
|
||||
orangefs_debug_disabled = 0;
|
||||
rc = 0;
|
||||
|
||||
rc = orangefs_kernel_debug_init();
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize the kernel-debug file.
|
||||
*/
|
||||
static int orangefs_kernel_debug_init(void)
|
||||
{
|
||||
int rc = -ENOMEM;
|
||||
struct dentry *ret;
|
||||
char *k_buffer = NULL;
|
||||
|
||||
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
|
||||
if (!k_buffer)
|
||||
goto out;
|
||||
|
||||
if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
|
||||
strcpy(k_buffer, kernel_debug_string);
|
||||
strcat(k_buffer, "\n");
|
||||
} else {
|
||||
strcpy(k_buffer, "none\n");
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
}
|
||||
|
||||
ret = debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE,
|
||||
0444,
|
||||
debug_dir,
|
||||
k_buffer,
|
||||
&kernel_debug_fops);
|
||||
if (!ret) {
|
||||
pr_info("%s: failed to create %s.\n",
|
||||
__func__,
|
||||
ORANGEFS_KMOD_DEBUG_FILE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
|
||||
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void orangefs_debugfs_cleanup(void)
|
||||
{
|
||||
debugfs_remove_recursive(debug_dir);
|
||||
@ -195,49 +316,6 @@ static int help_show(struct seq_file *m, void *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize the kernel-debug file.
|
||||
*/
|
||||
int orangefs_kernel_debug_init(void)
|
||||
{
|
||||
int rc = -ENOMEM;
|
||||
struct dentry *ret;
|
||||
char *k_buffer = NULL;
|
||||
|
||||
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
|
||||
if (!k_buffer)
|
||||
goto out;
|
||||
|
||||
if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
|
||||
strcpy(k_buffer, kernel_debug_string);
|
||||
strcat(k_buffer, "\n");
|
||||
} else {
|
||||
strcpy(k_buffer, "none\n");
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
}
|
||||
|
||||
ret = debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE,
|
||||
0444,
|
||||
debug_dir,
|
||||
k_buffer,
|
||||
&kernel_debug_fops);
|
||||
if (!ret) {
|
||||
pr_info("%s: failed to create %s.\n",
|
||||
__func__,
|
||||
ORANGEFS_KMOD_DEBUG_FILE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
|
||||
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize the client-debug file.
|
||||
*/
|
||||
@ -282,7 +360,7 @@ out:
|
||||
}
|
||||
|
||||
/* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/
|
||||
int orangefs_debug_open(struct inode *inode, struct file *file)
|
||||
static int orangefs_debug_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int rc = -ENODEV;
|
||||
|
||||
@ -384,8 +462,8 @@ static ssize_t orangefs_debug_write(struct file *file,
|
||||
*/
|
||||
if (!strcmp(file->f_path.dentry->d_name.name,
|
||||
ORANGEFS_KMOD_DEBUG_FILE)) {
|
||||
debug_string_to_mask(buf, &gossip_debug_mask, 0);
|
||||
debug_mask_to_string(&gossip_debug_mask, 0);
|
||||
debug_string_to_mask(buf, &orangefs_gossip_debug_mask, 0);
|
||||
debug_mask_to_string(&orangefs_gossip_debug_mask, 0);
|
||||
debug_string = kernel_debug_string;
|
||||
gossip_debug(GOSSIP_DEBUGFS_DEBUG,
|
||||
"New kernel debug string is %s\n",
|
||||
@ -452,3 +530,546 @@ out:
|
||||
kfree(buf);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* After obtaining a string representation of the client's debug
|
||||
* keywords and their associated masks, this function is called to build an
|
||||
* array of these values.
|
||||
*/
|
||||
static int orangefs_prepare_cdm_array(char *debug_array_string)
|
||||
{
|
||||
int i;
|
||||
int rc = -EINVAL;
|
||||
char *cds_head = NULL;
|
||||
char *cds_delimiter = NULL;
|
||||
int keyword_len = 0;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
/*
|
||||
* figure out how many elements the cdm_array needs.
|
||||
*/
|
||||
for (i = 0; i < strlen(debug_array_string); i++)
|
||||
if (debug_array_string[i] == '\n')
|
||||
cdm_element_count++;
|
||||
|
||||
if (!cdm_element_count) {
|
||||
pr_info("No elements in client debug array string!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
cdm_array =
|
||||
kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
|
||||
GFP_KERNEL);
|
||||
if (!cdm_array) {
|
||||
pr_info("malloc failed for cdm_array!\n");
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
cds_head = debug_array_string;
|
||||
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
cds_delimiter = strchr(cds_head, '\n');
|
||||
*cds_delimiter = '\0';
|
||||
|
||||
keyword_len = strcspn(cds_head, " ");
|
||||
|
||||
cdm_array[i].keyword = kzalloc(keyword_len + 1, GFP_KERNEL);
|
||||
if (!cdm_array[i].keyword) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
sscanf(cds_head,
|
||||
"%s %llx %llx",
|
||||
cdm_array[i].keyword,
|
||||
(unsigned long long *)&(cdm_array[i].mask1),
|
||||
(unsigned long long *)&(cdm_array[i].mask2));
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, ORANGEFS_VERBOSE))
|
||||
client_verbose_index = i;
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, ORANGEFS_ALL))
|
||||
client_all_index = i;
|
||||
|
||||
cds_head = cds_delimiter + 1;
|
||||
}
|
||||
|
||||
rc = cdm_element_count;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: rc:%d:\n", __func__, rc);
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* /sys/kernel/debug/orangefs/debug-help can be catted to
|
||||
* see all the available kernel and client debug keywords.
|
||||
*
|
||||
* When the kernel boots, we have no idea what keywords the
|
||||
* client supports, nor their associated masks.
|
||||
*
|
||||
* We pass through this function once at boot and stamp a
|
||||
* boilerplate "we don't know" message for the client in the
|
||||
* debug-help file. We pass through here again when the client
|
||||
* starts and then we can fill out the debug-help file fully.
|
||||
*
|
||||
* The client might be restarted any number of times between
|
||||
* reboots, we only build the debug-help file the first time.
|
||||
*/
|
||||
int orangefs_prepare_debugfs_help_string(int at_boot)
|
||||
{
|
||||
int rc = -EINVAL;
|
||||
int i;
|
||||
int byte_count = 0;
|
||||
char *client_title = "Client Debug Keywords:\n";
|
||||
char *kernel_title = "Kernel Debug Keywords:\n";
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (at_boot) {
|
||||
byte_count += strlen(HELP_STRING_UNINITIALIZED);
|
||||
client_title = HELP_STRING_UNINITIALIZED;
|
||||
} else {
|
||||
/*
|
||||
* fill the client keyword/mask array and remember
|
||||
* how many elements there were.
|
||||
*/
|
||||
cdm_element_count =
|
||||
orangefs_prepare_cdm_array(client_debug_array_string);
|
||||
if (cdm_element_count <= 0)
|
||||
goto out;
|
||||
|
||||
/* Count the bytes destined for debug_help_string. */
|
||||
byte_count += strlen(client_title);
|
||||
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
byte_count += strlen(cdm_array[i].keyword + 2);
|
||||
if (byte_count >= DEBUG_HELP_STRING_SIZE) {
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG,
|
||||
"%s: cdm_element_count:%d:\n",
|
||||
__func__,
|
||||
cdm_element_count);
|
||||
}
|
||||
|
||||
byte_count += strlen(kernel_title);
|
||||
for (i = 0; i < num_kmod_keyword_mask_map; i++) {
|
||||
byte_count +=
|
||||
strlen(s_kmod_keyword_mask_map[i].keyword + 2);
|
||||
if (byte_count >= DEBUG_HELP_STRING_SIZE) {
|
||||
pr_info("%s: overflow 2!\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* build debug_help_string. */
|
||||
debug_help_string = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL);
|
||||
if (!debug_help_string) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
strcat(debug_help_string, client_title);
|
||||
|
||||
if (!at_boot) {
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
strcat(debug_help_string, "\t");
|
||||
strcat(debug_help_string, cdm_array[i].keyword);
|
||||
strcat(debug_help_string, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
strcat(debug_help_string, "\n");
|
||||
strcat(debug_help_string, kernel_title);
|
||||
|
||||
for (i = 0; i < num_kmod_keyword_mask_map; i++) {
|
||||
strcat(debug_help_string, "\t");
|
||||
strcat(debug_help_string, s_kmod_keyword_mask_map[i].keyword);
|
||||
strcat(debug_help_string, "\n");
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*/
|
||||
static void debug_mask_to_string(void *mask, int type)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
char *debug_string;
|
||||
int element_count = 0;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (type) {
|
||||
debug_string = client_debug_string;
|
||||
element_count = cdm_element_count;
|
||||
} else {
|
||||
debug_string = kernel_debug_string;
|
||||
element_count = num_kmod_keyword_mask_map;
|
||||
}
|
||||
|
||||
memset(debug_string, 0, ORANGEFS_MAX_DEBUG_STRING_LEN);
|
||||
|
||||
/*
|
||||
* Some keywords, like "all" or "verbose", are amalgams of
|
||||
* numerous other keywords. Make a special check for those
|
||||
* before grinding through the whole mask only to find out
|
||||
* later...
|
||||
*/
|
||||
if (check_amalgam_keyword(mask, type))
|
||||
goto out;
|
||||
|
||||
/* Build the debug string. */
|
||||
for (i = 0; i < element_count; i++)
|
||||
if (type)
|
||||
do_c_string(mask, i);
|
||||
else
|
||||
do_k_string(mask, i);
|
||||
|
||||
len = strlen(debug_string);
|
||||
|
||||
if ((len) && (type))
|
||||
client_debug_string[len - 1] = '\0';
|
||||
else if (len)
|
||||
kernel_debug_string[len - 1] = '\0';
|
||||
else if (type)
|
||||
strcpy(client_debug_string, "none");
|
||||
else
|
||||
strcpy(kernel_debug_string, "none");
|
||||
|
||||
out:
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_string);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void do_k_string(void *k_mask, int index)
|
||||
{
|
||||
__u64 *mask = (__u64 *) k_mask;
|
||||
|
||||
if (keyword_is_amalgam((char *) s_kmod_keyword_mask_map[index].keyword))
|
||||
goto out;
|
||||
|
||||
if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
|
||||
if ((strlen(kernel_debug_string) +
|
||||
strlen(s_kmod_keyword_mask_map[index].keyword))
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 1) {
|
||||
strcat(kernel_debug_string,
|
||||
s_kmod_keyword_mask_map[index].keyword);
|
||||
strcat(kernel_debug_string, ",");
|
||||
} else {
|
||||
gossip_err("%s: overflow!\n", __func__);
|
||||
strcpy(kernel_debug_string, ORANGEFS_ALL);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void do_c_string(void *c_mask, int index)
|
||||
{
|
||||
struct client_debug_mask *mask = (struct client_debug_mask *) c_mask;
|
||||
|
||||
if (keyword_is_amalgam(cdm_array[index].keyword))
|
||||
goto out;
|
||||
|
||||
if ((mask->mask1 & cdm_array[index].mask1) ||
|
||||
(mask->mask2 & cdm_array[index].mask2)) {
|
||||
if ((strlen(client_debug_string) +
|
||||
strlen(cdm_array[index].keyword) + 1)
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 2) {
|
||||
strcat(client_debug_string,
|
||||
cdm_array[index].keyword);
|
||||
strcat(client_debug_string, ",");
|
||||
} else {
|
||||
gossip_err("%s: overflow!\n", __func__);
|
||||
strcpy(client_debug_string, ORANGEFS_ALL);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
static int keyword_is_amalgam(char *keyword)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ((!strcmp(keyword, ORANGEFS_ALL)) || (!strcmp(keyword, ORANGEFS_VERBOSE)))
|
||||
rc = 1;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*
|
||||
* return 1 if we found an amalgam.
|
||||
*/
|
||||
static int check_amalgam_keyword(void *mask, int type)
|
||||
{
|
||||
__u64 *k_mask;
|
||||
struct client_debug_mask *c_mask;
|
||||
int k_all_index = num_kmod_keyword_mask_map - 1;
|
||||
int rc = 0;
|
||||
|
||||
if (type) {
|
||||
c_mask = (struct client_debug_mask *) mask;
|
||||
|
||||
if ((c_mask->mask1 == cdm_array[client_all_index].mask1) &&
|
||||
(c_mask->mask2 == cdm_array[client_all_index].mask2)) {
|
||||
strcpy(client_debug_string, ORANGEFS_ALL);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((c_mask->mask1 == cdm_array[client_verbose_index].mask1) &&
|
||||
(c_mask->mask2 == cdm_array[client_verbose_index].mask2)) {
|
||||
strcpy(client_debug_string, ORANGEFS_VERBOSE);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
} else {
|
||||
k_mask = (__u64 *) mask;
|
||||
|
||||
if (*k_mask >= s_kmod_keyword_mask_map[k_all_index].mask_val) {
|
||||
strcpy(kernel_debug_string, ORANGEFS_ALL);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*/
|
||||
static void debug_string_to_mask(char *debug_string, void *mask, int type)
|
||||
{
|
||||
char *unchecked_keyword;
|
||||
int i;
|
||||
char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
|
||||
char *original_pointer;
|
||||
int element_count = 0;
|
||||
struct client_debug_mask *c_mask = NULL;
|
||||
__u64 *k_mask = NULL;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (type) {
|
||||
c_mask = (struct client_debug_mask *)mask;
|
||||
element_count = cdm_element_count;
|
||||
} else {
|
||||
k_mask = (__u64 *)mask;
|
||||
*k_mask = 0;
|
||||
element_count = num_kmod_keyword_mask_map;
|
||||
}
|
||||
|
||||
original_pointer = strsep_fodder;
|
||||
while ((unchecked_keyword = strsep(&strsep_fodder, ",")))
|
||||
if (strlen(unchecked_keyword)) {
|
||||
for (i = 0; i < element_count; i++)
|
||||
if (type)
|
||||
do_c_mask(i,
|
||||
unchecked_keyword,
|
||||
&c_mask);
|
||||
else
|
||||
do_k_mask(i,
|
||||
unchecked_keyword,
|
||||
&k_mask);
|
||||
}
|
||||
|
||||
kfree(original_pointer);
|
||||
}
|
||||
|
||||
static void do_c_mask(int i, char *unchecked_keyword,
|
||||
struct client_debug_mask **sane_mask)
|
||||
{
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, unchecked_keyword)) {
|
||||
(**sane_mask).mask1 = (**sane_mask).mask1 | cdm_array[i].mask1;
|
||||
(**sane_mask).mask2 = (**sane_mask).mask2 | cdm_array[i].mask2;
|
||||
}
|
||||
}
|
||||
|
||||
static void do_k_mask(int i, char *unchecked_keyword, __u64 **sane_mask)
|
||||
{
|
||||
|
||||
if (!strcmp(s_kmod_keyword_mask_map[i].keyword, unchecked_keyword))
|
||||
**sane_mask = (**sane_mask) |
|
||||
s_kmod_keyword_mask_map[i].mask_val;
|
||||
}
|
||||
|
||||
int orangefs_debugfs_new_client_mask(void __user *arg)
|
||||
{
|
||||
struct dev_mask2_info_s mask2_info = {0};
|
||||
int ret;
|
||||
|
||||
ret = copy_from_user(&mask2_info,
|
||||
(void __user *)arg,
|
||||
sizeof(struct dev_mask2_info_s));
|
||||
|
||||
if (ret != 0)
|
||||
return -EIO;
|
||||
|
||||
client_debug_mask.mask1 = mask2_info.mask1_value;
|
||||
client_debug_mask.mask2 = mask2_info.mask2_value;
|
||||
|
||||
pr_info("%s: client debug mask has been been received "
|
||||
":%llx: :%llx:\n",
|
||||
__func__,
|
||||
(unsigned long long)client_debug_mask.mask1,
|
||||
(unsigned long long)client_debug_mask.mask2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int orangefs_debugfs_new_client_string(void __user *arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = copy_from_user(&client_debug_array_string,
|
||||
(void __user *)arg,
|
||||
ORANGEFS_MAX_DEBUG_STRING_LEN);
|
||||
if (ret != 0)
|
||||
return -EIO;
|
||||
|
||||
/*
|
||||
* The real client-core makes an effort to ensure
|
||||
* that actual strings that aren't too long to fit in
|
||||
* this buffer is what we get here. We're going to use
|
||||
* string functions on the stuff we got, so we'll make
|
||||
* this extra effort to try and keep from
|
||||
* flowing out of this buffer when we use the string
|
||||
* functions, even if somehow the stuff we end up
|
||||
* with here is garbage.
|
||||
*/
|
||||
client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] =
|
||||
'\0';
|
||||
|
||||
if (ret != 0) {
|
||||
pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
|
||||
__func__);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pr_info("%s: client debug array string has been received.\n",
|
||||
__func__);
|
||||
|
||||
if (!help_string_initialized) {
|
||||
|
||||
/* Free the "we don't know yet" default string... */
|
||||
kfree(debug_help_string);
|
||||
|
||||
/* build a proper debug help string */
|
||||
if (orangefs_prepare_debugfs_help_string(0)) {
|
||||
gossip_err("%s: no debug help string \n",
|
||||
__func__);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Replace the boilerplate boot-time debug-help file. */
|
||||
debugfs_remove(help_file_dentry);
|
||||
|
||||
help_file_dentry =
|
||||
debugfs_create_file(
|
||||
ORANGEFS_KMOD_DEBUG_HELP_FILE,
|
||||
0444,
|
||||
debug_dir,
|
||||
debug_help_string,
|
||||
&debug_help_fops);
|
||||
|
||||
if (!help_file_dentry) {
|
||||
gossip_err("%s: debugfs_create_file failed for"
|
||||
" :%s:!\n",
|
||||
__func__,
|
||||
ORANGEFS_KMOD_DEBUG_HELP_FILE);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
debug_mask_to_string(&client_debug_mask, 1);
|
||||
|
||||
debugfs_remove(client_debug_dentry);
|
||||
|
||||
orangefs_client_debug_init();
|
||||
|
||||
help_string_initialized++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int orangefs_debugfs_new_debug(void __user *arg)
|
||||
{
|
||||
struct dev_mask_info_s mask_info = {0};
|
||||
int ret;
|
||||
|
||||
ret = copy_from_user(&mask_info,
|
||||
(void __user *)arg,
|
||||
sizeof(mask_info));
|
||||
|
||||
if (ret != 0)
|
||||
return -EIO;
|
||||
|
||||
if (mask_info.mask_type == KERNEL_MASK) {
|
||||
if ((mask_info.mask_value == 0)
|
||||
&& (kernel_mask_set_mod_init)) {
|
||||
/*
|
||||
* the kernel debug mask was set when the
|
||||
* kernel module was loaded; don't override
|
||||
* it if the client-core was started without
|
||||
* a value for ORANGEFS_KMODMASK.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
debug_mask_to_string(&mask_info.mask_value,
|
||||
mask_info.mask_type);
|
||||
orangefs_gossip_debug_mask = mask_info.mask_value;
|
||||
pr_info("%s: kernel debug mask has been modified to "
|
||||
":%s: :%llx:\n",
|
||||
__func__,
|
||||
kernel_debug_string,
|
||||
(unsigned long long)orangefs_gossip_debug_mask);
|
||||
} else if (mask_info.mask_type == CLIENT_MASK) {
|
||||
debug_mask_to_string(&mask_info.mask_value,
|
||||
mask_info.mask_type);
|
||||
pr_info("%s: client debug mask has been modified to"
|
||||
":%s: :%llx:\n",
|
||||
__func__,
|
||||
client_debug_string,
|
||||
llu(mask_info.mask_value));
|
||||
} else {
|
||||
gossip_lerr("Invalid mask type....\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
int orangefs_debugfs_init(void);
|
||||
int orangefs_kernel_debug_init(void);
|
||||
int orangefs_debugfs_init(int);
|
||||
void orangefs_debugfs_cleanup(void);
|
||||
int orangefs_client_debug_init(void);
|
||||
int orangefs_prepare_debugfs_help_string(int);
|
||||
int orangefs_debugfs_new_client_mask(void __user *);
|
||||
int orangefs_debugfs_new_client_string(void __user *);
|
||||
int orangefs_debugfs_new_debug(void __user *);
|
||||
|
@ -41,6 +41,10 @@
|
||||
#define ORANGEFS_VFS_OP_FSYNC 0xFF00EE01
|
||||
#define ORANGEFS_VFS_OP_FSKEY 0xFF00EE02
|
||||
#define ORANGEFS_VFS_OP_READDIRPLUS 0xFF00EE03
|
||||
#define ORANGEFS_VFS_OP_FEATURES 0xFF00EE05 /* 2.9.6 */
|
||||
|
||||
/* features is a 64-bit unsigned bitmask */
|
||||
#define ORANGEFS_FEATURE_READAHEAD 1
|
||||
|
||||
/*
|
||||
* Misc constants. Please retain them as multiples of 8!
|
||||
|
@ -99,16 +99,6 @@ enum orangefs_vfs_op_states {
|
||||
OP_VFS_STATE_GIVEN_UP = 16,
|
||||
};
|
||||
|
||||
/*
|
||||
* An array of client_debug_mask will be built to hold debug keyword/mask
|
||||
* values fetched from userspace.
|
||||
*/
|
||||
struct client_debug_mask {
|
||||
char *keyword;
|
||||
__u64 mask1;
|
||||
__u64 mask2;
|
||||
};
|
||||
|
||||
/*
|
||||
* orangefs kernel memory related flags
|
||||
*/
|
||||
@ -119,29 +109,6 @@ struct client_debug_mask {
|
||||
#define ORANGEFS_CACHE_CREATE_FLAGS 0
|
||||
#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
|
||||
|
||||
/* these functions are defined in orangefs-utils.c */
|
||||
int orangefs_prepare_cdm_array(char *debug_array_string);
|
||||
int orangefs_prepare_debugfs_help_string(int);
|
||||
|
||||
/* defined in orangefs-debugfs.c */
|
||||
int orangefs_client_debug_init(void);
|
||||
|
||||
void debug_string_to_mask(char *, void *, int);
|
||||
void do_c_mask(int, char *, struct client_debug_mask **);
|
||||
void do_k_mask(int, char *, __u64 **);
|
||||
|
||||
void debug_mask_to_string(void *, int);
|
||||
void do_k_string(void *, int);
|
||||
void do_c_string(void *, int);
|
||||
int check_amalgam_keyword(void *, int);
|
||||
int keyword_is_amalgam(char *);
|
||||
|
||||
/*these variables are defined in orangefs-mod.c */
|
||||
extern char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
extern char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
extern char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
extern unsigned int kernel_mask_set_mod_init;
|
||||
|
||||
extern int orangefs_init_acl(struct inode *inode, struct inode *dir);
|
||||
extern const struct xattr_handler *orangefs_xattr_handlers[];
|
||||
|
||||
@ -331,7 +298,7 @@ struct orangefs_stats {
|
||||
unsigned long writes;
|
||||
};
|
||||
|
||||
extern struct orangefs_stats g_orangefs_stats;
|
||||
extern struct orangefs_stats orangefs_stats;
|
||||
|
||||
/*
|
||||
* NOTE: See Documentation/filesystems/porting for information
|
||||
@ -447,6 +414,8 @@ void purge_waiting_ops(void);
|
||||
/*
|
||||
* defined in super.c
|
||||
*/
|
||||
extern uint64_t orangefs_features;
|
||||
|
||||
struct dentry *orangefs_mount(struct file_system_type *fst,
|
||||
int flags,
|
||||
const char *devname,
|
||||
@ -506,6 +475,8 @@ ssize_t orangefs_inode_read(struct inode *inode,
|
||||
/*
|
||||
* defined in devorangefs-req.c
|
||||
*/
|
||||
extern uint32_t orangefs_userspace_version;
|
||||
|
||||
int orangefs_dev_init(void);
|
||||
void orangefs_dev_cleanup(void);
|
||||
int is_daemon_in_service(void);
|
||||
@ -543,20 +514,18 @@ bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
|
||||
|
||||
int orangefs_normalize_to_errno(__s32 error_code);
|
||||
|
||||
extern struct mutex devreq_mutex;
|
||||
extern struct mutex request_mutex;
|
||||
extern int debug;
|
||||
extern struct mutex orangefs_request_mutex;
|
||||
extern int op_timeout_secs;
|
||||
extern int slot_timeout_secs;
|
||||
extern int dcache_timeout_msecs;
|
||||
extern int getattr_timeout_msecs;
|
||||
extern int orangefs_dcache_timeout_msecs;
|
||||
extern int orangefs_getattr_timeout_msecs;
|
||||
extern struct list_head orangefs_superblocks;
|
||||
extern spinlock_t orangefs_superblocks_lock;
|
||||
extern struct list_head orangefs_request_list;
|
||||
extern spinlock_t orangefs_request_list_lock;
|
||||
extern wait_queue_head_t orangefs_request_list_waitq;
|
||||
extern struct list_head *htable_ops_in_progress;
|
||||
extern spinlock_t htable_ops_in_progress_lock;
|
||||
extern struct list_head *orangefs_htable_ops_in_progress;
|
||||
extern spinlock_t orangefs_htable_ops_in_progress_lock;
|
||||
extern int hash_table_size;
|
||||
|
||||
extern const struct address_space_operations orangefs_address_operations;
|
||||
|
@ -21,34 +21,17 @@
|
||||
* global variables declared here
|
||||
*/
|
||||
|
||||
/* array of client debug keyword/mask values */
|
||||
struct client_debug_mask *cdm_array;
|
||||
int cdm_element_count;
|
||||
|
||||
char kernel_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN] = "none";
|
||||
char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN];
|
||||
|
||||
char *debug_help_string;
|
||||
int help_string_initialized;
|
||||
struct dentry *help_file_dentry;
|
||||
struct dentry *client_debug_dentry;
|
||||
struct dentry *debug_dir;
|
||||
int client_verbose_index;
|
||||
int client_all_index;
|
||||
struct orangefs_stats g_orangefs_stats;
|
||||
struct orangefs_stats orangefs_stats;
|
||||
|
||||
/* the size of the hash tables for ops in progress */
|
||||
int hash_table_size = 509;
|
||||
|
||||
static ulong module_parm_debug_mask;
|
||||
__u64 gossip_debug_mask;
|
||||
struct client_debug_mask client_debug_mask = { NULL, 0, 0 };
|
||||
unsigned int kernel_mask_set_mod_init; /* implicitly false */
|
||||
__u64 orangefs_gossip_debug_mask;
|
||||
int op_timeout_secs = ORANGEFS_DEFAULT_OP_TIMEOUT_SECS;
|
||||
int slot_timeout_secs = ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS;
|
||||
int dcache_timeout_msecs = 50;
|
||||
int getattr_timeout_msecs = 50;
|
||||
int orangefs_dcache_timeout_msecs = 50;
|
||||
int orangefs_getattr_timeout_msecs = 50;
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("ORANGEFS Development Team");
|
||||
@ -71,20 +54,17 @@ module_param(module_parm_debug_mask, ulong, 0644);
|
||||
module_param(op_timeout_secs, int, 0);
|
||||
module_param(slot_timeout_secs, int, 0);
|
||||
|
||||
/* synchronizes the request device file */
|
||||
DEFINE_MUTEX(devreq_mutex);
|
||||
|
||||
/*
|
||||
* Blocks non-priority requests from being queued for servicing. This
|
||||
* could be used for protecting the request list data structure, but
|
||||
* for now it's only being used to stall the op addition to the request
|
||||
* list
|
||||
*/
|
||||
DEFINE_MUTEX(request_mutex);
|
||||
DEFINE_MUTEX(orangefs_request_mutex);
|
||||
|
||||
/* hash table for storing operations waiting for matching downcall */
|
||||
struct list_head *htable_ops_in_progress;
|
||||
DEFINE_SPINLOCK(htable_ops_in_progress_lock);
|
||||
struct list_head *orangefs_htable_ops_in_progress;
|
||||
DEFINE_SPINLOCK(orangefs_htable_ops_in_progress_lock);
|
||||
|
||||
/* list for queueing upcall operations */
|
||||
LIST_HEAD(orangefs_request_list);
|
||||
@ -100,32 +80,6 @@ static int __init orangefs_init(void)
|
||||
int ret = -1;
|
||||
__u32 i = 0;
|
||||
|
||||
/* convert input debug mask to a 64-bit unsigned integer */
|
||||
gossip_debug_mask = (unsigned long long) module_parm_debug_mask;
|
||||
|
||||
/*
|
||||
* set the kernel's gossip debug string; invalid mask values will
|
||||
* be ignored.
|
||||
*/
|
||||
debug_mask_to_string(&gossip_debug_mask, 0);
|
||||
|
||||
/* remove any invalid values from the mask */
|
||||
debug_string_to_mask(kernel_debug_string, &gossip_debug_mask, 0);
|
||||
|
||||
/*
|
||||
* if the mask has a non-zero value, then indicate that the mask
|
||||
* was set when the kernel module was loaded. The orangefs dev ioctl
|
||||
* command will look at this boolean to determine if the kernel's
|
||||
* debug mask should be overwritten when the client-core is started.
|
||||
*/
|
||||
if (gossip_debug_mask != 0)
|
||||
kernel_mask_set_mod_init = true;
|
||||
|
||||
pr_info("%s: called with debug mask: :%s: :%llx:\n",
|
||||
__func__,
|
||||
kernel_debug_string,
|
||||
(unsigned long long)gossip_debug_mask);
|
||||
|
||||
ret = bdi_init(&orangefs_backing_dev_info);
|
||||
|
||||
if (ret)
|
||||
@ -146,9 +100,9 @@ static int __init orangefs_init(void)
|
||||
if (ret < 0)
|
||||
goto cleanup_op;
|
||||
|
||||
htable_ops_in_progress =
|
||||
orangefs_htable_ops_in_progress =
|
||||
kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
|
||||
if (!htable_ops_in_progress) {
|
||||
if (!orangefs_htable_ops_in_progress) {
|
||||
gossip_err("Failed to initialize op hashtable");
|
||||
ret = -ENOMEM;
|
||||
goto cleanup_inode;
|
||||
@ -156,7 +110,7 @@ static int __init orangefs_init(void)
|
||||
|
||||
/* initialize a doubly linked at each hash table index */
|
||||
for (i = 0; i < hash_table_size; i++)
|
||||
INIT_LIST_HEAD(&htable_ops_in_progress[i]);
|
||||
INIT_LIST_HEAD(&orangefs_htable_ops_in_progress[i]);
|
||||
|
||||
ret = fsid_key_table_initialize();
|
||||
if (ret < 0)
|
||||
@ -179,14 +133,10 @@ static int __init orangefs_init(void)
|
||||
if (ret)
|
||||
goto cleanup_key_table;
|
||||
|
||||
ret = orangefs_debugfs_init();
|
||||
ret = orangefs_debugfs_init(module_parm_debug_mask);
|
||||
if (ret)
|
||||
goto debugfs_init_failed;
|
||||
|
||||
ret = orangefs_kernel_debug_init();
|
||||
if (ret)
|
||||
goto kernel_debug_init_failed;
|
||||
|
||||
ret = orangefs_sysfs_init();
|
||||
if (ret)
|
||||
goto sysfs_init_failed;
|
||||
@ -214,8 +164,6 @@ cleanup_device:
|
||||
|
||||
sysfs_init_failed:
|
||||
|
||||
kernel_debug_init_failed:
|
||||
|
||||
debugfs_init_failed:
|
||||
orangefs_debugfs_cleanup();
|
||||
|
||||
@ -223,7 +171,7 @@ cleanup_key_table:
|
||||
fsid_key_table_finalize();
|
||||
|
||||
cleanup_progress_table:
|
||||
kfree(htable_ops_in_progress);
|
||||
kfree(orangefs_htable_ops_in_progress);
|
||||
|
||||
cleanup_inode:
|
||||
orangefs_inode_cache_finalize();
|
||||
@ -250,12 +198,12 @@ static void __exit orangefs_exit(void)
|
||||
orangefs_dev_cleanup();
|
||||
BUG_ON(!list_empty(&orangefs_request_list));
|
||||
for (i = 0; i < hash_table_size; i++)
|
||||
BUG_ON(!list_empty(&htable_ops_in_progress[i]));
|
||||
BUG_ON(!list_empty(&orangefs_htable_ops_in_progress[i]));
|
||||
|
||||
orangefs_inode_cache_finalize();
|
||||
op_cache_finalize();
|
||||
|
||||
kfree(htable_ops_in_progress);
|
||||
kfree(orangefs_htable_ops_in_progress);
|
||||
|
||||
bdi_destroy(&orangefs_backing_dev_info);
|
||||
|
||||
@ -274,10 +222,10 @@ void purge_inprogress_ops(void)
|
||||
struct orangefs_kernel_op_s *op;
|
||||
struct orangefs_kernel_op_s *next;
|
||||
|
||||
spin_lock(&htable_ops_in_progress_lock);
|
||||
spin_lock(&orangefs_htable_ops_in_progress_lock);
|
||||
list_for_each_entry_safe(op,
|
||||
next,
|
||||
&htable_ops_in_progress[i],
|
||||
&orangefs_htable_ops_in_progress[i],
|
||||
list) {
|
||||
set_op_state_purged(op);
|
||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||
@ -287,7 +235,7 @@ void purge_inprogress_ops(void)
|
||||
op->op_state,
|
||||
current->comm);
|
||||
}
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -347,7 +347,8 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass)
|
||||
inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) |
|
||||
orangefs_inode_perms(&new_op->downcall.resp.getattr.attributes);
|
||||
|
||||
orangefs_inode->getattr_time = jiffies + getattr_timeout_msecs*HZ/1000;
|
||||
orangefs_inode->getattr_time = jiffies +
|
||||
orangefs_getattr_timeout_msecs*HZ/1000;
|
||||
ret = 0;
|
||||
out:
|
||||
op_release(new_op);
|
||||
@ -656,401 +657,3 @@ __s32 ORANGEFS_util_translate_mode(int mode)
|
||||
return ret;
|
||||
}
|
||||
#undef NUM_MODES
|
||||
|
||||
/*
|
||||
* After obtaining a string representation of the client's debug
|
||||
* keywords and their associated masks, this function is called to build an
|
||||
* array of these values.
|
||||
*/
|
||||
int orangefs_prepare_cdm_array(char *debug_array_string)
|
||||
{
|
||||
int i;
|
||||
int rc = -EINVAL;
|
||||
char *cds_head = NULL;
|
||||
char *cds_delimiter = NULL;
|
||||
int keyword_len = 0;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
/*
|
||||
* figure out how many elements the cdm_array needs.
|
||||
*/
|
||||
for (i = 0; i < strlen(debug_array_string); i++)
|
||||
if (debug_array_string[i] == '\n')
|
||||
cdm_element_count++;
|
||||
|
||||
if (!cdm_element_count) {
|
||||
pr_info("No elements in client debug array string!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
cdm_array =
|
||||
kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
|
||||
GFP_KERNEL);
|
||||
if (!cdm_array) {
|
||||
pr_info("malloc failed for cdm_array!\n");
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
cds_head = debug_array_string;
|
||||
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
cds_delimiter = strchr(cds_head, '\n');
|
||||
*cds_delimiter = '\0';
|
||||
|
||||
keyword_len = strcspn(cds_head, " ");
|
||||
|
||||
cdm_array[i].keyword = kzalloc(keyword_len + 1, GFP_KERNEL);
|
||||
if (!cdm_array[i].keyword) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
sscanf(cds_head,
|
||||
"%s %llx %llx",
|
||||
cdm_array[i].keyword,
|
||||
(unsigned long long *)&(cdm_array[i].mask1),
|
||||
(unsigned long long *)&(cdm_array[i].mask2));
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, ORANGEFS_VERBOSE))
|
||||
client_verbose_index = i;
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, ORANGEFS_ALL))
|
||||
client_all_index = i;
|
||||
|
||||
cds_head = cds_delimiter + 1;
|
||||
}
|
||||
|
||||
rc = cdm_element_count;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: rc:%d:\n", __func__, rc);
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* /sys/kernel/debug/orangefs/debug-help can be catted to
|
||||
* see all the available kernel and client debug keywords.
|
||||
*
|
||||
* When the kernel boots, we have no idea what keywords the
|
||||
* client supports, nor their associated masks.
|
||||
*
|
||||
* We pass through this function once at boot and stamp a
|
||||
* boilerplate "we don't know" message for the client in the
|
||||
* debug-help file. We pass through here again when the client
|
||||
* starts and then we can fill out the debug-help file fully.
|
||||
*
|
||||
* The client might be restarted any number of times between
|
||||
* reboots, we only build the debug-help file the first time.
|
||||
*/
|
||||
int orangefs_prepare_debugfs_help_string(int at_boot)
|
||||
{
|
||||
int rc = -EINVAL;
|
||||
int i;
|
||||
int byte_count = 0;
|
||||
char *client_title = "Client Debug Keywords:\n";
|
||||
char *kernel_title = "Kernel Debug Keywords:\n";
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (at_boot) {
|
||||
byte_count += strlen(HELP_STRING_UNINITIALIZED);
|
||||
client_title = HELP_STRING_UNINITIALIZED;
|
||||
} else {
|
||||
/*
|
||||
* fill the client keyword/mask array and remember
|
||||
* how many elements there were.
|
||||
*/
|
||||
cdm_element_count =
|
||||
orangefs_prepare_cdm_array(client_debug_array_string);
|
||||
if (cdm_element_count <= 0)
|
||||
goto out;
|
||||
|
||||
/* Count the bytes destined for debug_help_string. */
|
||||
byte_count += strlen(client_title);
|
||||
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
byte_count += strlen(cdm_array[i].keyword + 2);
|
||||
if (byte_count >= DEBUG_HELP_STRING_SIZE) {
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG,
|
||||
"%s: cdm_element_count:%d:\n",
|
||||
__func__,
|
||||
cdm_element_count);
|
||||
}
|
||||
|
||||
byte_count += strlen(kernel_title);
|
||||
for (i = 0; i < num_kmod_keyword_mask_map; i++) {
|
||||
byte_count +=
|
||||
strlen(s_kmod_keyword_mask_map[i].keyword + 2);
|
||||
if (byte_count >= DEBUG_HELP_STRING_SIZE) {
|
||||
pr_info("%s: overflow 2!\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* build debug_help_string. */
|
||||
debug_help_string = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL);
|
||||
if (!debug_help_string) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
strcat(debug_help_string, client_title);
|
||||
|
||||
if (!at_boot) {
|
||||
for (i = 0; i < cdm_element_count; i++) {
|
||||
strcat(debug_help_string, "\t");
|
||||
strcat(debug_help_string, cdm_array[i].keyword);
|
||||
strcat(debug_help_string, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
strcat(debug_help_string, "\n");
|
||||
strcat(debug_help_string, kernel_title);
|
||||
|
||||
for (i = 0; i < num_kmod_keyword_mask_map; i++) {
|
||||
strcat(debug_help_string, "\t");
|
||||
strcat(debug_help_string, s_kmod_keyword_mask_map[i].keyword);
|
||||
strcat(debug_help_string, "\n");
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*/
|
||||
void debug_mask_to_string(void *mask, int type)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
char *debug_string;
|
||||
int element_count = 0;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (type) {
|
||||
debug_string = client_debug_string;
|
||||
element_count = cdm_element_count;
|
||||
} else {
|
||||
debug_string = kernel_debug_string;
|
||||
element_count = num_kmod_keyword_mask_map;
|
||||
}
|
||||
|
||||
memset(debug_string, 0, ORANGEFS_MAX_DEBUG_STRING_LEN);
|
||||
|
||||
/*
|
||||
* Some keywords, like "all" or "verbose", are amalgams of
|
||||
* numerous other keywords. Make a special check for those
|
||||
* before grinding through the whole mask only to find out
|
||||
* later...
|
||||
*/
|
||||
if (check_amalgam_keyword(mask, type))
|
||||
goto out;
|
||||
|
||||
/* Build the debug string. */
|
||||
for (i = 0; i < element_count; i++)
|
||||
if (type)
|
||||
do_c_string(mask, i);
|
||||
else
|
||||
do_k_string(mask, i);
|
||||
|
||||
len = strlen(debug_string);
|
||||
|
||||
if ((len) && (type))
|
||||
client_debug_string[len - 1] = '\0';
|
||||
else if (len)
|
||||
kernel_debug_string[len - 1] = '\0';
|
||||
else if (type)
|
||||
strcpy(client_debug_string, "none");
|
||||
else
|
||||
strcpy(kernel_debug_string, "none");
|
||||
|
||||
out:
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_string);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void do_k_string(void *k_mask, int index)
|
||||
{
|
||||
__u64 *mask = (__u64 *) k_mask;
|
||||
|
||||
if (keyword_is_amalgam((char *) s_kmod_keyword_mask_map[index].keyword))
|
||||
goto out;
|
||||
|
||||
if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
|
||||
if ((strlen(kernel_debug_string) +
|
||||
strlen(s_kmod_keyword_mask_map[index].keyword))
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 1) {
|
||||
strcat(kernel_debug_string,
|
||||
s_kmod_keyword_mask_map[index].keyword);
|
||||
strcat(kernel_debug_string, ",");
|
||||
} else {
|
||||
gossip_err("%s: overflow!\n", __func__);
|
||||
strcpy(kernel_debug_string, ORANGEFS_ALL);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void do_c_string(void *c_mask, int index)
|
||||
{
|
||||
struct client_debug_mask *mask = (struct client_debug_mask *) c_mask;
|
||||
|
||||
if (keyword_is_amalgam(cdm_array[index].keyword))
|
||||
goto out;
|
||||
|
||||
if ((mask->mask1 & cdm_array[index].mask1) ||
|
||||
(mask->mask2 & cdm_array[index].mask2)) {
|
||||
if ((strlen(client_debug_string) +
|
||||
strlen(cdm_array[index].keyword) + 1)
|
||||
< ORANGEFS_MAX_DEBUG_STRING_LEN - 2) {
|
||||
strcat(client_debug_string,
|
||||
cdm_array[index].keyword);
|
||||
strcat(client_debug_string, ",");
|
||||
} else {
|
||||
gossip_err("%s: overflow!\n", __func__);
|
||||
strcpy(client_debug_string, ORANGEFS_ALL);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
int keyword_is_amalgam(char *keyword)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ((!strcmp(keyword, ORANGEFS_ALL)) || (!strcmp(keyword, ORANGEFS_VERBOSE)))
|
||||
rc = 1;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*
|
||||
* return 1 if we found an amalgam.
|
||||
*/
|
||||
int check_amalgam_keyword(void *mask, int type)
|
||||
{
|
||||
__u64 *k_mask;
|
||||
struct client_debug_mask *c_mask;
|
||||
int k_all_index = num_kmod_keyword_mask_map - 1;
|
||||
int rc = 0;
|
||||
|
||||
if (type) {
|
||||
c_mask = (struct client_debug_mask *) mask;
|
||||
|
||||
if ((c_mask->mask1 == cdm_array[client_all_index].mask1) &&
|
||||
(c_mask->mask2 == cdm_array[client_all_index].mask2)) {
|
||||
strcpy(client_debug_string, ORANGEFS_ALL);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((c_mask->mask1 == cdm_array[client_verbose_index].mask1) &&
|
||||
(c_mask->mask2 == cdm_array[client_verbose_index].mask2)) {
|
||||
strcpy(client_debug_string, ORANGEFS_VERBOSE);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
} else {
|
||||
k_mask = (__u64 *) mask;
|
||||
|
||||
if (*k_mask >= s_kmod_keyword_mask_map[k_all_index].mask_val) {
|
||||
strcpy(kernel_debug_string, ORANGEFS_ALL);
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* kernel = type 0
|
||||
* client = type 1
|
||||
*/
|
||||
void debug_string_to_mask(char *debug_string, void *mask, int type)
|
||||
{
|
||||
char *unchecked_keyword;
|
||||
int i;
|
||||
char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
|
||||
char *original_pointer;
|
||||
int element_count = 0;
|
||||
struct client_debug_mask *c_mask;
|
||||
__u64 *k_mask;
|
||||
|
||||
gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
|
||||
|
||||
if (type) {
|
||||
c_mask = (struct client_debug_mask *)mask;
|
||||
element_count = cdm_element_count;
|
||||
} else {
|
||||
k_mask = (__u64 *)mask;
|
||||
*k_mask = 0;
|
||||
element_count = num_kmod_keyword_mask_map;
|
||||
}
|
||||
|
||||
original_pointer = strsep_fodder;
|
||||
while ((unchecked_keyword = strsep(&strsep_fodder, ",")))
|
||||
if (strlen(unchecked_keyword)) {
|
||||
for (i = 0; i < element_count; i++)
|
||||
if (type)
|
||||
do_c_mask(i,
|
||||
unchecked_keyword,
|
||||
&c_mask);
|
||||
else
|
||||
do_k_mask(i,
|
||||
unchecked_keyword,
|
||||
&k_mask);
|
||||
}
|
||||
|
||||
kfree(original_pointer);
|
||||
}
|
||||
|
||||
void do_c_mask(int i,
|
||||
char *unchecked_keyword,
|
||||
struct client_debug_mask **sane_mask)
|
||||
{
|
||||
|
||||
if (!strcmp(cdm_array[i].keyword, unchecked_keyword)) {
|
||||
(**sane_mask).mask1 = (**sane_mask).mask1 | cdm_array[i].mask1;
|
||||
(**sane_mask).mask2 = (**sane_mask).mask2 | cdm_array[i].mask2;
|
||||
}
|
||||
}
|
||||
|
||||
void do_k_mask(int i, char *unchecked_keyword, __u64 **sane_mask)
|
||||
{
|
||||
|
||||
if (!strcmp(s_kmod_keyword_mask_map[i].keyword, unchecked_keyword))
|
||||
**sane_mask = (**sane_mask) |
|
||||
s_kmod_keyword_mask_map[i].mask_val;
|
||||
}
|
||||
|
@ -4,26 +4,6 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
extern struct client_debug_mask *cdm_array;
|
||||
extern char *debug_help_string;
|
||||
extern int help_string_initialized;
|
||||
extern struct dentry *debug_dir;
|
||||
extern struct dentry *help_file_dentry;
|
||||
extern struct dentry *client_debug_dentry;
|
||||
extern const struct file_operations debug_help_fops;
|
||||
extern int client_all_index;
|
||||
extern int client_verbose_index;
|
||||
extern int cdm_element_count;
|
||||
#define DEBUG_HELP_STRING_SIZE 4096
|
||||
#define HELP_STRING_UNINITIALIZED \
|
||||
"Client Debug Keywords are unknown until the first time\n" \
|
||||
"the client is started after boot.\n"
|
||||
#define ORANGEFS_KMOD_DEBUG_HELP_FILE "debug-help"
|
||||
#define ORANGEFS_KMOD_DEBUG_FILE "kernel-debug"
|
||||
#define ORANGEFS_CLIENT_DEBUG_FILE "client-debug"
|
||||
#define ORANGEFS_VERBOSE "verbose"
|
||||
#define ORANGEFS_ALL "all"
|
||||
|
||||
/* pvfs2-config.h ***********************************************************/
|
||||
#define ORANGEFS_VERSION_MAJOR 2
|
||||
#define ORANGEFS_VERSION_MINOR 9
|
||||
@ -426,13 +406,12 @@ do { \
|
||||
printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
extern __u64 gossip_debug_mask;
|
||||
extern struct client_debug_mask client_debug_mask;
|
||||
extern __u64 orangefs_gossip_debug_mask;
|
||||
|
||||
/* try to avoid function call overhead by checking masks in macro */
|
||||
#define gossip_debug(mask, fmt, ...) \
|
||||
do { \
|
||||
if (gossip_debug_mask & (mask)) \
|
||||
if (orangefs_gossip_debug_mask & (mask)) \
|
||||
printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif /* GOSSIP_DISABLE_DEBUG */
|
||||
|
@ -33,6 +33,7 @@ static const match_table_t tokens = {
|
||||
{ Opt_err, NULL }
|
||||
};
|
||||
|
||||
uint64_t orangefs_features;
|
||||
|
||||
static int parse_mount_options(struct super_block *sb, char *options,
|
||||
int silent)
|
||||
@ -249,6 +250,19 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
|
||||
}
|
||||
|
||||
op_release(new_op);
|
||||
|
||||
if (orangefs_userspace_version >= 20907) {
|
||||
new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
|
||||
if (!new_op)
|
||||
return -ENOMEM;
|
||||
new_op->upcall.req.features.features = 0;
|
||||
ret = service_operation(new_op, "orangefs_features", 0);
|
||||
orangefs_features = new_op->downcall.resp.features.features;
|
||||
op_release(new_op);
|
||||
} else {
|
||||
orangefs_features = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -492,6 +506,19 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
|
||||
list_add_tail(&ORANGEFS_SB(sb)->list, &orangefs_superblocks);
|
||||
spin_unlock(&orangefs_superblocks_lock);
|
||||
op_release(new_op);
|
||||
|
||||
if (orangefs_userspace_version >= 20907) {
|
||||
new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
|
||||
if (!new_op)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
new_op->upcall.req.features.features = 0;
|
||||
ret = service_operation(new_op, "orangefs_features", 0);
|
||||
orangefs_features = new_op->downcall.resp.features.features;
|
||||
op_release(new_op);
|
||||
} else {
|
||||
orangefs_features = 0;
|
||||
}
|
||||
|
||||
return dget(sb->s_root);
|
||||
|
||||
free_op:
|
||||
@ -530,8 +557,8 @@ void orangefs_kill_sb(struct super_block *sb)
|
||||
* make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us
|
||||
* gets completed before we free the dang thing.
|
||||
*/
|
||||
mutex_lock(&request_mutex);
|
||||
mutex_unlock(&request_mutex);
|
||||
mutex_lock(&orangefs_request_mutex);
|
||||
mutex_unlock(&orangefs_request_mutex);
|
||||
|
||||
/* free the orangefs superblock private data */
|
||||
kfree(ORANGEFS_SB(sb));
|
||||
|
@ -210,6 +210,11 @@ struct orangefs_fs_key_request_s {
|
||||
__s32 __pad1;
|
||||
};
|
||||
|
||||
/* 2.9.6 */
|
||||
struct orangefs_features_request_s {
|
||||
__u64 features;
|
||||
};
|
||||
|
||||
struct orangefs_upcall_s {
|
||||
__s32 type;
|
||||
__u32 uid;
|
||||
@ -246,6 +251,7 @@ struct orangefs_upcall_s {
|
||||
struct orangefs_param_request_s param;
|
||||
struct orangefs_perf_count_request_s perf_count;
|
||||
struct orangefs_fs_key_request_s fs_key;
|
||||
struct orangefs_features_request_s features;
|
||||
} req;
|
||||
};
|
||||
|
||||
|
@ -87,9 +87,9 @@ retry_servicing:
|
||||
*/
|
||||
if (!(flags & ORANGEFS_OP_NO_MUTEX)) {
|
||||
if (flags & ORANGEFS_OP_INTERRUPTIBLE)
|
||||
ret = mutex_lock_interruptible(&request_mutex);
|
||||
ret = mutex_lock_interruptible(&orangefs_request_mutex);
|
||||
else
|
||||
ret = mutex_lock_killable(&request_mutex);
|
||||
ret = mutex_lock_killable(&orangefs_request_mutex);
|
||||
/*
|
||||
* check to see if we were interrupted while waiting for
|
||||
* mutex
|
||||
@ -129,7 +129,7 @@ retry_servicing:
|
||||
spin_unlock(&orangefs_request_list_lock);
|
||||
|
||||
if (!(flags & ORANGEFS_OP_NO_MUTEX))
|
||||
mutex_unlock(&request_mutex);
|
||||
mutex_unlock(&orangefs_request_mutex);
|
||||
|
||||
ret = wait_for_matching_downcall(op, timeout,
|
||||
flags & ORANGEFS_OP_INTERRUPTIBLE);
|
||||
@ -272,9 +272,9 @@ static void
|
||||
} else if (op_state_in_progress(op)) {
|
||||
/* op must be removed from the in progress htable */
|
||||
spin_unlock(&op->lock);
|
||||
spin_lock(&htable_ops_in_progress_lock);
|
||||
spin_lock(&orangefs_htable_ops_in_progress_lock);
|
||||
list_del_init(&op->list);
|
||||
spin_unlock(&htable_ops_in_progress_lock);
|
||||
spin_unlock(&orangefs_htable_ops_in_progress_lock);
|
||||
gossip_debug(GOSSIP_WAIT_DEBUG,
|
||||
"Interrupted: Removed op %p"
|
||||
" from htable_ops_in_progress\n",
|
||||
|
Loading…
Reference in New Issue
Block a user