From: James Simmons Date: Wed, 3 May 2017 20:00:21 +0000 (-0400) Subject: LU-6401 uapi: turn lustre_param.h into a proper UAPI header X-Git-Tag: 2.9.58~5 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=424e56abd685c5eabc6a276154dec1c031cf5044 LU-6401 uapi: turn lustre_param.h into a proper UAPI header Move all the kernel specific function prototypes from lustre_param.h into obd_config.h which is a kernel only header. The inline functions lustre_is_*_valid are used only by user land so we can remove them. Remove the user land error checking with lustre_is_*_valid() since its the job of the kernel to validate the date passed in. The libcfs.h header shouldn't be exposed to user land so remove it. Change-Id: I6b6b4fe8f4d6799608c0e74318afecb85168ad54 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/24325 Tested-by: Jenkins Reviewed-by: Ben Evans Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index 44ff84d..b00a1be 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -78,7 +78,6 @@ EXTRA_DIST = \ lustre_nrs_orr.h \ lustre_nrs_tbf.h \ lustre_obdo.h \ - lustre_param.h \ lustre_patchless_compat.h \ lustre_quota.h \ lustre_req_layout.h \ diff --git a/lustre/include/lustre_param.h b/lustre/include/lustre_param.h deleted file mode 100644 index eb2f5fa..0000000 --- a/lustre/include/lustre_param.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2015, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/include/lustre_param.h - * - * User-settable parameter keys - * - * Author: Nathan Rutman - */ - -#ifndef _LUSTRE_PARAM_H -#define _LUSTRE_PARAM_H - -#include -#include - -/** \defgroup param param - * - * @{ - */ - -/* For interoperability */ -struct cfg_interop_param { - char *old_param; - char *new_param; -}; - -/* obd_config.c */ -int class_find_param(char *buf, char *key, char **valp); -struct cfg_interop_param *class_find_old_param(const char *param, - struct cfg_interop_param *ptr); -int class_get_next_param(char **params, char *copy); -int class_match_param(char *buf, const char *key, char **valp); -int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh); -int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh); -int class_parse_net(char *buf, __u32 *net, char **endh); -int class_match_nid(char *buf, char *key, lnet_nid_t nid); -int class_match_net(char *buf, char *key, __u32 net); -/* obd_mount.c */ -int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, - char *s1, char *s2, char *s3, char *s4); - - - -/****************** User-settable parameter keys *********************/ -/* e.g. - tunefs.lustre --param="failover.node=192.168.0.13@tcp0" /dev/sda - lctl conf_param testfs-OST0000 failover.node=3@elan,192.168.0.3@tcp0 - ... testfs-MDT0000.lov.stripesize=4M - ... testfs-OST0000.ost.client_cache_seconds=15 - ... testfs.sys.timeout= - ... testfs.llite.max_read_ahead_mb=16 -*/ - -/* System global or special params not handled in obd's proc - * See mgs_write_log_sys() - */ -#define PARAM_TIMEOUT "timeout=" /* global */ -#define PARAM_LDLM_TIMEOUT "ldlm_timeout=" /* global */ -#define PARAM_AT_MIN "at_min=" /* global */ -#define PARAM_AT_MAX "at_max=" /* global */ -#define PARAM_AT_EXTRA "at_extra=" /* global */ -#define PARAM_AT_EARLY_MARGIN "at_early_margin=" /* global */ -#define PARAM_AT_HISTORY "at_history=" /* global */ -#define PARAM_JOBID_VAR "jobid_var=" /* global */ -#define PARAM_MGSNODE "mgsnode=" /* only at mounttime */ -#define PARAM_FAILNODE "failover.node=" /* add failover nid */ -#define PARAM_FAILMODE "failover.mode=" /* initial mount only */ -#define PARAM_ACTIVE "active=" /* activate/deactivate */ -#define PARAM_NETWORK "network=" /* bind on nid */ -#define PARAM_ID_UPCALL "identity_upcall=" /* identity upcall */ - -/* Prefixes for parameters handled by obd's proc methods (XXX_process_config) */ -#define PARAM_OST "ost." -#define PARAM_OSD "osd." -#define PARAM_OSC "osc." -#define PARAM_MDT "mdt." -#define PARAM_HSM "mdt.hsm." -#define PARAM_MDD "mdd." -#define PARAM_MDC "mdc." -#define PARAM_LLITE "llite." -#define PARAM_LOV "lov." -#define PARAM_LOD "lod." -#define PARAM_OSP "osp." -#define PARAM_SYS "sys." /* global */ -#define PARAM_SRPC "srpc." -#define PARAM_SRPC_FLVR "srpc.flavor." -#define PARAM_SRPC_UDESC "srpc.udesc.cli2mdt" -#define PARAM_SEC "security." -#define PARAM_QUOTA "quota." /* global */ - -/** @} param */ - -#define LUSTRE_MAXFSNAME 8 - -/** - * Check whether the name is valid. - * - * \param name [in] the name to be checked - * \param minlen [in] the minimum length of the name - * \param maxlen [in] the maximum length of the name - * - * \retval 0 the name is valid - * \retval >0 the invalid character in the name - * \retval -1 the name is too short - * \retval -2 the name is too long - */ -static inline int lustre_is_name_valid(const char *name, const int minlen, - const int maxlen) -{ - const char *tmp; - size_t len; - - len = strlen(name); - - if (len < minlen) - return -1; - - if (len > maxlen) - return -2; - - for (tmp = name; *tmp != '\0'; ++tmp) { - if (isalnum(*tmp) || *tmp == '_' || *tmp == '-') - continue; - else - break; - } - - return *tmp == '\0' ? 0 : *tmp; -} - -/** - * Check whether the fsname is valid. - * - * \param fsname [in] the fsname to be checked - * \param minlen [in] the minimum length of the fsname - * \param maxlen [in] the maximum length of the fsname - * - * \retval 0 the fsname is valid - * \retval >0 the invalid character in the fsname - * \retval -1 the fsname is too short - * \retval -2 the fsname is too long - */ -static inline int lustre_is_fsname_valid(const char *fsname, const int minlen, - const int maxlen) -{ - return lustre_is_name_valid(fsname, minlen, maxlen); -} - -/** - * Check whether the poolname is valid. - * - * \param poolname [in] the poolname to be checked - * \param minlen [in] the minimum length of the poolname - * \param maxlen [in] the maximum length of the poolname - * - * \retval 0 the poolname is valid - * \retval >0 the invalid character in the poolname - * \retval -1 the poolname is too short - * \retval -2 the poolname is too long - */ -static inline int lustre_is_poolname_valid(const char *poolname, - const int minlen, const int maxlen) -{ - return lustre_is_name_valid(poolname, minlen, maxlen); -} - -#endif /* _LUSTRE_PARAM_H */ diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 0fafed0..5ae50e0 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -122,6 +122,12 @@ void obd_stale_export_put(struct obd_export *exp); void obd_stale_export_adjust(struct obd_export *exp); /* obd_config.c */ +/* For interoperability */ +struct cfg_interop_param { + char *old_param; + char *new_param; +}; + struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, const char *new_name); int class_process_config(struct lustre_cfg *lcfg); @@ -131,6 +137,18 @@ int class_attach(struct lustre_cfg *lcfg); int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg); int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg); int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg); + +int class_find_param(char *buf, char *key, char **valp); +struct cfg_interop_param *class_find_old_param(const char *param, + struct cfg_interop_param *ptr); +int class_get_next_param(char **params, char *copy); +int class_match_param(char *buf, const char *key, char **valp); +int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh); +int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh); +int class_parse_net(char *buf, u32 *net, char **endh); +int class_match_nid(char *buf, char *key, lnet_nid_t nid); +int class_match_net(char *buf, char *key, u32 net); + struct obd_device *class_incref(struct obd_device *obd, const char *scope, const void *source); void class_decref(struct obd_device *obd, diff --git a/lustre/include/uapi/linux/Makefile.am b/lustre/include/uapi/linux/Makefile.am index b07e08a..fa01e3d 100644 --- a/lustre/include/uapi/linux/Makefile.am +++ b/lustre/include/uapi/linux/Makefile.am @@ -33,4 +33,5 @@ EXTRA_DIST = \ lustre_disk.h \ lustre_fid.h \ lustre_ioctl.h \ - lustre_ostid.h + lustre_ostid.h \ + lustre_param.h diff --git a/lustre/include/uapi/linux/lustre_param.h b/lustre/include/uapi/linux/lustre_param.h new file mode 100644 index 0000000..022d253 --- /dev/null +++ b/lustre/include/uapi/linux/lustre_param.h @@ -0,0 +1,94 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2015, Intel Corporation. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * User-settable parameter keys + * + * Author: Nathan Rutman + */ + +#ifndef _UAPI_LUSTRE_PARAM_H +#define _UAPI_LUSTRE_PARAM_H + +/** \defgroup param param + * + * @{ + */ + +/****************** User-settable parameter keys *********************/ +/* e.g. + * tunefs.lustre --param="failover.node=192.168.0.13@tcp0" /dev/sda + * lctl conf_param testfs-OST0000 failover.node=3@elan,192.168.0.3@tcp0 + * ... testfs-MDT0000.lov.stripesize=4M + * ... testfs-OST0000.ost.client_cache_seconds=15 + * ... testfs.sys.timeout= + * ... testfs.llite.max_read_ahead_mb=16 + */ + +/* System global or special params not handled in obd's proc + * See mgs_write_log_sys() + */ +#define PARAM_TIMEOUT "timeout=" /* global */ +#define PARAM_LDLM_TIMEOUT "ldlm_timeout=" /* global */ +#define PARAM_AT_MIN "at_min=" /* global */ +#define PARAM_AT_MAX "at_max=" /* global */ +#define PARAM_AT_EXTRA "at_extra=" /* global */ +#define PARAM_AT_EARLY_MARGIN "at_early_margin=" /* global */ +#define PARAM_AT_HISTORY "at_history=" /* global */ +#define PARAM_JOBID_VAR "jobid_var=" /* global */ +#define PARAM_MGSNODE "mgsnode=" /* only at mounttime */ +#define PARAM_FAILNODE "failover.node=" /* add failover nid */ +#define PARAM_FAILMODE "failover.mode=" /* initial mount only */ +#define PARAM_ACTIVE "active=" /* activate/deactivate */ +#define PARAM_NETWORK "network=" /* bind on nid */ +#define PARAM_ID_UPCALL "identity_upcall=" /* identity upcall */ + +/* Prefixes for parameters handled by obd's proc methods (XXX_process_config) */ +#define PARAM_OST "ost." +#define PARAM_OSD "osd." +#define PARAM_OSC "osc." +#define PARAM_MDT "mdt." +#define PARAM_HSM "mdt.hsm." +#define PARAM_MDD "mdd." +#define PARAM_MDC "mdc." +#define PARAM_LLITE "llite." +#define PARAM_LOV "lov." +#define PARAM_LOD "lod." +#define PARAM_OSP "osp." +#define PARAM_SYS "sys." /* global */ +#define PARAM_SRPC "srpc." +#define PARAM_SRPC_FLVR "srpc.flavor." +#define PARAM_SRPC_UDESC "srpc.udesc.cli2mdt" +#define PARAM_SEC "security." +#define PARAM_QUOTA "quota." /* global */ + +/** @} param */ + +#endif /* _UAPI_LUSTRE_PARAM_H */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 53ac328..c3c149c 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 30fad42..63ccf88 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -36,7 +36,7 @@ #ifdef HAVE_UIDGID_HEADER # include #endif -#include +#include #include #include diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 7c4078e..8d95026 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -93,7 +93,7 @@ #include #include #include -#include +#include #include #include diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 52537b6..2318bdb 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/lod/lod_sub_object.c b/lustre/lod/lod_sub_object.c index 2b0d71e..a81d619 100644 --- a/lustre/lod/lod_sub_object.c +++ b/lustre/lod/lod_sub_object.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include #include diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c index 0c4a391..1144165 100644 --- a/lustre/lod/lproc_lod.c +++ b/lustre/lod/lproc_lod.c @@ -35,7 +35,7 @@ #include #include #include "lod_internal.h" -#include +#include /* * Notice, all the functions below (except for lod_procfs_init() and diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index d5a9f7a..563f121 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c index 1bd4275..25b4e17 100644 --- a/lustre/lov/lproc_lov.c +++ b/lustre/lov/lproc_lov.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include "lov_internal.h" #ifdef CONFIG_PROC_FS diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 2410df8..349ba27 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 91b3fee..d11d1ea 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index cc32f59..03e8e5a 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -46,7 +46,7 @@ /* fid_be_cpu(), fid_cpu_to_be(). */ #include #include -#include +#include #include #include diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index f90593c..2a2063e 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/mdt/mdt_mds.c b/lustre/mdt/mdt_mds.c index 1105242..7c5560d 100644 --- a/lustre/mdt/mdt_mds.c +++ b/lustre/mdt/mdt_mds.c @@ -52,7 +52,7 @@ #include "mdt_internal.h" #include #include -#include +#include struct mds_device { /* super-class */ diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 4be26c5..3caf79c 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "mgs_internal.h" #ifdef CONFIG_PROC_FS diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 1c73276..7ef4c27 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include "mgs_internal.h" @@ -729,22 +729,43 @@ static inline int mgs_destroy_export(struct obd_export *exp) RETURN(0); } -static int mgs_extract_fs_pool(char * arg, char *fsname, char *poolname) +static int mgs_extract_fs_pool(char *arg, char *fsname, char *poolname) { - char *ptr; + size_t len; + char *ptr; - ENTRY; - for (ptr = arg; (*ptr != '\0') && (*ptr != '.'); ptr++ ) { - *fsname = *ptr; - fsname++; - } - if (*ptr == '\0') - return -EINVAL; - *fsname = '\0'; - ptr++; - strcpy(poolname, ptr); + ENTRY; + /* Validate name */ + for (ptr = arg; *ptr != '\0'; ptr++) { + if (!isalnum(*ptr) && *ptr != '_' && *ptr != '-' && *ptr != '.') + return -EINVAL; + } - RETURN(0); + /* Test for fsname.poolname format. + * strlen() test if poolname is empty + */ + ptr = strchr(arg, '.'); + if (!ptr || !strlen(ptr)) + return -EINVAL; + ptr++; + + /* Also make sure poolname is not to long. */ + if (strlen(ptr) > LOV_MAXPOOLNAME) + return -ENAMETOOLONG; + strncpy(poolname, ptr, strlen(ptr)); + + /* Test if fsname is empty */ + len = strlen(arg) - strlen(ptr) - 1; + if (!len) + return -EINVAL; + + /* or too long */ + if (len > MTI_NAME_MAXLEN) + return -ENAMETOOLONG; + + strncpy(fsname, arg, len); + + RETURN(0); } static int mgs_iocontrol_nodemap(const struct lu_env *env, diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 895a1e2..68c8681 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 07b3ab0..2df9664 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include "llog_internal.h" diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index db8a225..394ee14 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include static int (*client_fill_super)(struct super_block *sb, struct vfsmount *mnt); @@ -151,11 +151,11 @@ EXPORT_SYMBOL(lustre_end_log); /** lustre_cfg_bufs are a holdover from 1.4; we can still set these up from * lctl (and do for echo cli/srv. */ -int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, - char *s1, char *s2, char *s3, char *s4) +static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, + char *s1, char *s2, char *s3, char *s4) { struct lustre_cfg_bufs bufs; - struct lustre_cfg * lcfg = NULL; + struct lustre_cfg *lcfg = NULL; int rc; CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname, diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index e3e675e..cec80aa 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include #include diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 96d5de9..31c17f9 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -70,7 +70,7 @@ #include #include -#include +#include #include #include #include diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index b9c2153..6038107 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index e440762..c950c21 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -67,7 +67,7 @@ #include #include /* process_config */ -#include +#include #include "osd_internal.h" #include "osd_dynlocks.h" diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index 4954e2a..47a8e82 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include "osd_internal.h" diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index 7d47dc7..d11a320 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -40,7 +40,7 @@ #define DEBUG_SUBSYSTEM S_OST #include -#include +#include #include #include diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 8c0e0c5..52b624c 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -75,7 +75,7 @@ #include #include #include -#include +#include #include #include "osp_internal.h" diff --git a/lustre/ptlrpc/sec_config.c b/lustre/ptlrpc/sec_config.c index 5fc4dc4..4951efe 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include "ptlrpc_internal.h" diff --git a/lustre/quota/qsd_config.c b/lustre/quota/qsd_config.c index 08cbeb6..91e1386 100644 --- a/lustre/quota/qsd_config.c +++ b/lustre/quota/qsd_config.c @@ -31,7 +31,7 @@ #define DEBUG_SUBSYSTEM S_LQUOTA #include -#include +#include #include "qsd_internal.h" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index aa46f2d..4b21114 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -66,7 +66,7 @@ #include #include #include -#include +#include #ifndef ARRAY_SIZE # define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0]))) @@ -1011,42 +1011,19 @@ static int parse_targets(__u32 *osts, int size, int offset, char *arg) static int verify_pool_name(char *prog_name, char *pool_name) { - char *ptr; - int rc; + char *ptr; if (pool_name == NULL) return 0; ptr = strchr(pool_name, '.'); - if (ptr == NULL) { - ptr = pool_name; - } else { - if (ptr == pool_name) { - fprintf(stderr, "error: %s: fsname is empty " - "in pool name '%s'\n", - prog_name, pool_name); - return -EINVAL; - } - ++ptr; - } - - rc = lustre_is_poolname_valid(ptr, 1, LOV_MAXPOOLNAME); - if (rc == -1) { - fprintf(stderr, "error: %s: poolname '%s' is empty\n", + if (ptr != NULL && ptr == pool_name) { + fprintf(stderr, "error: %s: fsname is empty in pool name '%s'\n", prog_name, pool_name); return -EINVAL; - } else if (rc == -2) { - fprintf(stderr, "error: %s: pool name '%s' is too long " - "(max is %d characters)\n", - prog_name, pool_name, LOV_MAXPOOLNAME); - return -EINVAL; - } else if (rc > 0) { - fprintf(stderr, "error: %s: char '%c' not allowed in " - "pool name '%s'\n", - prog_name, rc, pool_name); - return -EINVAL; } - return rc; + + return 0; } struct lfs_setstripe_args { diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index df4c165..5073a73 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -41,6 +41,7 @@ #define _GNU_SOURCE #endif +#include #include #include #include diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 69fc7e8..7bf83ea 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include @@ -514,23 +514,9 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop, ldd->ldd_flags &= ~LDD_F_NEED_INDEX; break; } - case 'L': { - rc = lustre_is_fsname_valid(optarg, 1, - LUSTRE_MAXFSNAME); - if (rc < 0) { - fprintf(stderr, "%s: filesystem name must be " - "1-%d chars\n", progname, - LUSTRE_MAXFSNAME); - return 1; - } else if (rc > 0) { - fprintf(stderr, "%s: char '%c' not allowed in " - "filesystem name\n", progname, rc); - return 1; - } - + case 'L': strscpy(new_fsname, optarg, sizeof(new_fsname)); break; - } case 'm': { char *nids = convert_hostnames(optarg); diff --git a/lustre/utils/mount_utils.h b/lustre/utils/mount_utils.h index 613dd65..7540d06 100644 --- a/lustre/utils/mount_utils.h +++ b/lustre/utils/mount_utils.h @@ -56,7 +56,7 @@ #include #include -#include +#include extern char *progname; extern int verbose; diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index f8999db..94a795f 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -68,7 +68,6 @@ #endif #include #include -#include #include #include diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 08047e5..07fb7a9 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -75,7 +75,7 @@ #include #include -#include +#include #include #define MAX_STRING_SIZE 128 @@ -4011,35 +4011,10 @@ static int extract_fsname_poolname(const char *arg, char *fsname, *ptr = '\0'; ++ptr; - rc = lustre_is_fsname_valid(fsname, 1, LUSTRE_MAXFSNAME); - if (rc < 0) { - fprintf(stderr, "filesystem name %s must be 1-%d chars\n", - fsname, LUSTRE_MAXFSNAME); - rc = -EINVAL; - goto err; - } else if (rc > 0) { - fprintf(stderr, "char '%c' not allowed in filesystem name\n", - rc); - rc = -EINVAL; - goto err; - } - - rc = lustre_is_poolname_valid(ptr, 1, LOV_MAXPOOLNAME); - if (rc == -1) { + if (strlen(ptr) == 0) { fprintf(stderr, "poolname is empty\n"); rc = -EINVAL; goto err; - } else if (rc == -2) { - fprintf(stderr, - "poolname %s is too long (max is %d)\n", - ptr, LOV_MAXPOOLNAME); - rc = -ENAMETOOLONG; - goto err; - } else if (rc > 0) { - fprintf(stderr, "char '%c' not allowed in pool name '%s'\n", - rc, ptr); - rc = -EINVAL; - goto err; } strncpy(poolname, ptr, LOV_MAXPOOLNAME);