#define OBD_IOC_NO_TRANSNO _IOW('f', 140, OBD_IOC_DATA_TYPE)
#endif
+static bool is_mds(void)
+{
+ glob_t path;
+ int rc;
+
+ rc = cfs_get_param_paths(&path, "mdt/*-MDT0000");
+ if (!rc) {
+ cfs_free_param_data(&path);
+ return true;
+ }
+
+ return false;
+}
+
+static bool is_oss(void)
+{
+ glob_t path;
+ int rc;
+
+ rc = cfs_get_param_paths(&path, "obdfilter/*-OST0000");
+ if (!rc) {
+ cfs_free_param_data(&path);
+ return true;
+ }
+
+ return false;
+}
+
+static int get_mds_device(void)
+{
+ char mds[] = "$MDS";
+ int rc;
+
+ do_disconnect(NULL, 1);
+ rc = do_device("mdsioc", mds);
+ if (rc) {
+ errno = ENODEV;
+ return -errno;
+ }
+ return cur_device;
+}
+
+static int get_oss_device(void)
+{
+ char oss[] = "$OSS";
+ int rc;
+
+ do_disconnect(NULL, 1);
+ rc = do_device("ossioc", oss);
+ if (rc) {
+ errno = ENODEV;
+ return -errno;
+ }
+ return cur_device;
+}
+
int jt_obd_no_transno(int argc, char **argv)
{
struct obd_ioctl_data data;
*
* \retval 0 on success
*/
-static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data,
- unsigned int ret_size, ...)
+static int nodemap_cmd(enum lcfg_command_type cmd, bool dynamic,
+ void *ret_data, unsigned int ret_size, ...)
{
va_list ap;
char *arg;
lustre_cfg_init(lcfg, cmd, &bufs);
memset(&data, 0, sizeof(data));
- rc = data.ioc_dev = get_mgs_device();
+ if (dynamic) {
+ if (is_mds()) {
+ rc = data.ioc_dev = get_mds_device();
+ } else if (is_oss()) {
+ rc = data.ioc_dev = get_oss_device();
+ } else {
+ errno = EINVAL;
+ rc = -errno;
+ }
+ } else {
+ rc = data.ioc_dev = get_mgs_device();
+ }
if (rc < 0)
goto out;
{
int rc;
- rc = nodemap_cmd(LCFG_NODEMAP_ACTIVATE, NULL, 0, argv[0], argv[1],
- NULL);
+ rc = nodemap_cmd(LCFG_NODEMAP_ACTIVATE, false, NULL, 0,
+ argv[0], argv[1], NULL);
if (rc != 0) {
errno = -rc;
return 1;
}
- rc = nodemap_cmd(LCFG_NODEMAP_ADD, NULL, 0, argv[0], argv[1], NULL);
+ rc = nodemap_cmd(LCFG_NODEMAP_ADD, false, NULL, 0, argv[0],
+ argv[1], NULL);
if (rc != 0) {
errno = -rc;
argv[1]);
return rc;
}
- rc = nodemap_cmd(LCFG_NODEMAP_DEL, NULL, 0, argv[0], argv[1], NULL);
+ rc = nodemap_cmd(LCFG_NODEMAP_DEL, false, NULL, 0, argv[0],
+ argv[1], NULL);
if (rc != 0) {
errno = -rc;
char rawbuf[MAX_IOC_BUFLEN];
int rc;
- rc = nodemap_cmd(LCFG_NODEMAP_TEST_NID, &rawbuf, sizeof(rawbuf),
+ rc = nodemap_cmd(LCFG_NODEMAP_TEST_NID, false, &rawbuf, sizeof(rawbuf),
argv[0], argv[1], NULL);
if (rc == 0)
printf("%s\n", (char *)rawbuf);
return -1;
}
- rc = nodemap_cmd(LCFG_NODEMAP_TEST_ID, &rawbuf, sizeof(rawbuf),
+ rc = nodemap_cmd(LCFG_NODEMAP_TEST_ID, false, &rawbuf, sizeof(rawbuf),
argv[0], nidstr, typestr, idstr, NULL);
if (rc == 0)
printf("%s\n", (char *)rawbuf);
if (rc) {
return rc;
}
- rc = nodemap_cmd(LCFG_NODEMAP_ADD_RANGE, NULL, 0, argv[0],
+ rc = nodemap_cmd(LCFG_NODEMAP_ADD_RANGE, false, NULL, 0, argv[0],
nodemap_name, nid_range, NULL);
if (rc) {
fprintf(stderr,
errno = -rc;
return rc;
}
- rc = nodemap_cmd(LCFG_NODEMAP_DEL_RANGE, NULL, 0, argv[0],
+ rc = nodemap_cmd(LCFG_NODEMAP_DEL_RANGE, false, NULL, 0, argv[0],
nodemap_name, nid_range, NULL);
if (rc != 0) {
errno = -rc;
return -1;
}
- rc = nodemap_cmd(LCFG_NODEMAP_SET_FILESET, NULL, 0, argv[0],
+ rc = nodemap_cmd(LCFG_NODEMAP_SET_FILESET, false, NULL, 0, argv[0],
nodemap_name, fileset_name, NULL);
if (rc != 0) {
errno = -rc;
return -1;
}
- rc = nodemap_cmd(LCFG_NODEMAP_SET_SEPOL, NULL, 0, argv[0],
+ rc = nodemap_cmd(LCFG_NODEMAP_SET_SEPOL, false, NULL, 0, argv[0],
nodemap_name, sepol, NULL);
if (rc != 0) {
errno = -rc;
return -1;
}
- rc = nodemap_cmd(cmd, NULL, 0, argv[0], nodemap_name, param,
+ rc = nodemap_cmd(cmd, false, NULL, 0, argv[0], nodemap_name, param,
value, NULL);
if (rc != 0) {
errno = -rc;
return -1;
}
- rc = nodemap_cmd(cmd, NULL, 0, argv[0], nodemap_name, idmap, NULL);
+ rc = nodemap_cmd(cmd, false, NULL, 0,
+ argv[0], nodemap_name, idmap, NULL);
if (rc != 0) {
errno = -rc;
fprintf(stderr,
return -1;
}
- rc = nodemap_cmd(cmd, NULL, 0, argv[0], nodemap_name, idmap, NULL);
+ rc = nodemap_cmd(cmd, false, NULL, 0,
+ argv[0], nodemap_name, idmap, NULL);
if (rc != 0) {
errno = -rc;
fprintf(stderr,