All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: NeilBrown <neilb@suse.de>,
	tasleson@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] exportfs: Return non-zero exit value on error
Date: Thu, 24 Oct 2013 11:56:38 -0400	[thread overview]
Message-ID: <52694336.9050303@RedHat.com> (raw)
In-Reply-To: <D9521932-DDAA-47D2-996F-62D2A37BA5B0@oracle.com>



On 23/10/13 19:31, Chuck Lever wrote:
> 
> On Oct 23, 2013, at 6:18 PM, NeilBrown <neilb@suse.de> wrote:
> 
>> On Wed, 23 Oct 2013 12:36:23 -0500 Tony Asleson <tasleson@redhat.com> wrote:
>>
>>> On 10/22/2013 08:44 PM, NeilBrown wrote:
>>>> On Tue, 22 Oct 2013 10:23:14 -0500 Tony Asleson <tasleson@redhat.com> wrote:
>>>>> The reason I chose to return values was to make sure requested operation
>>>>> actually completed requested operation.  Unexporting a non-existent
>>>>> export is not considered an error and returns no indication you did
>>>>> absolutely nothing.
>>>>
>>>> Hi,
>>>> thanks makes sense - I had missed that (even though you explained it in the
>>>> patch description :-( )
>>>>
>>>> With your patch, if asked to unexport something that wasn't exported it
>>>> would not report any error, but would exit with an error status.  Is that
>>>> correct?  I think I would rather have a message printed if there is an error.
>>>
>>> Correct, I only made changes for the exit status.  I was trying to make
>>> changes that would be mostly invisible to end users.  I have no concerns
>>> adding a printed error output too, but others may.
>>>
>>> Changing the behavior of any command line tool is potentially
>>> problematic when scripted.
>>>
>>>> So would something like this (on top of my patch) address you need, or was
>>>> there something else I missed?
>>>
>>> Yes, this should work for the unexport fs case.
>>>
>>> However, the reason my patch was a little more invasive was to ensure
>>> that both the export and unexport paths were covered.
>>>
>>> For example, if the strdup call fails in function client_init, we fail
>>> the operation and return exit value of 0.  Unlikely, but just the first
>>> example I stumbled across.
>>
>> I think it is a lot closer to "impossible" than just "unlikely".
>> malloc doesn't fail in this sort of context, the OOM killer kills something
>> off instead.
>> My personal preference is to replace all malloc/calloc/strdup calls with
>> the xmalloc, xstrdup etc calls in support/nfs/xcommon.c.
>> If you are worried about malloc failing, I'd much prefer to see a patch which
>> changes nfs-utils to use those uniformly.
>>
>> There might be a question over the best behaviour for daemons like mountd
>> and  gssd.  However as we move towards having systemd manage those, they will
>> be restarted if they ever exit, and they are mostly stateless so that is
>> quite safe.
>>
>> Does anyone else have thoughts on this?
> 
> Yes.  My thought is "xmalloc is an abomination."  :-)
> 
> We really do not want any of these tools exiting left if there's a memory allocation failure.  
> For a user, that's no better than a segfault.
I the past I have agreed with this... But as Neil points out, we now live in
a systemd world were daemons are restarted, so maybe it does make sense to 
exit on these types of failures. With daemons like mountd there is 
really no state that would be lost.... 

steved.
> 
> What's more, if a utility like exportfs isn't very carefully coded, a sideways exit 
> can leave on-disk files in an inconsistent state.
> 
> A rule of thumb is never hide control flow (like exiting) inside macros or libraries.
> 
> --
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
> 
> 
> 

  reply	other threads:[~2013-10-24 15:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 23:29 [PATCH] exportfs: Return non-zero exit value on error Tony Asleson
2013-10-21 22:25 ` NeilBrown
2013-10-22  8:38   ` Steve Dickson
2013-10-22 15:23   ` Tony Asleson
2013-10-23  1:44     ` NeilBrown
2013-10-23 17:36       ` Tony Asleson
2013-10-23 22:18         ` NeilBrown
2013-10-23 23:31           ` Chuck Lever
2013-10-24 15:56             ` Steve Dickson [this message]
2013-10-24 16:05               ` Chuck Lever
2013-10-28  3:39                 ` NeilBrown
2013-10-28 14:09                   ` Chuck Lever
2013-10-24  5:34           ` Tony Asleson
2013-10-22  8:30 ` Steve Dickson
2013-10-22  8:36   ` Steve Dickson
2013-10-28 22:35     ` NeilBrown
2013-11-04 15:33       ` Steve Dickson

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=52694336.9050303@RedHat.com \
    --to=steved@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tasleson@redhat.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.