linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 10/24] uas: zap_pending: data urbs should have completed at this time
Date: Sun, 14 Sep 2014 12:32:58 +0200	[thread overview]
Message-ID: <54156EDA.6050106@redhat.com> (raw)
In-Reply-To: <1410690587.2270.2.camel@jarvis>

Hi,

On 09/14/2014 12:29 PM, James Bottomley wrote:
> On Sun, 2014-09-14 at 11:26 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 09/13/2014 09:31 PM, Sergei Shtylyov wrote:
>>> Hello.
>>>
>>> On 9/13/2014 1:26 PM, Hans de Goede wrote:
>>>
>>>> The data urbs are all killed before calling zap_pending, and their completion
>>>> handler should have cleared their inflight flag.
>>>
>>>> Do not 0 the data inflight flags, and add a check for try_complete succeeding,
>>>> as it should always succeed when called from zap_pending.
>>>
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>> ---
>>>>   drivers/usb/storage/uas.c | 10 +++++-----
>>>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
>>>> index 08edb6b..85bbc1d 100644
>>>> --- a/drivers/usb/storage/uas.c
>>>> +++ b/drivers/usb/storage/uas.c
>>>> @@ -145,6 +145,7 @@ static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
>>>>       struct uas_cmd_info *cmdinfo;
>>>>       struct uas_cmd_info *temp;
>>>>       unsigned long flags;
>>>> +    int err;
>>>
>>>    Er, I don't see why this variable is necessary.
>>>
>>> [...]
>>>> @@ -152,12 +153,11 @@ static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
>>>>           struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd,
>>>>                                 SCp);
>>>>           uas_log_cmd_state(cmnd, __func__);
>>>> -        /* all urbs are killed, clear inflight bits */
>>>> -        cmdinfo->state &= ~(COMMAND_INFLIGHT |
>>>> -                    DATA_IN_URB_INFLIGHT |
>>>> -                    DATA_OUT_URB_INFLIGHT);
>>>> +        /* Sense urbs were killed, clear COMMAND_INFLIGHT manually */
>>>> +        cmdinfo->state &= ~COMMAND_INFLIGHT;
>>>>           cmnd->result = result << 16;
>>>> -        uas_try_complete(cmnd, __func__);
>>>> +        err = uas_try_complete(cmnd, __func__);
>>>> +        WARN_ON(err != 0);
>>>
>>>    Why not:
>>>
>>>         WARN_ON(uas_try_complete(cmnd, __func__));
>>>
>>
>> This was discussed already during v1 of this patch-set, WARN_ON may
>> not have a side-effect, as it may be defined as an empty macro.
> 
> Must have missed the discussion, but whoever said that loses all their
> review points.  We're very careful to make sure that even in the case
> where WARN_ON and BUG_ON (and indeed any macros) are compiled out, the
> side effects are still accounted for.  This is the canonical definition
> of WARN_ON in the compiled out case:
> 
> #define WARN_ON(condition) ({						\
> 	int __ret_warn_on = !!(condition);				\
> 	unlikely(__ret_warn_on);					\
> })
> 
> So the compiler will eliminate the statement only if there are no side
> effects.

Ah that is good to know. Still I would like to stick with the new version
(which adds the err), as I believe that that code is more readable.

AFAIK in general the kernel coding style is to favor:

err = func();
if (err)

over:

if (func())

And this is sorta the same.

Regards,

Hans

  reply	other threads:[~2014-09-14 10:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-13 10:26 [PATCH v2 00/24] uas: rewrite error handling for robustness + misc cleanups Hans de Goede
2014-09-13 10:26 ` [PATCH v2 01/24] uas: replace WARN_ON_ONCE() with lockdep_assert_held() Hans de Goede
     [not found] ` <1410604011-3828-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-09-13 10:26   ` [PATCH v2 02/24] uas: Remove task-management / abort error handling code Hans de Goede
2014-09-13 10:26   ` [PATCH v2 03/24] uas: Fix resetting flag handling Hans de Goede
2014-09-13 10:26   ` [PATCH v2 04/24] uas: Add uas_get_tag() helper function Hans de Goede
2014-09-13 10:26   ` [PATCH v2 05/24] uas: Do not use scsi_host_find_tag Hans de Goede
2014-09-13 10:26   ` [PATCH v2 07/24] uas: Simplify unlink of data urbs on error Hans de Goede
2014-09-13 10:26   ` [PATCH v2 08/24] uas: Free data urbs on completion Hans de Goede
2014-09-13 10:26   ` [PATCH v2 11/24] uas: Drop inflight list Hans de Goede
2014-09-13 10:26   ` [PATCH v2 15/24] uas: pre_reset and suspend: Fix a few races Hans de Goede
2014-09-13 10:26   ` [PATCH v2 16/24] uas: Use streams on upcoming 10Gbps / 3.1 USB Hans de Goede
2014-09-13 10:26   ` [PATCH v2 19/24] uas: Drop COMMAND_COMPLETED flag Hans de Goede
2014-09-13 10:26   ` [PATCH v2 21/24] uas: Remove protype hardware usb interface info Hans de Goede
2014-09-13 10:26   ` [PATCH v2 23/24] uas: Log error codes when logging errors Hans de Goede
2014-09-13 10:26 ` [PATCH v2 06/24] uas: Check against unexpected completions Hans de Goede
2014-09-13 10:26 ` [PATCH v2 09/24] uas: Simplify reset / disconnect handling Hans de Goede
2014-09-13 10:26 ` [PATCH v2 10/24] uas: zap_pending: data urbs should have completed at this time Hans de Goede
     [not found]   ` <1410604011-3828-11-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-09-13 19:31     ` Sergei Shtylyov
2014-09-14  9:26       ` Hans de Goede
2014-09-14 10:29         ` James Bottomley
2014-09-14 10:32           ` Hans de Goede [this message]
2014-09-14 10:34             ` James Bottomley
2014-10-02  8:56               ` Oliver Neukum
2014-09-13 10:26 ` [PATCH v2 12/24] uas: Remove cmnd reference from the cmd urb Hans de Goede
2014-09-13 10:26 ` [PATCH v2 13/24] uas: Drop all references to a scsi_cmnd once it has been aborted Hans de Goede
2014-09-13 10:26 ` [PATCH v2 14/24] uas: Fix memleak of non-submitted urbs Hans de Goede
2014-09-13 10:26 ` [PATCH v2 17/24] uas: Do not log urb status error on cancellation Hans de Goede
2014-09-13 10:26 ` [PATCH v2 18/24] uas: Use scsi_print_command Hans de Goede
2014-09-13 10:26 ` [PATCH v2 20/24] uas: Remove support for old sense ui as used in pre-production hardware Hans de Goede
2014-09-13 10:26 ` [PATCH v2 22/24] uas: Cleanup uas_log_cmd_state usage Hans de Goede
2014-09-13 10:26 ` [PATCH v2 24/24] uas: Add response iu handling Hans de Goede

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=54156EDA.6050106@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).