+ * 2.6.37 API change
+ * The WRITE_FLUSH, WRITE_FUA, and WRITE_FLUSH_FUA flags have been
+ * introduced as a replacement for WRITE_BARRIER. This was done to
+ * allow richer semantics to be expressed to the block layer. It is
+ * the block layers responsibility to choose the correct way to
+ * implement these semantics.
+ *
+ * The existence of these flags implies that REQ_FLUSH an REQ_FUA are
+ * defined. Thus we can safely define VDEV_REQ_FLUSH and VDEV_REQ_FUA
+ * compatibility macros.
+ */
+#ifdef WRITE_FLUSH_FUA
+# define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
+# define VDEV_REQ_FLUSH REQ_FLUSH
+# define VDEV_REQ_FUA REQ_FUA
+#else
+# define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
+# define VDEV_REQ_FLUSH REQ_HARDBARRIER
+# define VDEV_REQ_FUA REQ_HARDBARRIER
+#endif
+
+/*
+ * 2.6.32 API change
+ * Use the normal I/O patch for discards.
+ */
+#ifdef REQ_DISCARD
+# define VDEV_REQ_DISCARD REQ_DISCARD
+#endif
+
+/*
+ * 2.6.33 API change
+ * Discard granularity and alignment restrictions may now be set. For
+ * older kernels which do not support this it is safe to skip it.
+ */
+#ifdef HAVE_DISCARD_GRANULARITY
+static inline void
+blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
+{
+ q->limits.discard_granularity = dg;
+}
+#else
+#define blk_queue_discard_granularity(x, dg) ((void)0)
+#endif /* HAVE_DISCARD_GRANULARITY */
+
+/*