static int echocli_setup(char *oname, char *ename, int *dev) { char *args[5]; char proc_path[50]; int rc; pthread_mutex_lock(&m_config); args[0] = cmdname; /* OSC */ /* attach "osc" oscname oscuuid */ args[1] = "osc"; args[2] = args[3] = oname; rc = jt_lcfg_attach(4, args); if (rc) { fprintf(stderr, "%s: can't attach osc '%s' (%d)\n", cmdname, oname, rc); /* Assume we want e.g. an old one cleaned anyhow. */ goto clean; } /* setup ostname "OSS_UUID" */ args[1] = target; args[2] = "OSS_UUID"; rc = jt_lcfg_setup(3, args); if (rc) { fprintf(stderr, "%s: can't setup osc '%s' (%d)\n", cmdname, oname, rc); goto clean; } /* Large grants cause ENOSPC to be reported, even though there's space left. We can reduce the grant size by minimizing these */ sprintf(proc_path, "/proc/fs/lustre/osc/%s/max_dirty_mb", oname); rc = write_proc(proc_path, "1"); sprintf(proc_path, "/proc/fs/lustre/osc/%s/max_rpcs_in_flight", oname); rc = write_proc(proc_path, "1"); /* ECHO CLI */ /* attach "echo_client" echoname echouuid */ args[1] = "echo_client"; args[2] = args[3] = ename; rc = jt_lcfg_attach(4, args); if (rc) { fprintf(stderr, "%s: can't attach '%s' (%d)\n", cmdname, ename, rc); if (rc == ENODEV) fprintf(stderr, "%s: is the obdecho module loaded?\n", cmdname); goto clean; } /* setup oscname */ args[1] = oname; rc = jt_lcfg_setup(2, args); if (rc) { fprintf(stderr, "%s: can't setup '%s' (%d)\n", cmdname, ename, rc); goto clean; } args[1] = ename; rc = jt_obd_device(2, args); if (rc) { fprintf(stderr, "%s: can't set device '%s' (%d)\n", cmdname, ename, rc); goto clean; } if (!rc) *dev = jt_obd_get_device(); pthread_mutex_unlock(&m_config); return rc; clean: pthread_mutex_unlock(&m_config); cleanup(ename, 1); cleanup(oname, 1); return rc; }
int jt_lcfg_device(int argc, char **argv) { return jt_obd_device(argc, argv); }