X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Fselftest%2Fconctl.c;h=4767ab882506656eb28eeadcad593b6a69eeb8de;hb=3cce65712d94cffe8f1626545845b95b88aef672;hp=b3adca06db8fdd39147d3a64e64ef734c6ab4d2f;hpb=33984c012883a7c714429d2c612cf6dcda191974;p=fs%2Flustre-release.git diff --git a/lnet/selftest/conctl.c b/lnet/selftest/conctl.c index b3adca0..4767ab8 100644 --- a/lnet/selftest/conctl.c +++ b/lnet/selftest/conctl.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -39,15 +35,14 @@ * * Author: Liang Zhen */ -#ifdef __KERNEL__ #include #include -#include +#include #include "console.h" static int -lst_session_new_ioctl(lstio_session_new_args_t *args) +lst_session_new_ioctl(struct lstio_session_new_args *args) { char *name; int rc; @@ -74,8 +69,8 @@ lst_session_new_ioctl(lstio_session_new_args_t *args) rc = lstcon_session_new(name, args->lstio_ses_key, args->lstio_ses_feats, - args->lstio_ses_force, args->lstio_ses_timeout, + args->lstio_ses_force, args->lstio_ses_idp); LIBCFS_FREE(name, args->lstio_ses_nmlen + 1); @@ -83,7 +78,7 @@ lst_session_new_ioctl(lstio_session_new_args_t *args) } static int -lst_session_end_ioctl(lstio_session_end_args_t *args) +lst_session_end_ioctl(struct lstio_session_end_args *args) { if (args->lstio_ses_key != console_session.ses_key) return -EACCES; @@ -92,7 +87,7 @@ lst_session_end_ioctl(lstio_session_end_args_t *args) } static int -lst_session_info_ioctl(lstio_session_info_args_t *args) +lst_session_info_ioctl(struct lstio_session_info_args *args) { /* no checking of key */ @@ -114,7 +109,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args) } static int -lst_debug_ioctl(lstio_debug_args_t *args) +lst_debug_ioctl(struct lstio_debug_args *args) { char *name = NULL; int client = 1; @@ -195,7 +190,7 @@ out: } static int -lst_group_add_ioctl(lstio_group_add_args_t *args) +lst_group_add_ioctl(struct lstio_group_add_args *args) { char *name; int rc; @@ -228,7 +223,7 @@ lst_group_add_ioctl(lstio_group_add_args_t *args) } static int -lst_group_del_ioctl(lstio_group_del_args_t *args) +lst_group_del_ioctl(struct lstio_group_del_args *args) { int rc; char *name; @@ -261,7 +256,7 @@ lst_group_del_ioctl(lstio_group_del_args_t *args) } static int -lst_group_update_ioctl(lstio_group_update_args_t *args) +lst_group_update_ioctl(struct lstio_group_update_args *args) { int rc; char *name; @@ -318,7 +313,7 @@ lst_group_update_ioctl(lstio_group_update_args_t *args) } static int -lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) +lst_nodes_add_ioctl(struct lstio_group_nodes_args *args) { unsigned feats; int rc; @@ -363,7 +358,7 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) } static int -lst_group_list_ioctl(lstio_group_list_args_t *args) +lst_group_list_ioctl(struct lstio_group_list_args *args) { if (args->lstio_grp_key != console_session.ses_key) return -EACCES; @@ -380,7 +375,7 @@ lst_group_list_ioctl(lstio_group_list_args_t *args) } static int -lst_group_info_ioctl(lstio_group_info_args_t *args) +lst_group_info_ioctl(struct lstio_group_info_args *args) { char *name; int ndent; @@ -437,13 +432,13 @@ lst_group_info_ioctl(lstio_group_info_args_t *args) if (args->lstio_grp_dentsp != NULL && (copy_to_user(args->lstio_grp_idxp, &index, sizeof(index)) || copy_to_user(args->lstio_grp_ndentp, &ndent, sizeof(ndent)))) - rc = -EFAULT; + return -EFAULT; return 0; } static int -lst_batch_add_ioctl(lstio_batch_add_args_t *args) +lst_batch_add_ioctl(struct lstio_batch_add_args *args) { int rc; char *name; @@ -476,7 +471,7 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args) } static int -lst_batch_run_ioctl(lstio_batch_run_args_t *args) +lst_batch_run_ioctl(struct lstio_batch_run_args *args) { int rc; char *name; @@ -510,7 +505,7 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args) } static int -lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) +lst_batch_stop_ioctl(struct lstio_batch_stop_args *args) { int rc; char *name; @@ -545,7 +540,7 @@ lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) } static int -lst_batch_query_ioctl(lstio_batch_query_args_t *args) +lst_batch_query_ioctl(struct lstio_batch_query_args *args) { char *name; int rc; @@ -586,7 +581,7 @@ lst_batch_query_ioctl(lstio_batch_query_args_t *args) } static int -lst_batch_list_ioctl(lstio_batch_list_args_t *args) +lst_batch_list_ioctl(struct lstio_batch_list_args *args) { if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -603,7 +598,7 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args) } static int -lst_batch_info_ioctl(lstio_batch_info_args_t *args) +lst_batch_info_ioctl(struct lstio_batch_info_args *args) { char *name; int rc; @@ -668,7 +663,7 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args) } static int -lst_stat_query_ioctl(lstio_stat_args_t *args) +lst_stat_query_ioctl(struct lstio_stat_args *args) { int rc; char *name = NULL; @@ -714,7 +709,7 @@ lst_stat_query_ioctl(lstio_stat_args_t *args) return rc; } -static int lst_test_add_ioctl(lstio_test_args_t *args) +static int lst_test_add_ioctl(struct lstio_test_args *args) { char *batch_name; char *src_name = NULL; @@ -746,7 +741,7 @@ static int lst_test_add_ioctl(lstio_test_args_t *args) if (args->lstio_tes_param != NULL && (args->lstio_tes_param_len <= 0 || args->lstio_tes_param_len > - PAGE_CACHE_SIZE - sizeof(lstcon_test_t))) + PAGE_SIZE - sizeof(struct lstcon_test))) return -EINVAL; LIBCFS_ALLOC(batch_name, args->lstio_tes_bat_nmlen + 1); @@ -810,36 +805,40 @@ out: } int -lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) +lstcon_ioctl_entry(struct notifier_block *nb, + unsigned long cmd, void *vdata) { - char *buf; + struct libcfs_ioctl_hdr *hdr = vdata; struct libcfs_ioctl_data *data; - int opc; - int rc; + char *buf = NULL; + int rc = -EINVAL; + int opc; if (cmd != IOC_LIBCFS_LNETST) - return -EINVAL; + goto err; data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); opc = data->ioc_u32[0]; - if (data->ioc_plen1 > PAGE_CACHE_SIZE) - return -EINVAL; + if (data->ioc_plen1 > PAGE_SIZE) + goto err; LIBCFS_ALLOC(buf, data->ioc_plen1); - if (buf == NULL) - return -ENOMEM; + if (buf == NULL) { + rc = -ENOMEM; + goto err; + } /* copy in parameter */ if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { - LIBCFS_FREE(buf, data->ioc_plen1); - return -EFAULT; + rc = -EFAULT; + goto out_free_buf; } mutex_lock(&console_session.ses_mutex); - console_session.ses_laststamp = cfs_time_current_sec(); + console_session.ses_laststamp = ktime_get_real_seconds(); if (console_session.ses_shutdown) { rc = -ESHUTDOWN; @@ -856,78 +855,75 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) goto out; } - memset(&console_session.ses_trans_stat, 0, sizeof(lstcon_trans_stat_t)); + memset(&console_session.ses_trans_stat, 0, sizeof(struct lstcon_trans_stat)); switch (opc) { case LSTIO_SESSION_NEW: - rc = lst_session_new_ioctl((lstio_session_new_args_t *)buf); + rc = lst_session_new_ioctl((struct lstio_session_new_args *)buf); break; case LSTIO_SESSION_END: - rc = lst_session_end_ioctl((lstio_session_end_args_t *)buf); + rc = lst_session_end_ioctl((struct lstio_session_end_args *)buf); break; case LSTIO_SESSION_INFO: - rc = lst_session_info_ioctl((lstio_session_info_args_t *)buf); + rc = lst_session_info_ioctl((struct lstio_session_info_args *)buf); break; case LSTIO_DEBUG: - rc = lst_debug_ioctl((lstio_debug_args_t *)buf); + rc = lst_debug_ioctl((struct lstio_debug_args *)buf); break; case LSTIO_GROUP_ADD: - rc = lst_group_add_ioctl((lstio_group_add_args_t *)buf); + rc = lst_group_add_ioctl((struct lstio_group_add_args *)buf); break; case LSTIO_GROUP_DEL: - rc = lst_group_del_ioctl((lstio_group_del_args_t *)buf); + rc = lst_group_del_ioctl((struct lstio_group_del_args *)buf); break; case LSTIO_GROUP_UPDATE: - rc = lst_group_update_ioctl((lstio_group_update_args_t *)buf); + rc = lst_group_update_ioctl((struct lstio_group_update_args *)buf); break; case LSTIO_NODES_ADD: - rc = lst_nodes_add_ioctl((lstio_group_nodes_args_t *)buf); + rc = lst_nodes_add_ioctl((struct lstio_group_nodes_args *)buf); break; case LSTIO_GROUP_LIST: - rc = lst_group_list_ioctl((lstio_group_list_args_t *)buf); + rc = lst_group_list_ioctl((struct lstio_group_list_args *)buf); break; case LSTIO_GROUP_INFO: - rc = lst_group_info_ioctl((lstio_group_info_args_t *)buf); + rc = lst_group_info_ioctl((struct lstio_group_info_args *)buf); break; case LSTIO_BATCH_ADD: - rc = lst_batch_add_ioctl((lstio_batch_add_args_t *)buf); + rc = lst_batch_add_ioctl((struct lstio_batch_add_args *)buf); break; case LSTIO_BATCH_START: - rc = lst_batch_run_ioctl((lstio_batch_run_args_t *)buf); + rc = lst_batch_run_ioctl((struct lstio_batch_run_args *)buf); break; case LSTIO_BATCH_STOP: - rc = lst_batch_stop_ioctl((lstio_batch_stop_args_t *)buf); + rc = lst_batch_stop_ioctl((struct lstio_batch_stop_args *)buf); break; case LSTIO_BATCH_QUERY: - rc = lst_batch_query_ioctl((lstio_batch_query_args_t *)buf); + rc = lst_batch_query_ioctl((struct lstio_batch_query_args *)buf); break; case LSTIO_BATCH_LIST: - rc = lst_batch_list_ioctl((lstio_batch_list_args_t *)buf); + rc = lst_batch_list_ioctl((struct lstio_batch_list_args *)buf); break; case LSTIO_BATCH_INFO: - rc = lst_batch_info_ioctl((lstio_batch_info_args_t *)buf); + rc = lst_batch_info_ioctl((struct lstio_batch_info_args *)buf); break; case LSTIO_TEST_ADD: - rc = lst_test_add_ioctl((lstio_test_args_t *)buf); + rc = lst_test_add_ioctl((struct lstio_test_args *)buf); break; case LSTIO_STAT_QUERY: - rc = lst_stat_query_ioctl((lstio_stat_args_t *)buf); + rc = lst_stat_query_ioctl((struct lstio_stat_args *)buf); break; default: rc = -EINVAL; + goto out; } if (copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat, - sizeof(lstcon_trans_stat_t))) + sizeof(struct lstcon_trans_stat))) rc = -EFAULT; out: mutex_unlock(&console_session.ses_mutex); - +out_free_buf: LIBCFS_FREE(buf, data->ioc_plen1); - - return rc; +err: + return notifier_from_ioctl_errno(rc); } - -EXPORT_SYMBOL(lstcon_ioctl_entry); - -#endif