Re: [PATCH] Fix setting bio flags in drivers (sd_dif/floppy).

From: Jens Axboe
Date: Thu Mar 01 2012 - 15:25:40 EST


On 2012-03-01 21:23, Muthu Kumar wrote:
>>> kunmap_atomic(sdt, KM_USER0);
>>> }
>>>
>>> - bio->bi_flags |= BIO_MAPPED_INTEGRITY;
>>> + bio->bi_flags |= (1 << BIO_MAPPED_INTEGRITY);
>>> }
>>>
>>> return 0;
>>
>> urgh. This isn't the first time.
>>
>> It's too easy for people to make this mistake. I'm not sure what a
>> good fix would be - I don't think sparse can save us with __bitwise or
>> similar.
>>
>> The approach we took in buffer_head.h with BH_Foo and BUFFER_FNS
>> accessors worked pretty well.
>>
>
> Does this look good? BTW, I used the non-atomic variants __set/__clear
> to match the behavior of current usage.
> If this looks good, I can send the proper patch as attachment (so no
> line wraps :)

Lets not wrap this in macros, it just makes the code harder to read.
Making the BIO_ flags a bit shift value was a mistake in hindsight, too
easy to get wrong.

If we're going to be changing everything anyway, it'd be better to have
__ variants if we really need the bit shifts, and the non __ variants be
the value. Similar to what is done for request flags.

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/