#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
lustre_handles.h \
lustre_idmap.h \
lustre_import.h \
+ lustre_ioctl.h \
lustre_lfsck.h \
lustre_lib.h \
lustre_linkea.h \
#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))
* *STRIPE* - set/get lov_user_md
* *INFO - set/get lov_user_mds_data
*/
-/* see <lustre_lib.h> 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)
#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 <lustre_lib.h> 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)
struct lustre_swap_layouts)
#define LL_IOC_HSM_ACTION _IOR('f', 220, \
struct hsm_current_action)
-/* see <lustre_lib.h> 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)
#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
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.
--- /dev/null
+/*
+ * 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 <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
+
+#ifdef __KERNEL__
+# include <linux/ioctl.h>
+# include <linux/string.h>
+# include <obd_support.h>
+#else /* __KERNEL__ */
+# include <malloc.h>
+# include <string.h>
+#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_ */
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);
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 <obd_support.h>
-
-#ifdef __KERNEL__
-/* function defined in lustre/obdclass/<platform>/<platform>-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 <lustre/lustre_user.h> 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 <lustre/lustre_user.h> 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 <lustre/lustre_user.h> 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)
-
-/* <lustre/lustre_user.h> 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
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,
#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 <lustre/lustre_idl.h>
#include <lustre_lib.h>
#include <libcfs/bitmap.h>
/* 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;
#include <lustre/lustre_idl.h>
#include <obd_support.h>
#include <obd_class.h>
+#include <lustre_ioctl.h>
#include <lustre_lib.h>
-#include <lustre/lustre_idl.h>
#include <lustre_lite.h>
#include <lustre_dlm.h>
#include <lustre_fid.h>
}
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:
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;
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) ||
#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);
#include <linux/file.h>
#include "llite_internal.h"
#include <lustre/ll_fiemap.h>
+#include <lustre_ioctl.h>
#include "cl_object.h"
#include <linux/version.h>
#include <linux/mm.h>
+#include <lustre_ioctl.h>
#include <lustre_lite.h>
#include <lustre_ha.h>
#include <lustre_dlm.h>
#include <lclient.h>
#include <lustre_lite.h>
#include <lustre_fid.h>
+#include <lustre_ioctl.h>
#include "lmv_internal.h"
/* This hash is only for testing purpose */
#endif
#include <obd_support.h>
+#include <lustre_ioctl.h>
#include <lustre_lib.h>
#include <lustre_net.h>
#include <lustre/lustre_idl.h>
#endif
#include <lustre_acl.h>
+#include <lustre_ioctl.h>
#include <obd_class.h>
#include <lustre_lmv.h>
#include <lustre_fid.h>
#include <linux/module.h>
#include <obd_class.h>
+#include <lustre_ioctl.h>
#include <lustre_mds.h>
#include <obd_support.h>
#include <lu_object.h>
* struct OBD_{ALLOC,FREE}*()
*/
#include <obd_support.h>
+#include <lustre_ioctl.h>
/* struct ptlrpc_request */
#include <lustre_net.h>
/* struct obd_export */
#include <obd_class.h>
#include <lprocfs_status.h>
+#include <lustre_ioctl.h>
#include <lustre_param.h>
#include "mgs_internal.h"
#define D_MGS D_CONFIG
#include <obd.h>
+#include <lustre_ioctl.h>
#include <lustre_param.h>
#include <lustre_sec.h>
#include <lustre_quota.h>
# include <dt_object.h>
# include <md_object.h>
#endif /* HAVE_SERVER_SUPPORT */
+#include <lustre_ioctl.h>
#include "llog_internal.h"
#ifndef __KERNEL__
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;
#include <obd_class.h>
#include <lnet/lnetctl.h>
#include <lprocfs_status.h>
+#include <lustre_ioctl.h>
#include <lustre_ver.h>
#include <lustre/lustre_build_version.h>
#ifdef __KERNEL__
#define DEBUG_SUBSYSTEM S_LOG
#include <obd_class.h>
+#include <lustre_ioctl.h>
#include <lustre_log.h>
#include "llog_internal.h"
#include <obd_class.h>
#include <obd.h>
#endif
+#include <lustre_ioctl.h>
#include <lustre_log.h>
#include <lprocfs_status.h>
#include <lustre_param.h>
#include <obd_class.h>
#include <lustre/lustre_user.h>
#include <linux/version.h>
+#include <lustre_ioctl.h>
#include <lustre_log.h>
#include <lustre_disk.h>
#include <lustre_param.h>
#include <md_object.h>
#include <lustre_fid.h>
#include <lustre_acl.h>
+#include <lustre_ioctl.h>
#include <lustre_net.h>
#include "echo_internal.h"
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);
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)
{
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)
{
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)
{
}
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)
{
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);
#include <lustre/lustre_idl.h>
#include "ofd_internal.h"
#include <obd_cksum.h>
+#include <lustre_ioctl.h>
#include <lustre_quota.h>
#include <lustre_lfsck.h>
#include <lustre_ha.h>
#include <lprocfs_status.h>
+#include <lustre_ioctl.h>
#include <lustre_log.h>
#include <lustre_debug.h>
#include <lustre_param.h>
#define DEBUG_SUBSYSTEM S_MDS
#include <obd_class.h>
+#include <lustre_ioctl.h>
#include <lustre_param.h>
#include <lustre_log.h>
#include <lustre_mdc.h>
#include <dirent.h>
#include <liblustre.h>
-#include <obd.h>
-#include <lustre_lib.h>
#include <lustre/lustreapi.h>
#include <lnet/lnetctl.h>
#elif defined(USE_MDC_LOOKUP)
#include <config.h>
#include <liblustre.h>
-#include <linux/lustre_lib.h>
+#include <lustre_ioctl.h>
int llapi_file_lookup(int dirfd, const char *name)
{
#include <unistd.h>
#include <liblustre.h>
-#include <obd.h> /* needed for lov_stripe_md_size */
#include <lustre/lustreapi.h>
#define ACT_NONE 0
#include <sys/ioctl.h>
#include <liblustre.h>
-#include <lustre_lib.h>
-#include <obd.h>
+#include <lustre_ioctl.h>
struct option longopts[] = {
{"ea", 0, 0, 'e'},
#include <fcntl.h>
#include <liblustre.h>
-#include <lustre_lib.h>
-#include <obd.h>
+#include <lustre_ioctl.h>
int main(int argc, char **argv)
{
/wiretest
/llog_reader
/lr_reader
-/obdio
-/obdbarrier
/lload
/llverfs
/llverdev
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 \
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
#include <lustre/lustreapi.h>
#include <libcfs/libcfsutil.h>
-#include <obd.h>
#include "obdctl.h"
/* all functions */
#include <liblustre.h>
#include <lnet/lnetctl.h>
-#include <obd.h>
#include <lustre/lustreapi.h>
+#include <lustre_ioctl.h>
#include "lustreapi_internal.h"
static unsigned llapi_dir_filetype_table[] = {
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);
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;
}
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);
return rc;
}
- rc = ioctl(dirfd(root), LL_IOC_QUOTACTL, qctl);
+ rc = ioctl(dirfd(root), OBD_IOC_QUOTACTL, qctl);
if (rc < 0)
rc = -errno;
#include <liblustre.h>
#include <lnet/lnetctl.h>
-#include <obd.h>
#include <lustre/lustreapi.h>
#include "lustreapi_internal.h"
#include <lnet/lnetctl.h>
#include <libcfs/libcfsutil.h>
+#include <lustre_ioctl.h>
#include "obdctl.h"
static char cmdname[512];
#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <lustre_lib.h>
#include <lustre_cfg.h>
#include <lustre/lustre_idl.h>
-#include <lustre_dlm.h>
-#include <obd.h> /* for struct lov_stripe_md */
#include <lustre/lustre_build_version.h>
#include <unistd.h>
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;
#include "obdctl.h"
-#include <obd.h>
#include <lustre/lustre_lfsck_user.h>
#include <libcfs/libcfsutil.h>
#include <lnet/lnetctl.h>
+#include <lustre_ioctl.h>
static struct option long_opt_start[] = {
{"device", required_argument, 0, 'M'},
#include "obdctl.h"
-#include <obd.h> /* for struct lov_stripe_md */
+#include <lustre_ioctl.h>
#include <lustre/lustre_build_version.h>
#include <lnet/lnetctl.h>
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);
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];
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 <count> [<file_create_mode>] [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) {
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;
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));
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;
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)
+++ /dev/null
-/*
- * 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 <eeb@clusterfs.com>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include <liblustre.h>
-#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);
-}
#include <liblustre.h>
#endif
-#include <lustre_lib.h>
#include <lustre/lustre_idl.h>
-#include <lustre_dlm.h>
-#include <lustre_cfg.h>
#define MAX_IOC_BUFLEN 8192
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);
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);
+++ /dev/null
-/*
- * 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 <eeb@clusterfs.com>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include <liblustre.h>
-#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);
-}
+++ /dev/null
-/*
- * 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 <eeb@clusterfs.com>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <liblustre.h>
-#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);
-}
+++ /dev/null
-/*
- * 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 <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <lustre_lib.h>
-#include <lustre/lustre_idl.h>
-#include <obd_class.h>
-
-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
#include <sys/types.h>
#include <sys/wait.h>
#include <liblustre.h>
-#include <lustre_lib.h>
#include <lustre/lustre_idl.h>
#include <lustre_disk.h>
#include <stdio.h>
#include <liblustre.h>
-#include <lustre_lib.h>
#include <lustre/lustre_idl.h>
#include <lustre_disk.h>
#include <stdio.h>
#include <liblustre.h>
-#include <lustre_lib.h>
#include <lustre/lustre_idl.h>
#include <lustre_disk.h>