Whamcloud - gitweb
LU-16634 misc: replace obsolete ioctl numbers 90/50390/10
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 23 Mar 2023 08:01:53 +0000 (02:01 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 31 May 2023 19:01:22 +0000 (19:01 +0000)
Renumber the OBD_IOC_BARRIER and IOC_OSC_SET_ACTIVE ioctl numbers
to use IOC type 'f' instead of 'g' and 'h', respectively.  Add
compatibility code to handle their deprecation in the future.

Move already-deprecated ioctls OBD_IOC_GETNAME_OLD, OBD_GET_VERSION,
IOC_LIBCFS_GET_NI, and IOC_LIBCFS_PING to lustre_ioctl_old.h also.
Remove other already obsolete ioctl number definitions.

Add new llapi_ioctl() and llapi_ioctl_dev() helper functions to
handle fallback of ioctl commands to older versions when needed.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I519f23d34ce6197f3430a3825c5190cedb00cf14
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50390
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
22 files changed:
lnet/include/uapi/linux/lnet/libcfs_ioctl.h
lustre/doc/Makefile.am
lustre/doc/llapi_ioctl.3 [new file with mode: 0644]
lustre/include/Makefile.am
lustre/include/lustre/lustreapi.h
lustre/include/lustre_ioctl_old.h [new file with mode: 0644]
lustre/include/uapi/linux/lustre/lustre_ioctl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/llite_lib.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/mgs/mgs_handler.c
lustre/obdclass/class_obd.c
lustre/osc/osc_request.c
lustre/osp/osp_dev.c
lustre/utils/Makefile.am
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_ioctl.c [new file with mode: 0644]
lustre/utils/lustreapi_internal.h
lustre/utils/obd.c
lustre/utils/portals.c

index 88f51bb..7a55e55 100644 (file)
@@ -86,20 +86,19 @@ struct libcfs_ioctl_data {
 #define IOC_LIBCFS_TYPE                                      ('e')
 #define IOC_LIBCFS_MIN_NR                            30
 /* libcfs ioctls */
-/* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */
+/* XXX: all of these ioctl definitions are broken, the first parameter
+ * should be IOCTL_LIBCFS_TYPE and the last parameter is the struct size.
+ */
 #define IOC_LIBCFS_CLEAR_DEBUG             _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_MARK_DEBUG              _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
-/* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
 /* lnet ioctls */
 #define IOC_LIBCFS_GET_NI                 _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_FAIL_NID               _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_NOTIFY_ROUTER          _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_UNCONFIGURE            _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
-/*      IOC_LIBCFS_PORTALS_COMPATIBILITY  _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */
 #define IOC_LIBCFS_LNET_DIST              _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_CONFIGURE              _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_TESTPROTOCOMPAT        _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
-/* IOC_LIBCFS_PING obsolete in 2.16, was _IOWR('e', 61, IOCTL_LIBCFS_TYPE) */
 #define IOC_LIBCFS_PING_PEER               _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_LNETST                 _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_LNET_FAULT             _IOWR('e', 64, IOCTL_LIBCFS_TYPE)
index b7e50fc..22c9086 100644 (file)
@@ -143,6 +143,7 @@ LIBMAN =                                    \
        llapi_hsm_copytool_unregister.3         \
        llapi_hsm_state_get.3                   \
        llapi_hsm_state_set.3                   \
+       llapi_ioctl.3                           \
        llapi_ladvise.3                         \
        llapi_layout.7                          \
        llapi_layout_alloc.3                    \
diff --git a/lustre/doc/llapi_ioctl.3 b/lustre/doc/llapi_ioctl.3
new file mode 100644 (file)
index 0000000..9059aa4
--- /dev/null
@@ -0,0 +1,69 @@
+.TH lustreapi 3 "2023 Mar 22" Lustre user application interface library
+.SH NAME
+llapi_ioctl \- call ioctl() with possible command remapping
+.SH SYNOPSIS
+.nf
+.B #include <lustre/lustreapi.h>
+.sp
+.BI "int llapi_ioctl(int " fd ", unsigned int " cmd ", void *" buf ");"
+.SH DESCRIPTION
+.LP
+.B llapi_ioctl()
+calls the
+.BR ioctl (2)
+system call with the supplied arguments.  However, if the ioctl() returns
+.B ENOTTY
+(no such ioctl) then if
+.I cmd
+has been remapped from an older ioctl command number the ioctl() call will
+be retried with the old ioctl command number.
+.SH RETURN VALUES
+.LP
+.B llapi_ioctl()
+typically returns:
+.TP
+0
+on success in most cases
+.TP
+<0
+a negative value on failure and sets
+.BR errno .
+Due to the variety of ioctl commands, it may return different values
+and errno as appropriate for the
+.IR fd ,
+.I cmd
+number, and argument
+.I buf
+passed.
+.SH "EXAMPLE"
+.nf
+#include <lustre/lustreapi.h>
+
+int main(int argc, char *argv[])
+{
+        unsigned long group = 1234;
+        int rc, fd;
+
+        fd = open(argv[1], O_RDONLY);
+        if (rc < 0) {
+                fprintf(stderr, "error opening file '%s': %s\\n",
+                        argv[1], strerror(errno));
+                return -1;
+        }
+
+        rc = llapi_ioctl(fd, LL_IOC_GROUP_LOCK, &group);
+        if (rc < 0) {
+                fprintf(stderr, "%s: ioctl error: %s\\n",
+                        argv[1], strerror(errno));
+                return rc;
+        }
+
+        printf("%s: locked with group %lu\\n", argv[1], group);
+        return 0;
+}
+.fi
+.SH "SEE ALSO"
+.BR lustre (7),
+.BR ioctl (2),
+.BR lustreapi (7)
+
index 96795c7..22f60f0 100644 (file)
@@ -60,6 +60,7 @@ EXTRA_DIST = \
        lustre_idmap.h \
        lustre_import.h \
        lustre_intent.h \
+       lustre_ioctl_old.h \
        lustre_lfsck.h \
        lustre_lib.h \
        lustre_linkea.h \
index 0f0a23f..013ab04 100644 (file)
@@ -1259,6 +1259,8 @@ int llapi_mirror_punch(int fd, unsigned int id, off_t start, size_t length);
 int llapi_heat_get(int fd, struct lu_heat *heat);
 int llapi_heat_set(int fd, __u64 flags);
 
+int llapi_ioctl(int fd, unsigned int cmd, void *buf);
+
 int llapi_layout_sanity(struct llapi_layout *layout, bool incomplete, bool flr);
 void llapi_layout_sanity_perror(int error);
 int llapi_layout_dom_size(struct llapi_layout *layout, uint64_t *size);
diff --git a/lustre/include/lustre_ioctl_old.h b/lustre/include/lustre_ioctl_old.h
new file mode 100644 (file)
index 0000000..bc54625
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ *
+ * Compatibility for deprecated ioctls that should no longer be used by tools.
+ *
+ * Copyright (c) 2023, DataDirect Networks Storage, all rights reserved.
+ */
+#ifndef __LUSTRE_IOCTL_OLD_H
+#define __LUSTRE_IOCTL_OLD_H
+
+#include <linux/lnet/libcfs_ioctl.h> /* for IOCTL_LIBCFS_TYPE */
+
+/* ioctl command is deprecated after release v1.v2 */
+#define case_OBD_IOC_DEPRECATED(cmd, dev, v1, v2)                      \
+       case cmd:                                                       \
+       if (LUSTRE_VERSION_CODE > OBD_OCD_VERSION(v1, v2, 53, 0)) {     \
+               static bool printed;                                    \
+               obd_ioctl_msg(__FILE__, __func__, __LINE__,             \
+                             printed ? D_IOCTL : D_WARNING, dev, cmd,  \
+                             "deprecated " #cmd " usage", 0);          \
+               printed = true;                                         \
+       }
+
+#define case_OBD_IOC_DEPRECATED_FT(cmd, dev, v1, v2)                   \
+       case_OBD_IOC_DEPRECATED(cmd, dev, v1, v2)                       \
+       fallthrough
+
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 19, 53, 0)
+#define OBD_GET_VERSION                _IOWR('f', 144, OBD_IOC_DATA_TYPE) /*< 2.8.55 */
+#endif
+
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 99, 53, 0)
+/* for binary compatibility until 3.0, no more compiling into tools */
+#define OBD_IOC_GETNAME_OLD    _IOWR('f', 131, OBD_IOC_DATA_TYPE) /*< 2.14.52*/
+
+#define IOC_LIBCFS_GET_NI      _IOWR('e', 50, IOCTL_LIBCFS_TYPE)  /*< 2.15.53*/
+#define IOC_LIBCFS_PING                _IOWR('e', 61, IOCTL_LIBCFS_TYPE)  /*< 2.15.53*/
+
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 19, 53, 0)
+#define OBD_IOC_BARRIER                _IOWR('g', 5, OBD_IOC_DATA_TYPE)   /*< 2.16.55*/
+#define IOC_OSC_SET_ACTIVE     _IOWR('h', 21, void *)             /*< 2.16.55*/
+#endif
+
+#endif /* OBD_OCD_VERSION(2, 99, 53, 0) */
+
+/* We don't need *_ALLOW() macros for most ioctls, just a few using a bad
+ * _IOC_TYPE value (i.e. not 'f') so that "early exit" type checks work.
+ */
+#define OBD_IOC_CMD_LATE(cmd, name) unlikely(cmd == name)
+#define OBD_IOC_CMD_GONE(cmd, name) (false)
+
+#ifdef OBD_IOC_BARRIER
+#define OBD_IOC_BARRIER_ALLOW(cmd) OBD_IOC_CMD_LATE(cmd, OBD_IOC_BARRIER)
+#else
+#define OBD_IOC_BARRIER_ALLOW(cmd) OBD_IOC_CMD_GONE(cmd)
+#endif
+#ifdef IOC_OSC_SET_ACTIVE
+#define IOC_OSC_SET_ACTIVE_ALLOW(cmd) OBD_IOC_CMD_LATE(cmd, IOC_OSC_SET_ACTIVE)
+#else
+#define IOC_OSC_SET_ACTIVE_ALLOW(cmd) OBD_IOC_CMD_GONE(cmd)
+#endif
+
+#endif /* __LUSTRE_IOCTL_OLD_H */
index 2e9a9bb..5b05816 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/lustre/lustre_idl.h>
+#include <linux/lustre/lustre_ver.h>
 
 /*
  * sparse kernel source annotations
@@ -134,7 +135,14 @@ static inline __u32 obd_ioctl_packlen(struct obd_ioctl_data *data)
 
 #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_BARRIER_V2     _IOW('f', 105, struct obd_ioctl_data)
+#define OBD_IOC_SET_ACTIVE     _IOW('f', 106, struct obd_ioctl_data)
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 19, 53, 0)
+/* for API compatibility until 2.19.x, but prefer to use new IOC values above */
+/* OBD_IOC_BARRIER wrongly defined as _IOWR('f', 261, OBD_IOC_DATA_TYPE) */
+#define OBD_IOC_BARRIER                _IOWR('g', 5, OBD_IOC_DATA_TYPE) /* < 2.16 */
+#define IOC_OSC_SET_ACTIVE     _IOWR('h', 21, void *) /* deprecated 2.16 */
+#endif
 
 #define OBD_IOC_SETATTR                _IOW('f', 107, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_GETATTR                _IOWR('f', 108, OBD_IOC_DATA_TYPE)
@@ -150,14 +158,9 @@ static inline __u32 obd_ioctl_packlen(struct obd_ioctl_data *data)
 #define OBD_IOC_GETDTNAME      _IOR('f', 127, char[MAX_OBD_NAME])
 /* ioctl codes 128-143 are reserved for fsverity */
 #define OBD_IOC_UUID2DEV       _IOWR('f', 130, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_GETNAME_OLD    _IOWR('f', 131, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_GETMDNAME      _IOR('f', 131, char[MAX_OBD_NAME])
-/*      OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, OBD_IOC_DATA_TYPE) until 2.14 */
 #define OBD_IOC_CLIENT_RECOVER _IOW('f', 133, OBD_IOC_DATA_TYPE)
 /* ioctl codes 128-143 are reserved for fsverity */
-/* FS_IOC_ENABLE_VERITY                _IOW('f', 133, struct fsverity_enable_arg) */
-/* FS_IOC_MEASURE_VERITY       _IOW('f', 134, struct fsverity_digest) */
-/* was OBD_IOC_NO_TRANSNO      _IOW('f', 140, OBD_IOC_DATA_TYPE) until 2.14 */
 #define OBD_IOC_SET_READONLY   _IOW('f', 141, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_ABORT_RECOVERY _IOR('f', 142, OBD_IOC_DATA_TYPE)
 enum obd_abort_recovery_flags {
@@ -165,31 +168,15 @@ enum obd_abort_recovery_flags {
        OBD_FLG_ABORT_RECOV_MDT = 0x40000, /* LMD_FLG_ABORT_RECOV_MDT */
 };
 /* ioctl codes 128-143 are reserved for fsverity */
-#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) */
-/*     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 */
-/*     OBD_IOC_QUOTACHECK      _IOW('f', 160, int) */
-/*     OBD_IOC_POLL_QUOTACHECK _IOR('f', 161, struct if_quotacheck *) */
+/*     lustre/lustre_user.h    151-159 */
 #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)
-/*     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)
@@ -200,33 +187,18 @@ enum obd_abort_recovery_flags {
 #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)
 #define OBD_IOC_CLEAR_CONFIGS   _IOWR('f', 198, 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_LCFG_FORK      _IOWR('f', 208, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_LCFG_ERASE     _IOWR('f', 209, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_GET_OBJ_VERSION        _IOR('f', 210, OBD_IOC_DATA_TYPE)
-
 /*     lustre/lustre_user.h    211-220 */
-/* was #define OBD_IOC_GET_MNTOPT      _IOW('f', 220, mntopt_t) until 2.11 */
 #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)
 #define OBD_IOC_QUERY_LFSCK    _IOR('f', 232, struct obd_ioctl_data)
 #define OBD_IOC_CHLG_POLL      _IOR('f', 233, long)
-/*     lustre/lustre_user.h    240-249 */
-/* was LIBCFS_IOC_DEBUG_MASK   _IOWR('f', 250, long) until 2.11 */
-
-/* OBD_IOC_BARRIER wrongly defined as _IOWR('f', 261, OBD_IOC_DATA_TYPE) */
-#define OBD_IOC_BARRIER                _IOWR('g', 5, OBD_IOC_DATA_TYPE)
-
-#define IOC_OSC_SET_ACTIVE     _IOWR('h', 21, void *)
+/*     lustre/lustre_user.h    240-253 */
 
 #endif /* _UAPI_LUSTRE_IOCTL_H */
index 70949e8..151dbf8 100644 (file)
@@ -588,17 +588,10 @@ struct ll_ioc_lease_id {
 #define LL_IOC_LOV_GETSTRIPE            _IOW ('f', 155, long)
 #define LL_IOC_LOV_GETSTRIPE_NEW       _IOR('f', 155, struct lov_user_md)
 #define LL_IOC_LOV_SETEA                _IOW ('f', 156, long)
-/*     LL_IOC_RECREATE_OBJ             157 obsolete */
-/*     LL_IOC_RECREATE_FID             157 obsolete */
 #define LL_IOC_GROUP_LOCK               _IOW ('f', 158, long)
 #define LL_IOC_GROUP_UNLOCK             _IOW ('f', 159, long)
-/*     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 *)
-/*     IOC_LOV_GETINFO                 165 obsolete */
 #define LL_IOC_FLUSHCTX                 _IOW ('f', 166, long)
-/*     LL_IOC_RMTACL                   167 obsolete */
 #define LL_IOC_GETOBDCOUNT              _IOR ('f', 168, long)
 #define LL_IOC_LLOOP_ATTACH             _IOWR('f', 169, long)
 #define LL_IOC_LLOOP_DETACH             _IOWR('f', 170, long)
@@ -622,7 +615,7 @@ struct ll_ioc_lease_id {
                                                struct lustre_swap_layouts)
 #define LL_IOC_HSM_ACTION              _IOR('f', 220, \
                                                struct hsm_current_action)
-/*     lustre_ioctl.h                  221-232 */
+/*     lustre_ioctl.h                  221-233 */
 #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)
index f3ab5a3..a0f1003 100644 (file)
@@ -56,6 +56,7 @@
 #endif
 #include <libcfs/linux/linux-misc.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #ifdef HAVE_UAPI_LINUX_MOUNT_H
 #include <uapi/linux/mount.h>
 #endif
@@ -3161,7 +3162,10 @@ int ll_iocontrol(struct inode *inode, struct file *file,
        }
        case OBD_IOC_FID2PATH:
                RETURN(ll_fid2path(inode, uarg));
-       case OBD_IOC_GETNAME_OLD:
+#ifdef OBD_IOC_GETNAME_OLD
+       case_OBD_IOC_DEPRECATED_FT(OBD_IOC_GETNAME_OLD,
+                                  sbi->ll_md_exp->exp_obd->obd_name, 2, 16);
+#endif
        case OBD_IOC_GETDTNAME:
        case OBD_IOC_GETMDNAME:
                RETURN(ll_get_obd_name(inode, cmd, uarg));
@@ -3220,10 +3224,10 @@ void ll_umount_begin(struct super_block *sb)
 
        OBD_ALLOC_PTR(ioc_data);
        if (ioc_data) {
-               obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
+               obd_iocontrol(OBD_IOC_SET_ACTIVE, sbi->ll_md_exp,
                              sizeof *ioc_data, ioc_data, NULL);
 
-               obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
+               obd_iocontrol(OBD_IOC_SET_ACTIVE, sbi->ll_dt_exp,
                              sizeof *ioc_data, ioc_data, NULL);
 
                OBD_FREE_PTR(ioc_data);
index 37182bf..ddaae05 100644 (file)
@@ -52,6 +52,7 @@
 #include <cl_object.h>
 #include <lustre_fid.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <lustre_kernelcomm.h>
 #include "lmv_internal.h"
 
@@ -857,7 +858,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
                RETURN(-ENOTTY);
 
        /* exit early for unknown ioctl types */
-       if (unlikely(_IOC_TYPE(cmd) != 'f' && cmd != IOC_OSC_SET_ACTIVE))
+       if (unlikely(_IOC_TYPE(cmd) != 'f' && !IOC_OSC_SET_ACTIVE_ALLOW(cmd)))
                RETURN(OBD_IOC_ERROR(obd->obd_name, cmd, "unknown", -ENOTTY));
 
        /* handle commands that don't use @karg first */
index f48a82b..3a74d9e 100644 (file)
@@ -43,6 +43,7 @@
 #include <lustre_dlm.h>
 #include <lustre_fid.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <lustre_lib.h>
 #include <lustre_mds.h>
 #include <lustre_net.h>
@@ -957,8 +958,8 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
        CDEBUG(D_IOCTL, "%s: cmd=%x len=%u karg=%pK uarg=%pK\n",
               exp->exp_obd->obd_name, cmd, len, karg, uarg);
 
-       /* exit early for unknown ioctl types */
-       if (unlikely(_IOC_TYPE(cmd) != 'f' && cmd != IOC_OSC_SET_ACTIVE))
+       /* exit early for unknown ioctl types. */
+       if (unlikely(_IOC_TYPE(cmd) != 'f' && !IOC_OSC_SET_ACTIVE_ALLOW(cmd)))
                RETURN(OBD_IOC_DEBUG(D_IOCTL, obd->obd_name, cmd, "unknown",
                                     -ENOTTY));
 
index f87acc7..3f70814 100644 (file)
 #include <lustre_compat.h>
 #include <lustre_fid.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <lustre_kernelcomm.h>
 #include <lustre_lmv.h>
 #include <lustre_log.h>
+#include <lustre_osc.h>
 #include <lustre_swab.h>
 #include <obd_class.h>
-#include <lustre_osc.h>
 
 #include "mdc_internal.h"
 
@@ -2253,7 +2254,10 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                if (rc < 0)
                        GOTO(out, rc);
                GOTO(out, rc = 0);
-       case IOC_OSC_SET_ACTIVE:
+#ifdef IOC_OSC_SET_ACTIVE
+       case_OBD_IOC_DEPRECATED_FT(IOC_OSC_SET_ACTIVE, obd->obd_name, 2, 17);
+#endif
+       case OBD_IOC_SET_ACTIVE:
                rc = ptlrpc_set_import_active(imp, data->ioc_offset);
                GOTO(out, rc);
        /*
index 26287c1..f12e5db 100644 (file)
@@ -41,6 +41,7 @@
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <uapi/linux/lustre/lustre_param.h>
 #include <uapi/linux/lustre/lustre_barrier_user.h>
 
@@ -1104,7 +1105,10 @@ out_free:
        case OBD_IOC_POOL:
                rc = mgs_iocontrol_pool(&env, mgs, data);
                break;
-       case OBD_IOC_BARRIER:
+#ifdef OBD_IOC_BARRIER
+       case_OBD_IOC_DEPRECATED_FT(OBD_IOC_BARRIER, obd->obd_name, 2, 17);
+#endif
+       case OBD_IOC_BARRIER_V2:
                rc = mgs_iocontrol_barrier(&env, mgs, data);
                break;
        case OBD_IOC_NODEMAP:
index 3c7862b..3cc1d37 100644 (file)
@@ -50,6 +50,7 @@
 #endif /* HAVE_SERVER_SUPPORT */
 #include <uapi/linux/lustre/lustre_ioctl.h>
 #include "llog_internal.h"
+#include <lustre_ioctl_old.h>
 
 #ifdef CONFIG_PROC_FS
 static __u64 obd_max_alloc;
@@ -338,8 +339,8 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg)
 
        ENTRY;
        CDEBUG(D_IOCTL, "obdclass: cmd=%x len=%u uarg=%pK\n", cmd, len, uarg);
-       if (unlikely(_IOC_TYPE(cmd) != 'f' && cmd != IOC_OSC_SET_ACTIVE &&
-                    cmd != OBD_IOC_BARRIER))
+       if (unlikely(_IOC_TYPE(cmd) != 'f' && !OBD_IOC_BARRIER_ALLOW(cmd) &&
+                    !IOC_OSC_SET_ACTIVE_ALLOW(cmd)))
                RETURN(OBD_IOC_ERROR(obd->obd_name, cmd, "unknown", -ENOTTY));
 
        rc = obd_ioctl_getdata(&data, &len, uarg);
@@ -370,10 +371,8 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg)
                GOTO(out, rc);
        }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-       case OBD_GET_VERSION: {
-               static bool warned;
-
+#ifdef OBD_GET_VERSION
+       case_OBD_IOC_DEPRECATED(OBD_GET_VERSION, "obdclass", 2, 15)
                if (!data->ioc_inlbuf1) {
                        rc = OBD_IOC_ERROR("obdclass", cmd, "no buffer passed",
                                           -EINVAL);
@@ -386,19 +385,12 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg)
                        GOTO(out, rc);
                }
 
-               if (!warned) {
-                       warned = true;
-                       CWARN("%s: ioctl(OBD_GET_VERSION) is deprecated, "
-                             "use llapi_get_version_string() and/or relink\n",
-                             current->comm);
-               }
                memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING,
                       strlen(LUSTRE_VERSION_STRING) + 1);
 
                if (copy_to_user(uarg, data, len))
                        rc = -EFAULT;
                GOTO(out, rc);
-       }
 #endif
        case OBD_IOC_NAME2DEV: {
                /* Resolve device name, does not change current selected dev */
index 1d0c2b0..32190a5 100644 (file)
 #include <lustre_fid.h>
 #include <lustre_ha.h>
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <lustre_net.h>
 #include <lustre_obdo.h>
+#include <lustre_osc.h>
 #include <obd.h>
 #include <obd_cksum.h>
 #include <obd_class.h>
-#include <lustre_osc.h>
-#include <linux/falloc.h>
 
 #include "osc_internal.h"
 #include <lnet/lnet_rdma.h>
@@ -3374,7 +3374,10 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                data = karg;
                rc = obd_getattr(NULL, exp, &data->ioc_obdo1);
                break;
-       case IOC_OSC_SET_ACTIVE:
+#ifdef IOC_OSC_SET_ACTIVE
+       case_OBD_IOC_DEPRECATED_FT(IOC_OSC_SET_ACTIVE, obd->obd_name, 2, 17);
+#endif
+       case OBD_IOC_SET_ACTIVE:
                if (unlikely(karg == NULL)) {
                        OBD_IOC_ERROR(obd->obd_name, cmd, "karg=NULL",
                                      rc = -EINVAL);
index ae3bb90..9d5b758 100644 (file)
@@ -72,6 +72,7 @@
 #include <linux/kthread.h>
 
 #include <uapi/linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
 #include <lustre_log.h>
 #include <lustre_obdo.h>
 #include <uapi/linux/lustre/lustre_param.h>
@@ -1699,7 +1700,10 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                if (rc > 0)
                        rc = 0;
                break;
-       case IOC_OSC_SET_ACTIVE:
+#ifdef IOC_OSC_SET_ACTIVE
+       case_OBD_IOC_DEPRECATED_FT(IOC_OSC_SET_ACTIVE, obd->obd_name, 2, 17);
+#endif
+       case OBD_IOC_SET_ACTIVE:
                rc = ptlrpc_set_import_active(obd->u.cli.cl_import,
                                              data->ioc_offset);
                break;
index 026eb5a..8e84fd1 100644 (file)
@@ -109,7 +109,7 @@ liblustreapi_la_SOURCES = liblustreapi.c liblustreapi_hsm.c \
                          liblustreapi_mirror.c liblustreapi_fid.c \
                          liblustreapi_ladvise.c liblustreapi_chlg.c \
                          liblustreapi_heat.c liblustreapi_pcc.c \
-                         liblustreapi_root.c \
+                         liblustreapi_ioctl.c liblustreapi_root.c \
                          liblustreapi_lseek.c liblustreapi_swap.c
 liblustreapi_la_CFLAGS = -fPIC -D_GNU_SOURCE $(LIBNL3_CFLAGS) \
                         -I $(top_builddir)/lnet/utils \
index 8cea04e..d4887db 100644 (file)
@@ -322,96 +322,6 @@ int llapi_parse_size(const char *optarg, unsigned long long *size,
        return 0;
 }
 
-int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len)
-{
-       struct obd_ioctl_data *overlay;
-       char *ptr;
-
-       data->ioc_len = obd_ioctl_packlen(data);
-       data->ioc_version = OBD_IOCTL_VERSION;
-
-       if (*pbuf != NULL && data->ioc_len > max_len) {
-               llapi_error(LLAPI_MSG_ERROR, -EINVAL,
-                           "pbuf = %p, ioc_len = %u, max_len = %d",
-                           *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) {
-               memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
-       }
-
-       if (data->ioc_inlbuf2) {
-               memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
-       }
-
-       if (data->ioc_inlbuf3) {
-               memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
-       }
-
-       if (data->ioc_inlbuf4) {
-               memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
-       }
-
-       return 0;
-}
-
-int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len)
-{
-       struct obd_ioctl_data *overlay;
-       char *ptr;
-
-       if (pbuf == NULL)
-               return -EINVAL;
-
-       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) {
-               memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
-       }
-
-       if (data->ioc_inlbuf2) {
-               memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
-       }
-
-       if (data->ioc_inlbuf3) {
-               memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
-       }
-
-       if (data->ioc_inlbuf4) {
-               memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
-               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
-       }
-
-       return 0;
-}
-
 /**
  * Verify the setstripe parameters before using.
  * This is a pair method for comp_args_to_layout()/llapi_layout_sanity_cb()
@@ -2141,8 +2051,6 @@ int llapi_file_fget_lov_uuid(int fd, struct obd_uuid *lov_name)
        int rc;
 
        rc = ioctl(fd, OBD_IOC_GETDTNAME, lov_name);
-       if (rc && errno == ENOTTY)
-               rc = ioctl(fd, OBD_IOC_GETNAME_OLD, lov_name);
        if (rc) {
                rc = -errno;
                llapi_error(LLAPI_MSG_ERROR, rc, "cannot get lov name");
@@ -2155,7 +2063,7 @@ int llapi_file_fget_lmv_uuid(int fd, struct obd_uuid *lov_name)
 {
        int rc;
 
-       rc = ioctl(fd, OBD_IOC_GETMDNAME, lov_name);
+       rc = llapi_ioctl(fd, OBD_IOC_GETMDNAME, lov_name);
        if (rc) {
                rc = -errno;
                llapi_error(LLAPI_MSG_ERROR, rc, "error: can't get lmv name.");
diff --git a/lustre/utils/liblustreapi_ioctl.c b/lustre/utils/liblustreapi_ioctl.c
new file mode 100644 (file)
index 0000000..183106c
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * LGPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 or (at your discretion) any later version.
+ * (LGPL) version 2.1 accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * LGPL HEADER END
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ *
+ * lustre/utils/liblustreapi_ioctl.c
+ *
+ * lustreapi library for packing/unpacking obd_ioctl_data structure to
+ * send commands to different OBD devices.  Mostly for internal use.
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2017, Intel Corporation.
+ *
+ * Copyright (c) 2023, DataDirect Networks Storage.
+ */
+
+#include <string.h>
+#include <stddef.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include <lustre/lustreapi.h>
+#include <libcfs/util/ioctl.h>
+#include <linux/lustre/lustre_ioctl.h>
+#include <lustre_ioctl_old.h>
+#include <linux/lustre/lustre_ver.h>
+
+int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len)
+{
+       struct obd_ioctl_data *overlay;
+       char *ptr;
+
+       data->ioc_len = obd_ioctl_packlen(data);
+       data->ioc_version = OBD_IOCTL_VERSION;
+
+       if (*pbuf != NULL && data->ioc_len > max_len) {
+               llapi_error(LLAPI_MSG_ERROR, -EINVAL,
+                           "pbuf = %p, ioc_len = %u, max_len = %d",
+                           *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) {
+               memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
+       }
+
+       if (data->ioc_inlbuf2) {
+               memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
+       }
+
+       if (data->ioc_inlbuf3) {
+               memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
+       }
+
+       if (data->ioc_inlbuf4) {
+               memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
+       }
+
+       return 0;
+}
+
+/**
+ * Remap OBD device ioctl cmd to old one in case running with older modules.
+ * Replaces callers that use "l_ioctl(OBD_DEV_ID, ...)".
+ *
+ * \param dev_id       Lustre device number (from 'lctl dl')
+ * \param cmd          ioctl command
+ * \param buf          ioctl data argument, usually obd_ioctl_data
+ */
+int llapi_ioctl_dev(unsigned int dev_id, unsigned int cmd, void *buf)
+{
+       unsigned int oldcmd;
+       int rc;
+
+       /* common case, ioctl works as expected */
+       rc = l_ioctl(dev_id, cmd, buf);
+       if (rc >= 0 || errno != ENOTTY)
+               return rc;
+
+       switch (cmd) {
+       /*
+        * Use #ifdef instead of version check to minimize the places that a
+        * version change might cause a compiler error in the future.
+        *
+        * Version in comment is to allow finding this code for later removal.
+        */
+#ifdef OBD_IOC_BARRIER         /* < OBD_OCD_VERSION(2, 19, 53, 0) */
+       case OBD_IOC_BARRIER_V2:
+               oldcmd = OBD_IOC_BARRIER;
+               break;
+#endif
+#ifdef IOC_OSC_SET_ACTIVE      /* < OBD_OCD_VERSION(2, 19, 53, 0) */
+       case OBD_IOC_SET_ACTIVE:
+               oldcmd = IOC_OSC_SET_ACTIVE;
+               break;
+#endif
+       default:
+               oldcmd = 0;
+               break;
+       }
+       if (oldcmd)
+               rc = l_ioctl(dev_id, oldcmd, buf);
+
+       return rc;
+}
+
+/**
+ * Remap regular file ioctl cmd to old one in case running with older modules.
+ * Replaces callers that use "ioctl(fd, ...)".
+ *
+ * \param fd           open file descriptor
+ * \param cmd          ioctl command
+ * \param buf          ioctl data argument
+ */
+int llapi_ioctl(int fd, unsigned int cmd, void *buf)
+{
+       unsigned int oldcmd;
+       int rc;
+
+       if (fd < 0)
+               return -EBADF;
+
+       /* common case, ioctl works as expected */
+       rc = ioctl(fd, cmd, buf);
+       if (rc >= 0 || errno != ENOTTY)
+               return rc;
+
+       switch (cmd) {
+       /*
+        * Use #ifdef instead of version check to minimize the places that a
+        * version change might cause a compiler error in the future.
+        *
+        * Version in comment is to allow finding this code for later removal.
+        */
+#ifdef OBD_IOC_GETNAME_OLD     /* < OBD_OCD_VERSION(2, 18, 53, 0) */
+       case OBD_IOC_GETMDNAME:
+               oldcmd = OBD_IOC_GETNAME_OLD;
+               break;
+#endif
+       default:
+               oldcmd = 0;
+               break;
+       }
+       if (oldcmd)
+               rc = ioctl(fd, oldcmd, buf);
+
+       return rc;
+}
+
+int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len)
+{
+       struct obd_ioctl_data *overlay;
+       char *ptr;
+
+       if (pbuf == NULL)
+               return -EINVAL;
+
+       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) {
+               memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
+       }
+
+       if (data->ioc_inlbuf2) {
+               memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
+       }
+
+       if (data->ioc_inlbuf3) {
+               memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
+       }
+
+       if (data->ioc_inlbuf4) {
+               memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
+       }
+
+       return 0;
+}
index a66cee4..38ce395 100644 (file)
@@ -68,6 +68,7 @@
 int get_root_path(int want, char *fsname, int *outfd, char *path, int index,
                  dev_t *dev, char *nid);
 int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len);
+int llapi_ioctl_dev(int dev_id, unsigned int cmd, void *buf);
 int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len);
 int sattr_cache_get_defaults(const char *const fsname,
                             const char *const pathname, unsigned int *scount,
index 20794fa..118c02c 100644 (file)
@@ -2176,7 +2176,7 @@ static int do_activate(int argc, char **argv, int flag)
                        jt_cmdname(argv[0]));
                return rc;
        }
-       rc = l_ioctl(OBD_DEV_ID, IOC_OSC_SET_ACTIVE, buf);
+       rc = llapi_ioctl_dev(OBD_DEV_ID, OBD_IOC_SET_ACTIVE, buf);
        if (rc)
                fprintf(stderr, "error: %s: failed: %s\n",
                        jt_cmdname(argv[0]), strerror(rc = errno));
@@ -5373,7 +5373,7 @@ int jt_barrier_freeze(int argc, char **argv)
                return rc;
        }
 
-       rc = l_ioctl(OBD_DEV_ID, OBD_IOC_BARRIER, buf);
+       rc = llapi_ioctl_dev(OBD_DEV_ID, OBD_IOC_BARRIER_V2, buf);
        if (rc < 0)
                fprintf(stderr, "Fail to freeze barrier for %s: %s\n",
                        argv[1], strerror(errno));
@@ -5417,7 +5417,7 @@ int jt_barrier_thaw(int argc, char **argv)
                return rc;
        }
 
-       rc = l_ioctl(OBD_DEV_ID, OBD_IOC_BARRIER, buf);
+       rc = llapi_ioctl_dev(OBD_DEV_ID, OBD_IOC_BARRIER_V2, buf);
        if (rc < 0)
                fprintf(stderr, "Fail to thaw barrier for %s: %s\n",
                        argv[1], strerror(errno));
@@ -5449,7 +5449,7 @@ int __jt_barrier_stat(const char *fsname, struct barrier_ctl *bc)
                return rc;
        }
 
-       rc = l_ioctl(OBD_DEV_ID, OBD_IOC_BARRIER, buf);
+       rc = llapi_ioctl_dev(OBD_DEV_ID, OBD_IOC_BARRIER_V2, buf);
        if (rc < 0)
                fprintf(stderr, "Fail to query barrier for %s: %s\n",
                        fsname, strerror(errno));
@@ -5570,7 +5570,7 @@ int jt_barrier_rescan(int argc, char **argv)
                return rc;
        }
 
-       rc = l_ioctl(OBD_DEV_ID, OBD_IOC_BARRIER, buf);
+       rc = llapi_ioctl_dev(OBD_DEV_ID, OBD_IOC_BARRIER_V2, buf);
        if (rc < 0) {
                fprintf(stderr, "Fail to rescan barrier bitmap for %s: %s\n",
                        argv[1], strerror(errno));
index 3fba44c..aac8b78 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/lnet/socklnd.h>
 #include <lnetconfig/liblnetconfig.h>
 #include <lustre/lustreapi.h>
+#include <lustre_ioctl_old.h>
 
 unsigned int libcfs_debug;
 unsigned int libcfs_printk = D_CANTMASK;
@@ -353,7 +354,6 @@ int jt_ptl_network(int argc, char **argv)
 int
 jt_ptl_list_nids(int argc, char **argv)
 {
-       struct libcfs_ioctl_data data;
        int all = 0, return_nid = 0;
        yaml_emitter_t request;
        yaml_parser_t reply;
@@ -361,7 +361,6 @@ jt_ptl_list_nids(int argc, char **argv)
        struct nl_sock *sk;
        bool done = false;
        int rc = 0;
-       int count;
 
        all = (argc == 2) && (strcmp(argv[1], "all") == 0);
        /* Hack to pass back value */
@@ -534,13 +533,18 @@ emitter_error:
        if (rc == 0)
                yaml_parser_log_error(&reply, stderr, NULL);
        yaml_parser_delete(&reply);
-old_api:
+old_api: {
+#ifdef IOC_LIBCFS_GET_NI
+       int count;
+
        if (sk)
                nl_socket_free(sk);
        if (rc == 1)
                return 0;
 
        for (count = 0;; count++) {
+               struct libcfs_ioctl_data data;
+
                LIBCFS_IOC_INIT(data);
                data.ioc_count = count;
                rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
@@ -563,7 +567,11 @@ old_api:
                }
        }
 
-       return 0;
+#else
+       rc = -1;
+#endif
+       }
+       return rc;
 }
 
 int
@@ -1084,16 +1092,11 @@ int jt_ptl_ping(int argc, char **argv)
        int rc;
        int timeout;
        struct lnet_process_id id;
-       struct lnet_process_id ids[LNET_INTERFACES_MAX_DEFAULT];
-       lnet_nid_t src = LNET_NID_ANY;
-       int maxids = sizeof(ids) / sizeof(ids[0]);
-       struct lnet_ioctl_ping_data ping = { { 0 } };
        yaml_emitter_t request;
        yaml_parser_t reply;
        yaml_event_t event;
        struct nl_sock *sk;
        char *sep;
-       int i;
 
        if (argc < 2) {
                fprintf(stderr, "usage: %s id [timeout (secs)]\n", argv[0]);
@@ -1330,13 +1333,20 @@ free_reply:
        nl_socket_free(sk);
        return rc;
 old_api:
+#ifdef IOC_LIBCFS_PING_PEER
+       {
+       struct lnet_process_id ids[LNET_INTERFACES_MAX_DEFAULT];
+       int maxids = sizeof(ids) / sizeof(ids[0]);
+       struct lnet_ioctl_ping_data ping = { { 0 } };
+       int i;
+
        if (sk)
                nl_socket_free(sk);
 
        LIBCFS_IOC_INIT_V2(ping, ping_hdr);
        ping.ping_hdr.ioc_len = sizeof(ping);
        ping.ping_id = id;
-       ping.ping_src = src;
+       ping.ping_src = LNET_NID_ANY;
        ping.op_param = timeout;
        ping.ping_count = maxids;
        ping.ping_buf = ids;
@@ -1353,8 +1363,11 @@ old_api:
 
        if (ping.ping_count > maxids)
                printf("%d out of %d ids listed\n", maxids, ping.ping_count);
-
-       return 0;
+       }
+#else
+       rc = -ENOTTY;
+#endif
+       return rc;
 }
 
 int jt_ptl_mynid(int argc, char **argv)