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

From: Martin K. Petersen
Date: Wed Feb 29 2012 - 19:22:36 EST


>>>>> "Andrew" == Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes:

>> + bio->bi_flags |= (1 << BIO_MAPPED_INTEGRITY);
>> }
>>
>> return 0;

Andrew> urgh. This isn't the first time.

Andrew> It's too easy for people to make this mistake. I'm not sure
Andrew> what a good fix would be - I don't think sparse can save us with
Andrew> __bitwise or similar.

Yeah. I actually got bitten by this recently.

This is what I'm doing in my current working tree (this particular flag
has moved for other reasons). But we could provide a similar wrapper for
bio->bi_flags...

[...]
+static inline unsigned int bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
+{
+ if (bio && bio->bi_integrity)
+ return bio->bi_integrity->bip_flags & (1 << flag);
+
+ return 0;
+}
+
+static inline void bio_integrity_flag(struct bio *bio, enum bip_flags flag)
+{
+ if (bio && bio->bi_integrity)
+ bio->bi_integrity->bip_flags |= (1 << flag);
+}
[...]

--
Martin K. Petersen Oracle Linux Engineering
--
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/