Add the default device "MGS" for lctl llog_catlist, llog_print,
llog_check, llog_remove, llog_cancel and llog_info.
Example:
The two lines below are equivalent.
$ lctl --device MGS llog_catlist
$ lctl llog_catlist
Tests 123xx of conf_sanity have been modified to mix between the old
and new syntax.
lctl-llog_* man page have been modified to match the new syntax.
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: If988dfc5d8171b2ca47bb68dd06f9d2953548cb2
Reviewed-on: https://review.whamcloud.com/38940
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
.SH NAME
lctl llog_cancel \- cancel a record in a Lustre llog file
.SH SYNOPSIS
.SH NAME
lctl llog_cancel \- cancel a record in a Lustre llog file
.SH SYNOPSIS
-.B lctl --device
-.RI < device >
.B llog_cancel --log_idx
.RI < index >
.RI < logname >
.B llog_cancel --log_idx
.RI < index >
.RI < logname >
.TP
To cancel record 15 from the \fBtestfs-client\fR conf_param log:
.br
.TP
To cancel record 15 from the \fBtestfs-client\fR conf_param log:
.br
-# lctl --device MGS llog_cancel --log_idx=15 testfs-client
+# lctl llog_cancel --log_idx=15 testfs-client
.TP
To cancel record 22 from the \fBparams\fR set_param log:
.br
.TP
To cancel record 22 from the \fBparams\fR set_param log:
.br
-# lctl --device MGS llog_cancel --log_idx=22 params
+# lctl llog_cancel --log_idx=22 params
.SH AVAILABILITY
.B lctl llog_cancel
is a subcommand of
.SH AVAILABILITY
.B lctl llog_cancel
is a subcommand of
.SH NAME
lctl llog_catlist \- list Lustre configuration log files
.SH SYNOPSIS
.SH NAME
lctl llog_catlist \- list Lustre configuration log files
.SH SYNOPSIS
+.B lctl
+[--device <\fIdevice\fR>]
+.B llog_catlist
.SH DESCRIPTION
.B lctl llog_catlist
is used to list the configuration log files on the MGS, or other target.
.SH DESCRIPTION
.B lctl llog_catlist
is used to list the configuration log files on the MGS, or other target.
log file contains the
.B lctl set_param -P
parameters for all filesystems serviced by this MGS.
log file contains the
.B lctl set_param -P
parameters for all filesystems serviced by this MGS.
+.SH OPTIONS
+.TP
+.B --device \fIdevice\fR
+The
+.I device
+to be used. By default MGS device is used for this operation.
.SH EXAMPLES
.TP
To list all of the configuration logs on the MGS:
.br
.SH EXAMPLES
.TP
To list all of the configuration logs on the MGS:
.br
-# lctl --device MGS llog_catlist
.br
config_log: testfs-OST0000
.br
.br
config_log: testfs-OST0000
.br
is used to print information about the configuration log given by
.IR logname .
.SH OPTIONS
is used to print information about the configuration log given by
.IR logname .
.SH OPTIONS
The name of the configuration log, in the form
.IR fsname - target ,
The name of the configuration log, in the form
.IR fsname - target ,
-like
-.B testfs-client
-or
-.BR lustrefs-MDT0000 .
+like \fBtestfs-client\fR or \fBlustrefs-MDT0000\fR. See
+.BR lctl-llog_catlist (8)
+for a list of configuration logs.
.SH EXAMPLES
.TP
To print all of the records from the testfs-client configuration log:
.br
.SH EXAMPLES
.TP
To print all of the records from the testfs-client configuration log:
.br
-# lctl --device MGS llog_info testfs-client
+# lctl llog_info testfs-client
.br
logid: [0x4:0xa:0x0]:0
.br
.br
logid: [0x4:0xa:0x0]:0
.br
.TP
To print the configuration records from the \fBtestfs-client\fR logfile:
.br
.TP
To print the configuration records from the \fBtestfs-client\fR logfile:
.br
-# lctl --device MGS llog_print testfs-client
+# lctl llog_print testfs-client
.br
- { index: 3, event: attach, device: testfs-clilov, type: lov,
.br
.br
- { index: 3, event: attach, device: testfs-clilov, type: lov,
.br
:
.TP
To print the first 10 \fBset_param -P\fR records from \fBparams\fR:
:
.TP
To print the first 10 \fBset_param -P\fR records from \fBparams\fR:
-# lctl --device MGS llog_print --end=10 params
+# lctl llog_print --end=10 params
.br
- { index: 2, event: set_param, device: general, parameter: osc.*.max_dirty_mb, value: 32 }
.br
.br
- { index: 2, event: set_param, device: general, parameter: osc.*.max_dirty_mb, value: 32 }
.br
local yaml
local orig_val
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"
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")
grep jobid_name | tail -n 1)
local param=$(awk '{ print $10 }' <<< "$yaml")
local start=10
local end=50
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 }
[ -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"
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)
[ -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
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
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 }
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 , )
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"
tail -1 | awk '{ print $4 }' | tr -d , )
(( new == orig )) ||
error "new llog_cancel now $new, not at $orig records"
"usage: recover [MDC/OSC device]"},
/* Llog operations */
{"llog_catlist", jt_llog_catlist, 0,
"usage: recover [MDC/OSC device]"},
/* Llog operations */
{"llog_catlist", jt_llog_catlist, 0,
- "list all catalog files on current device.\n"
+ "list all catalog files on current device. If current device is not\n"
+ "set, MGS device is used by default.\n"
"usage: llog_catlist"},
{"llog_info", jt_llog_info, 0,
"print log header information.\n"
"usage: llog_catlist"},
{"llog_info", jt_llog_info, 0,
"print log header information.\n"
+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;
int jt_llog_catlist(int argc, char **argv)
{
struct obd_ioctl_data data;
if (argc != 1)
return CMD_HELP;
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;
do {
memset(&data, 0, sizeof(data));
data.ioc_dev = cur_device;
if (rc) {
fprintf(stderr, "error: %s: invalid ioctl\n",
jt_cmdname(argv[0]));
if (rc) {
fprintf(stderr, "error: %s: invalid ioctl\n",
jt_cmdname(argv[0]));
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_CATLOGLIST, buf);
if (rc < 0)
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_CATLOGLIST, buf);
if (rc < 0)
fprintf(stderr, "OBD_IOC_CATLOGLIST failed: %s\n",
strerror(errno));
fprintf(stderr, "OBD_IOC_CATLOGLIST failed: %s\n",
strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
+ /* 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;
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));
if (rc) {
fprintf(stderr, "%s: ioctl_pack failed for catalog '%s': %s\n",
jt_cmdname(cmd), catalog, strerror(-rc));
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_INFO, buf);
}
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));
fprintf(stderr, "%s: OBD_IOC_LLOG_INFO failed: %s\n",
jt_cmdname(cmd), strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
+ 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);
rc = jt_llog_print_iter(catalog, start, end, jt_llog_print_cb,
NULL, false);
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+
char *cmd = argv[0];
int 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);
/* 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];
}
data.ioc_inlbuf3 = argv[1];
}
- if (!data.ioc_inlbuf1 || !data.ioc_inlbuf3)
+ if (!data.ioc_inlbuf1 || !data.ioc_inlbuf3) {
/* missing mandatory parameters */
/* missing mandatory parameters */
+ 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));
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));
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CANCEL, buf);
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CANCEL, buf);
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf3,
strerror(errno));
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf3,
strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
+ if (llog_default_device(LLOG_DFLT_MGS_SET))
+ return CMD_INCOMPLETE;
+
if (end == -1)
end = 0x7fffffff;
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));
if (rc) {
fprintf(stderr, "%s: ioctl_pack failed for catalog '%s': %s\n",
jt_cmdname(cmd), data.ioc_inlbuf1, strerror(-rc));
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CHECK, buf);
}
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));
else
fprintf(stderr, "%s: OBD_IOC_LLOG_CHECK failed: %s\n",
jt_cmdname(cmd), strerror(errno));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);
char *cmd = argv[0];
int 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)
rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hl:", 2, &data);
if (rc)
if (argc == 1) {
if (data.ioc_inlbuf2) {
fprintf(stderr,
"%s: --log_id is set, unknown argument '%s'\n",
jt_cmdname(cmd), argv[0]);
if (argc == 1) {
if (data.ioc_inlbuf2) {
fprintf(stderr,
"%s: --log_id is set, unknown argument '%s'\n",
jt_cmdname(cmd), argv[0]);
+ rc = CMD_HELP;
+ goto err;
}
data.ioc_inllen2 = strlen(argv[0]) + 1;
data.ioc_inlbuf2 = argv[0];
}
}
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));
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));
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_REMOVE, buf);
}
rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_REMOVE, buf);
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf2,
strerror(-rc));
jt_cmdname(cmd), data.ioc_inlbuf1, data.ioc_inlbuf2,
strerror(-rc));
+err:
+ llog_default_device(LLOG_DFLT_DEV_RESET);