From a44f229bcfd8636517460788753070f8af2b0ebf Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 28 Apr 2014 17:06:40 -0500 Subject: [PATCH] LU-4961 lustre: move ioctls to lustre_ioctl.h Move ioctl definitions and related functions from lustre_dlm.h, lustre_lib.h, obd.h, to lustre_ioctl.h. Replace the definitions of retired ioctls with comment. Remove inclusions of lustre_dlm.h, lustre_lib.h, and obd.h in userspace, adding lustre_ioctl.h where needed. Remove the uses of lov_stripe_md from jt_obd_create() in lustre/utils/obd.c. Remove the unused commands obdio and obdbarrier. Signed-off-by: John L. Hammond Change-Id: I076ac84084ae3166e9b4525f2813510482523dc9 Reviewed-on: http://review.whamcloud.com/10139 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Robert Read --- libcfs/include/libcfs/libcfs_ioctl.h | 3 +- lustre/include/Makefile.am | 1 + lustre/include/linux/lustre_lib.h | 6 - lustre/include/lustre/lustre_user.h | 26 +-- lustre/include/lustre_dlm.h | 11 - lustre/include/lustre_ioctl.h | 405 ++++++++++++++++++++++++++++++++ lustre/include/lustre_lib.h | 437 ----------------------------------- lustre/include/lustre_log.h | 1 + lustre/include/obd.h | 10 - lustre/llite/dir.c | 15 +- lustre/llite/file.c | 1 + lustre/llite/llite_lib.c | 1 + lustre/lmv/lmv_obd.c | 1 + lustre/lov/lov_obd.c | 1 + lustre/mdc/mdc_request.c | 1 + lustre/mdd/mdd_device.c | 1 + lustre/mdt/mdt_handler.c | 1 + lustre/mgs/mgs_handler.c | 1 + lustre/mgs/mgs_llog.c | 1 + lustre/obdclass/class_obd.c | 7 +- lustre/obdclass/linux/linux-module.c | 1 + lustre/obdclass/llog_ioctl.c | 1 + lustre/obdclass/obd_config.c | 1 + lustre/obdclass/obd_mount_server.c | 1 + lustre/obdecho/echo_client.c | 162 +------------ lustre/ofd/ofd_obd.c | 1 + lustre/osc/osc_request.c | 1 + lustre/osp/osp_dev.c | 1 + lustre/tests/ll_dirstripe_verify.c | 2 - lustre/tests/mpi/mdsrate.c | 2 +- lustre/tests/rwv.c | 1 - lustre/tests/statmany.c | 3 +- lustre/tests/statone.c | 3 +- lustre/utils/.gitignore | 2 - lustre/utils/Makefile.am | 4 - lustre/utils/lfs.c | 1 - lustre/utils/liblustreapi.c | 10 +- lustre/utils/liblustreapi_hsm.c | 1 - lustre/utils/loadgen.c | 1 + lustre/utils/lustre_cfg.c | 8 - lustre/utils/lustre_lfsck.c | 2 +- lustre/utils/obd.c | 198 ++-------------- lustre/utils/obdbarrier.c | 239 ------------------- lustre/utils/obdctl.h | 6 +- lustre/utils/obdio.c | 310 ------------------------- lustre/utils/obdiolib.c | 406 -------------------------------- lustre/utils/obdiolib.h | 82 ------- lustre/utils/wirecheck.c | 1 - lustre/utils/wirehdr.c | 1 - lustre/utils/wiretest.c | 1 - 50 files changed, 462 insertions(+), 1922 deletions(-) create mode 100644 lustre/include/lustre_ioctl.h delete mode 100644 lustre/utils/obdbarrier.c delete mode 100644 lustre/utils/obdio.c delete mode 100644 lustre/utils/obdiolib.c delete mode 100644 lustre/utils/obdiolib.h diff --git a/libcfs/include/libcfs/libcfs_ioctl.h b/libcfs/include/libcfs/libcfs_ioctl.h index 2f51d19..ba4350b 100644 --- a/libcfs/include/libcfs/libcfs_ioctl.h +++ b/libcfs/include/libcfs/libcfs_ioctl.h @@ -106,10 +106,9 @@ struct libcfs_ioctl_handler { #endif -/* FIXME check conflict with lustre_lib.h */ +/* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */ #define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long) - /* ioctls for manipulating snapshots 30- */ #define IOC_LIBCFS_TYPE 'e' #define IOC_LIBCFS_MIN_NR 30 diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index 41f07f6..093b587 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -64,6 +64,7 @@ EXTRA_DIST = \ lustre_handles.h \ lustre_idmap.h \ lustre_import.h \ + lustre_ioctl.h \ lustre_lfsck.h \ lustre_lib.h \ lustre_linkea.h \ diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 82a6abd..2110b3a 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -69,12 +69,6 @@ #endif #endif -/* This macro is only for compatibility reasons with older Linux Lustre user - * tools. New ioctls should NOT use this macro as the ioctl "size". Instead - * the ioctl should get a "size" argument which is the actual data type used - * by the ioctl, to ensure the ioctl interface is versioned correctly. */ -#define OBD_IOC_DATA_TYPE long - #define LUSTRE_FATAL_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | \ sigmask(SIGTERM) | sigmask(SIGQUIT) | \ sigmask(SIGALRM)) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 9aea58b..59532f7 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -216,26 +216,20 @@ struct ost_id { * *STRIPE* - set/get lov_user_md * *INFO - set/get lov_user_mds_data */ -/* see for ioctl numberss 101-150 */ +/* lustre_ioctl.h 101-150 */ #define LL_IOC_GETFLAGS _IOR ('f', 151, long) #define LL_IOC_SETFLAGS _IOW ('f', 152, long) #define LL_IOC_CLRFLAGS _IOW ('f', 153, long) -/* LL_IOC_LOV_SETSTRIPE: See also OBD_IOC_LOV_SETSTRIPE */ #define LL_IOC_LOV_SETSTRIPE _IOW ('f', 154, long) -/* LL_IOC_LOV_GETSTRIPE: See also OBD_IOC_LOV_GETSTRIPE */ #define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long) -/* LL_IOC_LOV_SETEA: See also OBD_IOC_LOV_SETEA */ #define LL_IOC_LOV_SETEA _IOW ('f', 156, long) #define LL_IOC_RECREATE_OBJ _IOW ('f', 157, long) #define LL_IOC_RECREATE_FID _IOW ('f', 157, struct lu_fid) #define LL_IOC_GROUP_LOCK _IOW ('f', 158, long) #define LL_IOC_GROUP_UNLOCK _IOW ('f', 159, long) -/* LL_IOC_QUOTACHECK: See also OBD_IOC_QUOTACHECK */ -#define LL_IOC_QUOTACHECK _IOW ('f', 160, int) -/* LL_IOC_POLL_QUOTACHECK: See also OBD_IOC_POLL_QUOTACHECK */ -#define LL_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *) -/* LL_IOC_QUOTACTL: See also OBD_IOC_QUOTACTL */ -#define LL_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl) +/* LL_IOC_QUOTACHECK 160 OBD_IOC_QUOTACHECK */ +/* LL_IOC_POLL_QUOTACHECK 161 OBD_IOC_POLL_QUOTACHECK */ +/* LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */ #define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) #define IOC_LOV_GETINFO _IOWR('f', 165, struct lov_user_mds_data *) #define LL_IOC_FLUSHCTX _IOW ('f', 166, long) @@ -248,9 +242,7 @@ struct ost_id { #define LL_IOC_PATH2FID _IOR ('f', 173, long) #define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *) #define LL_IOC_GET_MDTIDX _IOR ('f', 175, int) - -/* see for ioctl numbers 177-210 */ - +/* lustre_ioctl.h 177-210 */ #define LL_IOC_HSM_STATE_GET _IOR('f', 211, struct hsm_user_state) #define LL_IOC_HSM_STATE_SET _IOW('f', 212, struct hsm_state_set) #define LL_IOC_HSM_CT_START _IOW('f', 213, struct lustre_kernelcomm) @@ -263,8 +255,7 @@ struct ost_id { struct lustre_swap_layouts) #define LL_IOC_HSM_ACTION _IOR('f', 220, \ struct hsm_current_action) -/* see for ioctl numbers 221-232 */ - +/* lustre_ioctl.h 221-232 */ #define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) #define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) #define LL_IOC_REMOVE_ENTRY _IOWR('f', 242, __u64) @@ -284,11 +275,6 @@ struct ost_id { #define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *) #define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *) -/* Keep these for backward compartability. */ -#define LL_IOC_OBD_STATFS IOC_OBD_STATFS -#define IOC_MDC_GETSTRIPE IOC_MDC_GETFILESTRIPE - - #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */ /* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 0c669cc..de9863f 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1460,17 +1460,6 @@ int ldlm_cli_cancel_list(cfs_list_t *head, int count, int intent_disposition(struct ldlm_reply *rep, int flag); void intent_set_disposition(struct ldlm_reply *rep, int flag); - -/* ioctls for trying requests */ -#define IOC_LDLM_TYPE 'f' -#define IOC_LDLM_MIN_NR 40 - -#define IOC_LDLM_TEST _IOWR('f', 40, long) -#define IOC_LDLM_DUMP _IOWR('f', 41, long) -#define IOC_LDLM_REGRESS_START _IOWR('f', 42, long) -#define IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long) -#define IOC_LDLM_MAX_NR 43 - /** * "Modes" of acquiring lock_res, necessary to tell lockdep that taking more * than one lock_res is dead-lock safe. diff --git a/lustre/include/lustre_ioctl.h b/lustre/include/lustre_ioctl.h new file mode 100644 index 0000000..dc48ad0 --- /dev/null +++ b/lustre/include/lustre_ioctl.h @@ -0,0 +1,405 @@ +/* + * 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, 2013, 2014, Intel Corporation. + */ +#ifndef LUSTRE_IOCTL_H_ +#define LUSTRE_IOCTL_H_ + +#include +#include + +#ifdef __KERNEL__ +# include +# include +# include +#else /* __KERNEL__ */ +# include +# include +#endif /* !__KERNEL__ */ + +#if !defined(__KERNEL__) && !defined(LUSTRE_UTILS) +# error This file is for Lustre internal use only. +#endif + +enum md_echo_cmd { + ECHO_MD_CREATE = 1, /* Open/Create file on MDT */ + ECHO_MD_MKDIR = 2, /* Mkdir on MDT */ + ECHO_MD_DESTROY = 3, /* Unlink file on MDT */ + ECHO_MD_RMDIR = 4, /* Rmdir on MDT */ + ECHO_MD_LOOKUP = 5, /* Lookup on MDT */ + ECHO_MD_GETATTR = 6, /* Getattr on MDT */ + ECHO_MD_SETATTR = 7, /* Setattr on MDT */ + ECHO_MD_ALLOC_FID = 8, /* Get FIDs from MDT */ +}; + +#define OBD_IOCTL_VERSION 0x00010004 +#define OBD_DEV_BY_DEVNAME 0xffffd0de +#define OBD_MAX_IOCTL_BUFFER CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER + +struct obd_ioctl_data { + __u32 ioc_len; + __u32 ioc_version; + + union { + __u64 ioc_cookie; + __u64 ioc_u64_1; + }; + union { + __u32 ioc_conn1; + __u32 ioc_u32_1; + }; + union { + __u32 ioc_conn2; + __u32 ioc_u32_2; + }; + + struct obdo ioc_obdo1; + struct obdo ioc_obdo2; + + obd_size ioc_count; + obd_off ioc_offset; + __u32 ioc_dev; + __u32 ioc_command; + + __u64 ioc_nid; + __u32 ioc_nal; + __u32 ioc_type; + + /* buffers the kernel will treat as user pointers */ + __u32 ioc_plen1; + char *ioc_pbuf1; + __u32 ioc_plen2; + char *ioc_pbuf2; + + /* inline buffers for various arguments */ + __u32 ioc_inllen1; + char *ioc_inlbuf1; + __u32 ioc_inllen2; + char *ioc_inlbuf2; + __u32 ioc_inllen3; + char *ioc_inlbuf3; + __u32 ioc_inllen4; + char *ioc_inlbuf4; + + char ioc_bulk[0]; +}; + +struct obd_ioctl_hdr { + __u32 ioc_len; + __u32 ioc_version; +}; + +static inline int obd_ioctl_packlen(struct obd_ioctl_data *data) +{ + int len = cfs_size_round(sizeof(*data)); + + len += cfs_size_round(data->ioc_inllen1); + len += cfs_size_round(data->ioc_inllen2); + len += cfs_size_round(data->ioc_inllen3); + len += cfs_size_round(data->ioc_inllen4); + + return len; +} + +static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) +{ + if (data->ioc_len > (1 << 30)) { + CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen1 > (1 << 30)) { + CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen2 > (1 << 30)) { + CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen3 > (1 << 30)) { + CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen4 > (1 << 30)) { + CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inlbuf1 != NULL && data->ioc_inllen1 == 0) { + CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf2 != NULL && data->ioc_inllen2 == 0) { + CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf3 != NULL && data->ioc_inllen3 == 0) { + CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf4 != NULL && data->ioc_inllen4 == 0) { + CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf1 != NULL && data->ioc_plen1 == 0) { + CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf2 != NULL && data->ioc_plen2 == 0) { + CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf1 == NULL && data->ioc_plen1 != 0) { + CERROR("OBD ioctl: plen1 set but NULL pointer\n"); + return 1; + } + + if (data->ioc_pbuf2 == NULL && data->ioc_plen2 != 0) { + CERROR("OBD ioctl: plen2 set but NULL pointer\n"); + return 1; + } + + if (obd_ioctl_packlen(data) > data->ioc_len) { + CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", + obd_ioctl_packlen(data), data->ioc_len); + return 1; + } + + return 0; +} + +#ifdef __KERNEL__ + +int obd_ioctl_getdata(char **buf, int *len, void *arg); +int obd_ioctl_popdata(void *arg, void *data, int len); + +static inline void obd_ioctl_freedata(char *buf, int len) +{ + ENTRY; + + OBD_FREE_LARGE(buf, len); + EXIT; +} + +#else /* __KERNEL__ */ + +static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, + int max_len) +{ + char *ptr; + struct obd_ioctl_data *overlay; + + data->ioc_len = obd_ioctl_packlen(data); + data->ioc_version = OBD_IOCTL_VERSION; + + if (*pbuf != NULL && data->ioc_len > max_len) { + fprintf(stderr, "pbuf = %p, ioc_len = %u, max_len = %d\n", + *pbuf, data->ioc_len, max_len); + return -EINVAL; + } + + if (*pbuf == NULL) + *pbuf = malloc(data->ioc_len); + + if (*pbuf == NULL) + return -ENOMEM; + + overlay = (struct obd_ioctl_data *)*pbuf; + memcpy(*pbuf, data, sizeof(*data)); + + ptr = overlay->ioc_bulk; + if (data->ioc_inlbuf1 != NULL) + LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr); + + if (data->ioc_inlbuf2 != NULL) + LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr); + + if (data->ioc_inlbuf3 != NULL) + LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr); + + if (data->ioc_inlbuf4 != NULL) + LOGL(data->ioc_inlbuf4, data->ioc_inllen4, ptr); + + if (obd_ioctl_is_invalid(overlay)) { + fprintf(stderr, "invalid ioctl data: ioc_len = %u, " + "max_len = %d\n", + data->ioc_len, max_len); + return -EINVAL; + } + + return 0; +} + +static inline int +obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len) +{ + char *ptr; + struct obd_ioctl_data *overlay; + + if (pbuf == NULL) + return 1; + + overlay = (struct obd_ioctl_data *)pbuf; + + /* Preserve the caller's buffer pointers */ + overlay->ioc_inlbuf1 = data->ioc_inlbuf1; + overlay->ioc_inlbuf2 = data->ioc_inlbuf2; + overlay->ioc_inlbuf3 = data->ioc_inlbuf3; + overlay->ioc_inlbuf4 = data->ioc_inlbuf4; + + memcpy(data, pbuf, sizeof(*data)); + + ptr = overlay->ioc_bulk; + if (data->ioc_inlbuf1 != NULL) + LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr); + + if (data->ioc_inlbuf2 != NULL) + LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr); + + if (data->ioc_inlbuf3 != NULL) + LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr); + + if (data->ioc_inlbuf4 != NULL) + LOGU(data->ioc_inlbuf4, data->ioc_inllen4, ptr); + + return 0; +} + +#endif /* !__KERNEL__ */ + +/* OBD_IOC_DATA_TYPE is only for compatibility reasons with older + * Linux Lustre user tools. New ioctls should NOT use this macro as + * the ioctl "size". Instead the ioctl should get a "size" argument + * which is the actual data type used by the ioctl, to ensure the + * ioctl interface is versioned correctly. */ +#define OBD_IOC_DATA_TYPE long + +/* IOC_LDLM_TEST _IOWR('f', 40, long) */ +/* IOC_LDLM_DUMP _IOWR('f', 41, long) */ +/* IOC_LDLM_REGRESS_START _IOWR('f', 42, long) */ +/* IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long) */ + +#define OBD_IOC_CREATE _IOWR('f', 101, OBD_IOC_DATA_TYPE) +#define OBD_IOC_DESTROY _IOW ('f', 104, OBD_IOC_DATA_TYPE) +/* OBD_IOC_PREALLOCATE _IOWR('f', 105, OBD_IOC_DATA_TYPE) */ + +#define OBD_IOC_SETATTR _IOW ('f', 107, OBD_IOC_DATA_TYPE) +#define OBD_IOC_GETATTR _IOWR('f', 108, OBD_IOC_DATA_TYPE) +#define OBD_IOC_READ _IOWR('f', 109, OBD_IOC_DATA_TYPE) +#define OBD_IOC_WRITE _IOWR('f', 110, OBD_IOC_DATA_TYPE) + +#define OBD_IOC_STATFS _IOWR('f', 113, OBD_IOC_DATA_TYPE) +#define OBD_IOC_SYNC _IOW ('f', 114, OBD_IOC_DATA_TYPE) +/* OBD_IOC_READ2 _IOWR('f', 115, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_FORMAT _IOWR('f', 116, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_PARTITION _IOWR('f', 117, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_COPY _IOWR('f', 120, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_MIGR _IOWR('f', 121, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_PUNCH _IOWR('f', 122, OBD_IOC_DATA_TYPE) */ + +/* OBD_IOC_MODULE_DEBUG _IOWR('f', 124, OBD_IOC_DATA_TYPE) */ +#define OBD_IOC_BRW_READ _IOWR('f', 125, OBD_IOC_DATA_TYPE) +#define OBD_IOC_BRW_WRITE _IOWR('f', 126, OBD_IOC_DATA_TYPE) +#define OBD_IOC_NAME2DEV _IOWR('f', 127, OBD_IOC_DATA_TYPE) +#define OBD_IOC_UUID2DEV _IOWR('f', 130, OBD_IOC_DATA_TYPE) +#define OBD_IOC_GETNAME _IOWR('f', 131, OBD_IOC_DATA_TYPE) +#define OBD_IOC_GETMDNAME _IOR ('f', 131, char[MAX_OBD_NAME]) +#define OBD_IOC_GETDTNAME OBD_IOC_GETNAME +#define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, OBD_IOC_DATA_TYPE) +#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, OBD_IOC_DATA_TYPE) +#define OBD_IOC_PING_TARGET _IOW ('f', 136, OBD_IOC_DATA_TYPE) + +/* OBD_IOC_DEC_FS_USE_COUNT _IO('f', 139) */ +#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, OBD_IOC_DATA_TYPE) +#define OBD_IOC_SET_READONLY _IOW ('f', 141, OBD_IOC_DATA_TYPE) +#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, OBD_IOC_DATA_TYPE) +/* OBD_IOC_ROOT_SQUASH _IOWR('f', 143, OBD_IOC_DATA_TYPE) */ +#define OBD_GET_VERSION _IOWR('f', 144, OBD_IOC_DATA_TYPE) +/* OBD_IOC_GSS_SUPPORT _IOWR('f', 145, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_CLOSE_UUID _IOWR('f', 147, OBD_IOC_DATA_TYPE) */ +#define OBD_IOC_CHANGELOG_SEND _IOW ('f', 148, OBD_IOC_DATA_TYPE) +#define OBD_IOC_GETDEVICE _IOWR('f', 149, OBD_IOC_DATA_TYPE) +#define OBD_IOC_FID2PATH _IOWR('f', 150, OBD_IOC_DATA_TYPE) +/* lustre/lustre_user.h 151-153 */ +/* OBD_IOC_LOV_SETSTRIPE 154 LL_IOC_LOV_SETSTRIPE */ +/* OBD_IOC_LOV_GETSTRIPE 155 LL_IOC_LOV_GETSTRIPE */ +/* OBD_IOC_LOV_SETEA 156 LL_IOC_LOV_SETEA */ +/* lustre/lustre_user.h 157-159 */ +#define OBD_IOC_QUOTACHECK _IOW ('f', 160, int) +#define OBD_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *) +#define OBD_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl) +/* lustre/lustre_user.h 163-176 */ +#define OBD_IOC_CHANGELOG_REG _IOW ('f', 177, struct obd_ioctl_data) +#define OBD_IOC_CHANGELOG_DEREG _IOW ('f', 178, struct obd_ioctl_data) +#define OBD_IOC_CHANGELOG_CLEAR _IOW ('f', 179, struct obd_ioctl_data) +/* OBD_IOC_RECORD _IOWR('f', 180, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_ENDRECORD _IOWR('f', 181, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_PARSE _IOWR('f', 182, OBD_IOC_DATA_TYPE) */ +/* OBD_IOC_DORECORD _IOWR('f', 183, OBD_IOC_DATA_TYPE) */ +#define OBD_IOC_PROCESS_CFG _IOWR('f', 184, OBD_IOC_DATA_TYPE) +#define OBD_IOC_DUMP_LOG _IOWR('f', 185, OBD_IOC_DATA_TYPE) +/* OBD_IOC_CLEAR_LOG _IOWR('f', 186, OBD_IOC_DATA_TYPE) */ +#define OBD_IOC_PARAM _IOW ('f', 187, OBD_IOC_DATA_TYPE) +#define OBD_IOC_POOL _IOWR('f', 188, OBD_IOC_DATA_TYPE) +#define OBD_IOC_REPLACE_NIDS _IOWR('f', 189, OBD_IOC_DATA_TYPE) + +#define OBD_IOC_CATLOGLIST _IOWR('f', 190, OBD_IOC_DATA_TYPE) +#define OBD_IOC_LLOG_INFO _IOWR('f', 191, OBD_IOC_DATA_TYPE) +#define OBD_IOC_LLOG_PRINT _IOWR('f', 192, OBD_IOC_DATA_TYPE) +#define OBD_IOC_LLOG_CANCEL _IOWR('f', 193, OBD_IOC_DATA_TYPE) +#define OBD_IOC_LLOG_REMOVE _IOWR('f', 194, OBD_IOC_DATA_TYPE) +#define OBD_IOC_LLOG_CHECK _IOWR('f', 195, OBD_IOC_DATA_TYPE) +/* OBD_IOC_LLOG_CATINFO _IOWR('f', 196, OBD_IOC_DATA_TYPE) */ +#define OBD_IOC_NODEMAP _IOWR('f', 197, OBD_IOC_DATA_TYPE) + +/* ECHO_IOC_GET_STRIPE _IOWR('f', 200, OBD_IOC_DATA_TYPE) */ +/* ECHO_IOC_SET_STRIPE _IOWR('f', 201, OBD_IOC_DATA_TYPE) */ +/* ECHO_IOC_ENQUEUE _IOWR('f', 202, OBD_IOC_DATA_TYPE) */ +/* ECHO_IOC_CANCEL _IOWR('f', 203, OBD_IOC_DATA_TYPE) */ + +#define OBD_IOC_GET_OBJ_VERSION _IOR ('f', 210, OBD_IOC_DATA_TYPE) + +/* lustre/lustre_user.h 212-217 */ +#define OBD_IOC_GET_MNTOPT _IOW ('f', 220, mntopt_t) +#define OBD_IOC_ECHO_MD _IOR ('f', 221, struct obd_ioctl_data) +#define OBD_IOC_ECHO_ALLOC_SEQ _IOWR('f', 222, struct obd_ioctl_data) +#define OBD_IOC_START_LFSCK _IOWR('f', 230, OBD_IOC_DATA_TYPE) +#define OBD_IOC_STOP_LFSCK _IOW ('f', 231, OBD_IOC_DATA_TYPE) +/* lustre/lustre_user.h 240-246 */ +/* LIBCFS_IOC_DEBUG_MASK 250 */ + +#define IOC_OSC_SET_ACTIVE _IOWR('h', 21, void *) + +#endif /* LUSTRE_IOCTL_H_ */ diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 7ff3671..fcf0684 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -93,7 +93,6 @@ int do_set_info_async(struct obd_import *imp, struct ptlrpc_request_set *set); #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */ -#define OBD_MAX_IOCTL_BUFFER CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id); @@ -117,442 +116,6 @@ struct obd_client_handle { void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs); void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs); -/* - * For md echo client - */ -enum md_echo_cmd { - ECHO_MD_CREATE = 1, /* Open/Create file on MDT */ - ECHO_MD_MKDIR = 2, /* Mkdir on MDT */ - ECHO_MD_DESTROY = 3, /* Unlink file on MDT */ - ECHO_MD_RMDIR = 4, /* Rmdir on MDT */ - ECHO_MD_LOOKUP = 5, /* Lookup on MDT */ - ECHO_MD_GETATTR = 6, /* Getattr on MDT */ - ECHO_MD_SETATTR = 7, /* Setattr on MDT */ - ECHO_MD_ALLOC_FID = 8, /* Get FIDs from MDT */ -}; - -/* - * OBD IOCTLS - */ -#define OBD_IOCTL_VERSION 0x00010004 - -struct obd_ioctl_data { - __u32 ioc_len; - __u32 ioc_version; - - union { - __u64 ioc_cookie; - __u64 ioc_u64_1; - }; - union { - __u32 ioc_conn1; - __u32 ioc_u32_1; - }; - union { - __u32 ioc_conn2; - __u32 ioc_u32_2; - }; - - struct obdo ioc_obdo1; - struct obdo ioc_obdo2; - - obd_size ioc_count; - obd_off ioc_offset; - __u32 ioc_dev; - __u32 ioc_command; - - __u64 ioc_nid; - __u32 ioc_nal; - __u32 ioc_type; - - /* buffers the kernel will treat as user pointers */ - __u32 ioc_plen1; - char *ioc_pbuf1; - __u32 ioc_plen2; - char *ioc_pbuf2; - - /* inline buffers for various arguments */ - __u32 ioc_inllen1; - char *ioc_inlbuf1; - __u32 ioc_inllen2; - char *ioc_inlbuf2; - __u32 ioc_inllen3; - char *ioc_inlbuf3; - __u32 ioc_inllen4; - char *ioc_inlbuf4; - - char ioc_bulk[0]; -}; - -struct obd_ioctl_hdr { - __u32 ioc_len; - __u32 ioc_version; -}; - -static inline int obd_ioctl_packlen(struct obd_ioctl_data *data) -{ - int len = cfs_size_round(sizeof(struct obd_ioctl_data)); - len += cfs_size_round(data->ioc_inllen1); - len += cfs_size_round(data->ioc_inllen2); - len += cfs_size_round(data->ioc_inllen3); - len += cfs_size_round(data->ioc_inllen4); - return len; -} - - -static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) -{ - if (data->ioc_len > (1<<30)) { - CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen1 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen2 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen3 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inllen4 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); - return 1; - } - if (data->ioc_inlbuf1 && !data->ioc_inllen1) { - CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_inlbuf2 && !data->ioc_inllen2) { - CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); - return 1; - } - if (data->ioc_inlbuf3 && !data->ioc_inllen3) { - CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); - return 1; - } - if (data->ioc_inlbuf4 && !data->ioc_inllen4) { - CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf1 && !data->ioc_plen1) { - CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); - return 1; - } - if (data->ioc_pbuf2 && !data->ioc_plen2) { - CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); - return 1; - } - if (data->ioc_plen1 && !data->ioc_pbuf1) { - CERROR("OBD ioctl: plen1 set but NULL pointer\n"); - return 1; - } - if (data->ioc_plen2 && !data->ioc_pbuf2) { - CERROR("OBD ioctl: plen2 set but NULL pointer\n"); - return 1; - } - if (obd_ioctl_packlen(data) > data->ioc_len) { - CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", - obd_ioctl_packlen(data), data->ioc_len); - return 1; - } - return 0; -} - -#ifndef __KERNEL__ -static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, - int max) -{ - char *ptr; - struct obd_ioctl_data *overlay; - data->ioc_len = obd_ioctl_packlen(data); - data->ioc_version = OBD_IOCTL_VERSION; - - if (*pbuf && data->ioc_len > max) { - fprintf(stderr, "pbuf %p ioc_len %u max %d\n", *pbuf, - data->ioc_len, max); - return -EINVAL; - } - if (*pbuf == NULL) { - *pbuf = malloc(data->ioc_len); - } - if (!*pbuf) - return -ENOMEM; - overlay = (struct obd_ioctl_data *)*pbuf; - memcpy(*pbuf, data, sizeof(*data)); - - ptr = overlay->ioc_bulk; - if (data->ioc_inlbuf1) - LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr); - if (data->ioc_inlbuf2) - LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr); - if (data->ioc_inlbuf3) - LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr); - if (data->ioc_inlbuf4) - LOGL(data->ioc_inlbuf4, data->ioc_inllen4, ptr); - if (obd_ioctl_is_invalid(overlay)) { - fprintf(stderr, "ioc_len %u max %d\n", - data->ioc_len, max); - return -EINVAL; - } - - return 0; -} - -static inline int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, - int max) -{ - char *ptr; - struct obd_ioctl_data *overlay; - - if (!pbuf) - return 1; - overlay = (struct obd_ioctl_data *)pbuf; - - /* Preserve the caller's buffer pointers */ - overlay->ioc_inlbuf1 = data->ioc_inlbuf1; - overlay->ioc_inlbuf2 = data->ioc_inlbuf2; - overlay->ioc_inlbuf3 = data->ioc_inlbuf3; - overlay->ioc_inlbuf4 = data->ioc_inlbuf4; - - memcpy(data, pbuf, sizeof(*data)); - - ptr = overlay->ioc_bulk; - if (data->ioc_inlbuf1) - LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr); - if (data->ioc_inlbuf2) - LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr); - if (data->ioc_inlbuf3) - LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr); - if (data->ioc_inlbuf4) - LOGU(data->ioc_inlbuf4, data->ioc_inllen4, ptr); - - return 0; -} -#endif - -#include - -#ifdef __KERNEL__ -/* function defined in lustre/obdclass//-module.c */ -int obd_ioctl_getdata(char **buf, int *len, void *arg); -int obd_ioctl_popdata(void *arg, void *data, int len); -#else -/* buffer MUST be at least the size of obd_ioctl_hdr */ -static inline int obd_ioctl_getdata(char **buf, int *len, void *arg) -{ - struct obd_ioctl_hdr hdr; - struct obd_ioctl_data *data; - int err; - int offset = 0; - ENTRY; - - err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); - if (err) - RETURN(err); - - if (hdr.ioc_version != OBD_IOCTL_VERSION) { - CERROR("Version mismatch kernel vs application\n"); - RETURN(-EINVAL); - } - - if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { - CERROR("User buffer len %d exceeds %d max buffer\n", - hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); - RETURN(-EINVAL); - } - - if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { - CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); - RETURN(-EINVAL); - } - - OBD_ALLOC_LARGE(*buf, hdr.ioc_len); - if (*buf == NULL) { - CERROR("Cannot allocate control buffer of len %d\n", - hdr.ioc_len); - RETURN(-EINVAL); - } - *len = hdr.ioc_len; - data = (struct obd_ioctl_data *)*buf; - - err = copy_from_user(*buf, (void *)arg, hdr.ioc_len); - if (err) { - OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(err); - } - - if (obd_ioctl_is_invalid(data)) { - CERROR("ioctl not correctly formatted\n"); - OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(-EINVAL); - } - - if (data->ioc_inllen1) { - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - offset += cfs_size_round(data->ioc_inllen1); - } - - if (data->ioc_inllen2) { - data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen2); - } - - if (data->ioc_inllen3) { - data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen3); - } - - if (data->ioc_inllen4) { - data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; - } - - RETURN(0); -} - -static inline int obd_ioctl_popdata(void *arg, void *data, int len) -{ - int err = copy_to_user(arg, data, len); - if (err) - err = -EFAULT; - return err; -} -#endif - -static inline void obd_ioctl_freedata(char *buf, int len) -{ - ENTRY; - - OBD_FREE_LARGE(buf, len); - EXIT; - return; -} - -/* - * BSD ioctl description: - * #define IOC_V1 _IOR(g, n1, long) - * #define IOC_V2 _IOW(g, n2, long) - * - * ioctl(f, IOC_V1, arg); - * arg will be treated as a long value, - * - * ioctl(f, IOC_V2, arg) - * arg will be treated as a pointer, bsd will call - * copyin(buf, arg, sizeof(long)) - * - * To make BSD ioctl handles argument correctly and simplely, - * we change _IOR to _IOWR so BSD will copyin obd_ioctl_data - * for us. Does this change affect Linux? (XXX Liang) - */ -#define OBD_IOC_CREATE _IOWR('f', 101, OBD_IOC_DATA_TYPE) -#define OBD_IOC_DESTROY _IOW ('f', 104, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PREALLOCATE _IOWR('f', 105, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_SETATTR _IOW ('f', 107, OBD_IOC_DATA_TYPE) -#define OBD_IOC_GETATTR _IOWR ('f', 108, OBD_IOC_DATA_TYPE) -#define OBD_IOC_READ _IOWR('f', 109, OBD_IOC_DATA_TYPE) -#define OBD_IOC_WRITE _IOWR('f', 110, OBD_IOC_DATA_TYPE) - - -#define OBD_IOC_STATFS _IOWR('f', 113, OBD_IOC_DATA_TYPE) -#define OBD_IOC_SYNC _IOW ('f', 114, OBD_IOC_DATA_TYPE) -#define OBD_IOC_READ2 _IOWR('f', 115, OBD_IOC_DATA_TYPE) -#define OBD_IOC_FORMAT _IOWR('f', 116, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PARTITION _IOWR('f', 117, OBD_IOC_DATA_TYPE) -#define OBD_IOC_COPY _IOWR('f', 120, OBD_IOC_DATA_TYPE) -#define OBD_IOC_MIGR _IOWR('f', 121, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PUNCH _IOWR('f', 122, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, OBD_IOC_DATA_TYPE) -#define OBD_IOC_BRW_READ _IOWR('f', 125, OBD_IOC_DATA_TYPE) -#define OBD_IOC_BRW_WRITE _IOWR('f', 126, OBD_IOC_DATA_TYPE) -#define OBD_IOC_NAME2DEV _IOWR('f', 127, OBD_IOC_DATA_TYPE) -#define OBD_IOC_UUID2DEV _IOWR('f', 130, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_GETNAME _IOWR('f', 131, OBD_IOC_DATA_TYPE) -#define OBD_IOC_GETMDNAME _IOR('f', 131, char[MAX_OBD_NAME]) -#define OBD_IOC_GETDTNAME OBD_IOC_GETNAME - -#define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, OBD_IOC_DATA_TYPE) -#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PING_TARGET _IOW ('f', 136, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 139 ) -#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, OBD_IOC_DATA_TYPE) -#define OBD_IOC_SET_READONLY _IOW ('f', 141, OBD_IOC_DATA_TYPE) -#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_ROOT_SQUASH _IOWR('f', 143, OBD_IOC_DATA_TYPE) - -#define OBD_GET_VERSION _IOWR ('f', 144, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_GSS_SUPPORT _IOWR('f', 145, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_CLOSE_UUID _IOWR ('f', 147, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_CHANGELOG_SEND _IOW ('f', 148, OBD_IOC_DATA_TYPE) -#define OBD_IOC_GETDEVICE _IOWR ('f', 149, OBD_IOC_DATA_TYPE) -#define OBD_IOC_FID2PATH _IOWR ('f', 150, OBD_IOC_DATA_TYPE) -/* see also for ioctls 151-153 */ -/* OBD_IOC_LOV_SETSTRIPE: See also LL_IOC_LOV_SETSTRIPE */ -#define OBD_IOC_LOV_SETSTRIPE _IOW ('f', 154, OBD_IOC_DATA_TYPE) -/* OBD_IOC_LOV_GETSTRIPE: See also LL_IOC_LOV_GETSTRIPE */ -#define OBD_IOC_LOV_GETSTRIPE _IOW ('f', 155, OBD_IOC_DATA_TYPE) -/* OBD_IOC_LOV_SETEA: See also LL_IOC_LOV_SETEA */ -#define OBD_IOC_LOV_SETEA _IOW ('f', 156, OBD_IOC_DATA_TYPE) -/* see for ioctls 157-159 */ -/* OBD_IOC_QUOTACHECK: See also LL_IOC_QUOTACHECK */ -#define OBD_IOC_QUOTACHECK _IOW ('f', 160, int) -/* OBD_IOC_POLL_QUOTACHECK: See also LL_IOC_POLL_QUOTACHECK */ -#define OBD_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *) -/* OBD_IOC_QUOTACTL: See also LL_IOC_QUOTACTL */ -#define OBD_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl) -/* see also for ioctls 163-176 */ -#define OBD_IOC_CHANGELOG_REG _IOW ('f', 177, struct obd_ioctl_data) -#define OBD_IOC_CHANGELOG_DEREG _IOW ('f', 178, struct obd_ioctl_data) -#define OBD_IOC_CHANGELOG_CLEAR _IOW ('f', 179, struct obd_ioctl_data) -#define OBD_IOC_RECORD _IOWR('f', 180, OBD_IOC_DATA_TYPE) -#define OBD_IOC_ENDRECORD _IOWR('f', 181, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PARSE _IOWR('f', 182, OBD_IOC_DATA_TYPE) -#define OBD_IOC_DORECORD _IOWR('f', 183, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PROCESS_CFG _IOWR('f', 184, OBD_IOC_DATA_TYPE) -#define OBD_IOC_DUMP_LOG _IOWR('f', 185, OBD_IOC_DATA_TYPE) -#define OBD_IOC_CLEAR_LOG _IOWR('f', 186, OBD_IOC_DATA_TYPE) -#define OBD_IOC_PARAM _IOW ('f', 187, OBD_IOC_DATA_TYPE) -#define OBD_IOC_POOL _IOWR('f', 188, OBD_IOC_DATA_TYPE) -#define OBD_IOC_REPLACE_NIDS _IOWR('f', 189, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_CATLOGLIST _IOWR('f', 190, OBD_IOC_DATA_TYPE) -#define OBD_IOC_LLOG_INFO _IOWR('f', 191, OBD_IOC_DATA_TYPE) -#define OBD_IOC_LLOG_PRINT _IOWR('f', 192, OBD_IOC_DATA_TYPE) -#define OBD_IOC_LLOG_CANCEL _IOWR('f', 193, OBD_IOC_DATA_TYPE) -#define OBD_IOC_LLOG_REMOVE _IOWR('f', 194, OBD_IOC_DATA_TYPE) -#define OBD_IOC_LLOG_CHECK _IOWR('f', 195, OBD_IOC_DATA_TYPE) -/* OBD_IOC_LLOG_CATINFO is deprecated */ -#define OBD_IOC_LLOG_CATINFO _IOWR('f', 196, OBD_IOC_DATA_TYPE) -#define OBD_IOC_NODEMAP _IOWR('f', 197, OBD_IOC_DATA_TYPE) - -#define ECHO_IOC_GET_STRIPE _IOWR('f', 200, OBD_IOC_DATA_TYPE) -#define ECHO_IOC_SET_STRIPE _IOWR('f', 201, OBD_IOC_DATA_TYPE) -#define ECHO_IOC_ENQUEUE _IOWR('f', 202, OBD_IOC_DATA_TYPE) -#define ECHO_IOC_CANCEL _IOWR('f', 203, OBD_IOC_DATA_TYPE) - -#define OBD_IOC_GET_OBJ_VERSION _IOR('f', 210, OBD_IOC_DATA_TYPE) - -/* defines ioctl number 218-219 */ -#define OBD_IOC_GET_MNTOPT _IOW('f', 220, mntopt_t) -#define OBD_IOC_ECHO_MD _IOR('f', 221, struct obd_ioctl_data) -#define OBD_IOC_ECHO_ALLOC_SEQ _IOWR('f', 222, struct obd_ioctl_data) -#define OBD_IOC_START_LFSCK _IOWR('f', 230, OBD_IOC_DATA_TYPE) -#define OBD_IOC_STOP_LFSCK _IOW('f', 231, OBD_IOC_DATA_TYPE) - -/* XXX _IOWR('f', 250, long) has been defined in - * libcfs/include/libcfs/libcfs_private.h for debug, don't use it - */ - /* Until such time as we get_info the per-stripe maximum from the OST, * we define this to be 2T - 4k, which is the ext3 maxbytes. */ #define LUSTRE_STRIPE_MAXBYTES 0x1fffffff000ULL diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 2dd6ad4..7b7a812 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -222,6 +222,7 @@ int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, int obd_llog_finish(struct obd_device *obd, int count); /* llog_ioctl.c */ +struct obd_ioctl_data; int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data); int llog_catalog_list(const struct lu_env *env, struct dt_device *d, diff --git a/lustre/include/obd.h b/lustre/include/obd.h index d06bbfe..eee94a3 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -47,15 +47,6 @@ #error Unsupported operating system. #endif -#define IOC_OSC_TYPE 'h' -#define IOC_OSC_MIN_NR 20 -#define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *) -#define IOC_OSC_MAX_NR 50 - -#define IOC_MDC_TYPE 'i' -#define IOC_MDC_MIN_NR 20 -#define IOC_MDC_MAX_NR 50 - #include #include #include @@ -711,7 +702,6 @@ struct obd_llog_group { /* corresponds to one of the obd's */ #define OBD_DEVICE_MAGIC 0XAB5CD6EF -#define OBD_DEV_BY_DEVNAME 0xffffd0de struct obd_device { struct obd_type *obd_type; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index fa720f6..0f811aa 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -51,8 +51,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -1274,8 +1274,8 @@ out_rmdir: } case LL_IOC_LOV_SWAP_LAYOUTS: RETURN(-EPERM); - case LL_IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + case IOC_OBD_STATFS: + RETURN(ll_obd_statfs(inode, (void *)arg)); case LL_IOC_LOV_GETSTRIPE: case LL_IOC_MDC_GETINFO: case IOC_MDC_GETFILEINFO: @@ -1426,10 +1426,7 @@ out_rmdir: OBD_FREE_LARGE(lmm, lmmsize); return rc; } - case OBD_IOC_LLOG_CATINFO: { - RETURN(-EOPNOTSUPP); - } - case OBD_IOC_QUOTACHECK: { + case OBD_IOC_QUOTACHECK: { struct obd_quotactl *oqctl; int error = 0; @@ -1454,7 +1451,7 @@ out_rmdir: OBD_FREE_PTR(oqctl); return error ?: rc; } - case OBD_IOC_POLL_QUOTACHECK: { + case OBD_IOC_POLL_QUOTACHECK: { struct if_quotacheck *check; if (!cfs_capable(CFS_CAP_SYS_ADMIN) || @@ -1542,7 +1539,7 @@ out_rmdir: #else #warning "remove old LL_IOC_QUOTACTL_18 compatibility code" #endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) */ - case LL_IOC_QUOTACTL: { + case OBD_IOC_QUOTACTL: { struct if_quotactl *qctl; OBD_ALLOC_PTR(qctl); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 0b39e4d..9debc22 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -47,6 +47,7 @@ #include #include "llite_internal.h" #include +#include #include "cl_object.h" diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 40961da..b76d7b6 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index e7e67b8..ad76048 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -60,6 +60,7 @@ #include #include #include +#include #include "lmv_internal.h" /* This hash is only for testing purpose */ diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 8cdc3f1..46496c5 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -49,6 +49,7 @@ #endif #include +#include #include #include #include diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 846b659..92f0332 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -47,6 +47,7 @@ #endif #include +#include #include #include #include diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 379874e..07b606d 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index ccbf2a9..a0b8b55 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -53,6 +53,7 @@ * struct OBD_{ALLOC,FREE}*() */ #include +#include /* struct ptlrpc_request */ #include /* struct obd_export */ diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 0403483..48209ac 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -45,6 +45,7 @@ #include #include +#include #include #include "mgs_internal.h" diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 25197b3..ae6124d 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -46,6 +46,7 @@ #define D_MGS D_CONFIG #include +#include #include #include #include diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 7ea460e..6b09174 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -53,6 +53,7 @@ # include # include #endif /* HAVE_SERVER_SUPPORT */ +#include #include "llog_internal.h" #ifndef __KERNEL__ @@ -358,12 +359,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) GOTO(out, err); } - case OBD_IOC_CLOSE_UUID: { - CDEBUG(D_IOCTL, "closing all connections to uuid %s (NOOP)\n", - data->ioc_inlbuf1); - GOTO(out, err = 0); - } - case OBD_IOC_GETDEVICE: { int index = data->ioc_count; char *status, *str; diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index 1642123..0d7f656 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #ifdef __KERNEL__ diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index 24471cc..bff97f3 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -37,6 +37,7 @@ #define DEBUG_SUBSYSTEM S_LOG #include +#include #include #include "llog_internal.h" diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 8fa81b3..d81a9a7 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -49,6 +49,7 @@ #include #include #endif +#include #include #include #include diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index 8c3e8f2..d67963b 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 98fb3e0..f89383e 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "echo_internal.h" @@ -168,9 +169,6 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c) static struct echo_object *cl_echo_object_find(struct echo_device *d, struct lov_stripe_md **lsm); static int cl_echo_object_put(struct echo_object *eco); -static int cl_echo_enqueue (struct echo_object *eco, obd_off start, - obd_off end, int mode, __u64 *cookie); -static int cl_echo_cancel (struct echo_device *d, __u64 cookie); static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, struct page **pages, int npages, int async); @@ -1194,38 +1192,6 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, RETURN(rc); } -static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, - int mode, __u64 *cookie) -{ - struct echo_thread_info *info; - struct lu_env *env; - struct cl_io *io; - int refcheck; - int result; - ENTRY; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - info = echo_env_info(env); - io = &info->eti_io; - - io->ci_ignore_layout = 1; - result = cl_io_init(env, io, CIT_MISC, echo_obj2cl(eco)); - if (result < 0) - GOTO(out, result); - LASSERT(result == 0); - - result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0); - cl_io_fini(env, io); - - EXIT; -out: - cl_env_put(env, &refcheck); - return result; -} - static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, __u64 cookie) { @@ -1258,23 +1224,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, RETURN(0); } -static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) -{ - struct lu_env *env; - int refcheck; - int rc; - ENTRY; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - - rc = cl_echo_cancel0(env, ed, cookie); - - cl_env_put(env, &refcheck); - RETURN(rc); -} - static void echo_commit_callback(const struct lu_env *env, struct cl_io *io, struct cl_page *page) { @@ -1389,27 +1338,6 @@ out: static obd_id last_object_id; static int -echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob) -{ - struct lov_stripe_md *ulsm = _ulsm; - int nob, i; - - nob = offsetof (struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]); - if (nob > ulsm_nob) - return (-EINVAL); - - if (copy_to_user (ulsm, lsm, sizeof(*ulsm))) - return (-EFAULT); - - for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (copy_to_user (ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i], - sizeof(lsm->lsm_oinfo[0]))) - return (-EFAULT); - } - return 0; -} - -static int echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm, void *ulsm, int ulsm_nob) { @@ -2722,54 +2650,6 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, } static int -echo_client_enqueue(struct obd_export *exp, struct obdo *oa, - int mode, obd_off offset, obd_size nob) -{ - struct echo_device *ed = obd2echo_dev(exp->exp_obd); - struct lustre_handle *ulh = &oa->o_handle; - struct echo_object *eco; - obd_off end; - int rc; - ENTRY; - - if (ed->ed_next == NULL) - RETURN(-EOPNOTSUPP); - - if (!(mode == LCK_PR || mode == LCK_PW)) - RETURN(-EINVAL); - - if ((offset & (~CFS_PAGE_MASK)) != 0 || - (nob & (~CFS_PAGE_MASK)) != 0) - RETURN(-EINVAL); - - rc = echo_get_object (&eco, ed, oa); - if (rc != 0) - RETURN(rc); - - end = (nob == 0) ? ((obd_off) -1) : (offset + nob - 1); - rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie); - if (rc == 0) { - oa->o_valid |= OBD_MD_FLHANDLE; - CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie); - } - echo_put_object(eco); - RETURN(rc); -} - -static int -echo_client_cancel(struct obd_export *exp, struct obdo *oa) -{ - struct echo_device *ed = obd2echo_dev(exp->exp_obd); - __u64 cookie = oa->o_handle.cookie; - - if ((oa->o_valid & OBD_MD_FLHANDLE) == 0) - return -EINVAL; - - CDEBUG(D_INFO, "Cookie is "LPX64"\n", cookie); - return cl_echo_cancel(ed, cookie); -} - -static int echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -2952,46 +2832,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = echo_client_brw_ioctl(env, rw, exp, data, &dummy_oti); GOTO(out, rc); - case ECHO_IOC_GET_STRIPE: - rc = echo_get_object(&eco, ed, oa); - if (rc == 0) { - rc = echo_copyout_lsm(eco->eo_lsm, data->ioc_pbuf1, - data->ioc_plen1); - echo_put_object(eco); - } - GOTO(out, rc); - - case ECHO_IOC_SET_STRIPE: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); - - if (data->ioc_pbuf1 == NULL) { /* unset */ - rc = echo_get_object(&eco, ed, oa); - if (rc == 0) { - eco->eo_deleted = 1; - echo_put_object(eco); - } - } else { - rc = echo_create_object(env, ed, 0, oa, - data->ioc_pbuf1, - data->ioc_plen1, &dummy_oti); - } - GOTO (out, rc); - - case ECHO_IOC_ENQUEUE: - if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - GOTO (out, rc = -EPERM); - - rc = echo_client_enqueue(exp, oa, - data->ioc_conn1, /* lock mode */ - data->ioc_offset, - data->ioc_count);/*extent*/ - GOTO (out, rc); - - case ECHO_IOC_CANCEL: - rc = echo_client_cancel(exp, oa); - GOTO (out, rc); - default: CERROR ("echo_ioctl(): unrecognised ioctl %#x\n", cmd); GOTO (out, rc = -ENOTTY); diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index f0ee987..8ba5eca 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -45,6 +45,7 @@ #include #include "ofd_internal.h" #include +#include #include #include diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 076dcf6..f6ce5cb 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -53,6 +53,7 @@ #include #include +#include #include #include #include diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index ff0b794..38d2de1 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -45,6 +45,7 @@ #define DEBUG_SUBSYSTEM S_MDS #include +#include #include #include #include diff --git a/lustre/tests/ll_dirstripe_verify.c b/lustre/tests/ll_dirstripe_verify.c index 7e3fed8..ed9baec 100644 --- a/lustre/tests/ll_dirstripe_verify.c +++ b/lustre/tests/ll_dirstripe_verify.c @@ -52,8 +52,6 @@ #include #include -#include -#include #include #include diff --git a/lustre/tests/mpi/mdsrate.c b/lustre/tests/mpi/mdsrate.c index 5d3dc3e..896854e 100644 --- a/lustre/tests/mpi/mdsrate.c +++ b/lustre/tests/mpi/mdsrate.c @@ -221,7 +221,7 @@ sigalrm_handler(int signum) #elif defined(USE_MDC_LOOKUP) #include #include -#include +#include int llapi_file_lookup(int dirfd, const char *name) { diff --git a/lustre/tests/rwv.c b/lustre/tests/rwv.c index 9af08f0..e184c62 100644 --- a/lustre/tests/rwv.c +++ b/lustre/tests/rwv.c @@ -44,7 +44,6 @@ #include #include -#include /* needed for lov_stripe_md_size */ #include #define ACT_NONE 0 diff --git a/lustre/tests/statmany.c b/lustre/tests/statmany.c index d121419..e33928e 100644 --- a/lustre/tests/statmany.c +++ b/lustre/tests/statmany.c @@ -46,8 +46,7 @@ #include #include -#include -#include +#include struct option longopts[] = { {"ea", 0, 0, 'e'}, diff --git a/lustre/tests/statone.c b/lustre/tests/statone.c index 980d63b..151fb59 100644 --- a/lustre/tests/statone.c +++ b/lustre/tests/statone.c @@ -39,8 +39,7 @@ #include #include -#include -#include +#include int main(int argc, char **argv) { diff --git a/lustre/utils/.gitignore b/lustre/utils/.gitignore index 1e5b331..7558760 100644 --- a/lustre/utils/.gitignore +++ b/lustre/utils/.gitignore @@ -8,8 +8,6 @@ /wiretest /llog_reader /lr_reader -/obdio -/obdbarrier /lload /llverfs /llverdev diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index d587b3b..7731442 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -18,8 +18,6 @@ bin_scripts = llstat llobdstat plot-llstat llbackup EXTRA_PROGRAMS = wirecheck if UTILS -noinst_PROGRAMS = obdio obdbarrier - # mount only finds helpers in /sbin rootsbin_PROGRAMS = mount.lustre sbin_PROGRAMS = lctl wiretest l_getidentity llverfs llverdev \ @@ -109,8 +107,6 @@ if LDISKFS_ENABLED libiam_a_SOURCES = libiam.c endif -obdio_SOURCES = obdio.c obdiolib.c obdiolib.h -obdbarrier_SOURCES = obdbarrier.c obdiolib.c obdiolib.h req_layout_SOURCES = req-layout.c llog_reader_SOURCES = llog_reader.c diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 6e48c4f..0001b8e 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -73,7 +73,6 @@ #include #include -#include #include "obdctl.h" /* all functions */ diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index ff20c9a..65eb0f9 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -71,8 +71,8 @@ #include #include -#include #include +#include #include "lustreapi_internal.h" static unsigned llapi_dir_filetype_table[] = { @@ -296,7 +296,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset, stripe_size, page_size); return rc; } - if (stripe_offset < -1 || stripe_offset > MAX_OBD_DEVICES) { + if (stripe_offset < -1) { rc = -EINVAL; llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe offset %d", stripe_offset); @@ -3564,7 +3564,7 @@ int llapi_quotacheck(char *mnt, int check_type) return rc; } - rc = ioctl(dirfd(root), LL_IOC_QUOTACHECK, check_type); + rc = ioctl(dirfd(root), OBD_IOC_QUOTACHECK, check_type); if (rc < 0) rc = -errno; @@ -3586,7 +3586,7 @@ int llapi_poll_quotacheck(char *mnt, struct if_quotacheck *qchk) } while (1) { - rc = ioctl(dirfd(root), LL_IOC_POLL_QUOTACHECK, qchk); + rc = ioctl(dirfd(root), OBD_IOC_POLL_QUOTACHECK, qchk); if (!rc) break; sleep(poll_intvl); @@ -3610,7 +3610,7 @@ int llapi_quotactl(char *mnt, struct if_quotactl *qctl) return rc; } - rc = ioctl(dirfd(root), LL_IOC_QUOTACTL, qctl); + rc = ioctl(dirfd(root), OBD_IOC_QUOTACTL, qctl); if (rc < 0) rc = -errno; diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index 738c394..94c6ba0 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -55,7 +55,6 @@ #include #include -#include #include #include "lustreapi_internal.h" diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c index e2bd8b3..f467d4d 100644 --- a/lustre/utils/loadgen.c +++ b/lustre/utils/loadgen.c @@ -59,6 +59,7 @@ #include #include +#include #include "obdctl.h" static char cmdname[512]; diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 720142b..fa23d5b 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -52,11 +52,8 @@ #ifndef __KERNEL__ #include #endif -#include #include #include -#include -#include /* for struct lov_stripe_md */ #include #include @@ -306,11 +303,6 @@ int jt_lcfg_add_uuid(int argc, char **argv) return do_add_uuid(argv[0], argv[1], nid); } -int obd_add_uuid(char *uuid, lnet_nid_t nid) -{ - return do_add_uuid("obd_add_uuid", uuid, nid); -} - int jt_lcfg_del_uuid(int argc, char **argv) { int rc; diff --git a/lustre/utils/lustre_lfsck.c b/lustre/utils/lustre_lfsck.c index 509a647..4f04f02 100644 --- a/lustre/utils/lustre_lfsck.c +++ b/lustre/utils/lustre_lfsck.c @@ -40,10 +40,10 @@ #include "obdctl.h" -#include #include #include #include +#include static struct option long_opt_start[] = { {"device", required_argument, 0, 'M'}, diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 5d84c95..c628510 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -64,7 +64,7 @@ #include "obdctl.h" -#include /* for struct lov_stripe_md */ +#include #include #include @@ -110,13 +110,6 @@ const int nthreads = 1; static int cur_device = -1; -struct lov_oinfo lov_oinfos[LOV_MAX_STRIPE_COUNT]; - -struct lsm_buffer { - struct lov_stripe_md lsm; - struct lov_oinfo *ptrs[LOV_MAX_STRIPE_COUNT]; -} lsm_buffer; - static int l2_ioctl(int dev_id, int opc, void *buf) { return l_ioctl(dev_id, opc, buf); @@ -281,75 +274,6 @@ int parse_devname(char *func, char *name) return ret; } -static void -reset_lsmb (struct lsm_buffer *lsmb) -{ - memset (&lsmb->lsm, 0, sizeof (lsmb->lsm)); - memset(lov_oinfos, 0, sizeof(lov_oinfos)); - lsmb->lsm.lsm_magic = LOV_MAGIC; -} - -static int -parse_lsm (struct lsm_buffer *lsmb, char *string) -{ - struct lov_stripe_md *lsm = &lsmb->lsm; - char *end; - int i; - - /* - * object_id[=size#count[@offset:id]*] - */ - - reset_lsmb (lsmb); - - ostid_set_id(&lsm->lsm_oi, strtoull(string, &end, 0)); - if (end == string) - return -1; - string = end; - - if (*string == 0) - return (0); - - if (*string != '=') - return (-1); - string++; - - lsm->lsm_stripe_size = strtoul (string, &end, 0); - if (end == string) - return (-1); - string = end; - - if (*string != '#') - return (-1); - string++; - - lsm->lsm_stripe_count = strtoul (string, &end, 0); - if (end == string) - return (-1); - string = end; - - if (*string == 0) /* don't have to specify obj ids */ - return (0); - - for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (*string != '@') - return (-1); - string++; - lsm->lsm_oinfo[i]->loi_ost_idx = strtoul(string, &end, 0); - if (*end != ':') - return (-1); - string = end + 1; - ostid_set_id(&lsm->lsm_oinfo[i]->loi_oi, - strtoull(string, &end, 0)); - string = end; - } - - if (*string != 0) - return (-1); - - return (0); -} - char *jt_cmdname(char *func) { static char buf[512]; @@ -1515,25 +1439,19 @@ int jt_obd_test_md_getattr(int argc, char **argv) return jt_obd_md_common(argc, argv, ECHO_MD_GETATTR); } -/* Create one or more objects, arg[4] may describe stripe meta-data. If - * not, defaults assumed. This echo-client instance stashes the stripe - * object ids. Use get_stripe on this node to print full lsm and - * set_stripe on another node to cut/paste between nodes. - */ -/* create [] [q|v|# verbosity] [striping] */ int jt_obd_create(int argc, char **argv) { - char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; - struct obd_ioctl_data data; - struct timeval next_time; - __u64 count = 1, next_count, base_id = 1; - int verbose = 1, mode = 0100644, rc = 0, i, valid_lsm = 0; + char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; + struct obd_ioctl_data data; + struct timeval next_time; + __u64 count = 1, next_count, base_id = 1; + int verbose = 1, mode = 0100644, rc = 0, i; char *end; memset(&data, 0, sizeof(data)); data.ioc_dev = cur_device; - if (argc < 2 || argc > 5) - return CMD_HELP; + if (argc < 2 || argc > 4) + return CMD_HELP; count = strtoull(argv[1], &end, 0); if (*end) { @@ -1559,19 +1477,6 @@ int jt_obd_create(int argc, char **argv) return CMD_HELP; } - if (argc < 5) { - reset_lsmb(&lsm_buffer); /* will set default */ - } else { - rc = parse_lsm(&lsm_buffer, argv[4]); - if (rc != 0) { - fprintf(stderr, "error: %s: invalid lsm '%s'\n", - jt_cmdname(argv[0]), argv[4]); - return CMD_HELP; - } - base_id = ostid_id(&lsm_buffer.lsm.lsm_oi); - valid_lsm = 1; - } - printf("%s: "LPD64" objects\n", jt_cmdname(argv[0]), count); gettimeofday(&next_time, NULL); next_time.tv_sec -= verbose; @@ -1585,10 +1490,6 @@ int jt_obd_create(int argc, char **argv) data.ioc_obdo1.o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGROUP; - if (valid_lsm) { - data.ioc_plen1 = sizeof lsm_buffer; - data.ioc_pbuf1 = (char *)&lsm_buffer; - } memset(buf, 0, sizeof(rawbuf)); rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf)); @@ -2322,74 +2223,6 @@ out: return rc; } -int jt_obd_ldlm_regress_start(int argc, char **argv) -{ - int rc; - struct obd_ioctl_data data; - char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; - char argstring[200]; - int i, count = sizeof(argstring) - 1; - - memset(&data, 0, sizeof(data)); - data.ioc_dev = cur_device; - if (argc > 5) - return CMD_HELP; - - argstring[0] = '\0'; - for (i = 1; i < argc; i++) { - strncat(argstring, " ", count); - count--; - strncat(argstring, argv[i], count); - count -= strlen(argv[i]); - } - - if (strlen(argstring)) { - data.ioc_inlbuf1 = argstring; - data.ioc_inllen1 = strlen(argstring) + 1; - } - - memset(buf, 0, sizeof(rawbuf)); - rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf)); - if (rc) { - fprintf(stderr, "error: %s: invalid ioctl\n", - jt_cmdname(argv[0])); - return rc; - } - rc = l2_ioctl(OBD_DEV_ID, IOC_LDLM_REGRESS_START, buf); - if (rc) - fprintf(stderr, "error: %s: test failed: %s\n", - jt_cmdname(argv[0]), strerror(rc = errno)); - - return rc; -} - -int jt_obd_ldlm_regress_stop(int argc, char **argv) -{ - int rc; - char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; - struct obd_ioctl_data data; - - memset(&data, 0, sizeof(data)); - data.ioc_dev = cur_device; - - if (argc != 1) - return CMD_HELP; - - memset(buf, 0, sizeof(rawbuf)); - rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf)); - if (rc) { - fprintf(stderr, "error: %s: invalid ioctl\n", - jt_cmdname(argv[0])); - return rc; - } - rc = l2_ioctl(OBD_DEV_ID, IOC_LDLM_REGRESS_STOP, buf); - - if (rc) - fprintf(stderr, "error: %s: test failed: %s\n", - jt_cmdname(argv[0]), strerror(rc = errno)); - return rc; -} - static int do_activate(int argc, char **argv, int flag) { struct obd_ioctl_data data; @@ -3117,18 +2950,13 @@ static void signal_server(int sig) int obd_initialize(int argc, char **argv) { - int i; - - for (i = 0; i < LOV_MAX_STRIPE_COUNT; i++) - lsm_buffer.lsm.lsm_oinfo[i] = lov_oinfos + i; - - if (shmem_setup() != 0) - return -1; + if (shmem_setup() != 0) + return -1; - register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH, - OBD_DEV_MAJOR, OBD_DEV_MINOR); + register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH, + OBD_DEV_MAJOR, OBD_DEV_MINOR); - return 0; + return 0; } void obd_finalize(int argc, char **argv) diff --git a/lustre/utils/obdbarrier.c b/lustre/utils/obdbarrier.c deleted file mode 100644 index 9f0af2e..0000000 --- a/lustre/utils/obdbarrier.c +++ /dev/null @@ -1,239 +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.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. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/utils/obdbarrier.c - * - * Author: Eric Barton - */ - -#include -#include -#include -#include - -#include -#include "obdiolib.h" - -int -parse_kmg (__u64 *valp, char *str) -{ - __u64 val; - char mod[32]; - - switch (sscanf (str, LPU64"%1[gGmMkK]", &val, mod)) - { - default: - return (-1); - - case 1: - *valp = val; - return (0); - - case 2: - switch (*mod) - { - case 'g': - case 'G': - *valp = val << 30; - return (0); - - case 'm': - case 'M': - *valp = val << 20; - return (0); - - case 'k': - case 'K': - *valp = val << 10; - return (0); - - default: - *valp = val; - return (0); - } - } -} - -void -usage (char *cmdname, int help) -{ - char *name = strrchr (cmdname, '/'); - - if (name == NULL) - name = cmdname; - - fprintf (help ? stdout : stderr, - "usage: %s -d device -s size -o offset [-i id][-n reps][-l] oid\n", - name); -} - -int -exponential_modulus (int i, int base) -{ - int top = base; - int mod = 1; - - for (;;) { - if (i < top) - return (i%mod == 0); - - mod = top; - top *= base; - } -} - -int -main (int argc, char **argv) -{ - __u64 bid = (((__u64)gethostid()) << 32) | getpid (); - int set_bid = 0; - __u64 oid; - int setup = 0; - int device = -1; - int npeers = 0; - int reps = 1; - char hostname[128]; - struct obdio_conn *conn; - struct obdio_barrier *b; - char *end; - __u64 val; - int rc; - int c; - - setvbuf (stdout, NULL, _IOLBF, 0); - memset (hostname, 0, sizeof (hostname)); - gethostname (hostname, sizeof (hostname)); - hostname[sizeof(hostname) - 1] = 0; - - while ((c = getopt (argc, argv, "hsi:d:n:p:")) != -1) - switch (c) { - case 'h': - usage (argv[0], 1); - return (0); - - case 'i': - bid = strtoll (optarg, &end, 0); - if (end == optarg || *end != 0) { - fprintf (stderr, "Can't parse id %s\n", - optarg); - return (1); - } - set_bid = 1; - break; - - case 's': - setup = 1; - break; - - case 'd': - device = strtol (optarg, &end, 0); - if (end == optarg || *end != 0 || device < 0) { - fprintf (stderr, "Can't parse device %s\n", - optarg); - return (1); - } - break; - - case 'n': - if (parse_kmg (&val, optarg) != 0) { - fprintf (stderr, "Can't parse reps %s\n", - optarg); - return (1); - } - reps = (int)val; - break; - - case 'p': - npeers = strtol (optarg, &end, 0); - if (end == optarg || *end != 0 || npeers <= 0) { - fprintf (stderr, "Can't parse npeers %s\n", - optarg); - return (1); - } - break; - - default: - usage (argv[0], 0); - return (1); - } - - if ((!setup && !set_bid) || - npeers <= 0 || - device < 0 || - optind == argc) { - fprintf (stderr, "%s not specified\n", - (!setup && !set_bid) ? "id" : - npeers <= 0 ? "npeers" : - device < 0 ? "device" : "object id"); - return (1); - } - - oid = strtoull (argv[optind], &end, 0); - if (end == argv[optind] || *end != 0) { - fprintf (stderr, "Can't parse object id %s\n", - argv[optind]); - return (1); - } - - conn = obdio_connect (device); - if (conn == NULL) - return (1); - - b = obdio_new_barrier (oid, bid, npeers); - if (b == NULL) { - rc = 1; - goto out; - } - - rc = 0; - if (setup) { - rc = obdio_setup_barrier (conn, b); - if (rc == 0) - printf ("Setup barrier: -d %d -i "LPX64" -p %d -n1 "LPX64"\n", - device, bid, npeers, oid); - } else { - for (c = 0; c < reps; c++) { - rc = obdio_barrier (conn, b); - if (rc != 0) - break; - if (exponential_modulus (c, 10)) - printf ("%s: Barrier %d\n", hostname, c); - } - } - - free(b); -out: - obdio_disconnect(conn, 0); - - return (rc == 0 ? 0 : 1); -} diff --git a/lustre/utils/obdctl.h b/lustre/utils/obdctl.h index b384e8a..abe2dbb 100644 --- a/lustre/utils/obdctl.h +++ b/lustre/utils/obdctl.h @@ -41,10 +41,7 @@ #include #endif -#include #include -#include -#include #define MAX_IOC_BUFLEN 8192 @@ -101,6 +98,7 @@ int jt_llog_cancel(int argc, char **argv); int jt_llog_remove(int argc, char **argv); int jt_llog_check(int argc, char **argv); +struct lustre_cfg; int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg); int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg); int parse_devname(char *func, char *name); @@ -126,8 +124,6 @@ int jt_lcfg_getparam(int argc, char **argv); int jt_lcfg_setparam(int argc, char **argv); int jt_lcfg_listparam(int argc, char **argv); -int obd_add_uuid(char *uuid, lnet_nid_t nid); - int jt_blockdev_attach(int argc, char **argv); int jt_blockdev_detach(int argc, char **argv); int jt_blockdev_info(int argc, char **argv); diff --git a/lustre/utils/obdio.c b/lustre/utils/obdio.c deleted file mode 100644 index c7b33f3..0000000 --- a/lustre/utils/obdio.c +++ /dev/null @@ -1,310 +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.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. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/utils/obdio.c - * - * Author: Eric Barton - */ - -#include -#include -#include -#include - -#include -#include "obdiolib.h" - -int -obdio_test_fixed_extent (struct obdio_conn *conn, - __u32 myhid, __u32 mypid, - int reps, int locked, __u64 oid, - __u64 offset, __u32 size) -{ - struct lustre_handle lh; - void *space; - void *buffer; - __u32 *ibuf; - int i; - int j; - int rc = 0; - - space = obdio_alloc_aligned_buffer (&buffer, size); - if (space == NULL) { - fprintf (stderr, "Can't allocate buffer size %d\n", size); - return (-1); - } - - for (i = 0; i < reps; i++) { - ibuf = (__u32 *) buffer; - for (j = 0; j < size / (4 * sizeof (*ibuf)); j++) { - ibuf[0] = myhid; - ibuf[1] = mypid; - ibuf[2] = i; - ibuf[3] = j; - ibuf += 4; - } - - if (locked) { - rc = obdio_enqueue(conn, oid, LCK_PW, offset, size,&lh); - if (rc != 0) { - fprintf(stderr, "Error on enqueue "LPX64" @ " - LPU64" for %u: %s\n", - oid, offset, size, strerror (errno)); - goto out; - } - } - - rc = obdio_pwrite (conn, oid, buffer, size, offset); - if (rc != 0) { - fprintf(stderr, "Error writing "LPX64" @ "LPU64 - " for %u: %s\n", - oid, offset, size, strerror (errno)); - if (locked) - obdio_cancel (conn, &lh); - rc = -1; - goto out; - } - - memset (buffer, 0xbb, size); - - rc = obdio_pread (conn, oid, buffer, size, offset); - if (rc != 0) { - fprintf(stderr, "Error reading "LPX64" @ "LPU64 - " for %u: %s\n", - oid, offset, size, strerror (errno)); - if (locked) - obdio_cancel (conn, &lh); - rc = -1; - goto out; - } - - if (locked) { - rc = obdio_cancel (conn, &lh); - if (rc != 0) { - fprintf(stderr, "Error on cancel "LPX64" @ " - LPU64" for %u: %s\n", - oid, offset, size, strerror (errno)); - rc = -1; - goto out; - } - } - - ibuf = (__u32 *) buffer; - for (j = 0; j < size / (4 * sizeof (*ibuf)); j++) { - if (ibuf[0] != myhid || - ibuf[1] != mypid || - ibuf[2] != i || - ibuf[3] != j) { - fprintf(stderr, "Error checking "LPX64" @ " - LPU64" for %u, chunk %d\n", - oid, offset, size, j); - fprintf(stderr, "Expected [%x,%x,%x,%x], " - "got [%x,%x,%x,%x]\n", - myhid, mypid, i, j, - ibuf[0], ibuf[1], ibuf[2], ibuf[3]); - rc = -1; - goto out; - } - ibuf += 4; - } - } - out: - free (space); - return (rc); -} - -int -parse_kmg (__u64 *valp, char *str) -{ - __u64 val; - char mod[32]; - - switch (sscanf (str, LPU64"%1[gGmMkK]", &val, mod)) - { - default: - return (-1); - - case 1: - *valp = val; - return (0); - - case 2: - switch (*mod) - { - case 'g': - case 'G': - *valp = val << 30; - return (0); - - case 'm': - case 'M': - *valp = val << 20; - return (0); - - case 'k': - case 'K': - *valp = val << 10; - return (0); - - default: - *valp = val; - return (0); - } - } -} - -void -usage (char *cmdname, int help) -{ - char *name = strrchr (cmdname, '/'); - - if (name == NULL) - name = cmdname; - - fprintf (help ? stdout : stderr, - "usage: %s -d device -s size -o offset [-i id][-n reps][-l] oid\n", - name); -} - -int -main (int argc, char **argv) -{ - __u32 mypid = getpid (); - __u32 myhid = gethostid (); - __u64 oid; - __u64 base_offset = 0; - __u32 size = 0; - int set_size = 0; - int device = -1; - int reps = 1; - int locked = 0; - char *end; - struct obdio_conn *conn; - __u64 val; - int v1; - int v2; - int rc; - int c; - - while ((c = getopt (argc, argv, "hi:s:o:d:n:l")) != -1) - switch (c) { - case 'h': - usage (argv[0], 1); - return (0); - - case 'i': - switch (sscanf (optarg, "%i.%i", &v1, &v2)) { - case 1: - mypid = v1; - break; - case 2: - myhid = v1; - mypid = v2; - break; - default: - fprintf (stderr, "Can't parse id %s\n", - optarg); - return (1); - } - break; - - case 's': - if (parse_kmg (&val, optarg) != 0) { - fprintf (stderr, "Can't parse size %s\n", - optarg); - return (1); - } - size = (__u32)val; - set_size++; - break; - - case 'o': - if (parse_kmg (&val, optarg) != 0) { - fprintf (stderr, "Can't parse offset %s\n", - optarg); - return (1); - } - base_offset = val; - break; - - case 'd': - device = strtol (optarg, &end, 0); - if (end == optarg || *end != 0 || device < 0) { - fprintf (stderr, "Can't parse device %s\n", - optarg); - return (1); - } - break; - case 'n': - if (parse_kmg (&val, optarg) != 0) { - fprintf (stderr, "Can't parse reps %s\n", - optarg); - return (1); - } - reps = (int)val; - break; - case 'l': - locked = 1; - break; - default: - usage (argv[0], 0); - return (1); - } - - if (!set_size || - device < 0 || - optind == argc) { - fprintf (stderr, "No %s specified\n", - !set_size ? "size" : - device < 0 ? "device" : "object id"); - return (1); - } - - oid = strtoull (argv[optind], &end, 0); - if (end == argv[optind] || *end != 0) { - fprintf (stderr, "Can't parse object id %s\n", - argv[optind]); - return (1); - } - - conn = obdio_connect (device); - if (conn == NULL) - return (1); - - rc = obdio_test_fixed_extent(conn, myhid, mypid, reps, locked, - oid, base_offset, size); - - obdio_disconnect(conn, 0); - - return (rc == 0 ? 0 : 1); -} diff --git a/lustre/utils/obdiolib.c b/lustre/utils/obdiolib.c deleted file mode 100644 index 544778b..0000000 --- a/lustre/utils/obdiolib.c +++ /dev/null @@ -1,406 +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.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. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/utils/obdiolib.c - * - * Author: Eric Barton - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "obdiolib.h" - -void -obdio_iocinit (struct obdio_conn *conn) -{ - memset (&conn->oc_data, 0, sizeof (conn->oc_data)); - conn->oc_data.ioc_version = OBD_IOCTL_VERSION; - conn->oc_data.ioc_dev = conn->oc_device; - conn->oc_data.ioc_len = sizeof (conn->oc_data); -} - -int -obdio_ioctl (struct obdio_conn *conn, int cmd) -{ - char *buf = conn->oc_buffer; - int rc; - int rc2; - - rc = obd_ioctl_pack (&conn->oc_data, &buf, sizeof (conn->oc_buffer)); - if (rc != 0) { - fprintf(stderr, "%s: obd_ioctl_pack: %d (%s)\n", - __FUNCTION__, rc, strerror(errno)); - abort(); - } - - rc = ioctl (conn->oc_fd, cmd, buf); - if (rc != 0) - return (rc); - - rc2 = obd_ioctl_unpack (&conn->oc_data, buf, sizeof (conn->oc_buffer)); - if (rc2 != 0) { - fprintf(stderr, "%s: obd_ioctl_unpack: %d (%s)\n", - __FUNCTION__, rc2, strerror(errno)); - abort (); - } - - return (rc); -} - -struct obdio_conn * -obdio_connect (int device) -{ - struct obdio_conn *conn; - - conn = malloc (sizeof (*conn)); - if (conn == NULL) { - fprintf (stderr, "%s: no memory\n", __FUNCTION__); - return (NULL); - } - memset (conn, 0, sizeof (*conn)); - - conn->oc_fd = open ("/dev/obd", O_RDWR); - if (conn->oc_fd < 0) { - fprintf(stderr, "%s: Can't open /dev/obd: %s\n", - __FUNCTION__, strerror(errno)); - goto failed; - } - - conn->oc_device = device; - return (conn); - - failed: - free (conn); - return (NULL); -} - -void -obdio_disconnect (struct obdio_conn *conn, int flags) -{ - close (conn->oc_fd); - /* obdclass will automatically close on last ref */ - free (conn); -} - -int -obdio_pread (struct obdio_conn *conn, __u64 oid, - void *buffer, __u32 count, __u64 offset) -{ - obdio_iocinit (conn); - - ostid_set_id(&conn->oc_data.ioc_obdo1.o_oi, oid); - conn->oc_data.ioc_obdo1.o_mode = S_IFREG; - conn->oc_data.ioc_obdo1.o_valid = - OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE; - - conn->oc_data.ioc_pbuf2 = buffer; - conn->oc_data.ioc_plen2 = count; - conn->oc_data.ioc_count = count; - conn->oc_data.ioc_offset = offset; - - return (obdio_ioctl (conn, OBD_IOC_BRW_READ)); -} - -int -obdio_pwrite (struct obdio_conn *conn, __u64 oid, - void *buffer, __u32 count, __u64 offset) -{ - obdio_iocinit (conn); - - ostid_set_id(&conn->oc_data.ioc_obdo1.o_oi, oid); - conn->oc_data.ioc_obdo1.o_mode = S_IFREG; - conn->oc_data.ioc_obdo1.o_valid = - OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE; - - conn->oc_data.ioc_pbuf1 = (void*)1; - conn->oc_data.ioc_plen1 = 1; - conn->oc_data.ioc_pbuf2 = buffer; - conn->oc_data.ioc_plen2 = count; - conn->oc_data.ioc_count = count; - conn->oc_data.ioc_offset = offset; - - return (obdio_ioctl (conn, OBD_IOC_BRW_WRITE)); -} - -int -obdio_enqueue (struct obdio_conn *conn, __u64 oid, - int mode, __u64 offset, __u32 count, - struct lustre_handle *lh) -{ - int rc; - - obdio_iocinit (conn); - - ostid_set_id(&conn->oc_data.ioc_obdo1.o_oi, oid); - conn->oc_data.ioc_obdo1.o_mode = S_IFREG; - conn->oc_data.ioc_obdo1.o_valid = - OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE; - - conn->oc_data.ioc_conn1 = mode; - conn->oc_data.ioc_count = count; - conn->oc_data.ioc_offset = offset; - - rc = obdio_ioctl (conn, ECHO_IOC_ENQUEUE); - - if (rc == 0) - *lh = conn->oc_data.ioc_obdo1.o_handle; - - return (rc); -} - -int -obdio_cancel (struct obdio_conn *conn, struct lustre_handle *lh) -{ - obdio_iocinit (conn); - - conn->oc_data.ioc_obdo1.o_handle = *lh; - conn->oc_data.ioc_obdo1.o_valid = OBD_MD_FLHANDLE; - - return (obdio_ioctl (conn, ECHO_IOC_CANCEL)); -} - -void * -obdio_alloc_aligned_buffer (void **spacep, int size) -{ - int pagemask = getpagesize() - 1; - void *space = malloc(size + pagemask); - - if (space == NULL) - return (NULL); - - *spacep = (void *)(((unsigned long)space + pagemask) & ~pagemask); - return space; -} - -struct obdio_barrier * -obdio_new_barrier (__u64 oid, __u64 id, int npeers) -{ - struct obdio_barrier *b; - - b = malloc(sizeof(*b)); - if (b == NULL) { - fprintf(stderr, "%s "LPX64": Can't allocate\n", - __FUNCTION__, oid); - return(NULL); - } - - b->ob_id = id; - b->ob_oid = oid; - b->ob_npeers = npeers; - b->ob_ordinal = 0; - b->ob_count = 0; - return (b); -} - -int -obdio_setup_barrier (struct obdio_conn *conn, struct obdio_barrier *b) -{ - struct lustre_handle lh; - int rc; - int rc2; - void *space, *fileptr; - struct obdio_barrier *fileb; - - if (b->ob_ordinal != 0 || - b->ob_count != 0) { - fprintf(stderr, "%s: invalid parameter\n", __FUNCTION__); - abort (); - } - - space = obdio_alloc_aligned_buffer(&fileptr, getpagesize()); - if (space == NULL) { - fprintf(stderr, "%s "LPX64": Can't allocate page buffer\n", - __FUNCTION__, b->ob_oid); - return (-1); - } - - fileb = fileptr; - memset(fileb, 0, getpagesize()); - *fileb = *b; - - rc = obdio_enqueue(conn, b->ob_oid, LCK_PW, 0, getpagesize(), &lh); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on enqueue: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out; - } - - rc = obdio_pwrite(conn, b->ob_oid, fileb, getpagesize(), 0); - if (rc != 0) - fprintf(stderr, "%s "LPX64": Error on write: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - - rc2 = obdio_cancel (conn, &lh); - if (rc == 0 && rc2 != 0) { - fprintf(stderr, "%s "LPX64": Error on cancel: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - rc = rc2; - } - out: - free (space); - return (rc); -} - -int -obdio_barrier (struct obdio_conn *conn, struct obdio_barrier *b) -{ - struct lustre_handle lh; - int rc; - int rc2; - void *space, *fileptr; - struct obdio_barrier *fileb; - char *mode; - - space = obdio_alloc_aligned_buffer(&fileptr, getpagesize()); - if (space == NULL) { - fprintf(stderr, "%s "LPX64": Can't allocate page buffer\n", - __FUNCTION__, b->ob_oid); - return (-1); - } - - rc = obdio_enqueue(conn, b->ob_oid, LCK_PW, 0, getpagesize(), &lh); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on PW enqueue: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out_1; - } - - fileb = fileptr; - memset(fileb, 0xeb, getpagesize()); - rc = obdio_pread(conn, b->ob_oid, fileb, getpagesize(), 0); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on initial read: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out_2; - } - - if (fileb->ob_id != b->ob_id || - fileb->ob_oid != b->ob_oid || - fileb->ob_npeers != b->ob_npeers || - fileb->ob_count >= b->ob_npeers || - fileb->ob_ordinal != b->ob_ordinal) { - fprintf(stderr, "%s "LPX64": corrupt on initial read\n", - __FUNCTION__, b->ob_id); - fprintf(stderr, - " got ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n", - fileb->ob_id, fileb->ob_oid, fileb->ob_npeers, - fileb->ob_ordinal, fileb->ob_count); - fprintf(stderr, - " expected ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n", - b->ob_id, b->ob_oid, b->ob_npeers, - b->ob_ordinal, b->ob_count); - rc = -1; - goto out_2; - } - - fileb->ob_count++; - if (fileb->ob_count == fileb->ob_npeers) { /* I'm the last joiner */ - fileb->ob_count = 0; /* join count for next barrier */ - fileb->ob_ordinal++; /* signal all joined */ - } - - rc = obdio_pwrite(conn, b->ob_oid, fileb, getpagesize(), 0); - if (rc != 0) { - fprintf (stderr, "%s "LPX64": Error on initial write: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out_2; - } - - mode = "PW"; - b->ob_ordinal++; /* now I wait... */ - while (fileb->ob_ordinal != b->ob_ordinal) { - rc = obdio_cancel (conn, &lh); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on %s cancel: %s\n", - __FUNCTION__, b->ob_oid, mode, strerror(errno)); - goto out_1; - } - - mode = "PR"; - rc = obdio_enqueue(conn, b->ob_oid, LCK_PR,0,getpagesize(),&lh); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on PR enqueue: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out_1; - } - - memset (fileb, 0xeb, getpagesize()); - rc = obdio_pread(conn, b->ob_oid, fileb, getpagesize(), 0); - if (rc != 0) { - fprintf(stderr, "%s "LPX64": Error on read: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - goto out_2; - } - - if (fileb->ob_id != b->ob_id || - fileb->ob_oid != b->ob_oid || - fileb->ob_npeers != b->ob_npeers || - fileb->ob_count >= b->ob_npeers || - (fileb->ob_ordinal != b->ob_ordinal - 1 && - fileb->ob_ordinal != b->ob_ordinal)) { - fprintf(stderr, "%s "LPX64": corrupt\n", - __FUNCTION__, b->ob_id); - fprintf(stderr, " got ["LPX64","LPX64","LPX64"," - LPX64","LPX64"]\n", - fileb->ob_id, fileb->ob_oid, fileb->ob_npeers, - fileb->ob_ordinal, fileb->ob_count); - fprintf(stderr, " expected ["LPX64","LPX64","LPX64 - ","LPX64","LPX64"]\n", - b->ob_id, b->ob_oid, b->ob_npeers, - b->ob_ordinal, b->ob_count); - rc = -1; - goto out_2; - } - } - - out_2: - rc2 = obdio_cancel (conn, &lh); - if (rc == 0 && rc2 != 0) { - fprintf(stderr, "%s "LPX64": Error on cancel: %s\n", - __FUNCTION__, b->ob_oid, strerror(errno)); - rc = rc2; - } - out_1: - free (space); - return (rc); -} diff --git a/lustre/utils/obdiolib.h b/lustre/utils/obdiolib.h deleted file mode 100644 index 9de8a3b..0000000 --- a/lustre/utils/obdiolib.h +++ /dev/null @@ -1,82 +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.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. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef _OBDIOLIB_H_ -#define _OBDIOLIB_H_ - -#include - -#include -#include - -#include -#include -#include - -struct obdio_conn { - int oc_fd; - __u32 oc_device; - struct obd_ioctl_data oc_data; - char oc_buffer[8192]; -}; - -struct obdio_barrier { - __u64 ob_id; - __u64 ob_oid; - __u64 ob_npeers; - __u64 ob_ordinal; - __u64 ob_count; -}; - -extern struct obdio_conn *obdio_connect(int device); -extern void obdio_disconnect(struct obdio_conn *conn, int flags); -extern int obdio_open(struct obdio_conn *conn, __u64 oid, - struct lustre_handle *fh); -extern int obdio_close(struct obdio_conn *conn, __u64 oid, - struct lustre_handle *fh); -extern int obdio_pread(struct obdio_conn *conn, __u64 oid, - void *buffer, __u32 count, __u64 offset); -extern int obdio_pwrite(struct obdio_conn *conn, __u64 oid, - void *buffer, __u32 count, __u64 offset); -extern int obdio_enqueue(struct obdio_conn *conn, __u64 oid, - int mode, __u64 offset, __u32 count, - struct lustre_handle *lh); -extern int obdio_cancel(struct obdio_conn *conn, struct lustre_handle *lh); -extern void *obdio_alloc_aligned_buffer(void **spacep, int size); -extern struct obdio_barrier *obdio_new_barrier(__u64 oid, __u64 id, - int npeers); -extern int obdio_setup_barrier(struct obdio_conn *conn,struct obdio_barrier *b); -extern int obdio_barrier(struct obdio_conn *conn, struct obdio_barrier *b); - -#endif diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index ae85ce6..f9313dc 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/lustre/utils/wirehdr.c b/lustre/utils/wirehdr.c index 906011a..f203baa 100644 --- a/lustre/utils/wirehdr.c +++ b/lustre/utils/wirehdr.c @@ -36,7 +36,6 @@ #include #include -#include #include #include diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 927034f..75966e2 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -36,7 +36,6 @@ #include #include -#include #include #include -- 1.8.3.1