From: Eric Sandeen <sandeen@sandeen.net>
To: Brian Foster <bfoster@redhat.com>, Dave Chinner <david@fromorbit.com>
Cc: Ari Sundholm <ari@tuxera.com>,
fstests@vger.kernel.org, Emil Karlson <jkarlson@tuxera.com>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs_io: fix exitcode handling (was Re: generic/399 and xfs_io pwrite command)
Date: Sun, 24 Dec 2017 11:51:49 -0800 [thread overview]
Message-ID: <9b5928ec-cb2d-52b3-fb4f-cab39c7e0830@sandeen.net> (raw)
In-Reply-To: <20171207140519.GB3486@bfoster.bfoster>
On 12/7/17 6:05 AM, Brian Foster wrote:
> On Wed, Dec 06, 2017 at 11:26:38AM +1100, Dave Chinner wrote:
...
>> diff --git a/io/copy_file_range.c b/io/copy_file_range.c
>> index d1dfc5a5e33a..9b737eff4c02 100644
>> --- a/io/copy_file_range.c
>> +++ b/io/copy_file_range.c
>> @@ -92,6 +92,7 @@ copy_range_f(int argc, char **argv)
>> int ret;
>> int fd;
>>
>> + exitcode = 1;
>> while ((opt = getopt(argc, argv, "s:d:l:")) != -1) {
>> switch (opt) {
>> case 's':
>> @@ -132,6 +133,8 @@ copy_range_f(int argc, char **argv)
>>
>> ret = copy_file_range(fd, &src, &dst, len);
>> close(fd);
>> + if (ret >= 0)
>> + exitcode = 0;
> I don't think it's appropriate to blindly overwrite the global exitcode
> value like this. What about the case where multiple commands are chained
> together? Should we expect an error code if any of the commands failed
> or only the last?
>
> For example:
>
> xfs_io -c "pwrite ..." <file>
>
> ... returns an error if the write fails, while:
>
> xfs_io -c "pwrite ..." -c "fadvise ..." <file>
>
> ... would never so long as the fadvise succeeds.
>
> Brian
<late to the party>
Seems we need to start by defining the expected behavior, which so far
has been pretty ad-hoc.
AFAICT this is the expected/desired behavior:
exitcode is the global xfs_io exit code and indicates that any error
has occurred during processing. It should never get reset to 0.
Using something like do_error to print the failure & set the exitcode
would seem to make sense.
Chained commands continue until some ->cfunc (foo_f()) returns nonzero,
but a nonzero return does /not/ affect exitcode, it simply stops chained
command processing.
It's not clear to me when a cfunc-> /should/ return non-zero and stop
the processing.
-Eric
next prev parent reply other threads:[~2017-12-24 19:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 14:21 generic/399 and xfs_io pwrite command Ari Sundholm
2017-12-04 19:56 ` Goldwyn Rodrigues
2017-12-04 22:28 ` Dave Chinner
2017-12-05 14:23 ` Ari Sundholm
2017-12-05 21:18 ` Dave Chinner
2017-12-06 0:26 ` [PATCH] xfs_io: fix exitcode handling (was Re: generic/399 and xfs_io pwrite command) Dave Chinner
2017-12-07 14:05 ` Brian Foster
2017-12-07 23:46 ` Dave Chinner
2017-12-08 14:15 ` Brian Foster
2017-12-08 22:52 ` Dave Chinner
2017-12-24 19:51 ` Eric Sandeen [this message]
2017-12-14 12:11 ` Ari Sundholm
2017-12-15 14:26 ` Ari Sundholm
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=9b5928ec-cb2d-52b3-fb4f-cab39c7e0830@sandeen.net \
--to=sandeen@sandeen.net \
--cc=ari@tuxera.com \
--cc=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=jkarlson@tuxera.com \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox