local yaml
local orig_val
+ local mgs_arg=""
+
+ [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+ mgs_arg="--device MGS"
orig_val=$(do_facet mgs $LCTL get_param jobid_name)
do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
- yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
+ yaml=$(do_facet mgs $LCTL $mgs_arg llog_print params |
grep jobid_name | tail -n 1)
local param=$(awk '{ print $10 }' <<< "$yaml")
local start=10
local end=50
+ local mgs_arg=""
+
+ [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+ mgs_arg="--device MGS"
[ -d $MOUNT/.lustre ] || setup
# - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
# node: 192.168.20.1@tcp }
- do_facet mgs $LCTL --device MGS \
+ do_facet mgs $LCTL $mgs_arg \
llog_print --start $start --end $end $FSNAME-client | tr -d , |
while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
(( idx >= start )) || error "llog_print index $idx < $start"
[ -d $MOUNT/.lustre ] || setupall
local max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
+ local mgs_arg=""
+
+ [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+ mgs_arg="--device MGS"
if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
# save one set_param -P record in case none exist
do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
local log=params
- local orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
+ local orig=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
tail -1 | awk '{ print $4 }' | tr -d , )
do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
- do_facet mgs $LCTL --device MGS llog_print $log | tail -1 |
+ do_facet mgs $LCTL $mgs_arg llog_print $log | tail -1 |
grep "parameter: osc.*.max_dirty_mb" ||
error "new set_param -P wasn't stored in params log"
# - { index: 71, event: set_param, device: general,
# param: osc.*.max_dirty_mb, value: 256 }
- local id=$(do_facet mgs $LCTL --device MGS llog_print $log |
+ local id=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
tail -1 | awk '{ print $4 }' | tr -d , )
- do_facet mgs $LCTL --device MGS llog_cancel $log --log_idx=$id
- local new=$(do_facet mgs $LCTL --device MGS llog_print $log |
+ do_facet mgs $LCTL $mgs_arg llog_cancel $log --log_idx=$id
+ local new=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
tail -1 | awk '{ print $4 }' | tr -d , )
(( new == orig )) ||
error "new llog_cancel now $new, not at $orig records"
return rc;
}
+enum llog_default_dev_op {
+ LLOG_DFLT_MGS_SET = 0,
+ LLOG_DFLT_DEV_RESET
+};
+
+static int llog_default_device(enum llog_default_dev_op op)
+{
+ int rc = 0;
+ static int dflt_dev = -1;
+
+ if (op == LLOG_DFLT_MGS_SET && (cur_device == -1)) {
+ char mgs[] = "$MGS";
+
+ rc = do_device("llog_default_device", mgs);
+ dflt_dev = cur_device;
+
+ } else if (op == LLOG_DFLT_DEV_RESET && (dflt_dev != -1)) {
+ do_disconnect(NULL, 1);
+ dflt_dev = -1;
+ }
+
+ return rc;
+}
+
int jt_llog_catlist(int argc, char **argv)
{
struct obd_ioctl_data data;
if (argc != 1)
return CMD_HELP;
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
do {
memset(&data, 0, sizeof(data));
data.ioc_dev = cur_device;
if (rc) {
fprintf(stderr, "error: %s: invalid ioctl\n",
jt_cmdname(argv[0]));
- return rc;
+ goto err;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_CATLOGLIST, buf);
if (rc < 0)
fprintf(stderr, "OBD_IOC_CATLOGLIST failed: %s\n",
strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
return rc;
}
return CMD_HELP;
}
+ /* Manage default device */
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
data.ioc_dev = cur_device;
data.ioc_inllen1 = strlen(catalog) + 1;
data.ioc_inlbuf1 = catalog;
if (rc) {
fprintf(stderr, "%s: ioctl_pack failed for catalog '%s': %s\n",
jt_cmdname(cmd), catalog, strerror(-rc));
- return rc;
+ goto err;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_INFO, buf);
fprintf(stderr, "%s: OBD_IOC_LLOG_INFO failed: %s\n",
jt_cmdname(cmd), strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
return rc;
}
if (rc)
return rc;
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
rc = jt_llog_print_iter(catalog, start, end, jt_llog_print_cb,
NULL, false);
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
return rc;
}
char *cmd = argv[0];
int rc;
+ /* Manage default device */
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
/* Parse catalog file (in inlbuf1) and named parameters */
rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hi:l:", 3, &data);
data.ioc_inlbuf3 = argv[1];
}
- if (!data.ioc_inlbuf1 || !data.ioc_inlbuf3)
+ if (!data.ioc_inlbuf1 || !data.ioc_inlbuf3) {
/* missing mandatory parameters */
- return CMD_HELP;
+ rc = CMD_HELP;
+ goto err;
+ }
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
fprintf(stderr, "%s: ioctl_pack for catalog '%s' failed: %s\n",
jt_cmdname(cmd), data.ioc_inlbuf1, strerror(-rc));
- return rc;
+ goto err;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CANCEL, buf);
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf3,
strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
return rc;
}
if (rc)
return rc;
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
if (end == -1)
end = 0x7fffffff;
if (rc) {
fprintf(stderr, "%s: ioctl_pack failed for catalog '%s': %s\n",
jt_cmdname(cmd), data.ioc_inlbuf1, strerror(-rc));
- return rc;
+ goto err;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CHECK, buf);
else
fprintf(stderr, "%s: OBD_IOC_LLOG_CHECK failed: %s\n",
jt_cmdname(cmd), strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
return rc;
}
char *cmd = argv[0];
int rc;
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hl:", 2, &data);
if (rc)
- return rc;
+ goto err;
if (argc == 1) {
if (data.ioc_inlbuf2) {
fprintf(stderr,
"%s: --log_id is set, unknown argument '%s'\n",
jt_cmdname(cmd), argv[0]);
- return CMD_HELP;
+ rc = CMD_HELP;
+ goto err;
}
data.ioc_inllen2 = strlen(argv[0]) + 1;
data.ioc_inlbuf2 = argv[0];
}
+
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
fprintf(stderr, "%s: ioctl_pack for catalog '%s' failed: %s\n",
jt_cmdname(cmd), data.ioc_inlbuf1, strerror(-rc));
- return rc;
+ goto err;
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_REMOVE, buf);
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf2,
strerror(-rc));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
return rc;
}