X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=include%2Fsys%2Fblkdev.h;h=7f242202ae76e6da51867bcd68075c404722ecec;hb=872e8d26978a8e1caa1ca7d931db7f95d987a3e7;hp=b84f66aed4cbadf71cfb6cde983b4674dffa431f;hpb=6283f55ea1b91e680386388c17d14b89e344fa8d;p=zfs.git diff --git a/include/sys/blkdev.h b/include/sys/blkdev.h index b84f66a..7f24220 100644 --- a/include/sys/blkdev.h +++ b/include/sys/blkdev.h @@ -163,6 +163,16 @@ __blk_rq_bytes(struct request *req) } #endif /* !HAVE_BLK_RQ_BYTES || HAVE_BLK_RQ_BYTES_GPL_ONLY */ +/* + * Most of the blk_* macros were removed in 2.6.36. Ostensibly this was + * done to improve readability and allow easier grepping. However, from + * a portability stand point the macros are helpful. Therefore the needed + * macros are redefined here if they are missing from the kernel. + */ +#ifndef blk_fs_request +#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) +#endif + #ifndef HAVE_GET_DISK_RO static inline int get_disk_ro(struct gendisk *disk) @@ -202,6 +212,49 @@ struct req_iterator { bio_for_each_segment(bvl, _iter.bio, _iter.i) #endif /* HAVE_RQ_FOR_EACH_SEGMENT */ +static inline void +bio_set_flags_failfast(struct block_device *bdev, int *flags) +{ +#ifdef CONFIG_BUG + /* + * Disable FAILFAST for loopback devices because of the + * following incorrect BUG_ON() in loop_make_request(). + * This support is also disabled for md devices because the + * test suite layers md devices on top of loopback devices. + * This may be removed when the loopback driver is fixed. + * + * BUG_ON(!lo || (rw != READ && rw != WRITE)); + */ + if ((MAJOR(bdev->bd_dev) == LOOP_MAJOR) || + (MAJOR(bdev->bd_dev) == MD_MAJOR)) + return; + +#ifdef BLOCK_EXT_MAJOR + if (MAJOR(bdev->bd_dev) == BLOCK_EXT_MAJOR) + return; +#endif /* BLOCK_EXT_MAJOR */ +#endif /* CONFIG_BUG */ + +#ifdef HAVE_BIO_RW_FAILFAST_DTD + /* BIO_RW_FAILFAST_* preferred interface from 2.6.28 - 2.6.35 */ + *flags |= + ((1 << BIO_RW_FAILFAST_DEV) | + (1 << BIO_RW_FAILFAST_TRANSPORT) | + (1 << BIO_RW_FAILFAST_DRIVER)); +#else +# ifdef HAVE_BIO_RW_FAILFAST + /* BIO_RW_FAILFAST preferred interface from 2.6.12 - 2.6.27 */ + *flags |= (1 << BIO_RW_FAILFAST); +# else +# ifdef HAVE_REQ_FAILFAST_MASK + /* REQ_FAILFAST_* preferred interface from 2.6.36 - 2.6.xx, + * the BIO_* and REQ_* flags were unified under REQ_* flags. */ + *flags |= REQ_FAILFAST_MASK; +# endif /* HAVE_REQ_FAILFAST_MASK */ +# endif /* HAVE_BIO_RW_FAILFAST */ +#endif /* HAVE_BIO_RW_FAILFAST_DTD */ +} + #ifndef DISK_NAME_LEN #define DISK_NAME_LEN 32 #endif /* DISK_NAME_LEN */