Fix harmless "BARRIER is deprecated" kernel warning on Centos 6.8

A one time warning after module load that "BARRIER is deprecated" was seen
on the heavily patched 2.6.32-642.13.1.el6.x86_64 Centos 6.8 kernel.  It seems
that kernel had both the old BARRIER and the newer FLUSH/FUA interfaces
defined.  This fixes the warning by prefering the newer FLUSH/FUA interface
if it's available.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #5739 
Closes #5828
This commit is contained in:
Tony Hutter 2017-03-08 09:20:21 -08:00 committed by Brian Behlendorf
parent 423e7b6261
commit 463009865f

View File

@ -343,12 +343,12 @@ bio_set_op_attrs(struct bio *bio, unsigned rw, unsigned flags)
static inline void static inline void
bio_set_flush(struct bio *bio) bio_set_flush(struct bio *bio)
{ {
#if defined(WRITE_BARRIER) /* < 2.6.37 */ #if defined(REQ_PREFLUSH) /* >= 4.10 */
bio_set_op_attrs(bio, 0, WRITE_BARRIER); bio_set_op_attrs(bio, 0, REQ_PREFLUSH);
#elif defined(WRITE_FLUSH_FUA) /* >= 2.6.37 and <= 4.9 */ #elif defined(WRITE_FLUSH_FUA) /* >= 2.6.37 and <= 4.9 */
bio_set_op_attrs(bio, 0, WRITE_FLUSH_FUA); bio_set_op_attrs(bio, 0, WRITE_FLUSH_FUA);
#elif defined(REQ_PREFLUSH) /* >= 4.10 */ #elif defined(WRITE_BARRIER) /* < 2.6.37 */
bio_set_op_attrs(bio, 0, REQ_PREFLUSH); bio_set_op_attrs(bio, 0, WRITE_BARRIER);
#else #else
#error "Allowing the build will cause bio_set_flush requests to be ignored." #error "Allowing the build will cause bio_set_flush requests to be ignored."
#endif #endif
@ -373,9 +373,6 @@ bio_set_flush(struct bio *bio)
* in all cases but may have a performance impact for some kernels. It * in all cases but may have a performance impact for some kernels. It
* has the advantage of minimizing kernel specific changes in the zvol code. * has the advantage of minimizing kernel specific changes in the zvol code.
* *
* Note that 2.6.32 era kernels provide both BIO_RW_BARRIER and REQ_FLUSH,
* where BIO_RW_BARRIER is the correct interface. Therefore, it is important
* that the HAVE_BIO_RW_BARRIER check occur before the REQ_FLUSH check.
*/ */
static inline boolean_t static inline boolean_t
bio_is_flush(struct bio *bio) bio_is_flush(struct bio *bio)
@ -386,10 +383,10 @@ bio_is_flush(struct bio *bio)
return (bio->bi_opf & REQ_PREFLUSH); return (bio->bi_opf & REQ_PREFLUSH);
#elif defined(REQ_PREFLUSH) && !defined(HAVE_BIO_BI_OPF) #elif defined(REQ_PREFLUSH) && !defined(HAVE_BIO_BI_OPF)
return (bio->bi_rw & REQ_PREFLUSH); return (bio->bi_rw & REQ_PREFLUSH);
#elif defined(HAVE_BIO_RW_BARRIER)
return (bio->bi_rw & (1 << BIO_RW_BARRIER));
#elif defined(REQ_FLUSH) #elif defined(REQ_FLUSH)
return (bio->bi_rw & REQ_FLUSH); return (bio->bi_rw & REQ_FLUSH);
#elif defined(HAVE_BIO_RW_BARRIER)
return (bio->bi_rw & (1 << BIO_RW_BARRIER));
#else #else
#error "Allowing the build will cause flush requests to be ignored." #error "Allowing the build will cause flush requests to be ignored."
#endif #endif