From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: dm-devel@redhat.com
Subject: Re: [RFC PATCH 2/7] mpathpersist: add option --batch-file (-f)
Date: Wed, 22 May 2019 14:31:31 -0500 [thread overview]
Message-ID: <20190522193131.GC7630@octiron.msp.redhat.com> (raw)
In-Reply-To: <20190517225703.16295-3-mwilck@suse.com>
On Sat, May 18, 2019 at 12:56:58AM +0200, Martin Wilck wrote:
> Add the option --batch-file (-f) to mpathpersist. The option argument
> is a text file that is parsed line-by-line. Every line of the file is
> interpreted as an additional input line for mpathpersist. The initial
> "mpathpersist" on each line is optional. The '#' character denotes
> a comment. '#' is only recognized after whitespace. Empty lines,
> or comment lines, are allowed.
>
> If -f is given, other command line options are parsed as usual and
> commands (if any) are run before running the batch file. Inside the
> batch file, the option -f is forbidden, and -v is ignored. If a command
> fails, the batch processing is not aborted. The return status of
> mpathpersist is 0 if all commands succeeded, and the status of the
> first failed command otherwise.
One small issue. Otherwise, this looks good.
> ---
> mpathpersist/main.c | 195 +++++++++++++++++++++++++++++++++++---------
> mpathpersist/main.h | 1 +
> 2 files changed, 159 insertions(+), 37 deletions(-)
>
<snip>
> @@ -487,10 +567,51 @@ int main (int argc, char * argv[])
> }
>
> out :
> - if (ret == MPATH_PR_SYNTAX_ERROR)
> - usage();
> - mpath_lib_exit(conf);
> + if (ret == MPATH_PR_SYNTAX_ERROR) {
It's possible to set batch_fn, and then later fail with
MPATH_PR_SYNTAX_ERROR. In that case, you should still free batch_fn.
-Ben
> + if (nline == 0)
> + usage();
> + else
> + fprintf(stderr, "syntax error on line %d in batch file\n",
> + nline);
> + } else if (batch_fn != NULL) {
> + int rv = do_batch_file(batch_fn);
> +
> + free(batch_fn);
> + ret = ret == 0 ? rv : ret;
> + }
> + return (ret >= 0) ? ret : MPATH_PR_OTHER;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + int ret;
> +
> + if (optind == argc)
> + {
> +
> + fprintf (stderr, "No parameter used\n");
> + usage ();
> + exit (1);
> + }
> +
> + if (getuid () != 0)
> + {
> + fprintf (stderr, "need to be root\n");
> + exit (1);
> + }
> +
> + udev = udev_new();
> + multipath_conf = mpath_lib_init();
> + if(!multipath_conf) {
> + udev_unref(udev);
> + exit(1);
> + }
> +
> + ret = handle_args(argc, argv, 0);
> +
> + mpath_lib_exit(multipath_conf);
> udev_unref(udev);
> +
> return (ret >= 0) ? ret : MPATH_PR_OTHER;
> }
>
> diff --git a/mpathpersist/main.h b/mpathpersist/main.h
> index beb8a21b..c5f53f52 100644
> --- a/mpathpersist/main.h
> +++ b/mpathpersist/main.h
> @@ -23,6 +23,7 @@ static struct option long_options[] = {
> {"reserve", 0, NULL, 'R'},
> {"transport-id", 1, NULL, 'X'},
> {"alloc-length", 1, NULL, 'l'},
> + {"batch-file", 1, NULL, 'f' },
> {NULL, 0, NULL, 0}
> };
>
> --
> 2.21.0
next prev parent reply other threads:[~2019-05-22 19:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-17 22:56 [RFC PATCH 0/7] speeding up mpathpersist Martin Wilck
2019-05-17 22:56 ` [RFC PATCH 1/7] mpathpersist: call usage() just once on return Martin Wilck
2019-05-17 22:56 ` [RFC PATCH 2/7] mpathpersist: add option --batch-file (-f) Martin Wilck
2019-05-22 19:28 ` Benjamin Marzinski
2019-05-22 19:30 ` Benjamin Marzinski
2019-05-22 19:31 ` Benjamin Marzinski [this message]
2019-05-17 22:56 ` [RFC PATCH 3/7] mpathpersist: no need to treat error close() as fatal Martin Wilck
2019-05-17 22:57 ` [RFC PATCH 4/7] libmpathpersist: updatepaths: deal with missing pp->udev Martin Wilck
2019-05-17 22:57 ` [RFC PATCH 5/7] libmpathpersist: factor out initialization and teardown Martin Wilck
2019-05-17 22:57 ` [RFC PATCH 6/7] mpathpersist: initialize data structures only once Martin Wilck
2019-05-17 22:57 ` [RFC PATCH 7/7] libmpathpersist: don't bother with priorities Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522193131.GC7630@octiron.msp.redhat.com \
--to=bmarzins@redhat.com \
--cc=dm-devel@redhat.com \
--cc=mwilck@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.