From 4fedbc879571305a0d14a2caa989c8c306efc54c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 30 May 2017 07:27:35 -0400 Subject: [PATCH] LU-6401 uapi: change lustre_cfg.h into a proper UAPI header Instead of handling memory allocation for both userland and kernel space remove lustre_cfg_new() and lustre_cfg_free() and just use what is required for both kernel and user space. To perserve the truncate warning move lustre_cfg_string() to obd_config.c. Implement user land version for llog_reader. Lastly remove libcfs.h via obd_support.h from lustre_cfg.h and move it to the uapi directory. Change-Id: I96469b9040a9b3f885e117debba107f90955e09f Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/26966 Reviewed-by: Quentin Bouget Tested-by: Jenkins Reviewed-by: Ben Evans Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/Makefile.am | 1 - lustre/include/lustre_cfg.h | 333 --------------------------------- lustre/include/lustre_lib.h | 2 +- lustre/include/obd_class.h | 1 + lustre/include/uapi/linux/Makefile.am | 1 + lustre/include/uapi/linux/lustre_cfg.h | 294 +++++++++++++++++++++++++++++ lustre/lod/lod_internal.h | 2 +- lustre/lod/lproc_lod.c | 5 +- lustre/mdt/mdt_handler.c | 48 ++--- lustre/mgc/mgc_request.c | 9 +- lustre/mgs/mgs_handler.c | 8 +- lustre/obdclass/obd_config.c | 93 ++++++--- lustre/obdclass/obd_mount.c | 50 ++--- lustre/obdclass/obd_mount_server.c | 20 +- lustre/ofd/ofd_dev.c | 7 +- lustre/osp/lwp_dev.c | 10 +- lustre/utils/llog_reader.c | 35 +++- lustre/utils/lustre_cfg.c | 186 ++++++------------ lustre/utils/mount_utils.c | 2 +- lustre/utils/obd.c | 15 +- 20 files changed, 555 insertions(+), 567 deletions(-) delete mode 100644 lustre/include/lustre_cfg.h create mode 100644 lustre/include/uapi/linux/lustre_cfg.h diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index b00a1be..1a2fa30 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -46,7 +46,6 @@ EXTRA_DIST = \ lu_ref.h \ lustre_acl.h \ lustre_barrier.h \ - lustre_cfg.h \ lustre_compat.h \ lustre_debug.h \ lustre_disk.h \ diff --git a/lustre/include/lustre_cfg.h b/lustre/include/lustre_cfg.h deleted file mode 100644 index bf2a62a..0000000 --- a/lustre/include/lustre_cfg.h +++ /dev/null @@ -1,333 +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) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, 2014, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef _LUSTRE_CFG_H -#define _LUSTRE_CFG_H - -#include -#include - -#ifdef __KERNEL__ -# include -#else /* !__KERNEL__ */ -# include -# include -#endif /* __KERNEL__ */ - -/** \defgroup cfg cfg - * - * @{ - */ - -/* - * 1cf6 - * lcfG - */ -#define LUSTRE_CFG_VERSION 0x1cf60001 -#define LUSTRE_CFG_MAX_BUFCOUNT 8 - -#define LCFG_HDR_SIZE(count) \ - cfs_size_round(offsetof (struct lustre_cfg, lcfg_buflens[(count)])) - -/** If the LCFG_REQUIRED bit is set in a configuration command, - * then the client is required to understand this parameter - * in order to mount the filesystem. If it does not understand - * a REQUIRED command the client mount will fail. */ -#define LCFG_REQUIRED 0x0001000 - -enum lcfg_command_type { - LCFG_ATTACH = 0x00cf001, /**< create a new obd instance */ - LCFG_DETACH = 0x00cf002, /**< destroy obd instance */ - LCFG_SETUP = 0x00cf003, /**< call type-specific setup */ - LCFG_CLEANUP = 0x00cf004, /**< call type-specific cleanup */ - LCFG_ADD_UUID = 0x00cf005, /**< add a nid to a niduuid */ - LCFG_DEL_UUID = 0x00cf006, /**< remove a nid from a niduuid */ - LCFG_MOUNTOPT = 0x00cf007, /**< create a profile (mdc, osc) */ - LCFG_DEL_MOUNTOPT = 0x00cf008, /**< destroy a profile */ - LCFG_SET_TIMEOUT = 0x00cf009, /**< set obd_timeout */ - LCFG_SET_UPCALL = 0x00cf00a, /**< deprecated */ - LCFG_ADD_CONN = 0x00cf00b, /**< add a failover niduuid to an obd */ - LCFG_DEL_CONN = 0x00cf00c, /**< remove a failover niduuid */ - LCFG_LOV_ADD_OBD = 0x00cf00d, /**< add an osc to a lov */ - LCFG_LOV_DEL_OBD = 0x00cf00e, /**< remove an osc from a lov */ - LCFG_PARAM = 0x00cf00f, /**< set a proc parameter */ - LCFG_MARKER = 0x00cf010, /**< metadata about next cfg rec */ - LCFG_LOG_START = 0x00ce011, /**< mgc only, process a cfg log */ - LCFG_LOG_END = 0x00ce012, /**< stop processing updates */ - LCFG_LOV_ADD_INA = 0x00ce013, /**< like LOV_ADD_OBD, inactive */ - LCFG_ADD_MDC = 0x00cf014, /**< add an mdc to a lmv */ - LCFG_DEL_MDC = 0x00cf015, /**< remove an mdc from a lmv */ - LCFG_SPTLRPC_CONF = 0x00ce016, /**< security */ - LCFG_POOL_NEW = 0x00ce020, /**< create an ost pool name */ - LCFG_POOL_ADD = 0x00ce021, /**< add an ost to a pool */ - LCFG_POOL_REM = 0x00ce022, /**< remove an ost from a pool */ - LCFG_POOL_DEL = 0x00ce023, /**< destroy an ost pool name */ - LCFG_SET_LDLM_TIMEOUT = 0x00ce030, /**< set ldlm_timeout */ - LCFG_PRE_CLEANUP = 0x00cf031, /**< call type-specific pre - * cleanup cleanup */ - LCFG_SET_PARAM = 0x00ce032, /**< use set_param syntax to set - *a proc parameters */ - LCFG_NODEMAP_ADD = 0x00ce040, /**< create a cluster */ - LCFG_NODEMAP_DEL = 0x00ce041, /**< destroy a cluster */ - LCFG_NODEMAP_ADD_RANGE = 0x00ce042, /**< add a nid range */ - LCFG_NODEMAP_DEL_RANGE = 0x00ce043, /**< delete an nid range */ - LCFG_NODEMAP_ADD_UIDMAP = 0x00ce044, /**< add a uidmap */ - LCFG_NODEMAP_DEL_UIDMAP = 0x00ce045, /**< delete a uidmap */ - LCFG_NODEMAP_ADD_GIDMAP = 0x00ce046, /**< add a gidmap */ - LCFG_NODEMAP_DEL_GIDMAP = 0x00ce047, /**< delete a gidmap */ - LCFG_NODEMAP_ACTIVATE = 0x00ce048, /**< activate cluster id mapping */ - LCFG_NODEMAP_ADMIN = 0x00ce049, /**< allow cluster to use id 0 */ - LCFG_NODEMAP_TRUSTED = 0x00ce050, /**< trust a clusters ids */ - LCFG_NODEMAP_SQUASH_UID = 0x00ce051, /**< default map uid */ - LCFG_NODEMAP_SQUASH_GID = 0x00ce052, /**< default map gid */ - LCFG_NODEMAP_ADD_SHKEY = 0x00ce053, /**< add shared key to cluster */ - LCFG_NODEMAP_DEL_SHKEY = 0x00ce054, /**< delete shared key from cluster */ - LCFG_NODEMAP_TEST_NID = 0x00ce055, /**< test for nodemap membership */ - LCFG_NODEMAP_TEST_ID = 0x00ce056, /**< test uid/gid mapping */ - LCFG_NODEMAP_SET_FILESET = 0x00ce057, /**< set fileset */ - LCFG_NODEMAP_DENY_UNKNOWN = 0x00ce058, /**< deny squashed nodemap users */ - LCFG_NODEMAP_MAP_MODE = 0x00ce059, /**< set the mapping mode */ -}; - -struct lustre_cfg_bufs { - void *lcfg_buf[LUSTRE_CFG_MAX_BUFCOUNT]; - __u32 lcfg_buflen[LUSTRE_CFG_MAX_BUFCOUNT]; - __u32 lcfg_bufcount; -}; - -struct lustre_cfg { - __u32 lcfg_version; - __u32 lcfg_command; - - __u32 lcfg_num; - __u32 lcfg_flags; - __u64 lcfg_nid; - __u32 lcfg_nal; /* not used any more */ - - __u32 lcfg_bufcount; - __u32 lcfg_buflens[0]; -}; - -enum cfg_record_type { - PORTALS_CFG_TYPE = 1, - LUSTRE_CFG_TYPE = 123, -}; - -#define LUSTRE_CFG_BUFLEN(lcfg, idx) \ - ((lcfg)->lcfg_bufcount <= (idx) \ - ? 0 \ - : (lcfg)->lcfg_buflens[(idx)]) - -static inline void lustre_cfg_bufs_set(struct lustre_cfg_bufs *bufs, - __u32 index, - void *buf, - __u32 buflen) -{ - if (index >= LUSTRE_CFG_MAX_BUFCOUNT) - return; - if (bufs == NULL) - return; - - if (bufs->lcfg_bufcount <= index) - bufs->lcfg_bufcount = index + 1; - - bufs->lcfg_buf[index] = buf; - bufs->lcfg_buflen[index] = buflen; -} - -static inline void lustre_cfg_bufs_set_string(struct lustre_cfg_bufs *bufs, - __u32 index, - char *str) -{ - lustre_cfg_bufs_set(bufs, index, str, str ? strlen(str) + 1 : 0); -} - -static inline void lustre_cfg_bufs_reset(struct lustre_cfg_bufs *bufs, char *name) -{ - memset((bufs), 0, sizeof(*bufs)); - if (name) - lustre_cfg_bufs_set_string(bufs, 0, name); -} - -static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, __u32 index) -{ - __u32 i; - size_t offset; - __u32 bufcount; - - if (!lcfg) - return NULL; - - bufcount = lcfg->lcfg_bufcount; - if (index >= bufcount) - return NULL; - - offset = LCFG_HDR_SIZE(lcfg->lcfg_bufcount); - for (i = 0; i < index; i++) - offset += cfs_size_round(lcfg->lcfg_buflens[i]); - return (char *)lcfg + offset; -} - -static inline void lustre_cfg_bufs_init(struct lustre_cfg_bufs *bufs, - struct lustre_cfg *lcfg) -{ - __u32 i; - bufs->lcfg_bufcount = lcfg->lcfg_bufcount; - for (i = 0; i < bufs->lcfg_bufcount; i++) { - bufs->lcfg_buflen[i] = lcfg->lcfg_buflens[i]; - bufs->lcfg_buf[i] = lustre_cfg_buf(lcfg, i); - } -} - -static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index) -{ - char *s; - - if (lcfg->lcfg_buflens[index] == 0) - return NULL; - - s = lustre_cfg_buf(lcfg, index); - if (s == NULL) - return NULL; - - /* - * make sure it's NULL terminated, even if this kills a char - * of data. Try to use the padding first though. - */ - if (s[lcfg->lcfg_buflens[index] - 1] != '\0') { - size_t last = cfs_size_round(lcfg->lcfg_buflens[index]) - 1; - char lost; - - /* Use the smaller value */ - if (last > lcfg->lcfg_buflens[index]) - last = lcfg->lcfg_buflens[index]; - - lost = s[last]; - s[last] = '\0'; - if (lost != '\0') { - CWARN("Truncated buf %d to '%s' (lost '%c'...)\n", - index, s, lost); - } - } - return s; -} - -static inline __u32 lustre_cfg_len(__u32 bufcount, __u32 *buflens) -{ - __u32 i; - __u32 len; - ENTRY; - - len = LCFG_HDR_SIZE(bufcount); - for (i = 0; i < bufcount; i++) - len += cfs_size_round(buflens[i]); - - RETURN(cfs_size_round(len)); -} - -static inline void lustre_cfg_init(struct lustre_cfg *lcfg, int cmd, - struct lustre_cfg_bufs *bufs) -{ - char *ptr; - __u32 i; - - lcfg->lcfg_version = LUSTRE_CFG_VERSION; - lcfg->lcfg_command = cmd; - lcfg->lcfg_bufcount = bufs->lcfg_bufcount; - - ptr = (char *)lcfg + LCFG_HDR_SIZE(lcfg->lcfg_bufcount); - for (i = 0; i < lcfg->lcfg_bufcount; i++) { - lcfg->lcfg_buflens[i] = bufs->lcfg_buflen[i]; - if (bufs->lcfg_buf[i]) { - memcpy(ptr, bufs->lcfg_buf[i], bufs->lcfg_buflen[i]); - ptr += cfs_size_round(bufs->lcfg_buflen[i]); - } - } -} - -static inline struct lustre_cfg *lustre_cfg_new(int cmd, - struct lustre_cfg_bufs *bufs) -{ - struct lustre_cfg *lcfg; - -#ifdef __KERNEL__ - OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); -#else /* !__KERNEL__ */ - lcfg = malloc(lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); -#endif /* __KERNEL__ */ - - if (lcfg != NULL) - lustre_cfg_init(lcfg, cmd, bufs); - - return lcfg; -} - -static inline void lustre_cfg_free(struct lustre_cfg *lcfg) -{ -#ifdef __KERNEL__ - OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); -#else /* ! __KERNEL__ */ - free(lcfg); -#endif /* __KERNEL__ */ -} - -static inline int lustre_cfg_sanity_check(void *buf, size_t len) -{ - struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; - ENTRY; - if (!lcfg) - RETURN(-EINVAL); - - /* check that the first bits of the struct are valid */ - if (len < LCFG_HDR_SIZE(0)) - RETURN(-EINVAL); - - if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) - RETURN(-EINVAL); - - if (lcfg->lcfg_bufcount >= LUSTRE_CFG_MAX_BUFCOUNT) - RETURN(-EINVAL); - - /* check that the buflens are valid */ - if (len < LCFG_HDR_SIZE(lcfg->lcfg_bufcount)) - RETURN(-EINVAL); - - /* make sure all the pointers point inside the data */ - if (len < lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)) - RETURN(-EINVAL); - - RETURN(0); -} - -/** @} cfg */ - -#endif /* _LUSTRE_CFG_H */ diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index c07366d..ad7a8c6 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -46,7 +46,7 @@ #include #include #include -#include +#include /* target.c */ struct ptlrpc_request; diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 0eb7578..72c43e5 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -128,6 +128,7 @@ struct cfg_interop_param { char *new_param; }; +char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, const char *new_name); int class_process_config(struct lustre_cfg *lcfg); diff --git a/lustre/include/uapi/linux/Makefile.am b/lustre/include/uapi/linux/Makefile.am index fa01e3d..06c3366 100644 --- a/lustre/include/uapi/linux/Makefile.am +++ b/lustre/include/uapi/linux/Makefile.am @@ -30,6 +30,7 @@ # EXTRA_DIST = \ + lustre_cfg.h \ lustre_disk.h \ lustre_fid.h \ lustre_ioctl.h \ diff --git a/lustre/include/uapi/linux/lustre_cfg.h b/lustre/include/uapi/linux/lustre_cfg.h new file mode 100644 index 0000000..b1f68d5 --- /dev/null +++ b/lustre/include/uapi/linux/lustre_cfg.h @@ -0,0 +1,294 @@ +/* + * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2012, 2014, Intel Corporation. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + */ + +#ifndef _UAPI_LUSTRE_CFG_H +#define _UAPI_LUSTRE_CFG_H + +#include +#include + +/* Handle older distros */ +#ifndef __ALIGN_KERNEL +# define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +# define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) +#endif + +/** \defgroup cfg cfg + * + * @{ + */ + +/* + * 1cf6 + * lcfG + */ +#define LUSTRE_CFG_VERSION 0x1cf60001 +#define LUSTRE_CFG_MAX_BUFCOUNT 8 + +#define LCFG_HDR_SIZE(count) \ + __ALIGN_KERNEL(offsetof(struct lustre_cfg, lcfg_buflens[(count)]), 8) + +/** If the LCFG_REQUIRED bit is set in a configuration command, + * then the client is required to understand this parameter + * in order to mount the filesystem. If it does not understand + * a REQUIRED command the client mount will fail. + */ +#define LCFG_REQUIRED 0x0001000 + +enum lcfg_command_type { + LCFG_ATTACH = 0x00cf001, /**< create a new obd instance */ + LCFG_DETACH = 0x00cf002, /**< destroy obd instance */ + LCFG_SETUP = 0x00cf003, /**< call type-specific setup */ + LCFG_CLEANUP = 0x00cf004, /**< call type-specific cleanup + */ + LCFG_ADD_UUID = 0x00cf005, /**< add a nid to a niduuid */ + LCFG_DEL_UUID = 0x00cf006, /**< remove a nid from + * a niduuid + */ + LCFG_MOUNTOPT = 0x00cf007, /**< create a profile + * (mdc, osc) + */ + LCFG_DEL_MOUNTOPT = 0x00cf008, /**< destroy a profile */ + LCFG_SET_TIMEOUT = 0x00cf009, /**< set obd_timeout */ + LCFG_SET_UPCALL = 0x00cf00a, /**< deprecated */ + LCFG_ADD_CONN = 0x00cf00b, /**< add a failover niduuid to + * an obd + */ + LCFG_DEL_CONN = 0x00cf00c, /**< remove a failover niduuid */ + LCFG_LOV_ADD_OBD = 0x00cf00d, /**< add an osc to a lov */ + LCFG_LOV_DEL_OBD = 0x00cf00e, /**< remove an osc from a lov */ + LCFG_PARAM = 0x00cf00f, /**< set a proc parameter */ + LCFG_MARKER = 0x00cf010, /**< metadata about next + * cfg rec + */ + LCFG_LOG_START = 0x00ce011, /**< mgc only, process a + * cfg log + */ + LCFG_LOG_END = 0x00ce012, /**< stop processing updates */ + LCFG_LOV_ADD_INA = 0x00ce013, /**< like LOV_ADD_OBD, + * inactive + */ + LCFG_ADD_MDC = 0x00cf014, /**< add an mdc to a lmv */ + LCFG_DEL_MDC = 0x00cf015, /**< remove an mdc from a lmv */ + LCFG_SPTLRPC_CONF = 0x00ce016, /**< security */ + LCFG_POOL_NEW = 0x00ce020, /**< create an ost pool name */ + LCFG_POOL_ADD = 0x00ce021, /**< add an ost to a pool */ + LCFG_POOL_REM = 0x00ce022, /**< remove an ost from a pool */ + LCFG_POOL_DEL = 0x00ce023, /**< destroy an ost pool name */ + LCFG_SET_LDLM_TIMEOUT = 0x00ce030, /**< set ldlm_timeout */ + LCFG_PRE_CLEANUP = 0x00cf031, /**< call type-specific pre + * cleanup cleanup + */ + LCFG_SET_PARAM = 0x00ce032, /**< use set_param syntax to set + * a proc parameters + */ + LCFG_NODEMAP_ADD = 0x00ce040, /**< create a cluster */ + LCFG_NODEMAP_DEL = 0x00ce041, /**< destroy a cluster */ + LCFG_NODEMAP_ADD_RANGE = 0x00ce042, /**< add a nid range */ + LCFG_NODEMAP_DEL_RANGE = 0x00ce043, /**< delete an nid range */ + LCFG_NODEMAP_ADD_UIDMAP = 0x00ce044, /**< add a uidmap */ + LCFG_NODEMAP_DEL_UIDMAP = 0x00ce045, /**< delete a uidmap */ + LCFG_NODEMAP_ADD_GIDMAP = 0x00ce046, /**< add a gidmap */ + LCFG_NODEMAP_DEL_GIDMAP = 0x00ce047, /**< delete a gidmap */ + LCFG_NODEMAP_ACTIVATE = 0x00ce048, /**< activate cluster + * id mapping + */ + LCFG_NODEMAP_ADMIN = 0x00ce049, /**< allow cluster to use id 0 */ + LCFG_NODEMAP_TRUSTED = 0x00ce050, /**< trust a clusters ids */ + LCFG_NODEMAP_SQUASH_UID = 0x00ce051, /**< default map uid */ + LCFG_NODEMAP_SQUASH_GID = 0x00ce052, /**< default map gid */ + LCFG_NODEMAP_ADD_SHKEY = 0x00ce053, /**< add shared key to cluster */ + LCFG_NODEMAP_DEL_SHKEY = 0x00ce054, /**< delete shared key from + * cluster + */ + LCFG_NODEMAP_TEST_NID = 0x00ce055, /**< test for nodemap + * membership + */ + LCFG_NODEMAP_TEST_ID = 0x00ce056, /**< test uid/gid mapping */ + LCFG_NODEMAP_SET_FILESET = 0x00ce057, /**< set fileset */ + LCFG_NODEMAP_DENY_UNKNOWN = 0x00ce058, /**< deny squashed nodemap + * users + */ + LCFG_NODEMAP_MAP_MODE = 0x00ce059, /**< set the mapping mode */ +}; + +struct lustre_cfg_bufs { + void *lcfg_buf[LUSTRE_CFG_MAX_BUFCOUNT]; + __u32 lcfg_buflen[LUSTRE_CFG_MAX_BUFCOUNT]; + __u32 lcfg_bufcount; +}; + +struct lustre_cfg { + __u32 lcfg_version; + __u32 lcfg_command; + + __u32 lcfg_num; + __u32 lcfg_flags; + __u64 lcfg_nid; + __u32 lcfg_nal; /* not used any more */ + + __u32 lcfg_bufcount; + __u32 lcfg_buflens[0]; +}; + +enum cfg_record_type { + PORTALS_CFG_TYPE = 1, + LUSTRE_CFG_TYPE = 123, +}; + +#define LUSTRE_CFG_BUFLEN(lcfg, idx) \ + ((lcfg)->lcfg_bufcount <= (idx) ? 0 : (lcfg)->lcfg_buflens[(idx)]) + +static inline void lustre_cfg_bufs_set(struct lustre_cfg_bufs *bufs, + __u32 index, void *buf, __u32 buflen) +{ + if (index >= LUSTRE_CFG_MAX_BUFCOUNT) + return; + + if (!bufs) + return; + + if (bufs->lcfg_bufcount <= index) + bufs->lcfg_bufcount = index + 1; + + bufs->lcfg_buf[index] = buf; + bufs->lcfg_buflen[index] = buflen; +} + +static inline void lustre_cfg_bufs_set_string(struct lustre_cfg_bufs *bufs, + __u32 index, char *str) +{ + lustre_cfg_bufs_set(bufs, index, str, str ? strlen(str) + 1 : 0); +} + +static inline void lustre_cfg_bufs_reset(struct lustre_cfg_bufs *bufs, + char *name) +{ + memset((bufs), 0, sizeof(*bufs)); + if (name) + lustre_cfg_bufs_set_string(bufs, 0, name); +} + +static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, __u32 index) +{ + __u32 i; + size_t offset; + __u32 bufcount; + + if (!lcfg) + return NULL; + + bufcount = lcfg->lcfg_bufcount; + if (index >= bufcount) + return NULL; + + offset = LCFG_HDR_SIZE(lcfg->lcfg_bufcount); + for (i = 0; i < index; i++) + offset += __ALIGN_KERNEL(lcfg->lcfg_buflens[i], 8); + return (char *)lcfg + offset; +} + +static inline void lustre_cfg_bufs_init(struct lustre_cfg_bufs *bufs, + struct lustre_cfg *lcfg) +{ + __u32 i; + + bufs->lcfg_bufcount = lcfg->lcfg_bufcount; + for (i = 0; i < bufs->lcfg_bufcount; i++) { + bufs->lcfg_buflen[i] = lcfg->lcfg_buflens[i]; + bufs->lcfg_buf[i] = lustre_cfg_buf(lcfg, i); + } +} + +static inline __u32 lustre_cfg_len(__u32 bufcount, __u32 *buflens) +{ + __u32 i; + __u32 len; + + len = LCFG_HDR_SIZE(bufcount); + for (i = 0; i < bufcount; i++) + len += __ALIGN_KERNEL(buflens[i], 8); + + return __ALIGN_KERNEL(len, 8); +} + +static inline void lustre_cfg_init(struct lustre_cfg *lcfg, int cmd, + struct lustre_cfg_bufs *bufs) +{ + char *ptr; + __u32 i; + + lcfg->lcfg_version = LUSTRE_CFG_VERSION; + lcfg->lcfg_command = cmd; + lcfg->lcfg_bufcount = bufs->lcfg_bufcount; + + ptr = (char *)lcfg + LCFG_HDR_SIZE(lcfg->lcfg_bufcount); + for (i = 0; i < lcfg->lcfg_bufcount; i++) { + lcfg->lcfg_buflens[i] = bufs->lcfg_buflen[i]; + if (bufs->lcfg_buf[i]) { + memcpy(ptr, bufs->lcfg_buf[i], bufs->lcfg_buflen[i]); + ptr += __ALIGN_KERNEL(bufs->lcfg_buflen[i], 8); + } + } +} + +static inline int lustre_cfg_sanity_check(void *buf, size_t len) +{ + struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; + + if (!lcfg) + return -EINVAL; + + /* check that the first bits of the struct are valid */ + if (len < LCFG_HDR_SIZE(0)) + return -EINVAL; + + if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) + return -EINVAL; + + if (lcfg->lcfg_bufcount >= LUSTRE_CFG_MAX_BUFCOUNT) + return -EINVAL; + + /* check that the buflens are valid */ + if (len < LCFG_HDR_SIZE(lcfg->lcfg_bufcount)) + return -EINVAL; + + /* make sure all the pointers point inside the data */ + if (len < lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)) + return -EINVAL; + + return 0; +} + +/** @} cfg */ + +#endif /* _UAPI_LUSTRE_CFG_H */ diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index b388347..09baa1a 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -39,7 +39,7 @@ #define _LOD_INTERNAL_H #include -#include +#include #include #include diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c index 1144165..06dd2ee 100644 --- a/lustre/lod/lproc_lod.c +++ b/lustre/lod/lproc_lod.c @@ -542,9 +542,10 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer, lustre_cfg_bufs_reset(&bufs, NULL); snprintf(str, 32, "%smaxage=%u", PARAM_OSP, (__u32)val); lustre_cfg_bufs_set_string(&bufs, 1, str); - lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, LCFG_PARAM, &bufs); lod_getref(&lod->lod_ost_descs); lod_foreach_ost(lod, i) { @@ -554,7 +555,7 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer, CERROR("can't set maxage on #%d: %d\n", i, rc); } lod_putref(lod, &lod->lod_ost_descs); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); return count; } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e902a3e..1b58617 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4220,12 +4220,13 @@ static void mdt_stack_pre_fini(const struct lu_env *env, * by osd only doesn't have mdt/mdd slices -bzzz */ lustre_cfg_bufs_reset(bufs, mdt_obd_name(m)); lustre_cfg_bufs_set_string(bufs, 1, NULL); - lcfg = lustre_cfg_new(LCFG_PRE_CLEANUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) RETURN_EXIT; + lustre_cfg_init(lcfg, LCFG_PRE_CLEANUP, bufs); top->ld_ops->ldo_process_config(env, top, lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); EXIT; } @@ -4255,13 +4256,14 @@ static void mdt_stack_fini(const struct lu_env *env, if (obd->obd_fail) strcat(flags, "A"); lustre_cfg_bufs_set_string(bufs, 1, flags); - lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) RETURN_EXIT; + lustre_cfg_init(lcfg, LCFG_CLEANUP, bufs); LASSERT(top); top->ld_ops->ldo_process_config(env, top, lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); lu_site_purge(env, top->ld_site, -1); @@ -4381,9 +4383,10 @@ static int mdt_stack_init(const struct lu_env *env, struct mdt_device *mdt, lustre_cfg_bufs_set_string(bufs, 2, uuid); lustre_cfg_bufs_set_string(bufs, 3, lprof->lp_dt); - lcfg = lustre_cfg_new(LCFG_ATTACH, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(put_profile, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_ATTACH, bufs); rc = class_attach(lcfg); if (rc) @@ -4396,16 +4399,17 @@ static int mdt_stack_init(const struct lu_env *env, struct mdt_device *mdt, GOTO(lcfg_cleanup, rc = -EINVAL); } - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); lustre_cfg_bufs_reset(bufs, name); lustre_cfg_bufs_set_string(bufs, 1, uuid); lustre_cfg_bufs_set_string(bufs, 2, dev); lustre_cfg_bufs_set_string(bufs, 3, lprof->lp_dt); - lcfg = lustre_cfg_new(LCFG_SETUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(class_detach, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_SETUP, bufs); rc = class_setup(obd, lcfg); if (rc) @@ -4442,7 +4446,7 @@ class_detach: if (rc) class_detach(obd, lcfg); lcfg_cleanup: - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); put_profile: class_put_profile(lprof); free_bufs: @@ -4513,9 +4517,10 @@ static int mdt_quota_init(const struct lu_env *env, struct mdt_device *mdt, lustre_cfg_bufs_set_string(bufs, 2, uuid); lustre_cfg_bufs_set_string(bufs, 3, lprof->lp_dt); - lcfg = lustre_cfg_new(LCFG_ATTACH, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(put_profile, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_ATTACH, bufs); rc = class_attach(lcfg); if (rc) @@ -4528,7 +4533,7 @@ static int mdt_quota_init(const struct lu_env *env, struct mdt_device *mdt, GOTO(lcfg_cleanup, rc = -EINVAL); } - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); lustre_cfg_bufs_reset(bufs, qmtname); lustre_cfg_bufs_set_string(bufs, 1, uuid); @@ -4538,9 +4543,10 @@ static int mdt_quota_init(const struct lu_env *env, struct mdt_device *mdt, lustre_cfg_bufs_set_string(bufs, 3, mdt->mdt_bottom->dd_lu_dev.ld_obd->obd_name); - lcfg = lustre_cfg_new(LCFG_SETUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(class_detach, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_SETUP, bufs); rc = class_setup(obd, lcfg); if (rc) @@ -4576,7 +4582,7 @@ class_detach: if (rc) class_detach(obd, lcfg); lcfg_cleanup: - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); put_profile: class_put_profile(lprof); cleanup_mem: @@ -5113,9 +5119,9 @@ static int mdt_process_config(const struct lu_env *env, cfg); } - if (old_cfg != NULL) - lustre_cfg_free(cfg); - + if (old_cfg) + OBD_FREE(cfg, lustre_cfg_len(cfg->lcfg_bufcount, + cfg->lcfg_buflens)); break; } default: diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 0266f1e..e6fc636 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1570,17 +1570,20 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, lustre_cfg_bufs_set_string(&bufs, 1, params); - lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); - if (lcfg == NULL) { + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, + bufs.lcfg_buflen)); + if (!lcfg) { rc = -ENOMEM; break; } + lustre_cfg_init(lcfg, LCFG_PARAM, &bufs); CDEBUG(D_INFO, "ir apply logs %lld/%lld for %s -> %s\n", prev_version, max_version, obdname, params); rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, + lcfg->lcfg_buflens)); if (rc) CDEBUG(D_INFO, "process config for %s error %d\n", obdname, rc); diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 7ef4c27..6077b0d 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -133,9 +133,11 @@ static int mgs_set_info(struct tgt_session_info *tsi) /* Construct lustre_cfg structure to pass to function mgs_setparam */ lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL); lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, msp->mgs_param); - lcfg = lustre_cfg_new(LCFG_PARAM, &mgi->mgi_bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(mgi->mgi_bufs.lcfg_bufcount, + mgi->mgi_bufs.lcfg_buflen)); + if (!lcfg) RETURN(-ENOMEM); + lustre_cfg_init(lcfg, LCFG_PARAM, &mgi->mgi_bufs); rc = mgs_setparam(tsi->tsi_env, exp2mgs_dev(tsi->tsi_exp), lcfg, mgi->mgi_fsname); @@ -151,7 +153,7 @@ static int mgs_set_info(struct tgt_session_info *tsi) *rep_msp = *msp; EXIT; out_cfg: - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); return rc; } #endif diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 2df9664..0557d82 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -323,6 +323,40 @@ int class_match_net(char *buf, char *key, __u32 net) return rc; } +char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index) +{ + char *s; + + if (!lcfg->lcfg_buflens[index]) + return NULL; + + s = lustre_cfg_buf(lcfg, index); + if (!s) + return NULL; + + /* + * make sure it's NULL terminated, even if this kills a char + * of data. Try to use the padding first though. + */ + if (s[lcfg->lcfg_buflens[index] - 1] != '\0') { + size_t last = ALIGN(lcfg->lcfg_buflens[index], 8) - 1; + char lost; + + /* Use the smaller value */ + if (last > lcfg->lcfg_buflens[index]) + last = lcfg->lcfg_buflens[index]; + + lost = s[last]; + s[last] = '\0'; + if (lost != '\0') { + CWARN("Truncated buf %d to '%s' (lost '%c'...)\n", + index, s, lost); + } + } + return s; +} +EXPORT_SYMBOL(lustre_cfg_string); + /********************** class fns **********************/ /** @@ -1037,12 +1071,12 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, int new_len = 0; ENTRY; - if (cfg == NULL || new_name == NULL) - RETURN(ERR_PTR(-EINVAL)); + if (!cfg || !new_name) + GOTO(out_nocfg, new_cfg = ERR_PTR(-EINVAL)); param = lustre_cfg_string(cfg, 1); - if (param == NULL) - RETURN(ERR_PTR(-EINVAL)); + if (!param) + GOTO(out_nocfg, new_cfg = ERR_PTR(-EINVAL)); value = strchr(param, '='); if (value == NULL) @@ -1053,34 +1087,37 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len; OBD_ALLOC(new_param, new_len); - if (new_param == NULL) - RETURN(ERR_PTR(-ENOMEM)); + if (!new_param) + GOTO(out_nocfg, new_cfg = ERR_PTR(-ENOMEM)); strcpy(new_param, new_name); if (value != NULL) strcat(new_param, value); OBD_ALLOC_PTR(bufs); - if (bufs == NULL) { - OBD_FREE(new_param, new_len); - RETURN(ERR_PTR(-ENOMEM)); - } + if (!bufs) + GOTO(out_free_param, new_cfg = ERR_PTR(-ENOMEM)); lustre_cfg_bufs_reset(bufs, NULL); lustre_cfg_bufs_init(bufs, cfg); lustre_cfg_bufs_set_string(bufs, 1, new_param); - new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs); - OBD_FREE(new_param, new_len); - OBD_FREE_PTR(bufs); - if (new_cfg == NULL) - RETURN(ERR_PTR(-ENOMEM)); + OBD_ALLOC(new_cfg, lustre_cfg_len(bufs->lcfg_bufcount, + bufs->lcfg_buflen)); + if (!new_cfg) + GOTO(out_free_buf, new_cfg = ERR_PTR(-ENOMEM)); + + lustre_cfg_init(new_cfg, cfg->lcfg_command, bufs); new_cfg->lcfg_num = cfg->lcfg_num; new_cfg->lcfg_flags = cfg->lcfg_flags; new_cfg->lcfg_nid = cfg->lcfg_nid; new_cfg->lcfg_nal = cfg->lcfg_nal; - +out_free_buf: + OBD_FREE_PTR(bufs); +out_free_param: + OBD_FREE(new_param, new_len); +out_nocfg: RETURN(new_cfg); } EXPORT_SYMBOL(lustre_cfg_rename); @@ -1466,7 +1503,7 @@ int class_config_llog_handler(const struct lu_env *env, struct lustre_cfg_bufs bufs; char *inst_name = NULL; int inst_len = 0; - int inst = 0, swab = 0; + int swab = 0; lcfg = (struct lustre_cfg *)cfg_buf; if (lcfg->lcfg_version == __swab32(LUSTRE_CFG_VERSION)) { @@ -1587,7 +1624,6 @@ int class_config_llog_handler(const struct lu_env *env, if (cfg->cfg_instance && LUSTRE_CFG_BUFLEN(lcfg, 0) > 0) { - inst = 1; inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + sizeof(cfg->cfg_instance) * 2 + 4; OBD_ALLOC(inst_name, inst_len); @@ -1667,10 +1703,12 @@ int class_config_llog_handler(const struct lu_env *env, } } - lcfg_new = lustre_cfg_new(lcfg->lcfg_command, &bufs); - if (lcfg_new == NULL) + OBD_ALLOC(lcfg_new, lustre_cfg_len(bufs.lcfg_bufcount, + bufs.lcfg_buflen)); + if (!lcfg_new) GOTO(out, rc = -ENOMEM); + lustre_cfg_init(lcfg_new, lcfg->lcfg_command, &bufs); lcfg_new->lcfg_num = lcfg->lcfg_num; lcfg_new->lcfg_flags = lcfg->lcfg_flags; @@ -1692,9 +1730,9 @@ int class_config_llog_handler(const struct lu_env *env, lcfg_new->lcfg_nal = 0; /* illegal value for obsolete field */ rc = class_process_config(lcfg_new); - lustre_cfg_free(lcfg_new); - - if (inst) + OBD_FREE(lcfg_new, lustre_cfg_len(lcfg_new->lcfg_bufcount, + lcfg_new->lcfg_buflens)); + if (inst_name) OBD_FREE(inst_name, inst_len); break; } @@ -1976,9 +2014,10 @@ int class_manual_cleanup(struct obd_device *obd) lustre_cfg_bufs_reset(&bufs, obd->obd_name); lustre_cfg_bufs_set_string(&bufs, 1, flags); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); + if (!lcfg) RETURN(-ENOMEM); + lustre_cfg_init(lcfg, LCFG_CLEANUP, &bufs); rc = class_process_config(lcfg); if (rc) { @@ -1992,8 +2031,8 @@ int class_manual_cleanup(struct obd_device *obd) if (rc) CERROR("detach failed %d: %s\n", rc, obd->obd_name); out: - lustre_cfg_free(lcfg); - RETURN(rc); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); + RETURN(rc); } EXPORT_SYMBOL(class_manual_cleanup); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 394ee14..f6797c1 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -85,16 +85,18 @@ int lustre_process_log(struct super_block *sb, char *logname, if (bufs == NULL) RETURN(-ENOMEM); - /* mgc_process_config */ - lustre_cfg_bufs_reset(bufs, mgc->obd_name); - lustre_cfg_bufs_set_string(bufs, 1, logname); - lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg)); - lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb)); - lcfg = lustre_cfg_new(LCFG_LOG_START, bufs); - if (lcfg == NULL) + /* mgc_process_config */ + lustre_cfg_bufs_reset(bufs, mgc->obd_name); + lustre_cfg_bufs_set_string(bufs, 1, logname); + lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg)); + lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb)); + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(out, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_LOG_START, bufs); + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); out: OBD_FREE_PTR(bufs); @@ -133,16 +135,17 @@ int lustre_end_log(struct super_block *sb, char *logname, RETURN(-ENOENT); /* mgc_process_config */ - lustre_cfg_bufs_reset(&bufs, mgc->obd_name); - lustre_cfg_bufs_set_string(&bufs, 1, logname); - if (cfg) - lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg)); - lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs); - if (lcfg == NULL) + lustre_cfg_bufs_reset(&bufs, mgc->obd_name); + lustre_cfg_bufs_set_string(&bufs, 1, logname); + if (cfg) + lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg)); + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); + if (!lcfg) RETURN(-ENOMEM); - rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); - lustre_cfg_free(lcfg); - RETURN(rc); + lustre_cfg_init(lcfg, LCFG_LOG_END, &bufs); + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); + RETURN(rc); } EXPORT_SYMBOL(lustre_end_log); @@ -171,13 +174,14 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, if (s4) lustre_cfg_bufs_set_string(&bufs, 4, s4); - lcfg = lustre_cfg_new(cmd, &bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); + if (!lcfg) return -ENOMEM; - lcfg->lcfg_nid = nid; - rc = class_process_config(lcfg); - lustre_cfg_free(lcfg); - return(rc); + lustre_cfg_init(lcfg, cmd, &bufs); + lcfg->lcfg_nid = nid; + rc = class_process_config(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); + return rc; } /** Call class_attach and class_setup. These methods in turn call diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index cec80aa..afd51ac 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -739,15 +739,18 @@ static int lustre_lwp_add_conn(struct lustre_cfg *cfg, lustre_cfg_bufs_set_string(bufs, 1, lustre_cfg_string(cfg, 1)); - lcfg = lustre_cfg_new(LCFG_ADD_CONN, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(out_cfg, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_ADD_CONN, bufs); + rc = class_add_conn(lwp, lcfg); if (rc) CERROR("%s: can't add conn: rc = %d\n", lwpname, rc); - if (lcfg != NULL) - lustre_cfg_free(lcfg); + if (lcfg) + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, + lcfg->lcfg_buflens)); out_cfg: if (bufs != NULL) OBD_FREE_PTR(bufs); @@ -937,15 +940,18 @@ static int lustre_disconnect_lwp(struct super_block *sb) lustre_cfg_bufs_reset(bufs, lwp->obd_name); lustre_cfg_bufs_set_string(bufs, 1, NULL); - lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, + bufs->lcfg_buflen)); + if (!lcfg) GOTO(out, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_CLEANUP, bufs); /* Disconnect import first. NULL is passed for the '@env', * since it will not be used. */ rc = lwp->obd_lu_dev->ld_ops->ldo_process_config(NULL, lwp->obd_lu_dev, lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, + lcfg->lcfg_buflens)); if (rc != 0 && rc != -ETIMEDOUT) { CERROR("%s: fail to disconnect LWP: rc = %d\n", lwp->obd_name, rc); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 5b8b56f..7c8fa9e 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -237,13 +237,14 @@ static void ofd_stack_fini(const struct lu_env *env, struct ofd_device *m, if (obd->obd_fail) strcat(flags, "A"); lustre_cfg_bufs_set_string(&bufs, 1, flags); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); + if (!lcfg) RETURN_EXIT; + lustre_cfg_init(lcfg, LCFG_CLEANUP, &bufs); LASSERT(top); top->ld_ops->ldo_process_config(env, top, lcfg); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); lu_site_purge(env, top->ld_site, ~0); if (!cfs_hash_is_empty(top->ld_site->ls_obj_hash)) { diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index d11a320..d966358 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -114,9 +114,10 @@ static int lwp_setup(const struct lu_env *env, struct lwp_device *lwp, lustre_cfg_bufs_reset(bufs, lwp_name); lustre_cfg_bufs_set_string(bufs, 1, server_uuid); lustre_cfg_bufs_set_string(bufs, 2, nidstring); - lcfg = lustre_cfg_new(LCFG_SETUP, bufs); - if (lcfg == NULL) + OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (!lcfg) GOTO(out, rc = -ENOMEM); + lustre_cfg_init(lcfg, LCFG_SETUP, bufs); rc = client_obd_setup(lwp->lpd_obd, lcfg); if (rc != 0) { @@ -137,8 +138,9 @@ out: OBD_FREE_PTR(bufs); if (server_uuid != NULL) OBD_FREE(server_uuid, len); - if (lcfg != NULL) - lustre_cfg_free(lcfg); + if (lcfg) + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, + lcfg->lcfg_buflens)); if (rc) client_obd_cleanup(lwp->lpd_obd); diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c index 949fed0..769a40a 100644 --- a/lustre/utils/llog_reader.c +++ b/lustre/utils/llog_reader.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ #include #include #include -#include +#include static inline int ext2_test_bit(int nr, const void *addr) { @@ -377,6 +378,38 @@ static void print_1_cfg(struct lustre_cfg *lcfg) return; } +static char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index) +{ + char *s; + + if (lcfg->lcfg_buflens[index] == 0) + return NULL; + + s = lustre_cfg_buf(lcfg, index); + if (s == NULL) + return NULL; + + /* + * make sure it's NULL terminated, even if this kills a char + * of data. Try to use the padding first though. + */ + if (s[lcfg->lcfg_buflens[index] - 1] != '\0') { + size_t last = __ALIGN_KERNEL(lcfg->lcfg_buflens[index], 8) - 1; + char lost; + + /* Use the smaller value */ + if (last > lcfg->lcfg_buflens[index]) + last = lcfg->lcfg_buflens[index]; + + lost = s[last]; + s[last] = '\0'; + if (lost != '\0') { + fprintf(stderr, "Truncated buf %d to '%s' (lost '%c'...)\n", + index, s, lost); + } + } + return s; +} static void print_setup_cfg(struct lustre_cfg *lcfg) { diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 9c4ef3f..ebe038b 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include @@ -114,10 +114,28 @@ int jt_lcfg_device(int argc, char **argv) return jt_obd_device(argc, argv); } +static int jt_lcfg_ioctl(struct lustre_cfg_bufs *bufs, char *arg, int cmd) +{ + struct lustre_cfg *lcfg; + int rc; + + lcfg = malloc(lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); + if (lcfg == NULL) { + rc = -ENOMEM; + } else { + lustre_cfg_init(lcfg, cmd, bufs); + rc = lcfg_ioctl(arg, OBD_DEV_ID, lcfg); + free(lcfg); + } + if (rc < 0) + fprintf(stderr, "error: %s: %s\n", jt_cmdname(arg), + strerror(rc = errno)); + return rc; +} + int jt_lcfg_attach(int argc, char **argv) { struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; int rc; if (argc != 4) @@ -129,29 +147,17 @@ int jt_lcfg_attach(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, 0, argv[2]); lustre_cfg_bufs_set_string(&bufs, 2, argv[3]); - lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) { - fprintf(stderr, "error: %s: LCFG_ATTACH %s\n", - jt_cmdname(argv[0]), strerror(rc = errno)); - } else { - lcfg_set_devname(argv[2]); - } + rc = jt_lcfg_ioctl(&bufs, argv[0], LCFG_ATTACH); + if (rc == 0) + lcfg_set_devname(argv[2]); - return rc; + return rc; } int jt_lcfg_setup(int argc, char **argv) { struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; int i; - int rc; if (lcfg_devname == NULL) { fprintf(stderr, "%s: please use 'device name' to set the " @@ -169,25 +175,12 @@ int jt_lcfg_setup(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, i, argv[i]); } - lcfg = lustre_cfg_new(LCFG_SETUP, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_SETUP); } int jt_obd_detach(int argc, char **argv) { struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; - int rc; if (lcfg_devname == NULL) { fprintf(stderr, "%s: please use 'device name' to set the " @@ -201,29 +194,16 @@ int jt_obd_detach(int argc, char **argv) if (argc != 1) return CMD_HELP; - lcfg = lustre_cfg_new(LCFG_DETACH, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DETACH); } int jt_obd_cleanup(int argc, char **argv) { struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; char force = 'F'; char failover = 'A'; char flags[3] = { 0 }; int flag_cnt = 0, n; - int rc; if (lcfg_devname == NULL) { fprintf(stderr, "%s: please use 'device name' to set the " @@ -255,22 +235,11 @@ int jt_obd_cleanup(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, 1, flags); } - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_CLEANUP); } static -int do_add_uuid(char * func, char *uuid, lnet_nid_t nid) +int do_add_uuid(char *func, char *uuid, lnet_nid_t nid) { int rc; struct lustre_cfg_bufs bufs; @@ -280,14 +249,15 @@ int do_add_uuid(char * func, char *uuid, lnet_nid_t nid) if (uuid != NULL) lustre_cfg_bufs_set_string(&bufs, 1, uuid); - lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs); + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) { rc = -ENOMEM; } else { + lustre_cfg_init(lcfg, LCFG_ADD_UUID, &bufs); lcfg->lcfg_nid = nid; rc = lcfg_ioctl(func, OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); + free(lcfg); } if (rc) { fprintf(stderr, "IOC_PORTAL_ADD_UUID failed: %s\n", @@ -320,9 +290,7 @@ int jt_lcfg_add_uuid(int argc, char **argv) int jt_lcfg_del_uuid(int argc, char **argv) { - int rc; struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; if (argc != 2) { fprintf(stderr, "usage: %s \n", argv[0]); @@ -333,26 +301,12 @@ int jt_lcfg_del_uuid(int argc, char **argv) if (strcmp (argv[1], "_all_")) lustre_cfg_bufs_set_string(&bufs, 1, argv[1]); - lcfg = lustre_cfg_new(LCFG_DEL_UUID, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc) { - fprintf(stderr, "IOC_PORTAL_DEL_UUID failed: %s\n", - strerror(errno)); - return -1; - } - return 0; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_UUID); } int jt_lcfg_del_mount_option(int argc, char **argv) { - int rc; struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; if (argc != 2) return CMD_HELP; @@ -362,18 +316,7 @@ int jt_lcfg_del_mount_option(int argc, char **argv) /* profile name */ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]); - lcfg = lustre_cfg_new(LCFG_DEL_MOUNTOPT, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) { - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - } - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_MOUNTOPT); } int jt_lcfg_set_timeout(int argc, char **argv) @@ -392,14 +335,16 @@ int jt_lcfg_set_timeout(int argc, char **argv) return CMD_HELP; lustre_cfg_bufs_reset(&bufs, lcfg_devname); - lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs); + + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) { rc = -ENOMEM; } else { + lustre_cfg_init(lcfg, LCFG_SET_TIMEOUT, &bufs); lcfg->lcfg_num = atoi(argv[1]); rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); + free(lcfg); } if (rc < 0) { fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), @@ -433,14 +378,15 @@ int jt_lcfg_add_conn(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, 1, argv[1]); - lcfg = lustre_cfg_new(LCFG_ADD_CONN, &bufs); + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) { rc = -ENOMEM; } else { + lustre_cfg_init(lcfg, LCFG_ADD_CONN, &bufs); lcfg->lcfg_num = priority; rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); + free(lcfg); } if (rc < 0) { fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), @@ -453,8 +399,6 @@ int jt_lcfg_add_conn(int argc, char **argv) int jt_lcfg_del_conn(int argc, char **argv) { struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; - int rc; if (argc != 2) return CMD_HELP; @@ -471,27 +415,14 @@ int jt_lcfg_del_conn(int argc, char **argv) /* connection uuid */ lustre_cfg_bufs_set_string(&bufs, 1, argv[1]); - lcfg = lustre_cfg_new(LCFG_DEL_MOUNTOPT, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) { - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - } - - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_DEL_MOUNTOPT); } /* Param set locally, directly on target */ int jt_lcfg_param(int argc, char **argv) { - int i, rc; - struct lustre_cfg_bufs bufs; - struct lustre_cfg *lcfg; + struct lustre_cfg_bufs bufs; + int i; if (argc >= LUSTRE_CFG_MAX_BUFCOUNT) return CMD_HELP; @@ -502,18 +433,7 @@ int jt_lcfg_param(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, i, argv[i]); } - lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); - if (lcfg == NULL) { - rc = -ENOMEM; - } else { - rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg); - lustre_cfg_free(lcfg); - } - if (rc < 0) { - fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - } - return rc; + return jt_lcfg_ioctl(&bufs, argv[0], LCFG_PARAM); } struct param_opts { @@ -575,21 +495,26 @@ static int jt_lcfg_mgsparam2(int argc, char **argv, struct param_opts *popt) } lustre_cfg_bufs_set_string(&bufs, 1, buf); - lcfg = lustre_cfg_new(LCFG_SET_PARAM, &bufs); + + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, + bufs.lcfg_buflen)); if (lcfg == NULL) { fprintf(stderr, "error: allocating lcfg for %s: %s\n", jt_cmdname(argv[0]), strerror(-ENOMEM)); if (rc == 0) rc = -ENOMEM; } else { - int rc2 = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); + int rc2; + + lustre_cfg_init(lcfg, LCFG_SET_PARAM, &bufs); + rc2 = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); if (rc2 != 0) { fprintf(stderr, "error: executing %s: %s\n", jt_cmdname(argv[0]), strerror(errno)); if (rc == 0) rc = rc2; } - lustre_cfg_free(lcfg); + free(lcfg); } if (buf != argv[i]) free(buf); @@ -647,15 +572,16 @@ int jt_lcfg_mgsparam(int argc, char **argv) lustre_cfg_bufs_set_string(&bufs, 1, argv[optind]); } - /* We could put other opcodes here. */ - lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); + /* We could put other opcodes here. */ + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) { rc = -ENOMEM; } else { + lustre_cfg_init(lcfg, LCFG_PARAM, &bufs); rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg); if (rc < 0) rc = -errno; - lustre_cfg_free(lcfg); + free(lcfg); } if (buf) free(buf); diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 22b84f4..ccb33cd 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 07fb7a9..b45c09d 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -69,7 +69,7 @@ #include #include -#include +#include #include #include @@ -3117,9 +3117,11 @@ static int pool_cmd(enum lcfg_command_type cmd, if (ostname != NULL) lustre_cfg_bufs_set_string(&bufs, 2, ostname); - lcfg = lustre_cfg_new(cmd, &bufs); + + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, cmd, &bufs); memset(&data, 0, sizeof(data)); rc = data.ioc_dev = get_mgs_device(); @@ -3136,14 +3138,14 @@ static int pool_cmd(enum lcfg_command_type cmd, if (rc) { fprintf(stderr, "error: %s: invalid ioctl\n", jt_cmdname(cmdname)); - lustre_cfg_free(lcfg); + free(lcfg); return rc; } rc = l_ioctl(OBD_DEV_ID, OBD_IOC_POOL, buf); out: if (rc) rc = -errno; - lustre_cfg_free(lcfg); + free(lcfg); return rc; } @@ -3183,9 +3185,10 @@ static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data, } va_end(ap); - lcfg = lustre_cfg_new(cmd, &bufs); + lcfg = malloc(lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, cmd, &bufs); memset(&data, 0, sizeof(data)); rc = data.ioc_dev = get_mgs_device(); @@ -3223,7 +3226,7 @@ static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data, memcpy(ret_data, data.ioc_pbuf1, ret_size); } out: - lustre_cfg_free(lcfg); + free(lcfg); return rc; } -- 1.8.3.1