linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Max Gurtovoy <maxg@mellanox.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-block@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 1/1] block: add default clause for unsupported T10_PI types
Date: Sun, 22 Sep 2019 10:25:14 -0600	[thread overview]
Message-ID: <ddd909c8-1309-5830-0669-371d2ae839fc@kernel.dk> (raw)
In-Reply-To: <423a031c-a016-96c6-97ee-fb4e49a0f247@mellanox.com>

On 9/22/19 3:38 AM, Max Gurtovoy wrote:
> 
> On 9/22/2019 2:29 AM, Jens Axboe wrote:
>> On 9/21/19 4:54 PM, Martin K. Petersen wrote:
>>> Jens,
>>>
>>>>> block/t10-pi.c: In function 't10_pi_verify':
>>>>> block/t10-pi.c:62:3: warning: enumeration value 'T10_PI_TYPE0_PROTECTION'
>>>>>                          not handled in switch [-Wswitch]
>>>>>           switch (type) {
>>>>>           ^~~~~~
>>>> This commit message is woefully lacking. It doesn't explain
>>>> anything...?  Why aren't we just flagging this as an error? Seems a
>>>> lot saner than adding a BUG().
>>> The fundamental issue is that T10_PI_TYPE0_PROTECTION means "no attached
>>> protection information". So it's a block layer bug if we ever end up in
>>> this function and the protection type is 0.
>>>
>>> My main beef with all this is that I don't particularly like introducing
>>> a nonsensical switch case to quiesce a compiler warning. We never call
>>> t10_pi_verify() with a type of 0 and there are lots of safeguards
>>> further up the stack preventing that from ever happening. Adding a Type
>>> 0 here gives the reader the false impression that it's valid input to
>>> the function. Which it really isn't.
>>>
>>> Arnd: Any ideas how to handle this?
>> Why not just add the default catch, that logs, and returns the error?
>> Would seem like the cleanest way to handle it to me. Since the
>> compiler knows the type, it'll complain if we have missing cases.
> 
> what about removing the switch/case and do the following change:

It's effectively the same thing, I really don't think we need (or should
have) a BUG/BUG_ON for this condition. Just return an error?

Just include a T10_PI_TYPE0_PROTECTION case in the switch, have it log
and return an error. Add a comment on how it's impossible, if need be.
I don't think it has to be more complicated than that.

-- 
Jens Axboe


  reply	other threads:[~2019-09-22 16:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-21 22:00 [PATCH 1/1] block: add default clause for unsupported T10_PI types Max Gurtovoy
2019-09-21 22:12 ` Jens Axboe
2019-09-21 22:54   ` Martin K. Petersen
2019-09-21 23:29     ` Jens Axboe
2019-09-22  9:38       ` Max Gurtovoy
2019-09-22 16:25         ` Jens Axboe [this message]
2019-09-22 17:31           ` Martin K. Petersen
2019-09-22 21:21             ` Max Gurtovoy
2019-09-23 14:05               ` Jens Axboe

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=ddd909c8-1309-5830-0669-371d2ae839fc@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=arnd@arndb.de \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=maxg@mellanox.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).